documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821
  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. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. 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>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. 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;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. 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;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. 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;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * 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".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * 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"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * 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"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * 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)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * 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
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. 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;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * 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"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * 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".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * 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"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * 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".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given 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. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * 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.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * 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)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @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
  5120. * @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
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. 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);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  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: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. 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;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. 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;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. 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;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. 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);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * 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;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * 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).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * 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).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * 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.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * 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.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * 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.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * 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.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * 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).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * 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).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * 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.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * 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.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * 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.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * 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.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * 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).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * 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).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * 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.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * 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.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * 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.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * 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.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * 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.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * 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.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * 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).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * 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).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * 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.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * 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.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * 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.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * 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.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * 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.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: Nullable<AbstractActionManager>;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  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 stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * 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
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @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
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @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
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @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
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @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
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. private _useInstancing;
  11027. /**
  11028. * An event triggered when the manager is disposed.
  11029. */
  11030. onDisposeObservable: Observable<SpriteManager>;
  11031. private _onDisposeObserver;
  11032. /**
  11033. * Callback called when the manager is disposed
  11034. */
  11035. set onDispose(callback: () => void);
  11036. private _capacity;
  11037. private _fromPacked;
  11038. private _spriteTexture;
  11039. private _epsilon;
  11040. private _scene;
  11041. private _vertexData;
  11042. private _buffer;
  11043. private _vertexBuffers;
  11044. private _spriteBuffer;
  11045. private _indexBuffer;
  11046. private _effectBase;
  11047. private _effectFog;
  11048. private _vertexBufferSize;
  11049. /**
  11050. * Gets or sets the unique id of the sprite
  11051. */
  11052. uniqueId: number;
  11053. /**
  11054. * Gets the array of sprites
  11055. */
  11056. get children(): Sprite[];
  11057. /**
  11058. * Gets the hosting scene
  11059. */
  11060. get scene(): Scene;
  11061. /**
  11062. * Gets the capacity of the manager
  11063. */
  11064. get capacity(): number;
  11065. /**
  11066. * Gets or sets the spritesheet texture
  11067. */
  11068. get texture(): Texture;
  11069. set texture(value: Texture);
  11070. private _blendMode;
  11071. /**
  11072. * Blend mode use to render the particle, it can be any of
  11073. * the static Constants.ALPHA_x properties provided in this class.
  11074. * Default value is Constants.ALPHA_COMBINE
  11075. */
  11076. get blendMode(): number;
  11077. set blendMode(blendMode: number);
  11078. /** Disables writing to the depth buffer when rendering the sprites.
  11079. * It can be handy to disable depth writing when using textures without alpha channel
  11080. * and setting some specific blend modes.
  11081. */
  11082. disableDepthWrite: boolean;
  11083. /**
  11084. * Creates a new sprite manager
  11085. * @param name defines the manager's name
  11086. * @param imgUrl defines the sprite sheet url
  11087. * @param capacity defines the maximum allowed number of sprites
  11088. * @param cellSize defines the size of a sprite cell
  11089. * @param scene defines the hosting scene
  11090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11091. * @param samplingMode defines the smapling mode to use with spritesheet
  11092. * @param fromPacked set to false; do not alter
  11093. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11094. */
  11095. constructor(
  11096. /** defines the manager's name */
  11097. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11098. /**
  11099. * Returns the string "SpriteManager"
  11100. * @returns "SpriteManager"
  11101. */
  11102. getClassName(): string;
  11103. private _makePacked;
  11104. private _appendSpriteVertex;
  11105. private _checkTextureAlpha;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11112. * @returns null if no hit or a PickingInfo
  11113. */
  11114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11115. /**
  11116. * Intersects the sprites with a ray
  11117. * @param ray defines the ray to intersect with
  11118. * @param camera defines the current active camera
  11119. * @param predicate defines a predicate used to select candidate sprites
  11120. * @returns null if no hit or a PickingInfo array
  11121. */
  11122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11123. /**
  11124. * Render all child sprites
  11125. */
  11126. render(): void;
  11127. /**
  11128. * Release associated resources
  11129. */
  11130. dispose(): void;
  11131. /**
  11132. * Serializes the sprite manager to a JSON object
  11133. * @param serializeTexture defines if the texture must be serialized as well
  11134. * @returns the JSON object
  11135. */
  11136. serialize(serializeTexture?: boolean): any;
  11137. /**
  11138. * Parses a JSON object to create a new sprite manager.
  11139. * @param parsedManager The JSON object to parse
  11140. * @param scene The scene to create the sprite managerin
  11141. * @param rootUrl The root url to use to load external dependencies like texture
  11142. * @returns the new sprite manager
  11143. */
  11144. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11145. /**
  11146. * Creates a sprite manager from a snippet saved in a remote file
  11147. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11148. * @param url defines the url to load from
  11149. * @param scene defines the hosting scene
  11150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11151. * @returns a promise that will resolve to the new sprite manager
  11152. */
  11153. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11154. /**
  11155. * Creates a sprite manager from a snippet saved by the sprite editor
  11156. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11157. * @param scene defines the hosting scene
  11158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11159. * @returns a promise that will resolve to the new sprite manager
  11160. */
  11161. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. /** Interface used by value gradients (color, factor, ...) */
  11166. export interface IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. }
  11172. /** Class used to store color4 gradient */
  11173. export class ColorGradient implements IValueGradient {
  11174. /**
  11175. * Gets or sets the gradient value (between 0 and 1)
  11176. */
  11177. gradient: number;
  11178. /**
  11179. * Gets or sets first associated color
  11180. */
  11181. color1: Color4;
  11182. /**
  11183. * Gets or sets second associated color
  11184. */
  11185. color2?: Color4 | undefined;
  11186. /**
  11187. * Creates a new color4 gradient
  11188. * @param gradient gets or sets the gradient value (between 0 and 1)
  11189. * @param color1 gets or sets first associated color
  11190. * @param color2 gets or sets first second color
  11191. */
  11192. constructor(
  11193. /**
  11194. * Gets or sets the gradient value (between 0 and 1)
  11195. */
  11196. gradient: number,
  11197. /**
  11198. * Gets or sets first associated color
  11199. */
  11200. color1: Color4,
  11201. /**
  11202. * Gets or sets second associated color
  11203. */
  11204. color2?: Color4 | undefined);
  11205. /**
  11206. * Will get a color picked randomly between color1 and color2.
  11207. * If color2 is undefined then color1 will be used
  11208. * @param result defines the target Color4 to store the result in
  11209. */
  11210. getColorToRef(result: Color4): void;
  11211. }
  11212. /** Class used to store color 3 gradient */
  11213. export class Color3Gradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets the associated color
  11220. */
  11221. color: Color3;
  11222. /**
  11223. * Creates a new color3 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color gets or sets associated color
  11226. */
  11227. constructor(
  11228. /**
  11229. * Gets or sets the gradient value (between 0 and 1)
  11230. */
  11231. gradient: number,
  11232. /**
  11233. * Gets or sets the associated color
  11234. */
  11235. color: Color3);
  11236. }
  11237. /** Class used to store factor gradient */
  11238. export class FactorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated factor
  11245. */
  11246. factor1: number;
  11247. /**
  11248. * Gets or sets second associated factor
  11249. */
  11250. factor2?: number | undefined;
  11251. /**
  11252. * Creates a new factor gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param factor1 gets or sets first associated factor
  11255. * @param factor2 gets or sets second associated factor
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated factor
  11264. */
  11265. factor1: number,
  11266. /**
  11267. * Gets or sets second associated factor
  11268. */
  11269. factor2?: number | undefined);
  11270. /**
  11271. * Will get a number picked randomly between factor1 and factor2.
  11272. * If factor2 is undefined then factor1 will be used
  11273. * @returns the picked number
  11274. */
  11275. getFactor(): number;
  11276. }
  11277. /**
  11278. * Helper used to simplify some generic gradient tasks
  11279. */
  11280. export class GradientHelper {
  11281. /**
  11282. * Gets the current gradient from an array of IValueGradient
  11283. * @param ratio defines the current ratio to get
  11284. * @param gradients defines the array of IValueGradient
  11285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11286. */
  11287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11288. }
  11289. }
  11290. declare module BABYLON {
  11291. interface ThinEngine {
  11292. /**
  11293. * Creates a raw texture
  11294. * @param data defines the data to store in the texture
  11295. * @param width defines the width of the texture
  11296. * @param height defines the height of the texture
  11297. * @param format defines the format of the data
  11298. * @param generateMipMaps defines if the engine should generate the mip levels
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. * @returns the raw texture inside an InternalTexture
  11304. */
  11305. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11306. /**
  11307. * Update a raw texture
  11308. * @param texture defines the texture to update
  11309. * @param data defines the data to store in the texture
  11310. * @param format defines the format of the data
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. */
  11313. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11314. /**
  11315. * Update a raw texture
  11316. * @param texture defines the texture to update
  11317. * @param data defines the data to store in the texture
  11318. * @param format defines the format of the data
  11319. * @param invertY defines if data must be stored with Y axis inverted
  11320. * @param compression defines the compression used (null by default)
  11321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11322. */
  11323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11324. /**
  11325. * Creates a new raw cube texture
  11326. * @param data defines the array of data to use to create each face
  11327. * @param size defines the size of the textures
  11328. * @param format defines the format of the data
  11329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11330. * @param generateMipMaps defines if the engine should generate the mip levels
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11333. * @param compression defines the compression used (null by default)
  11334. * @returns the cube texture as an InternalTexture
  11335. */
  11336. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. */
  11345. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11346. /**
  11347. * Update a raw cube texture
  11348. * @param texture defines the texture to udpdate
  11349. * @param data defines the data to store
  11350. * @param format defines the data format
  11351. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the compression used (null by default)
  11354. */
  11355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11356. /**
  11357. * Update a raw cube texture
  11358. * @param texture defines the texture to udpdate
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. * @param invertY defines if data must be stored with Y axis inverted
  11363. * @param compression defines the compression used (null by default)
  11364. * @param level defines which level of the texture to update
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11367. /**
  11368. * Creates a new raw cube texture from a specified url
  11369. * @param url defines the url where the data is located
  11370. * @param scene defines the current scene
  11371. * @param size defines the size of the textures
  11372. * @param format defines the format of the data
  11373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11374. * @param noMipmap defines if the engine should avoid generating the mip levels
  11375. * @param callback defines a callback used to extract texture data from loaded data
  11376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11377. * @param onLoad defines a callback called when texture is loaded
  11378. * @param onError defines a callback called if there is an error
  11379. * @returns the cube texture as an InternalTexture
  11380. */
  11381. 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;
  11382. /**
  11383. * Creates a new raw cube texture from a specified url
  11384. * @param url defines the url where the data is located
  11385. * @param scene defines the current scene
  11386. * @param size defines the size of the textures
  11387. * @param format defines the format of the data
  11388. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11389. * @param noMipmap defines if the engine should avoid generating the mip levels
  11390. * @param callback defines a callback used to extract texture data from loaded data
  11391. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11392. * @param onLoad defines a callback called when texture is loaded
  11393. * @param onError defines a callback called if there is an error
  11394. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11395. * @param invertY defines if data must be stored with Y axis inverted
  11396. * @returns the cube texture as an InternalTexture
  11397. */
  11398. 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;
  11399. /**
  11400. * Creates a new raw 3D texture
  11401. * @param data defines the data used to create the texture
  11402. * @param width defines the width of the texture
  11403. * @param height defines the height of the texture
  11404. * @param depth defines the depth of the texture
  11405. * @param format defines the format of the texture
  11406. * @param generateMipMaps defines if the engine must generate mip levels
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11409. * @param compression defines the compressed used (can be null)
  11410. * @param textureType defines the compressed used (can be null)
  11411. * @returns a new raw 3D texture (stored in an InternalTexture)
  11412. */
  11413. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11414. /**
  11415. * Update a raw 3D texture
  11416. * @param texture defines the texture to update
  11417. * @param data defines the data to store
  11418. * @param format defines the data format
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. */
  11421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11422. /**
  11423. * Update a raw 3D texture
  11424. * @param texture defines the texture to update
  11425. * @param data defines the data to store
  11426. * @param format defines the data format
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the used compression (can be null)
  11429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11430. */
  11431. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11432. /**
  11433. * Creates a new raw 2D array texture
  11434. * @param data defines the data used to create the texture
  11435. * @param width defines the width of the texture
  11436. * @param height defines the height of the texture
  11437. * @param depth defines the number of layers of the texture
  11438. * @param format defines the format of the texture
  11439. * @param generateMipMaps defines if the engine must generate mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11442. * @param compression defines the compressed used (can be null)
  11443. * @param textureType defines the compressed used (can be null)
  11444. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11445. */
  11446. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11447. /**
  11448. * Update a raw 2D array texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store
  11451. * @param format defines the data format
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw 2D array texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store
  11459. * @param format defines the data format
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the used compression (can be null)
  11462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11463. */
  11464. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * Raw texture can help creating a texture directly from an array of data.
  11470. * This can be super useful if you either get the data from an uncompressed source or
  11471. * if you wish to create your texture pixel by pixel.
  11472. */
  11473. export class RawTexture extends Texture {
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number;
  11478. /**
  11479. * Instantiates a new RawTexture.
  11480. * Raw texture can help creating a texture directly from an array of data.
  11481. * This can be super useful if you either get the data from an uncompressed source or
  11482. * if you wish to create your texture pixel by pixel.
  11483. * @param data define the array of data to use to create the texture
  11484. * @param width define the width of the texture
  11485. * @param height define the height of the texture
  11486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11487. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11488. * @param generateMipMaps define whether mip maps should be generated or not
  11489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11492. */
  11493. constructor(data: ArrayBufferView, width: number, height: number,
  11494. /**
  11495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11496. */
  11497. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11498. /**
  11499. * Updates the texture underlying data.
  11500. * @param data Define the new data of the texture
  11501. */
  11502. update(data: ArrayBufferView): void;
  11503. /**
  11504. * Creates a luminance texture from some data.
  11505. * @param data Define the texture data
  11506. * @param width Define the width of the texture
  11507. * @param height Define the height of the texture
  11508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @returns the luminance texture
  11513. */
  11514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11515. /**
  11516. * Creates a luminance alpha texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance alpha texture
  11525. */
  11526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates an alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the alpha texture
  11537. */
  11538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates a RGB texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11549. * @returns the RGB alpha texture
  11550. */
  11551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11552. /**
  11553. * Creates a RGBA texture from some data.
  11554. * @param data Define the texture data
  11555. * @param width Define the width of the texture
  11556. * @param height Define the height of the texture
  11557. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11562. * @returns the RGBA texture
  11563. */
  11564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11565. /**
  11566. * Creates a R texture from some data.
  11567. * @param data Define the texture data
  11568. * @param width Define the width of the texture
  11569. * @param height Define the height of the texture
  11570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11575. * @returns the R texture
  11576. */
  11577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. interface ThinEngine {
  11582. /**
  11583. * Update a dynamic index buffer
  11584. * @param indexBuffer defines the target index buffer
  11585. * @param indices defines the data to update
  11586. * @param offset defines the offset in the target index buffer where update should start
  11587. */
  11588. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11589. /**
  11590. * Updates a dynamic vertex buffer.
  11591. * @param vertexBuffer the vertex buffer to update
  11592. * @param data the data used to update the vertex buffer
  11593. * @param byteOffset the byte offset of the data
  11594. * @param byteLength the byte length of the data
  11595. */
  11596. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. interface AbstractScene {
  11601. /**
  11602. * The list of procedural textures added to the scene
  11603. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11604. */
  11605. proceduralTextures: Array<ProceduralTexture>;
  11606. }
  11607. /**
  11608. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11609. * in a given scene.
  11610. */
  11611. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /**
  11621. * Creates a new instance of the component for the given scene
  11622. * @param scene Defines the scene to register the component in
  11623. */
  11624. constructor(scene: Scene);
  11625. /**
  11626. * Registers the component in a given scene
  11627. */
  11628. register(): void;
  11629. /**
  11630. * Rebuilds the elements related to this component in case of
  11631. * context lost for instance.
  11632. */
  11633. rebuild(): void;
  11634. /**
  11635. * Disposes the component and the associated ressources.
  11636. */
  11637. dispose(): void;
  11638. private _beforeClear;
  11639. }
  11640. }
  11641. declare module BABYLON {
  11642. interface ThinEngine {
  11643. /**
  11644. * Creates a new render target cube texture
  11645. * @param size defines the size of the texture
  11646. * @param options defines the options used to create the texture
  11647. * @returns a new render target cube texture stored in an InternalTexture
  11648. */
  11649. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var proceduralVertexShader: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /**
  11661. * 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.
  11662. * This is the base class of any Procedural texture and contains most of the shareable code.
  11663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11664. */
  11665. export class ProceduralTexture extends Texture {
  11666. /**
  11667. * Define if the texture is enabled or not (disabled texture will not render)
  11668. */
  11669. isEnabled: boolean;
  11670. /**
  11671. * Define if the texture must be cleared before rendering (default is true)
  11672. */
  11673. autoClear: boolean;
  11674. /**
  11675. * Callback called when the texture is generated
  11676. */
  11677. onGenerated: () => void;
  11678. /**
  11679. * Event raised when the texture is generated
  11680. */
  11681. onGeneratedObservable: Observable<ProceduralTexture>;
  11682. /** @hidden */
  11683. _generateMipMaps: boolean;
  11684. /** @hidden **/
  11685. _effect: Effect;
  11686. /** @hidden */
  11687. _textures: {
  11688. [key: string]: Texture;
  11689. };
  11690. /** @hidden */
  11691. protected _fallbackTexture: Nullable<Texture>;
  11692. private _size;
  11693. private _currentRefreshId;
  11694. private _frameId;
  11695. private _refreshRate;
  11696. private _vertexBuffers;
  11697. private _indexBuffer;
  11698. private _uniforms;
  11699. private _samplers;
  11700. private _fragment;
  11701. private _floats;
  11702. private _ints;
  11703. private _floatsArrays;
  11704. private _colors3;
  11705. private _colors4;
  11706. private _vectors2;
  11707. private _vectors3;
  11708. private _matrices;
  11709. private _fallbackTextureUsed;
  11710. private _fullEngine;
  11711. private _cachedDefines;
  11712. private _contentUpdateId;
  11713. private _contentData;
  11714. /**
  11715. * Instantiates a new procedural texture.
  11716. * 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.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. * @param name Define the name of the texture
  11720. * @param size Define the size of the texture to create
  11721. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11722. * @param scene Define the scene the texture belongs to
  11723. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11724. * @param generateMipMaps Define if the texture should creates mip maps or not
  11725. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11726. */
  11727. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11728. /**
  11729. * The effect that is created when initializing the post process.
  11730. * @returns The created effect corresponding the the postprocess.
  11731. */
  11732. getEffect(): Effect;
  11733. /**
  11734. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11735. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11736. */
  11737. getContent(): Nullable<ArrayBufferView>;
  11738. private _createIndexBuffer;
  11739. /** @hidden */
  11740. _rebuild(): void;
  11741. /**
  11742. * Resets the texture in order to recreate its associated resources.
  11743. * This can be called in case of context loss
  11744. */
  11745. reset(): void;
  11746. protected _getDefines(): string;
  11747. /**
  11748. * Is the texture ready to be used ? (rendered at least once)
  11749. * @returns true if ready, otherwise, false.
  11750. */
  11751. isReady(): boolean;
  11752. /**
  11753. * Resets the refresh counter of the texture and start bak from scratch.
  11754. * Could be useful to regenerate the texture if it is setup to render only once.
  11755. */
  11756. resetRefreshCounter(): void;
  11757. /**
  11758. * Set the fragment shader to use in order to render the texture.
  11759. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11760. */
  11761. setFragment(fragment: any): void;
  11762. /**
  11763. * Define the refresh rate of the texture or the rendering frequency.
  11764. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11765. */
  11766. get refreshRate(): number;
  11767. set refreshRate(value: number);
  11768. /** @hidden */
  11769. _shouldRender(): boolean;
  11770. /**
  11771. * Get the size the texture is rendering at.
  11772. * @returns the size (texture is always squared)
  11773. */
  11774. getRenderSize(): number;
  11775. /**
  11776. * Resize the texture to new value.
  11777. * @param size Define the new size the texture should have
  11778. * @param generateMipMaps Define whether the new texture should create mip maps
  11779. */
  11780. resize(size: number, generateMipMaps: boolean): void;
  11781. private _checkUniform;
  11782. /**
  11783. * Set a texture in the shader program used to render.
  11784. * @param name Define the name of the uniform samplers as defined in the shader
  11785. * @param texture Define the texture to bind to this sampler
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setTexture(name: string, texture: Texture): ProceduralTexture;
  11789. /**
  11790. * Set a float in the shader.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setFloat(name: string, value: number): ProceduralTexture;
  11796. /**
  11797. * Set a int in the shader.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setInt(name: string, value: number): ProceduralTexture;
  11803. /**
  11804. * Set an array of floats in the shader.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setFloats(name: string, value: number[]): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Color3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setColor3(name: string, value: Color3): ProceduralTexture;
  11817. /**
  11818. * Set a vec4 in the shader from a Color4.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setColor4(name: string, value: Color4): ProceduralTexture;
  11824. /**
  11825. * Set a vec2 in the shader from a Vector2.
  11826. * @param name Define the name of the uniform as defined in the shader
  11827. * @param value Define the value to give to the uniform
  11828. * @return the texture itself allowing "fluent" like uniform updates
  11829. */
  11830. setVector2(name: string, value: Vector2): ProceduralTexture;
  11831. /**
  11832. * Set a vec3 in the shader from a Vector3.
  11833. * @param name Define the name of the uniform as defined in the shader
  11834. * @param value Define the value to give to the uniform
  11835. * @return the texture itself allowing "fluent" like uniform updates
  11836. */
  11837. setVector3(name: string, value: Vector3): ProceduralTexture;
  11838. /**
  11839. * Set a mat4 in the shader from a MAtrix.
  11840. * @param name Define the name of the uniform as defined in the shader
  11841. * @param value Define the value to give to the uniform
  11842. * @return the texture itself allowing "fluent" like uniform updates
  11843. */
  11844. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11845. /**
  11846. * Render the texture to its associated render target.
  11847. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11848. */
  11849. render(useCameraPostProcess?: boolean): void;
  11850. /**
  11851. * Clone the texture.
  11852. * @returns the cloned texture
  11853. */
  11854. clone(): ProceduralTexture;
  11855. /**
  11856. * Dispose the texture and release its asoociated resources.
  11857. */
  11858. dispose(): void;
  11859. }
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * This represents the base class for particle system in Babylon.
  11864. * 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.
  11865. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11866. * @example https://doc.babylonjs.com/babylon101/particles
  11867. */
  11868. export class BaseParticleSystem {
  11869. /**
  11870. * Source color is added to the destination color without alpha affecting the result
  11871. */
  11872. static BLENDMODE_ONEONE: number;
  11873. /**
  11874. * Blend current color and particle color using particle’s alpha
  11875. */
  11876. static BLENDMODE_STANDARD: number;
  11877. /**
  11878. * Add current color and particle color multiplied by particle’s alpha
  11879. */
  11880. static BLENDMODE_ADD: number;
  11881. /**
  11882. * Multiply current color with particle color
  11883. */
  11884. static BLENDMODE_MULTIPLY: number;
  11885. /**
  11886. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11887. */
  11888. static BLENDMODE_MULTIPLYADD: number;
  11889. /**
  11890. * List of animations used by the particle system.
  11891. */
  11892. animations: Animation[];
  11893. /**
  11894. * Gets or sets the unique id of the particle system
  11895. */
  11896. uniqueId: number;
  11897. /**
  11898. * The id of the Particle system.
  11899. */
  11900. id: string;
  11901. /**
  11902. * The friendly name of the Particle system.
  11903. */
  11904. name: string;
  11905. /**
  11906. * Snippet ID if the particle system was created from the snippet server
  11907. */
  11908. snippetId: string;
  11909. /**
  11910. * The rendering group used by the Particle system to chose when to render.
  11911. */
  11912. renderingGroupId: number;
  11913. /**
  11914. * The emitter represents the Mesh or position we are attaching the particle system to.
  11915. */
  11916. emitter: Nullable<AbstractMesh | Vector3>;
  11917. /**
  11918. * The maximum number of particles to emit per frame
  11919. */
  11920. emitRate: number;
  11921. /**
  11922. * If you want to launch only a few particles at once, that can be done, as well.
  11923. */
  11924. manualEmitCount: number;
  11925. /**
  11926. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11927. */
  11928. updateSpeed: number;
  11929. /**
  11930. * The amount of time the particle system is running (depends of the overall update speed).
  11931. */
  11932. targetStopDuration: number;
  11933. /**
  11934. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11935. */
  11936. disposeOnStop: boolean;
  11937. /**
  11938. * Minimum power of emitting particles.
  11939. */
  11940. minEmitPower: number;
  11941. /**
  11942. * Maximum power of emitting particles.
  11943. */
  11944. maxEmitPower: number;
  11945. /**
  11946. * Minimum life time of emitting particles.
  11947. */
  11948. minLifeTime: number;
  11949. /**
  11950. * Maximum life time of emitting particles.
  11951. */
  11952. maxLifeTime: number;
  11953. /**
  11954. * Minimum Size of emitting particles.
  11955. */
  11956. minSize: number;
  11957. /**
  11958. * Maximum Size of emitting particles.
  11959. */
  11960. maxSize: number;
  11961. /**
  11962. * Minimum scale of emitting particles on X axis.
  11963. */
  11964. minScaleX: number;
  11965. /**
  11966. * Maximum scale of emitting particles on X axis.
  11967. */
  11968. maxScaleX: number;
  11969. /**
  11970. * Minimum scale of emitting particles on Y axis.
  11971. */
  11972. minScaleY: number;
  11973. /**
  11974. * Maximum scale of emitting particles on Y axis.
  11975. */
  11976. maxScaleY: number;
  11977. /**
  11978. * Gets or sets the minimal initial rotation in radians.
  11979. */
  11980. minInitialRotation: number;
  11981. /**
  11982. * Gets or sets the maximal initial rotation in radians.
  11983. */
  11984. maxInitialRotation: number;
  11985. /**
  11986. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11987. */
  11988. minAngularSpeed: number;
  11989. /**
  11990. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11991. */
  11992. maxAngularSpeed: number;
  11993. /**
  11994. * The texture used to render each particle. (this can be a spritesheet)
  11995. */
  11996. particleTexture: Nullable<BaseTexture>;
  11997. /**
  11998. * The layer mask we are rendering the particles through.
  11999. */
  12000. layerMask: number;
  12001. /**
  12002. * This can help using your own shader to render the particle system.
  12003. * The according effect will be created
  12004. */
  12005. customShader: any;
  12006. /**
  12007. * By default particle system starts as soon as they are created. This prevents the
  12008. * automatic start to happen and let you decide when to start emitting particles.
  12009. */
  12010. preventAutoStart: boolean;
  12011. private _noiseTexture;
  12012. /**
  12013. * Gets or sets a texture used to add random noise to particle positions
  12014. */
  12015. get noiseTexture(): Nullable<ProceduralTexture>;
  12016. set noiseTexture(value: Nullable<ProceduralTexture>);
  12017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12018. noiseStrength: Vector3;
  12019. /**
  12020. * Callback triggered when the particle animation is ending.
  12021. */
  12022. onAnimationEnd: Nullable<() => void>;
  12023. /**
  12024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12025. */
  12026. blendMode: number;
  12027. /**
  12028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12029. * to override the particles.
  12030. */
  12031. forceDepthWrite: boolean;
  12032. /** 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 */
  12033. preWarmCycles: number;
  12034. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12035. preWarmStepOffset: number;
  12036. /**
  12037. * 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)
  12038. */
  12039. spriteCellChangeSpeed: number;
  12040. /**
  12041. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12042. */
  12043. startSpriteCellID: number;
  12044. /**
  12045. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12046. */
  12047. endSpriteCellID: number;
  12048. /**
  12049. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12050. */
  12051. spriteCellWidth: number;
  12052. /**
  12053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12054. */
  12055. spriteCellHeight: number;
  12056. /**
  12057. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12058. */
  12059. spriteRandomStartCell: boolean;
  12060. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12061. translationPivot: Vector2;
  12062. /** @hidden */
  12063. protected _isAnimationSheetEnabled: boolean;
  12064. /**
  12065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12066. */
  12067. beginAnimationOnStart: boolean;
  12068. /**
  12069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12070. */
  12071. beginAnimationFrom: number;
  12072. /**
  12073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12074. */
  12075. beginAnimationTo: number;
  12076. /**
  12077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12078. */
  12079. beginAnimationLoop: boolean;
  12080. /**
  12081. * Gets or sets a world offset applied to all particles
  12082. */
  12083. worldOffset: Vector3;
  12084. /**
  12085. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12086. */
  12087. get isAnimationSheetEnabled(): boolean;
  12088. set isAnimationSheetEnabled(value: boolean);
  12089. /**
  12090. * Get hosting scene
  12091. * @returns the scene
  12092. */
  12093. getScene(): Nullable<Scene>;
  12094. /**
  12095. * You can use gravity if you want to give an orientation to your particles.
  12096. */
  12097. gravity: Vector3;
  12098. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12099. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12100. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12102. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12103. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12105. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12106. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12107. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12108. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12109. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12111. /**
  12112. * Defines the delay in milliseconds before starting the system (0 by default)
  12113. */
  12114. startDelay: number;
  12115. /**
  12116. * Gets the current list of drag gradients.
  12117. * You must use addDragGradient and removeDragGradient to udpate this list
  12118. * @returns the list of drag gradients
  12119. */
  12120. getDragGradients(): Nullable<Array<FactorGradient>>;
  12121. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12122. limitVelocityDamping: number;
  12123. /**
  12124. * Gets the current list of limit velocity gradients.
  12125. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12126. * @returns the list of limit velocity gradients
  12127. */
  12128. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12129. /**
  12130. * Gets the current list of color gradients.
  12131. * You must use addColorGradient and removeColorGradient to udpate this list
  12132. * @returns the list of color gradients
  12133. */
  12134. getColorGradients(): Nullable<Array<ColorGradient>>;
  12135. /**
  12136. * Gets the current list of size gradients.
  12137. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12138. * @returns the list of size gradients
  12139. */
  12140. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of color remap gradients.
  12143. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12144. * @returns the list of color remap gradients
  12145. */
  12146. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of alpha remap gradients.
  12149. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12150. * @returns the list of alpha remap gradients
  12151. */
  12152. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of life time gradients.
  12155. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12156. * @returns the list of life time gradients
  12157. */
  12158. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of angular speed gradients.
  12161. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12162. * @returns the list of angular speed gradients
  12163. */
  12164. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of velocity gradients.
  12167. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12168. * @returns the list of velocity gradients
  12169. */
  12170. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of start size gradients.
  12173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12174. * @returns the list of start size gradients
  12175. */
  12176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Gets the current list of emit rate gradients.
  12179. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12180. * @returns the list of emit rate gradients
  12181. */
  12182. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction1(): Vector3;
  12188. set direction1(value: Vector3);
  12189. /**
  12190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get direction2(): Vector3;
  12194. set direction2(value: Vector3);
  12195. /**
  12196. * 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.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get minEmitBox(): Vector3;
  12200. set minEmitBox(value: Vector3);
  12201. /**
  12202. * 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.
  12203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12204. */
  12205. get maxEmitBox(): Vector3;
  12206. set maxEmitBox(value: Vector3);
  12207. /**
  12208. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12209. */
  12210. color1: Color4;
  12211. /**
  12212. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12213. */
  12214. color2: Color4;
  12215. /**
  12216. * Color the particle will have at the end of its lifetime
  12217. */
  12218. colorDead: Color4;
  12219. /**
  12220. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12221. */
  12222. textureMask: Color4;
  12223. /**
  12224. * The particle emitter type defines the emitter used by the particle system.
  12225. * It can be for example box, sphere, or cone...
  12226. */
  12227. particleEmitterType: IParticleEmitterType;
  12228. /** @hidden */
  12229. _isSubEmitter: boolean;
  12230. /**
  12231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12233. */
  12234. billboardMode: number;
  12235. protected _isBillboardBased: boolean;
  12236. /**
  12237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12238. */
  12239. get isBillboardBased(): boolean;
  12240. set isBillboardBased(value: boolean);
  12241. /**
  12242. * The scene the particle system belongs to.
  12243. */
  12244. protected _scene: Nullable<Scene>;
  12245. /**
  12246. * The engine the particle system belongs to.
  12247. */
  12248. protected _engine: ThinEngine;
  12249. /**
  12250. * Local cache of defines for image processing.
  12251. */
  12252. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12253. /**
  12254. * Default configuration related to image processing available in the standard Material.
  12255. */
  12256. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12257. /**
  12258. * Gets the image processing configuration used either in this material.
  12259. */
  12260. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12261. /**
  12262. * Sets the Default image processing configuration used either in the this material.
  12263. *
  12264. * If sets to null, the scene one is in use.
  12265. */
  12266. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12267. /**
  12268. * Attaches a new image processing configuration to the Standard Material.
  12269. * @param configuration
  12270. */
  12271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12272. /** @hidden */
  12273. protected _reset(): void;
  12274. /** @hidden */
  12275. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12276. /**
  12277. * Instantiates a particle system.
  12278. * 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.
  12279. * @param name The name of the particle system
  12280. */
  12281. constructor(name: string);
  12282. /**
  12283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @returns the emitter
  12287. */
  12288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12289. /**
  12290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12291. * @param radius The radius of the hemisphere to emit from
  12292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12293. * @returns the emitter
  12294. */
  12295. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12296. /**
  12297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12298. * @param radius The radius of the sphere to emit from
  12299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12300. * @returns the emitter
  12301. */
  12302. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12303. /**
  12304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12305. * @param radius The radius of the sphere to emit from
  12306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @returns the emitter
  12309. */
  12310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12311. /**
  12312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12313. * @param radius The radius of the emission cylinder
  12314. * @param height The height of the emission cylinder
  12315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12317. * @returns the emitter
  12318. */
  12319. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12320. /**
  12321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12322. * @param radius The radius of the cylinder to emit from
  12323. * @param height The height of the emission cylinder
  12324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @returns the emitter
  12328. */
  12329. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12330. /**
  12331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12332. * @param radius The radius of the cone to emit from
  12333. * @param angle The base angle of the cone
  12334. * @returns the emitter
  12335. */
  12336. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12337. /**
  12338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @returns the emitter
  12344. */
  12345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12346. }
  12347. }
  12348. declare module BABYLON {
  12349. /**
  12350. * Type of sub emitter
  12351. */
  12352. export enum SubEmitterType {
  12353. /**
  12354. * Attached to the particle over it's lifetime
  12355. */
  12356. ATTACHED = 0,
  12357. /**
  12358. * Created when the particle dies
  12359. */
  12360. END = 1
  12361. }
  12362. /**
  12363. * Sub emitter class used to emit particles from an existing particle
  12364. */
  12365. export class SubEmitter {
  12366. /**
  12367. * the particle system to be used by the sub emitter
  12368. */
  12369. particleSystem: ParticleSystem;
  12370. /**
  12371. * Type of the submitter (Default: END)
  12372. */
  12373. type: SubEmitterType;
  12374. /**
  12375. * 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)
  12376. * Note: This only is supported when using an emitter of type Mesh
  12377. */
  12378. inheritDirection: boolean;
  12379. /**
  12380. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12381. */
  12382. inheritedVelocityAmount: number;
  12383. /**
  12384. * Creates a sub emitter
  12385. * @param particleSystem the particle system to be used by the sub emitter
  12386. */
  12387. constructor(
  12388. /**
  12389. * the particle system to be used by the sub emitter
  12390. */
  12391. particleSystem: ParticleSystem);
  12392. /**
  12393. * Clones the sub emitter
  12394. * @returns the cloned sub emitter
  12395. */
  12396. clone(): SubEmitter;
  12397. /**
  12398. * Serialize current object to a JSON object
  12399. * @returns the serialized object
  12400. */
  12401. serialize(): any;
  12402. /** @hidden */
  12403. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12404. /**
  12405. * Creates a new SubEmitter from a serialized JSON version
  12406. * @param serializationObject defines the JSON object to read from
  12407. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12408. * @param rootUrl defines the rootUrl for data loading
  12409. * @returns a new SubEmitter
  12410. */
  12411. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12412. /** Release associated resources */
  12413. dispose(): void;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /** @hidden */
  12418. export var imageProcessingDeclaration: {
  12419. name: string;
  12420. shader: string;
  12421. };
  12422. }
  12423. declare module BABYLON {
  12424. /** @hidden */
  12425. export var imageProcessingFunctions: {
  12426. name: string;
  12427. shader: string;
  12428. };
  12429. }
  12430. declare module BABYLON {
  12431. /** @hidden */
  12432. export var particlesPixelShader: {
  12433. name: string;
  12434. shader: string;
  12435. };
  12436. }
  12437. declare module BABYLON {
  12438. /** @hidden */
  12439. export var particlesVertexShader: {
  12440. name: string;
  12441. shader: string;
  12442. };
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Interface used to define entities containing multiple clip planes
  12447. */
  12448. export interface IClipPlanesHolder {
  12449. /**
  12450. * Gets or sets the active clipplane 1
  12451. */
  12452. clipPlane: Nullable<Plane>;
  12453. /**
  12454. * Gets or sets the active clipplane 2
  12455. */
  12456. clipPlane2: Nullable<Plane>;
  12457. /**
  12458. * Gets or sets the active clipplane 3
  12459. */
  12460. clipPlane3: Nullable<Plane>;
  12461. /**
  12462. * Gets or sets the active clipplane 4
  12463. */
  12464. clipPlane4: Nullable<Plane>;
  12465. /**
  12466. * Gets or sets the active clipplane 5
  12467. */
  12468. clipPlane5: Nullable<Plane>;
  12469. /**
  12470. * Gets or sets the active clipplane 6
  12471. */
  12472. clipPlane6: Nullable<Plane>;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12478. *
  12479. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12480. *
  12481. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12482. */
  12483. export class ThinMaterialHelper {
  12484. /**
  12485. * Binds the clip plane information from the holder to the effect.
  12486. * @param effect The effect we are binding the data to
  12487. * @param holder The entity containing the clip plane information
  12488. */
  12489. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. interface ThinEngine {
  12494. /**
  12495. * Sets alpha constants used by some alpha blending modes
  12496. * @param r defines the red component
  12497. * @param g defines the green component
  12498. * @param b defines the blue component
  12499. * @param a defines the alpha component
  12500. */
  12501. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12502. /**
  12503. * Sets the current alpha mode
  12504. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12505. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12506. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12507. */
  12508. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12509. /**
  12510. * Gets the current alpha mode
  12511. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12512. * @returns the current alpha mode
  12513. */
  12514. getAlphaMode(): number;
  12515. /**
  12516. * Sets the current alpha equation
  12517. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12518. */
  12519. setAlphaEquation(equation: number): void;
  12520. /**
  12521. * Gets the current alpha equation.
  12522. * @returns the current alpha equation
  12523. */
  12524. getAlphaEquation(): number;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /**
  12529. * This represents a particle system in Babylon.
  12530. * 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.
  12531. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12532. * @example https://doc.babylonjs.com/babylon101/particles
  12533. */
  12534. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12535. /**
  12536. * Billboard mode will only apply to Y axis
  12537. */
  12538. static readonly BILLBOARDMODE_Y: number;
  12539. /**
  12540. * Billboard mode will apply to all axes
  12541. */
  12542. static readonly BILLBOARDMODE_ALL: number;
  12543. /**
  12544. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12545. */
  12546. static readonly BILLBOARDMODE_STRETCHED: number;
  12547. /**
  12548. * This function can be defined to provide custom update for active particles.
  12549. * This function will be called instead of regular update (age, position, color, etc.).
  12550. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12551. */
  12552. updateFunction: (particles: Particle[]) => void;
  12553. private _emitterWorldMatrix;
  12554. /**
  12555. * This function can be defined to specify initial direction for every new particle.
  12556. * It by default use the emitterType defined function
  12557. */
  12558. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12559. /**
  12560. * This function can be defined to specify initial position for every new particle.
  12561. * It by default use the emitterType defined function
  12562. */
  12563. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12564. /**
  12565. * @hidden
  12566. */
  12567. _inheritedVelocityOffset: Vector3;
  12568. /**
  12569. * An event triggered when the system is disposed
  12570. */
  12571. onDisposeObservable: Observable<IParticleSystem>;
  12572. private _onDisposeObserver;
  12573. /**
  12574. * Sets a callback that will be triggered when the system is disposed
  12575. */
  12576. set onDispose(callback: () => void);
  12577. private _particles;
  12578. private _epsilon;
  12579. private _capacity;
  12580. private _stockParticles;
  12581. private _newPartsExcess;
  12582. private _vertexData;
  12583. private _vertexBuffer;
  12584. private _vertexBuffers;
  12585. private _spriteBuffer;
  12586. private _indexBuffer;
  12587. private _effect;
  12588. private _customEffect;
  12589. private _cachedDefines;
  12590. private _scaledColorStep;
  12591. private _colorDiff;
  12592. private _scaledDirection;
  12593. private _scaledGravity;
  12594. private _currentRenderId;
  12595. private _alive;
  12596. private _useInstancing;
  12597. private _started;
  12598. private _stopped;
  12599. private _actualFrame;
  12600. private _scaledUpdateSpeed;
  12601. private _vertexBufferSize;
  12602. /** @hidden */
  12603. _currentEmitRateGradient: Nullable<FactorGradient>;
  12604. /** @hidden */
  12605. _currentEmitRate1: number;
  12606. /** @hidden */
  12607. _currentEmitRate2: number;
  12608. /** @hidden */
  12609. _currentStartSizeGradient: Nullable<FactorGradient>;
  12610. /** @hidden */
  12611. _currentStartSize1: number;
  12612. /** @hidden */
  12613. _currentStartSize2: number;
  12614. private readonly _rawTextureWidth;
  12615. private _rampGradientsTexture;
  12616. private _useRampGradients;
  12617. /** Gets or sets a matrix to use to compute projection */
  12618. defaultProjectionMatrix: Matrix;
  12619. /** Gets or sets a matrix to use to compute view */
  12620. defaultViewMatrix: Matrix;
  12621. /** Gets or sets a boolean indicating that ramp gradients must be used
  12622. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12623. */
  12624. get useRampGradients(): boolean;
  12625. set useRampGradients(value: boolean);
  12626. /**
  12627. * 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.
  12628. * 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: [])
  12629. */
  12630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12631. private _subEmitters;
  12632. /**
  12633. * @hidden
  12634. * If the particle systems emitter should be disposed when the particle system is disposed
  12635. */
  12636. _disposeEmitterOnDispose: boolean;
  12637. /**
  12638. * The current active Sub-systems, this property is used by the root particle system only.
  12639. */
  12640. activeSubSystems: Array<ParticleSystem>;
  12641. /**
  12642. * Specifies if the particles are updated in emitter local space or world space
  12643. */
  12644. isLocal: boolean;
  12645. private _rootParticleSystem;
  12646. /**
  12647. * Gets the current list of active particles
  12648. */
  12649. get particles(): Particle[];
  12650. /**
  12651. * Gets the number of particles active at the same time.
  12652. * @returns The number of active particles.
  12653. */
  12654. getActiveCount(): number;
  12655. /**
  12656. * Returns the string "ParticleSystem"
  12657. * @returns a string containing the class name
  12658. */
  12659. getClassName(): string;
  12660. /**
  12661. * Gets a boolean indicating that the system is stopping
  12662. * @returns true if the system is currently stopping
  12663. */
  12664. isStopping(): boolean;
  12665. /**
  12666. * Gets the custom effect used to render the particles
  12667. * @param blendMode Blend mode for which the effect should be retrieved
  12668. * @returns The effect
  12669. */
  12670. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12671. /**
  12672. * Sets the custom effect used to render the particles
  12673. * @param effect The effect to set
  12674. * @param blendMode Blend mode for which the effect should be set
  12675. */
  12676. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12677. /** @hidden */
  12678. private _onBeforeDrawParticlesObservable;
  12679. /**
  12680. * Observable that will be called just before the particles are drawn
  12681. */
  12682. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12683. /**
  12684. * Gets the name of the particle vertex shader
  12685. */
  12686. get vertexShaderName(): string;
  12687. /**
  12688. * Instantiates a particle system.
  12689. * 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.
  12690. * @param name The name of the particle system
  12691. * @param capacity The max number of particles alive at the same time
  12692. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12693. * @param customEffect a custom effect used to change the way particles are rendered by default
  12694. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12695. * @param epsilon Offset used to render the particles
  12696. */
  12697. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12698. private _addFactorGradient;
  12699. private _removeFactorGradient;
  12700. /**
  12701. * Adds a new life time gradient
  12702. * @param gradient defines the gradient to use (between 0 and 1)
  12703. * @param factor defines the life time factor to affect to the specified gradient
  12704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12705. * @returns the current particle system
  12706. */
  12707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12708. /**
  12709. * Remove a specific life time gradient
  12710. * @param gradient defines the gradient to remove
  12711. * @returns the current particle system
  12712. */
  12713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12714. /**
  12715. * Adds a new size gradient
  12716. * @param gradient defines the gradient to use (between 0 and 1)
  12717. * @param factor defines the size factor to affect to the specified gradient
  12718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12719. * @returns the current particle system
  12720. */
  12721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12722. /**
  12723. * Remove a specific size gradient
  12724. * @param gradient defines the gradient to remove
  12725. * @returns the current particle system
  12726. */
  12727. removeSizeGradient(gradient: number): IParticleSystem;
  12728. /**
  12729. * Adds a new color remap gradient
  12730. * @param gradient defines the gradient to use (between 0 and 1)
  12731. * @param min defines the color remap minimal range
  12732. * @param max defines the color remap maximal range
  12733. * @returns the current particle system
  12734. */
  12735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12736. /**
  12737. * Remove a specific color remap gradient
  12738. * @param gradient defines the gradient to remove
  12739. * @returns the current particle system
  12740. */
  12741. removeColorRemapGradient(gradient: number): IParticleSystem;
  12742. /**
  12743. * Adds a new alpha remap gradient
  12744. * @param gradient defines the gradient to use (between 0 and 1)
  12745. * @param min defines the alpha remap minimal range
  12746. * @param max defines the alpha remap maximal range
  12747. * @returns the current particle system
  12748. */
  12749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12750. /**
  12751. * Remove a specific alpha remap gradient
  12752. * @param gradient defines the gradient to remove
  12753. * @returns the current particle system
  12754. */
  12755. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12756. /**
  12757. * Adds a new angular speed gradient
  12758. * @param gradient defines the gradient to use (between 0 and 1)
  12759. * @param factor defines the angular speed to affect to the specified gradient
  12760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12761. * @returns the current particle system
  12762. */
  12763. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12764. /**
  12765. * Remove a specific angular speed gradient
  12766. * @param gradient defines the gradient to remove
  12767. * @returns the current particle system
  12768. */
  12769. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12770. /**
  12771. * Adds a new velocity gradient
  12772. * @param gradient defines the gradient to use (between 0 and 1)
  12773. * @param factor defines the velocity to affect to the specified gradient
  12774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12775. * @returns the current particle system
  12776. */
  12777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12778. /**
  12779. * Remove a specific velocity gradient
  12780. * @param gradient defines the gradient to remove
  12781. * @returns the current particle system
  12782. */
  12783. removeVelocityGradient(gradient: number): IParticleSystem;
  12784. /**
  12785. * Adds a new limit velocity gradient
  12786. * @param gradient defines the gradient to use (between 0 and 1)
  12787. * @param factor defines the limit velocity value to affect to the specified gradient
  12788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12789. * @returns the current particle system
  12790. */
  12791. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12792. /**
  12793. * Remove a specific limit velocity gradient
  12794. * @param gradient defines the gradient to remove
  12795. * @returns the current particle system
  12796. */
  12797. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12798. /**
  12799. * Adds a new drag gradient
  12800. * @param gradient defines the gradient to use (between 0 and 1)
  12801. * @param factor defines the drag value to affect to the specified gradient
  12802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12803. * @returns the current particle system
  12804. */
  12805. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12806. /**
  12807. * Remove a specific drag gradient
  12808. * @param gradient defines the gradient to remove
  12809. * @returns the current particle system
  12810. */
  12811. removeDragGradient(gradient: number): IParticleSystem;
  12812. /**
  12813. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12814. * @param gradient defines the gradient to use (between 0 and 1)
  12815. * @param factor defines the emit rate value to affect to the specified gradient
  12816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12817. * @returns the current particle system
  12818. */
  12819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12820. /**
  12821. * Remove a specific emit rate gradient
  12822. * @param gradient defines the gradient to remove
  12823. * @returns the current particle system
  12824. */
  12825. removeEmitRateGradient(gradient: number): IParticleSystem;
  12826. /**
  12827. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12828. * @param gradient defines the gradient to use (between 0 and 1)
  12829. * @param factor defines the start size value to affect to the specified gradient
  12830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12831. * @returns the current particle system
  12832. */
  12833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12834. /**
  12835. * Remove a specific start size gradient
  12836. * @param gradient defines the gradient to remove
  12837. * @returns the current particle system
  12838. */
  12839. removeStartSizeGradient(gradient: number): IParticleSystem;
  12840. private _createRampGradientTexture;
  12841. /**
  12842. * Gets the current list of ramp gradients.
  12843. * You must use addRampGradient and removeRampGradient to udpate this list
  12844. * @returns the list of ramp gradients
  12845. */
  12846. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12847. /** Force the system to rebuild all gradients that need to be resync */
  12848. forceRefreshGradients(): void;
  12849. private _syncRampGradientTexture;
  12850. /**
  12851. * Adds a new ramp gradient used to remap particle colors
  12852. * @param gradient defines the gradient to use (between 0 and 1)
  12853. * @param color defines the color to affect to the specified gradient
  12854. * @returns the current particle system
  12855. */
  12856. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12857. /**
  12858. * Remove a specific ramp gradient
  12859. * @param gradient defines the gradient to remove
  12860. * @returns the current particle system
  12861. */
  12862. removeRampGradient(gradient: number): ParticleSystem;
  12863. /**
  12864. * Adds a new color gradient
  12865. * @param gradient defines the gradient to use (between 0 and 1)
  12866. * @param color1 defines the color to affect to the specified gradient
  12867. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12868. * @returns this particle system
  12869. */
  12870. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12871. /**
  12872. * Remove a specific color gradient
  12873. * @param gradient defines the gradient to remove
  12874. * @returns this particle system
  12875. */
  12876. removeColorGradient(gradient: number): IParticleSystem;
  12877. private _fetchR;
  12878. protected _reset(): void;
  12879. private _resetEffect;
  12880. private _createVertexBuffers;
  12881. private _createIndexBuffer;
  12882. /**
  12883. * Gets the maximum number of particles active at the same time.
  12884. * @returns The max number of active particles.
  12885. */
  12886. getCapacity(): number;
  12887. /**
  12888. * Gets whether there are still active particles in the system.
  12889. * @returns True if it is alive, otherwise false.
  12890. */
  12891. isAlive(): boolean;
  12892. /**
  12893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12894. * @returns True if it has been started, otherwise false.
  12895. */
  12896. isStarted(): boolean;
  12897. private _prepareSubEmitterInternalArray;
  12898. /**
  12899. * Starts the particle system and begins to emit
  12900. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12901. */
  12902. start(delay?: number): void;
  12903. /**
  12904. * Stops the particle system.
  12905. * @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.
  12906. */
  12907. stop(stopSubEmitters?: boolean): void;
  12908. /**
  12909. * Remove all active particles
  12910. */
  12911. reset(): void;
  12912. /**
  12913. * @hidden (for internal use only)
  12914. */
  12915. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12916. /**
  12917. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12918. * Its lifetime will start back at 0.
  12919. */
  12920. recycleParticle: (particle: Particle) => void;
  12921. private _stopSubEmitters;
  12922. private _createParticle;
  12923. private _removeFromRoot;
  12924. private _emitFromParticle;
  12925. private _update;
  12926. /** @hidden */
  12927. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12928. /** @hidden */
  12929. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12930. /**
  12931. * Fill the defines array according to the current settings of the particle system
  12932. * @param defines Array to be updated
  12933. * @param blendMode blend mode to take into account when updating the array
  12934. */
  12935. fillDefines(defines: Array<string>, blendMode: number): void;
  12936. /**
  12937. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12938. * @param uniforms Uniforms array to fill
  12939. * @param attributes Attributes array to fill
  12940. * @param samplers Samplers array to fill
  12941. */
  12942. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12943. /** @hidden */
  12944. private _getEffect;
  12945. /**
  12946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12947. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12948. */
  12949. animate(preWarmOnly?: boolean): void;
  12950. private _appendParticleVertices;
  12951. /**
  12952. * Rebuilds the particle system.
  12953. */
  12954. rebuild(): void;
  12955. /**
  12956. * Is this system ready to be used/rendered
  12957. * @return true if the system is ready
  12958. */
  12959. isReady(): boolean;
  12960. private _render;
  12961. /**
  12962. * Renders the particle system in its current state.
  12963. * @returns the current number of particles
  12964. */
  12965. render(): number;
  12966. /**
  12967. * Disposes the particle system and free the associated resources
  12968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12969. */
  12970. dispose(disposeTexture?: boolean): void;
  12971. /**
  12972. * Clones the particle system.
  12973. * @param name The name of the cloned object
  12974. * @param newEmitter The new emitter to use
  12975. * @returns the cloned particle system
  12976. */
  12977. clone(name: string, newEmitter: any): ParticleSystem;
  12978. /**
  12979. * Serializes the particle system to a JSON object
  12980. * @param serializeTexture defines if the texture must be serialized as well
  12981. * @returns the JSON object
  12982. */
  12983. serialize(serializeTexture?: boolean): any;
  12984. /** @hidden */
  12985. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12986. /** @hidden */
  12987. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12988. /**
  12989. * Parses a JSON object to create a particle system.
  12990. * @param parsedParticleSystem The JSON object to parse
  12991. * @param sceneOrEngine The scene or the engine to create the particle system in
  12992. * @param rootUrl The root url to use to load external dependencies like texture
  12993. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12994. * @returns the Parsed particle system
  12995. */
  12996. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * A particle represents one of the element emitted by a particle system.
  13002. * This is mainly define by its coordinates, direction, velocity and age.
  13003. */
  13004. export class Particle {
  13005. /**
  13006. * The particle system the particle belongs to.
  13007. */
  13008. particleSystem: ParticleSystem;
  13009. private static _Count;
  13010. /**
  13011. * Unique ID of the particle
  13012. */
  13013. id: number;
  13014. /**
  13015. * The world position of the particle in the scene.
  13016. */
  13017. position: Vector3;
  13018. /**
  13019. * The world direction of the particle in the scene.
  13020. */
  13021. direction: Vector3;
  13022. /**
  13023. * The color of the particle.
  13024. */
  13025. color: Color4;
  13026. /**
  13027. * The color change of the particle per step.
  13028. */
  13029. colorStep: Color4;
  13030. /**
  13031. * Defines how long will the life of the particle be.
  13032. */
  13033. lifeTime: number;
  13034. /**
  13035. * The current age of the particle.
  13036. */
  13037. age: number;
  13038. /**
  13039. * The current size of the particle.
  13040. */
  13041. size: number;
  13042. /**
  13043. * The current scale of the particle.
  13044. */
  13045. scale: Vector2;
  13046. /**
  13047. * The current angle of the particle.
  13048. */
  13049. angle: number;
  13050. /**
  13051. * Defines how fast is the angle changing.
  13052. */
  13053. angularSpeed: number;
  13054. /**
  13055. * Defines the cell index used by the particle to be rendered from a sprite.
  13056. */
  13057. cellIndex: number;
  13058. /**
  13059. * The information required to support color remapping
  13060. */
  13061. remapData: Vector4;
  13062. /** @hidden */
  13063. _randomCellOffset?: number;
  13064. /** @hidden */
  13065. _initialDirection: Nullable<Vector3>;
  13066. /** @hidden */
  13067. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13068. /** @hidden */
  13069. _initialStartSpriteCellID: number;
  13070. /** @hidden */
  13071. _initialEndSpriteCellID: number;
  13072. /** @hidden */
  13073. _currentColorGradient: Nullable<ColorGradient>;
  13074. /** @hidden */
  13075. _currentColor1: Color4;
  13076. /** @hidden */
  13077. _currentColor2: Color4;
  13078. /** @hidden */
  13079. _currentSizeGradient: Nullable<FactorGradient>;
  13080. /** @hidden */
  13081. _currentSize1: number;
  13082. /** @hidden */
  13083. _currentSize2: number;
  13084. /** @hidden */
  13085. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13086. /** @hidden */
  13087. _currentAngularSpeed1: number;
  13088. /** @hidden */
  13089. _currentAngularSpeed2: number;
  13090. /** @hidden */
  13091. _currentVelocityGradient: Nullable<FactorGradient>;
  13092. /** @hidden */
  13093. _currentVelocity1: number;
  13094. /** @hidden */
  13095. _currentVelocity2: number;
  13096. /** @hidden */
  13097. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13098. /** @hidden */
  13099. _currentLimitVelocity1: number;
  13100. /** @hidden */
  13101. _currentLimitVelocity2: number;
  13102. /** @hidden */
  13103. _currentDragGradient: Nullable<FactorGradient>;
  13104. /** @hidden */
  13105. _currentDrag1: number;
  13106. /** @hidden */
  13107. _currentDrag2: number;
  13108. /** @hidden */
  13109. _randomNoiseCoordinates1: Vector3;
  13110. /** @hidden */
  13111. _randomNoiseCoordinates2: Vector3;
  13112. /** @hidden */
  13113. _localPosition?: Vector3;
  13114. /**
  13115. * Creates a new instance Particle
  13116. * @param particleSystem the particle system the particle belongs to
  13117. */
  13118. constructor(
  13119. /**
  13120. * The particle system the particle belongs to.
  13121. */
  13122. particleSystem: ParticleSystem);
  13123. private updateCellInfoFromSystem;
  13124. /**
  13125. * Defines how the sprite cell index is updated for the particle
  13126. */
  13127. updateCellIndex(): void;
  13128. /** @hidden */
  13129. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13130. /** @hidden */
  13131. _inheritParticleInfoToSubEmitters(): void;
  13132. /** @hidden */
  13133. _reset(): void;
  13134. /**
  13135. * Copy the properties of particle to another one.
  13136. * @param other the particle to copy the information to.
  13137. */
  13138. copyTo(other: Particle): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Particle emitter represents a volume emitting particles.
  13144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13145. */
  13146. export interface IParticleEmitterType {
  13147. /**
  13148. * Called by the particle System when the direction is computed for the created particle.
  13149. * @param worldMatrix is the world matrix of the particle system
  13150. * @param directionToUpdate is the direction vector to update with the result
  13151. * @param particle is the particle we are computed the direction for
  13152. * @param isLocal defines if the direction should be set in local space
  13153. */
  13154. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13155. /**
  13156. * Called by the particle System when the position is computed for the created particle.
  13157. * @param worldMatrix is the world matrix of the particle system
  13158. * @param positionToUpdate is the position vector to update with the result
  13159. * @param particle is the particle we are computed the position for
  13160. * @param isLocal defines if the position should be set in local space
  13161. */
  13162. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13163. /**
  13164. * Clones the current emitter and returns a copy of it
  13165. * @returns the new emitter
  13166. */
  13167. clone(): IParticleEmitterType;
  13168. /**
  13169. * Called by the GPUParticleSystem to setup the update shader
  13170. * @param effect defines the update shader
  13171. */
  13172. applyToShader(effect: Effect): void;
  13173. /**
  13174. * Returns a string to use to update the GPU particles update shader
  13175. * @returns the effect defines string
  13176. */
  13177. getEffectDefines(): string;
  13178. /**
  13179. * Returns a string representing the class name
  13180. * @returns a string containing the class name
  13181. */
  13182. getClassName(): string;
  13183. /**
  13184. * Serializes the particle system to a JSON object.
  13185. * @returns the JSON object
  13186. */
  13187. serialize(): any;
  13188. /**
  13189. * Parse properties from a JSON object
  13190. * @param serializationObject defines the JSON object
  13191. * @param scene defines the hosting scene
  13192. */
  13193. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13194. }
  13195. }
  13196. declare module BABYLON {
  13197. /**
  13198. * Particle emitter emitting particles from the inside of a box.
  13199. * It emits the particles randomly between 2 given directions.
  13200. */
  13201. export class BoxParticleEmitter implements IParticleEmitterType {
  13202. /**
  13203. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13204. */
  13205. direction1: Vector3;
  13206. /**
  13207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13208. */
  13209. direction2: Vector3;
  13210. /**
  13211. * 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.
  13212. */
  13213. minEmitBox: Vector3;
  13214. /**
  13215. * 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.
  13216. */
  13217. maxEmitBox: Vector3;
  13218. /**
  13219. * Creates a new instance BoxParticleEmitter
  13220. */
  13221. constructor();
  13222. /**
  13223. * Called by the particle System when the direction is computed for the created particle.
  13224. * @param worldMatrix is the world matrix of the particle system
  13225. * @param directionToUpdate is the direction vector to update with the result
  13226. * @param particle is the particle we are computed the direction for
  13227. * @param isLocal defines if the direction should be set in local space
  13228. */
  13229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13230. /**
  13231. * Called by the particle System when the position is computed for the created particle.
  13232. * @param worldMatrix is the world matrix of the particle system
  13233. * @param positionToUpdate is the position vector to update with the result
  13234. * @param particle is the particle we are computed the position for
  13235. * @param isLocal defines if the position should be set in local space
  13236. */
  13237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13238. /**
  13239. * Clones the current emitter and returns a copy of it
  13240. * @returns the new emitter
  13241. */
  13242. clone(): BoxParticleEmitter;
  13243. /**
  13244. * Called by the GPUParticleSystem to setup the update shader
  13245. * @param effect defines the update shader
  13246. */
  13247. applyToShader(effect: Effect): void;
  13248. /**
  13249. * Returns a string to use to update the GPU particles update shader
  13250. * @returns a string containng the defines string
  13251. */
  13252. getEffectDefines(): string;
  13253. /**
  13254. * Returns the string "BoxParticleEmitter"
  13255. * @returns a string containing the class name
  13256. */
  13257. getClassName(): string;
  13258. /**
  13259. * Serializes the particle system to a JSON object.
  13260. * @returns the JSON object
  13261. */
  13262. serialize(): any;
  13263. /**
  13264. * Parse properties from a JSON object
  13265. * @param serializationObject defines the JSON object
  13266. */
  13267. parse(serializationObject: any): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a cone.
  13273. * It emits the particles alongside the cone volume from the base to the particle.
  13274. * The emission direction might be randomized.
  13275. */
  13276. export class ConeParticleEmitter implements IParticleEmitterType {
  13277. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13278. directionRandomizer: number;
  13279. private _radius;
  13280. private _angle;
  13281. private _height;
  13282. /**
  13283. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13284. */
  13285. radiusRange: number;
  13286. /**
  13287. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13288. */
  13289. heightRange: number;
  13290. /**
  13291. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13292. */
  13293. emitFromSpawnPointOnly: boolean;
  13294. /**
  13295. * Gets or sets the radius of the emission cone
  13296. */
  13297. get radius(): number;
  13298. set radius(value: number);
  13299. /**
  13300. * Gets or sets the angle of the emission cone
  13301. */
  13302. get angle(): number;
  13303. set angle(value: number);
  13304. private _buildHeight;
  13305. /**
  13306. * Creates a new instance ConeParticleEmitter
  13307. * @param radius the radius of the emission cone (1 by default)
  13308. * @param angle the cone base angle (PI by default)
  13309. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13310. */
  13311. constructor(radius?: number, angle?: number,
  13312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13313. directionRandomizer?: number);
  13314. /**
  13315. * Called by the particle System when the direction is computed for the created particle.
  13316. * @param worldMatrix is the world matrix of the particle system
  13317. * @param directionToUpdate is the direction vector to update with the result
  13318. * @param particle is the particle we are computed the direction for
  13319. * @param isLocal defines if the direction should be set in local space
  13320. */
  13321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13322. /**
  13323. * Called by the particle System when the position is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param positionToUpdate is the position vector to update with the result
  13326. * @param particle is the particle we are computed the position for
  13327. * @param isLocal defines if the position should be set in local space
  13328. */
  13329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Clones the current emitter and returns a copy of it
  13332. * @returns the new emitter
  13333. */
  13334. clone(): ConeParticleEmitter;
  13335. /**
  13336. * Called by the GPUParticleSystem to setup the update shader
  13337. * @param effect defines the update shader
  13338. */
  13339. applyToShader(effect: Effect): void;
  13340. /**
  13341. * Returns a string to use to update the GPU particles update shader
  13342. * @returns a string containng the defines string
  13343. */
  13344. getEffectDefines(): string;
  13345. /**
  13346. * Returns the string "ConeParticleEmitter"
  13347. * @returns a string containing the class name
  13348. */
  13349. getClassName(): string;
  13350. /**
  13351. * Serializes the particle system to a JSON object.
  13352. * @returns the JSON object
  13353. */
  13354. serialize(): any;
  13355. /**
  13356. * Parse properties from a JSON object
  13357. * @param serializationObject defines the JSON object
  13358. */
  13359. parse(serializationObject: any): void;
  13360. }
  13361. }
  13362. declare module BABYLON {
  13363. /**
  13364. * Particle emitter emitting particles from the inside of a cylinder.
  13365. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13366. */
  13367. export class CylinderParticleEmitter implements IParticleEmitterType {
  13368. /**
  13369. * The radius of the emission cylinder.
  13370. */
  13371. radius: number;
  13372. /**
  13373. * The height of the emission cylinder.
  13374. */
  13375. height: number;
  13376. /**
  13377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13378. */
  13379. radiusRange: number;
  13380. /**
  13381. * How much to randomize the particle direction [0-1].
  13382. */
  13383. directionRandomizer: number;
  13384. /**
  13385. * Creates a new instance CylinderParticleEmitter
  13386. * @param radius the radius of the emission cylinder (1 by default)
  13387. * @param height the height of the emission cylinder (1 by default)
  13388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13389. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13390. */
  13391. constructor(
  13392. /**
  13393. * The radius of the emission cylinder.
  13394. */
  13395. radius?: number,
  13396. /**
  13397. * The height of the emission cylinder.
  13398. */
  13399. height?: number,
  13400. /**
  13401. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13402. */
  13403. radiusRange?: number,
  13404. /**
  13405. * How much to randomize the particle direction [0-1].
  13406. */
  13407. directionRandomizer?: number);
  13408. /**
  13409. * Called by the particle System when the direction is computed for the created particle.
  13410. * @param worldMatrix is the world matrix of the particle system
  13411. * @param directionToUpdate is the direction vector to update with the result
  13412. * @param particle is the particle we are computed the direction for
  13413. * @param isLocal defines if the direction should be set in local space
  13414. */
  13415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13416. /**
  13417. * Called by the particle System when the position is computed for the created particle.
  13418. * @param worldMatrix is the world matrix of the particle system
  13419. * @param positionToUpdate is the position vector to update with the result
  13420. * @param particle is the particle we are computed the position for
  13421. * @param isLocal defines if the position should be set in local space
  13422. */
  13423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13424. /**
  13425. * Clones the current emitter and returns a copy of it
  13426. * @returns the new emitter
  13427. */
  13428. clone(): CylinderParticleEmitter;
  13429. /**
  13430. * Called by the GPUParticleSystem to setup the update shader
  13431. * @param effect defines the update shader
  13432. */
  13433. applyToShader(effect: Effect): void;
  13434. /**
  13435. * Returns a string to use to update the GPU particles update shader
  13436. * @returns a string containng the defines string
  13437. */
  13438. getEffectDefines(): string;
  13439. /**
  13440. * Returns the string "CylinderParticleEmitter"
  13441. * @returns a string containing the class name
  13442. */
  13443. getClassName(): string;
  13444. /**
  13445. * Serializes the particle system to a JSON object.
  13446. * @returns the JSON object
  13447. */
  13448. serialize(): any;
  13449. /**
  13450. * Parse properties from a JSON object
  13451. * @param serializationObject defines the JSON object
  13452. */
  13453. parse(serializationObject: any): void;
  13454. }
  13455. /**
  13456. * Particle emitter emitting particles from the inside of a cylinder.
  13457. * It emits the particles randomly between two vectors.
  13458. */
  13459. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13460. /**
  13461. * The min limit of the emission direction.
  13462. */
  13463. direction1: Vector3;
  13464. /**
  13465. * The max limit of the emission direction.
  13466. */
  13467. direction2: Vector3;
  13468. /**
  13469. * Creates a new instance CylinderDirectedParticleEmitter
  13470. * @param radius the radius of the emission cylinder (1 by default)
  13471. * @param height the height of the emission cylinder (1 by default)
  13472. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13473. * @param direction1 the min limit of the emission direction (up vector by default)
  13474. * @param direction2 the max limit of the emission direction (up vector by default)
  13475. */
  13476. constructor(radius?: number, height?: number, radiusRange?: number,
  13477. /**
  13478. * The min limit of the emission direction.
  13479. */
  13480. direction1?: Vector3,
  13481. /**
  13482. * The max limit of the emission direction.
  13483. */
  13484. direction2?: Vector3);
  13485. /**
  13486. * Called by the particle System when the direction is computed for the created particle.
  13487. * @param worldMatrix is the world matrix of the particle system
  13488. * @param directionToUpdate is the direction vector to update with the result
  13489. * @param particle is the particle we are computed the direction for
  13490. */
  13491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13492. /**
  13493. * Clones the current emitter and returns a copy of it
  13494. * @returns the new emitter
  13495. */
  13496. clone(): CylinderDirectedParticleEmitter;
  13497. /**
  13498. * Called by the GPUParticleSystem to setup the update shader
  13499. * @param effect defines the update shader
  13500. */
  13501. applyToShader(effect: Effect): void;
  13502. /**
  13503. * Returns a string to use to update the GPU particles update shader
  13504. * @returns a string containng the defines string
  13505. */
  13506. getEffectDefines(): string;
  13507. /**
  13508. * Returns the string "CylinderDirectedParticleEmitter"
  13509. * @returns a string containing the class name
  13510. */
  13511. getClassName(): string;
  13512. /**
  13513. * Serializes the particle system to a JSON object.
  13514. * @returns the JSON object
  13515. */
  13516. serialize(): any;
  13517. /**
  13518. * Parse properties from a JSON object
  13519. * @param serializationObject defines the JSON object
  13520. */
  13521. parse(serializationObject: any): void;
  13522. }
  13523. }
  13524. declare module BABYLON {
  13525. /**
  13526. * Particle emitter emitting particles from the inside of a hemisphere.
  13527. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13528. */
  13529. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13530. /**
  13531. * The radius of the emission hemisphere.
  13532. */
  13533. radius: number;
  13534. /**
  13535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13536. */
  13537. radiusRange: number;
  13538. /**
  13539. * How much to randomize the particle direction [0-1].
  13540. */
  13541. directionRandomizer: number;
  13542. /**
  13543. * Creates a new instance HemisphericParticleEmitter
  13544. * @param radius the radius of the emission hemisphere (1 by default)
  13545. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13546. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13547. */
  13548. constructor(
  13549. /**
  13550. * The radius of the emission hemisphere.
  13551. */
  13552. radius?: number,
  13553. /**
  13554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13555. */
  13556. radiusRange?: number,
  13557. /**
  13558. * How much to randomize the particle direction [0-1].
  13559. */
  13560. directionRandomizer?: number);
  13561. /**
  13562. * Called by the particle System when the direction is computed for the created particle.
  13563. * @param worldMatrix is the world matrix of the particle system
  13564. * @param directionToUpdate is the direction vector to update with the result
  13565. * @param particle is the particle we are computed the direction for
  13566. * @param isLocal defines if the direction should be set in local space
  13567. */
  13568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13569. /**
  13570. * Called by the particle System when the position is computed for the created particle.
  13571. * @param worldMatrix is the world matrix of the particle system
  13572. * @param positionToUpdate is the position vector to update with the result
  13573. * @param particle is the particle we are computed the position for
  13574. * @param isLocal defines if the position should be set in local space
  13575. */
  13576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13577. /**
  13578. * Clones the current emitter and returns a copy of it
  13579. * @returns the new emitter
  13580. */
  13581. clone(): HemisphericParticleEmitter;
  13582. /**
  13583. * Called by the GPUParticleSystem to setup the update shader
  13584. * @param effect defines the update shader
  13585. */
  13586. applyToShader(effect: Effect): void;
  13587. /**
  13588. * Returns a string to use to update the GPU particles update shader
  13589. * @returns a string containng the defines string
  13590. */
  13591. getEffectDefines(): string;
  13592. /**
  13593. * Returns the string "HemisphericParticleEmitter"
  13594. * @returns a string containing the class name
  13595. */
  13596. getClassName(): string;
  13597. /**
  13598. * Serializes the particle system to a JSON object.
  13599. * @returns the JSON object
  13600. */
  13601. serialize(): any;
  13602. /**
  13603. * Parse properties from a JSON object
  13604. * @param serializationObject defines the JSON object
  13605. */
  13606. parse(serializationObject: any): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. /**
  13611. * Particle emitter emitting particles from a point.
  13612. * It emits the particles randomly between 2 given directions.
  13613. */
  13614. export class PointParticleEmitter implements IParticleEmitterType {
  13615. /**
  13616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13617. */
  13618. direction1: Vector3;
  13619. /**
  13620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13621. */
  13622. direction2: Vector3;
  13623. /**
  13624. * Creates a new instance PointParticleEmitter
  13625. */
  13626. constructor();
  13627. /**
  13628. * Called by the particle System when the direction is computed for the created particle.
  13629. * @param worldMatrix is the world matrix of the particle system
  13630. * @param directionToUpdate is the direction vector to update with the result
  13631. * @param particle is the particle we are computed the direction for
  13632. * @param isLocal defines if the direction should be set in local space
  13633. */
  13634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13635. /**
  13636. * Called by the particle System when the position is computed for the created particle.
  13637. * @param worldMatrix is the world matrix of the particle system
  13638. * @param positionToUpdate is the position vector to update with the result
  13639. * @param particle is the particle we are computed the position for
  13640. * @param isLocal defines if the position should be set in local space
  13641. */
  13642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13643. /**
  13644. * Clones the current emitter and returns a copy of it
  13645. * @returns the new emitter
  13646. */
  13647. clone(): PointParticleEmitter;
  13648. /**
  13649. * Called by the GPUParticleSystem to setup the update shader
  13650. * @param effect defines the update shader
  13651. */
  13652. applyToShader(effect: Effect): void;
  13653. /**
  13654. * Returns a string to use to update the GPU particles update shader
  13655. * @returns a string containng the defines string
  13656. */
  13657. getEffectDefines(): string;
  13658. /**
  13659. * Returns the string "PointParticleEmitter"
  13660. * @returns a string containing the class name
  13661. */
  13662. getClassName(): string;
  13663. /**
  13664. * Serializes the particle system to a JSON object.
  13665. * @returns the JSON object
  13666. */
  13667. serialize(): any;
  13668. /**
  13669. * Parse properties from a JSON object
  13670. * @param serializationObject defines the JSON object
  13671. */
  13672. parse(serializationObject: any): void;
  13673. }
  13674. }
  13675. declare module BABYLON {
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a sphere.
  13678. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13679. */
  13680. export class SphereParticleEmitter implements IParticleEmitterType {
  13681. /**
  13682. * The radius of the emission sphere.
  13683. */
  13684. radius: number;
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange: number;
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer: number;
  13693. /**
  13694. * Creates a new instance SphereParticleEmitter
  13695. * @param radius the radius of the emission sphere (1 by default)
  13696. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13697. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13698. */
  13699. constructor(
  13700. /**
  13701. * The radius of the emission sphere.
  13702. */
  13703. radius?: number,
  13704. /**
  13705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13706. */
  13707. radiusRange?: number,
  13708. /**
  13709. * How much to randomize the particle direction [0-1].
  13710. */
  13711. directionRandomizer?: number);
  13712. /**
  13713. * Called by the particle System when the direction is computed for the created particle.
  13714. * @param worldMatrix is the world matrix of the particle system
  13715. * @param directionToUpdate is the direction vector to update with the result
  13716. * @param particle is the particle we are computed the direction for
  13717. * @param isLocal defines if the direction should be set in local space
  13718. */
  13719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13720. /**
  13721. * Called by the particle System when the position is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param positionToUpdate is the position vector to update with the result
  13724. * @param particle is the particle we are computed the position for
  13725. * @param isLocal defines if the position should be set in local space
  13726. */
  13727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Clones the current emitter and returns a copy of it
  13730. * @returns the new emitter
  13731. */
  13732. clone(): SphereParticleEmitter;
  13733. /**
  13734. * Called by the GPUParticleSystem to setup the update shader
  13735. * @param effect defines the update shader
  13736. */
  13737. applyToShader(effect: Effect): void;
  13738. /**
  13739. * Returns a string to use to update the GPU particles update shader
  13740. * @returns a string containng the defines string
  13741. */
  13742. getEffectDefines(): string;
  13743. /**
  13744. * Returns the string "SphereParticleEmitter"
  13745. * @returns a string containing the class name
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Serializes the particle system to a JSON object.
  13750. * @returns the JSON object
  13751. */
  13752. serialize(): any;
  13753. /**
  13754. * Parse properties from a JSON object
  13755. * @param serializationObject defines the JSON object
  13756. */
  13757. parse(serializationObject: any): void;
  13758. }
  13759. /**
  13760. * Particle emitter emitting particles from the inside of a sphere.
  13761. * It emits the particles randomly between two vectors.
  13762. */
  13763. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13764. /**
  13765. * The min limit of the emission direction.
  13766. */
  13767. direction1: Vector3;
  13768. /**
  13769. * The max limit of the emission direction.
  13770. */
  13771. direction2: Vector3;
  13772. /**
  13773. * Creates a new instance SphereDirectedParticleEmitter
  13774. * @param radius the radius of the emission sphere (1 by default)
  13775. * @param direction1 the min limit of the emission direction (up vector by default)
  13776. * @param direction2 the max limit of the emission direction (up vector by default)
  13777. */
  13778. constructor(radius?: number,
  13779. /**
  13780. * The min limit of the emission direction.
  13781. */
  13782. direction1?: Vector3,
  13783. /**
  13784. * The max limit of the emission direction.
  13785. */
  13786. direction2?: Vector3);
  13787. /**
  13788. * Called by the particle System when the direction is computed for the created particle.
  13789. * @param worldMatrix is the world matrix of the particle system
  13790. * @param directionToUpdate is the direction vector to update with the result
  13791. * @param particle is the particle we are computed the direction for
  13792. */
  13793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13794. /**
  13795. * Clones the current emitter and returns a copy of it
  13796. * @returns the new emitter
  13797. */
  13798. clone(): SphereDirectedParticleEmitter;
  13799. /**
  13800. * Called by the GPUParticleSystem to setup the update shader
  13801. * @param effect defines the update shader
  13802. */
  13803. applyToShader(effect: Effect): void;
  13804. /**
  13805. * Returns a string to use to update the GPU particles update shader
  13806. * @returns a string containng the defines string
  13807. */
  13808. getEffectDefines(): string;
  13809. /**
  13810. * Returns the string "SphereDirectedParticleEmitter"
  13811. * @returns a string containing the class name
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Serializes the particle system to a JSON object.
  13816. * @returns the JSON object
  13817. */
  13818. serialize(): any;
  13819. /**
  13820. * Parse properties from a JSON object
  13821. * @param serializationObject defines the JSON object
  13822. */
  13823. parse(serializationObject: any): void;
  13824. }
  13825. }
  13826. declare module BABYLON {
  13827. /**
  13828. * Particle emitter emitting particles from a custom list of positions.
  13829. */
  13830. export class CustomParticleEmitter implements IParticleEmitterType {
  13831. /**
  13832. * Gets or sets the position generator that will create the inital position of each particle.
  13833. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13834. */
  13835. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13836. /**
  13837. * Gets or sets the destination generator that will create the final destination of each particle.
  13838. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13839. */
  13840. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13841. /**
  13842. * Creates a new instance CustomParticleEmitter
  13843. */
  13844. constructor();
  13845. /**
  13846. * Called by the particle System when the direction is computed for the created particle.
  13847. * @param worldMatrix is the world matrix of the particle system
  13848. * @param directionToUpdate is the direction vector to update with the result
  13849. * @param particle is the particle we are computed the direction for
  13850. * @param isLocal defines if the direction should be set in local space
  13851. */
  13852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13853. /**
  13854. * Called by the particle System when the position is computed for the created particle.
  13855. * @param worldMatrix is the world matrix of the particle system
  13856. * @param positionToUpdate is the position vector to update with the result
  13857. * @param particle is the particle we are computed the position for
  13858. * @param isLocal defines if the position should be set in local space
  13859. */
  13860. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13861. /**
  13862. * Clones the current emitter and returns a copy of it
  13863. * @returns the new emitter
  13864. */
  13865. clone(): CustomParticleEmitter;
  13866. /**
  13867. * Called by the GPUParticleSystem to setup the update shader
  13868. * @param effect defines the update shader
  13869. */
  13870. applyToShader(effect: Effect): void;
  13871. /**
  13872. * Returns a string to use to update the GPU particles update shader
  13873. * @returns a string containng the defines string
  13874. */
  13875. getEffectDefines(): string;
  13876. /**
  13877. * Returns the string "PointParticleEmitter"
  13878. * @returns a string containing the class name
  13879. */
  13880. getClassName(): string;
  13881. /**
  13882. * Serializes the particle system to a JSON object.
  13883. * @returns the JSON object
  13884. */
  13885. serialize(): any;
  13886. /**
  13887. * Parse properties from a JSON object
  13888. * @param serializationObject defines the JSON object
  13889. */
  13890. parse(serializationObject: any): void;
  13891. }
  13892. }
  13893. declare module BABYLON {
  13894. /**
  13895. * Particle emitter emitting particles from the inside of a box.
  13896. * It emits the particles randomly between 2 given directions.
  13897. */
  13898. export class MeshParticleEmitter implements IParticleEmitterType {
  13899. private _indices;
  13900. private _positions;
  13901. private _normals;
  13902. private _storedNormal;
  13903. private _mesh;
  13904. /**
  13905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13914. */
  13915. useMeshNormalsForDirection: boolean;
  13916. /** Defines the mesh to use as source */
  13917. get mesh(): Nullable<AbstractMesh>;
  13918. set mesh(value: Nullable<AbstractMesh>);
  13919. /**
  13920. * Creates a new instance MeshParticleEmitter
  13921. * @param mesh defines the mesh to use as source
  13922. */
  13923. constructor(mesh?: Nullable<AbstractMesh>);
  13924. /**
  13925. * Called by the particle System when the direction is computed for the created particle.
  13926. * @param worldMatrix is the world matrix of the particle system
  13927. * @param directionToUpdate is the direction vector to update with the result
  13928. * @param particle is the particle we are computed the direction for
  13929. * @param isLocal defines if the direction should be set in local space
  13930. */
  13931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13932. /**
  13933. * Called by the particle System when the position is computed for the created particle.
  13934. * @param worldMatrix is the world matrix of the particle system
  13935. * @param positionToUpdate is the position vector to update with the result
  13936. * @param particle is the particle we are computed the position for
  13937. * @param isLocal defines if the position should be set in local space
  13938. */
  13939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13940. /**
  13941. * Clones the current emitter and returns a copy of it
  13942. * @returns the new emitter
  13943. */
  13944. clone(): MeshParticleEmitter;
  13945. /**
  13946. * Called by the GPUParticleSystem to setup the update shader
  13947. * @param effect defines the update shader
  13948. */
  13949. applyToShader(effect: Effect): void;
  13950. /**
  13951. * Returns a string to use to update the GPU particles update shader
  13952. * @returns a string containng the defines string
  13953. */
  13954. getEffectDefines(): string;
  13955. /**
  13956. * Returns the string "BoxParticleEmitter"
  13957. * @returns a string containing the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Serializes the particle system to a JSON object.
  13962. * @returns the JSON object
  13963. */
  13964. serialize(): any;
  13965. /**
  13966. * Parse properties from a JSON object
  13967. * @param serializationObject defines the JSON object
  13968. * @param scene defines the hosting scene
  13969. */
  13970. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13971. }
  13972. }
  13973. declare module BABYLON {
  13974. /**
  13975. * Interface representing a particle system in Babylon.js.
  13976. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13977. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13978. */
  13979. export interface IParticleSystem {
  13980. /**
  13981. * List of animations used by the particle system.
  13982. */
  13983. animations: Animation[];
  13984. /**
  13985. * The id of the Particle system.
  13986. */
  13987. id: string;
  13988. /**
  13989. * The name of the Particle system.
  13990. */
  13991. name: string;
  13992. /**
  13993. * The emitter represents the Mesh or position we are attaching the particle system to.
  13994. */
  13995. emitter: Nullable<AbstractMesh | Vector3>;
  13996. /**
  13997. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13998. */
  13999. isBillboardBased: boolean;
  14000. /**
  14001. * The rendering group used by the Particle system to chose when to render.
  14002. */
  14003. renderingGroupId: number;
  14004. /**
  14005. * The layer mask we are rendering the particles through.
  14006. */
  14007. layerMask: number;
  14008. /**
  14009. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14010. */
  14011. updateSpeed: number;
  14012. /**
  14013. * The amount of time the particle system is running (depends of the overall update speed).
  14014. */
  14015. targetStopDuration: number;
  14016. /**
  14017. * The texture used to render each particle. (this can be a spritesheet)
  14018. */
  14019. particleTexture: Nullable<BaseTexture>;
  14020. /**
  14021. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14022. */
  14023. blendMode: number;
  14024. /**
  14025. * Minimum life time of emitting particles.
  14026. */
  14027. minLifeTime: number;
  14028. /**
  14029. * Maximum life time of emitting particles.
  14030. */
  14031. maxLifeTime: number;
  14032. /**
  14033. * Minimum Size of emitting particles.
  14034. */
  14035. minSize: number;
  14036. /**
  14037. * Maximum Size of emitting particles.
  14038. */
  14039. maxSize: number;
  14040. /**
  14041. * Minimum scale of emitting particles on X axis.
  14042. */
  14043. minScaleX: number;
  14044. /**
  14045. * Maximum scale of emitting particles on X axis.
  14046. */
  14047. maxScaleX: number;
  14048. /**
  14049. * Minimum scale of emitting particles on Y axis.
  14050. */
  14051. minScaleY: number;
  14052. /**
  14053. * Maximum scale of emitting particles on Y axis.
  14054. */
  14055. maxScaleY: number;
  14056. /**
  14057. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14058. */
  14059. color1: Color4;
  14060. /**
  14061. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14062. */
  14063. color2: Color4;
  14064. /**
  14065. * Color the particle will have at the end of its lifetime.
  14066. */
  14067. colorDead: Color4;
  14068. /**
  14069. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14070. */
  14071. emitRate: number;
  14072. /**
  14073. * You can use gravity if you want to give an orientation to your particles.
  14074. */
  14075. gravity: Vector3;
  14076. /**
  14077. * Minimum power of emitting particles.
  14078. */
  14079. minEmitPower: number;
  14080. /**
  14081. * Maximum power of emitting particles.
  14082. */
  14083. maxEmitPower: number;
  14084. /**
  14085. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14086. */
  14087. minAngularSpeed: number;
  14088. /**
  14089. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14090. */
  14091. maxAngularSpeed: number;
  14092. /**
  14093. * Gets or sets the minimal initial rotation in radians.
  14094. */
  14095. minInitialRotation: number;
  14096. /**
  14097. * Gets or sets the maximal initial rotation in radians.
  14098. */
  14099. maxInitialRotation: number;
  14100. /**
  14101. * The particle emitter type defines the emitter used by the particle system.
  14102. * It can be for example box, sphere, or cone...
  14103. */
  14104. particleEmitterType: Nullable<IParticleEmitterType>;
  14105. /**
  14106. * Defines the delay in milliseconds before starting the system (0 by default)
  14107. */
  14108. startDelay: number;
  14109. /**
  14110. * 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
  14111. */
  14112. preWarmCycles: number;
  14113. /**
  14114. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14115. */
  14116. preWarmStepOffset: number;
  14117. /**
  14118. * 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)
  14119. */
  14120. spriteCellChangeSpeed: number;
  14121. /**
  14122. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14123. */
  14124. startSpriteCellID: number;
  14125. /**
  14126. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14127. */
  14128. endSpriteCellID: number;
  14129. /**
  14130. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14131. */
  14132. spriteCellWidth: number;
  14133. /**
  14134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14135. */
  14136. spriteCellHeight: number;
  14137. /**
  14138. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14139. */
  14140. spriteRandomStartCell: boolean;
  14141. /**
  14142. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14143. */
  14144. isAnimationSheetEnabled: boolean;
  14145. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14146. translationPivot: Vector2;
  14147. /**
  14148. * Gets or sets a texture used to add random noise to particle positions
  14149. */
  14150. noiseTexture: Nullable<BaseTexture>;
  14151. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14152. noiseStrength: Vector3;
  14153. /**
  14154. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14155. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14156. */
  14157. billboardMode: number;
  14158. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14159. limitVelocityDamping: number;
  14160. /**
  14161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14162. */
  14163. beginAnimationOnStart: boolean;
  14164. /**
  14165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14166. */
  14167. beginAnimationFrom: number;
  14168. /**
  14169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14170. */
  14171. beginAnimationTo: number;
  14172. /**
  14173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14174. */
  14175. beginAnimationLoop: boolean;
  14176. /**
  14177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14178. */
  14179. disposeOnStop: boolean;
  14180. /**
  14181. * Specifies if the particles are updated in emitter local space or world space
  14182. */
  14183. isLocal: boolean;
  14184. /** Snippet ID if the particle system was created from the snippet server */
  14185. snippetId: string;
  14186. /** Gets or sets a matrix to use to compute projection */
  14187. defaultProjectionMatrix: Matrix;
  14188. /**
  14189. * Gets the maximum number of particles active at the same time.
  14190. * @returns The max number of active particles.
  14191. */
  14192. getCapacity(): number;
  14193. /**
  14194. * Gets the number of particles active at the same time.
  14195. * @returns The number of active particles.
  14196. */
  14197. getActiveCount(): number;
  14198. /**
  14199. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14200. * @returns True if it has been started, otherwise false.
  14201. */
  14202. isStarted(): boolean;
  14203. /**
  14204. * Animates the particle system for this frame.
  14205. */
  14206. animate(): void;
  14207. /**
  14208. * Renders the particle system in its current state.
  14209. * @returns the current number of particles
  14210. */
  14211. render(): number;
  14212. /**
  14213. * Dispose the particle system and frees its associated resources.
  14214. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14215. */
  14216. dispose(disposeTexture?: boolean): void;
  14217. /**
  14218. * An event triggered when the system is disposed
  14219. */
  14220. onDisposeObservable: Observable<IParticleSystem>;
  14221. /**
  14222. * Clones the particle system.
  14223. * @param name The name of the cloned object
  14224. * @param newEmitter The new emitter to use
  14225. * @returns the cloned particle system
  14226. */
  14227. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14228. /**
  14229. * Serializes the particle system to a JSON object
  14230. * @param serializeTexture defines if the texture must be serialized as well
  14231. * @returns the JSON object
  14232. */
  14233. serialize(serializeTexture: boolean): any;
  14234. /**
  14235. * Rebuild the particle system
  14236. */
  14237. rebuild(): void;
  14238. /** Force the system to rebuild all gradients that need to be resync */
  14239. forceRefreshGradients(): void;
  14240. /**
  14241. * Starts the particle system and begins to emit
  14242. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14243. */
  14244. start(delay?: number): void;
  14245. /**
  14246. * Stops the particle system.
  14247. */
  14248. stop(): void;
  14249. /**
  14250. * Remove all active particles
  14251. */
  14252. reset(): void;
  14253. /**
  14254. * Gets a boolean indicating that the system is stopping
  14255. * @returns true if the system is currently stopping
  14256. */
  14257. isStopping(): boolean;
  14258. /**
  14259. * Is this system ready to be used/rendered
  14260. * @return true if the system is ready
  14261. */
  14262. isReady(): boolean;
  14263. /**
  14264. * Returns the string "ParticleSystem"
  14265. * @returns a string containing the class name
  14266. */
  14267. getClassName(): string;
  14268. /**
  14269. * Gets the custom effect used to render the particles
  14270. * @param blendMode Blend mode for which the effect should be retrieved
  14271. * @returns The effect
  14272. */
  14273. getCustomEffect(blendMode: number): Nullable<Effect>;
  14274. /**
  14275. * Sets the custom effect used to render the particles
  14276. * @param effect The effect to set
  14277. * @param blendMode Blend mode for which the effect should be set
  14278. */
  14279. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14280. /**
  14281. * Fill the defines array according to the current settings of the particle system
  14282. * @param defines Array to be updated
  14283. * @param blendMode blend mode to take into account when updating the array
  14284. */
  14285. fillDefines(defines: Array<string>, blendMode: number): void;
  14286. /**
  14287. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14288. * @param uniforms Uniforms array to fill
  14289. * @param attributes Attributes array to fill
  14290. * @param samplers Samplers array to fill
  14291. */
  14292. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14293. /**
  14294. * Observable that will be called just before the particles are drawn
  14295. */
  14296. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14297. /**
  14298. * Gets the name of the particle vertex shader
  14299. */
  14300. vertexShaderName: string;
  14301. /**
  14302. * Adds a new color gradient
  14303. * @param gradient defines the gradient to use (between 0 and 1)
  14304. * @param color1 defines the color to affect to the specified gradient
  14305. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14306. * @returns the current particle system
  14307. */
  14308. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14309. /**
  14310. * Remove a specific color gradient
  14311. * @param gradient defines the gradient to remove
  14312. * @returns the current particle system
  14313. */
  14314. removeColorGradient(gradient: number): IParticleSystem;
  14315. /**
  14316. * Adds a new size gradient
  14317. * @param gradient defines the gradient to use (between 0 and 1)
  14318. * @param factor defines the size factor to affect to the specified gradient
  14319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14320. * @returns the current particle system
  14321. */
  14322. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14323. /**
  14324. * Remove a specific size gradient
  14325. * @param gradient defines the gradient to remove
  14326. * @returns the current particle system
  14327. */
  14328. removeSizeGradient(gradient: number): IParticleSystem;
  14329. /**
  14330. * Gets the current list of color gradients.
  14331. * You must use addColorGradient and removeColorGradient to udpate this list
  14332. * @returns the list of color gradients
  14333. */
  14334. getColorGradients(): Nullable<Array<ColorGradient>>;
  14335. /**
  14336. * Gets the current list of size gradients.
  14337. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14338. * @returns the list of size gradients
  14339. */
  14340. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14341. /**
  14342. * Gets the current list of angular speed gradients.
  14343. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14344. * @returns the list of angular speed gradients
  14345. */
  14346. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14347. /**
  14348. * Adds a new angular speed gradient
  14349. * @param gradient defines the gradient to use (between 0 and 1)
  14350. * @param factor defines the angular speed to affect to the specified gradient
  14351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14352. * @returns the current particle system
  14353. */
  14354. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14355. /**
  14356. * Remove a specific angular speed gradient
  14357. * @param gradient defines the gradient to remove
  14358. * @returns the current particle system
  14359. */
  14360. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14361. /**
  14362. * Gets the current list of velocity gradients.
  14363. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14364. * @returns the list of velocity gradients
  14365. */
  14366. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Adds a new velocity gradient
  14369. * @param gradient defines the gradient to use (between 0 and 1)
  14370. * @param factor defines the velocity to affect to the specified gradient
  14371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14372. * @returns the current particle system
  14373. */
  14374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14375. /**
  14376. * Remove a specific velocity gradient
  14377. * @param gradient defines the gradient to remove
  14378. * @returns the current particle system
  14379. */
  14380. removeVelocityGradient(gradient: number): IParticleSystem;
  14381. /**
  14382. * Gets the current list of limit velocity gradients.
  14383. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14384. * @returns the list of limit velocity gradients
  14385. */
  14386. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14387. /**
  14388. * Adds a new limit velocity gradient
  14389. * @param gradient defines the gradient to use (between 0 and 1)
  14390. * @param factor defines the limit velocity to affect to the specified gradient
  14391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14392. * @returns the current particle system
  14393. */
  14394. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14395. /**
  14396. * Remove a specific limit velocity gradient
  14397. * @param gradient defines the gradient to remove
  14398. * @returns the current particle system
  14399. */
  14400. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14401. /**
  14402. * Adds a new drag gradient
  14403. * @param gradient defines the gradient to use (between 0 and 1)
  14404. * @param factor defines the drag to affect to the specified gradient
  14405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14406. * @returns the current particle system
  14407. */
  14408. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14409. /**
  14410. * Remove a specific drag gradient
  14411. * @param gradient defines the gradient to remove
  14412. * @returns the current particle system
  14413. */
  14414. removeDragGradient(gradient: number): IParticleSystem;
  14415. /**
  14416. * Gets the current list of drag gradients.
  14417. * You must use addDragGradient and removeDragGradient to udpate this list
  14418. * @returns the list of drag gradients
  14419. */
  14420. getDragGradients(): Nullable<Array<FactorGradient>>;
  14421. /**
  14422. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param factor defines the emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14429. /**
  14430. * Remove a specific emit rate gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeEmitRateGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Gets the current list of emit rate gradients.
  14437. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14438. * @returns the list of emit rate gradients
  14439. */
  14440. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14441. /**
  14442. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14443. * @param gradient defines the gradient to use (between 0 and 1)
  14444. * @param factor defines the start size to affect to the specified gradient
  14445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14446. * @returns the current particle system
  14447. */
  14448. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14449. /**
  14450. * Remove a specific start size gradient
  14451. * @param gradient defines the gradient to remove
  14452. * @returns the current particle system
  14453. */
  14454. removeStartSizeGradient(gradient: number): IParticleSystem;
  14455. /**
  14456. * Gets the current list of start size gradients.
  14457. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14458. * @returns the list of start size gradients
  14459. */
  14460. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Adds a new life time gradient
  14463. * @param gradient defines the gradient to use (between 0 and 1)
  14464. * @param factor defines the life time factor to affect to the specified gradient
  14465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14466. * @returns the current particle system
  14467. */
  14468. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14469. /**
  14470. * Remove a specific life time gradient
  14471. * @param gradient defines the gradient to remove
  14472. * @returns the current particle system
  14473. */
  14474. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14475. /**
  14476. * Gets the current list of life time gradients.
  14477. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14478. * @returns the list of life time gradients
  14479. */
  14480. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of color gradients.
  14483. * You must use addColorGradient and removeColorGradient to udpate this list
  14484. * @returns the list of color gradients
  14485. */
  14486. getColorGradients(): Nullable<Array<ColorGradient>>;
  14487. /**
  14488. * Adds a new ramp gradient used to remap particle colors
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param color defines the color to affect to the specified gradient
  14491. * @returns the current particle system
  14492. */
  14493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14494. /**
  14495. * Gets the current list of ramp gradients.
  14496. * You must use addRampGradient and removeRampGradient to udpate this list
  14497. * @returns the list of ramp gradients
  14498. */
  14499. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14500. /** Gets or sets a boolean indicating that ramp gradients must be used
  14501. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14502. */
  14503. useRampGradients: boolean;
  14504. /**
  14505. * Adds a new color remap gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param min defines the color remap minimal range
  14508. * @param max defines the color remap maximal range
  14509. * @returns the current particle system
  14510. */
  14511. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14512. /**
  14513. * Gets the current list of color remap gradients.
  14514. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14515. * @returns the list of color remap gradients
  14516. */
  14517. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14518. /**
  14519. * Adds a new alpha remap gradient
  14520. * @param gradient defines the gradient to use (between 0 and 1)
  14521. * @param min defines the alpha remap minimal range
  14522. * @param max defines the alpha remap maximal range
  14523. * @returns the current particle system
  14524. */
  14525. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14526. /**
  14527. * Gets the current list of alpha remap gradients.
  14528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14529. * @returns the list of alpha remap gradients
  14530. */
  14531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @returns the emitter
  14537. */
  14538. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14539. /**
  14540. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14541. * @param radius The radius of the hemisphere to emit from
  14542. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14543. * @returns the emitter
  14544. */
  14545. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14546. /**
  14547. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14548. * @param radius The radius of the sphere to emit from
  14549. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14550. * @returns the emitter
  14551. */
  14552. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14553. /**
  14554. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14555. * @param radius The radius of the sphere to emit from
  14556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @returns the emitter
  14559. */
  14560. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14561. /**
  14562. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14563. * @param radius The radius of the emission cylinder
  14564. * @param height The height of the emission cylinder
  14565. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14566. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14567. * @returns the emitter
  14568. */
  14569. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14570. /**
  14571. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14572. * @param radius The radius of the cylinder to emit from
  14573. * @param height The height of the emission cylinder
  14574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @returns the emitter
  14578. */
  14579. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14580. /**
  14581. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14582. * @param radius The radius of the cone to emit from
  14583. * @param angle The base angle of the cone
  14584. * @returns the emitter
  14585. */
  14586. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14587. /**
  14588. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14592. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @returns the emitter
  14594. */
  14595. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14596. /**
  14597. * Get hosting scene
  14598. * @returns the scene
  14599. */
  14600. getScene(): Nullable<Scene>;
  14601. }
  14602. }
  14603. declare module BABYLON {
  14604. /**
  14605. * 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.
  14606. * @see https://doc.babylonjs.com/how_to/transformnode
  14607. */
  14608. export class TransformNode extends Node {
  14609. /**
  14610. * Object will not rotate to face the camera
  14611. */
  14612. static BILLBOARDMODE_NONE: number;
  14613. /**
  14614. * Object will rotate to face the camera but only on the x axis
  14615. */
  14616. static BILLBOARDMODE_X: number;
  14617. /**
  14618. * Object will rotate to face the camera but only on the y axis
  14619. */
  14620. static BILLBOARDMODE_Y: number;
  14621. /**
  14622. * Object will rotate to face the camera but only on the z axis
  14623. */
  14624. static BILLBOARDMODE_Z: number;
  14625. /**
  14626. * Object will rotate to face the camera
  14627. */
  14628. static BILLBOARDMODE_ALL: number;
  14629. /**
  14630. * Object will rotate to face the camera's position instead of orientation
  14631. */
  14632. static BILLBOARDMODE_USE_POSITION: number;
  14633. private static _TmpRotation;
  14634. private static _TmpScaling;
  14635. private static _TmpTranslation;
  14636. private _forward;
  14637. private _forwardInverted;
  14638. private _up;
  14639. private _right;
  14640. private _rightInverted;
  14641. private _position;
  14642. private _rotation;
  14643. private _rotationQuaternion;
  14644. protected _scaling: Vector3;
  14645. protected _isDirty: boolean;
  14646. private _transformToBoneReferal;
  14647. private _isAbsoluteSynced;
  14648. private _billboardMode;
  14649. /**
  14650. * Gets or sets the billboard mode. Default is 0.
  14651. *
  14652. * | Value | Type | Description |
  14653. * | --- | --- | --- |
  14654. * | 0 | BILLBOARDMODE_NONE | |
  14655. * | 1 | BILLBOARDMODE_X | |
  14656. * | 2 | BILLBOARDMODE_Y | |
  14657. * | 4 | BILLBOARDMODE_Z | |
  14658. * | 7 | BILLBOARDMODE_ALL | |
  14659. *
  14660. */
  14661. get billboardMode(): number;
  14662. set billboardMode(value: number);
  14663. private _preserveParentRotationForBillboard;
  14664. /**
  14665. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14666. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14667. */
  14668. get preserveParentRotationForBillboard(): boolean;
  14669. set preserveParentRotationForBillboard(value: boolean);
  14670. /**
  14671. * 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
  14672. */
  14673. scalingDeterminant: number;
  14674. private _infiniteDistance;
  14675. /**
  14676. * Gets or sets the distance of the object to max, often used by skybox
  14677. */
  14678. get infiniteDistance(): boolean;
  14679. set infiniteDistance(value: boolean);
  14680. /**
  14681. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14682. * By default the system will update normals to compensate
  14683. */
  14684. ignoreNonUniformScaling: boolean;
  14685. /**
  14686. * 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
  14687. */
  14688. reIntegrateRotationIntoRotationQuaternion: boolean;
  14689. /** @hidden */
  14690. _poseMatrix: Nullable<Matrix>;
  14691. /** @hidden */
  14692. _localMatrix: Matrix;
  14693. private _usePivotMatrix;
  14694. private _absolutePosition;
  14695. private _absoluteScaling;
  14696. private _absoluteRotationQuaternion;
  14697. private _pivotMatrix;
  14698. private _pivotMatrixInverse;
  14699. protected _postMultiplyPivotMatrix: boolean;
  14700. protected _isWorldMatrixFrozen: boolean;
  14701. /** @hidden */
  14702. _indexInSceneTransformNodesArray: number;
  14703. /**
  14704. * An event triggered after the world matrix is updated
  14705. */
  14706. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14707. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14708. /**
  14709. * Gets a string identifying the name of the class
  14710. * @returns "TransformNode" string
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14715. */
  14716. get position(): Vector3;
  14717. set position(newPosition: Vector3);
  14718. /**
  14719. * 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)).
  14720. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14721. */
  14722. get rotation(): Vector3;
  14723. set rotation(newRotation: Vector3);
  14724. /**
  14725. * 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)).
  14726. */
  14727. get scaling(): Vector3;
  14728. set scaling(newScaling: Vector3);
  14729. /**
  14730. * 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).
  14731. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14732. */
  14733. get rotationQuaternion(): Nullable<Quaternion>;
  14734. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14735. /**
  14736. * The forward direction of that transform in world space.
  14737. */
  14738. get forward(): Vector3;
  14739. /**
  14740. * The up direction of that transform in world space.
  14741. */
  14742. get up(): Vector3;
  14743. /**
  14744. * The right direction of that transform in world space.
  14745. */
  14746. get right(): Vector3;
  14747. /**
  14748. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14749. * @param matrix the matrix to copy the pose from
  14750. * @returns this TransformNode.
  14751. */
  14752. updatePoseMatrix(matrix: Matrix): TransformNode;
  14753. /**
  14754. * Returns the mesh Pose matrix.
  14755. * @returns the pose matrix
  14756. */
  14757. getPoseMatrix(): Matrix;
  14758. /** @hidden */
  14759. _isSynchronized(): boolean;
  14760. /** @hidden */
  14761. _initCache(): void;
  14762. /**
  14763. * Flag the transform node as dirty (Forcing it to update everything)
  14764. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14765. * @returns this transform node
  14766. */
  14767. markAsDirty(property: string): TransformNode;
  14768. /**
  14769. * Returns the current mesh absolute position.
  14770. * Returns a Vector3.
  14771. */
  14772. get absolutePosition(): Vector3;
  14773. /**
  14774. * Returns the current mesh absolute scaling.
  14775. * Returns a Vector3.
  14776. */
  14777. get absoluteScaling(): Vector3;
  14778. /**
  14779. * Returns the current mesh absolute rotation.
  14780. * Returns a Quaternion.
  14781. */
  14782. get absoluteRotationQuaternion(): Quaternion;
  14783. /**
  14784. * Sets a new matrix to apply before all other transformation
  14785. * @param matrix defines the transform matrix
  14786. * @returns the current TransformNode
  14787. */
  14788. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14789. /**
  14790. * Sets a new pivot matrix to the current node
  14791. * @param matrix defines the new pivot matrix to use
  14792. * @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
  14793. * @returns the current TransformNode
  14794. */
  14795. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14796. /**
  14797. * Returns the mesh pivot matrix.
  14798. * Default : Identity.
  14799. * @returns the matrix
  14800. */
  14801. getPivotMatrix(): Matrix;
  14802. /**
  14803. * Instantiate (when possible) or clone that node with its hierarchy
  14804. * @param newParent defines the new parent to use for the instance (or clone)
  14805. * @param options defines options to configure how copy is done
  14806. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14807. * @returns an instance (or a clone) of the current node with its hiearchy
  14808. */
  14809. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14810. doNotInstantiate: boolean;
  14811. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14812. /**
  14813. * Prevents the World matrix to be computed any longer
  14814. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14815. * @returns the TransformNode.
  14816. */
  14817. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14818. /**
  14819. * Allows back the World matrix computation.
  14820. * @returns the TransformNode.
  14821. */
  14822. unfreezeWorldMatrix(): this;
  14823. /**
  14824. * True if the World matrix has been frozen.
  14825. */
  14826. get isWorldMatrixFrozen(): boolean;
  14827. /**
  14828. * Retuns the mesh absolute position in the World.
  14829. * @returns a Vector3.
  14830. */
  14831. getAbsolutePosition(): Vector3;
  14832. /**
  14833. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14834. * @param absolutePosition the absolute position to set
  14835. * @returns the TransformNode.
  14836. */
  14837. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14838. /**
  14839. * Sets the mesh position in its local space.
  14840. * @param vector3 the position to set in localspace
  14841. * @returns the TransformNode.
  14842. */
  14843. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14844. /**
  14845. * Returns the mesh position in the local space from the current World matrix values.
  14846. * @returns a new Vector3.
  14847. */
  14848. getPositionExpressedInLocalSpace(): Vector3;
  14849. /**
  14850. * Translates the mesh along the passed Vector3 in its local space.
  14851. * @param vector3 the distance to translate in localspace
  14852. * @returns the TransformNode.
  14853. */
  14854. locallyTranslate(vector3: Vector3): TransformNode;
  14855. private static _lookAtVectorCache;
  14856. /**
  14857. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14858. * @param targetPoint the position (must be in same space as current mesh) to look at
  14859. * @param yawCor optional yaw (y-axis) correction in radians
  14860. * @param pitchCor optional pitch (x-axis) correction in radians
  14861. * @param rollCor optional roll (z-axis) correction in radians
  14862. * @param space the choosen space of the target
  14863. * @returns the TransformNode.
  14864. */
  14865. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14866. /**
  14867. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14868. * This Vector3 is expressed in the World space.
  14869. * @param localAxis axis to rotate
  14870. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14871. */
  14872. getDirection(localAxis: Vector3): Vector3;
  14873. /**
  14874. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14875. * localAxis is expressed in the mesh local space.
  14876. * result is computed in the Wordl space from the mesh World matrix.
  14877. * @param localAxis axis to rotate
  14878. * @param result the resulting transformnode
  14879. * @returns this TransformNode.
  14880. */
  14881. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14882. /**
  14883. * Sets this transform node rotation to the given local axis.
  14884. * @param localAxis the axis in local space
  14885. * @param yawCor optional yaw (y-axis) correction in radians
  14886. * @param pitchCor optional pitch (x-axis) correction in radians
  14887. * @param rollCor optional roll (z-axis) correction in radians
  14888. * @returns this TransformNode
  14889. */
  14890. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14891. /**
  14892. * Sets a new pivot point to the current node
  14893. * @param point defines the new pivot point to use
  14894. * @param space defines if the point is in world or local space (local by default)
  14895. * @returns the current TransformNode
  14896. */
  14897. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14898. /**
  14899. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14900. * @returns the pivot point
  14901. */
  14902. getPivotPoint(): Vector3;
  14903. /**
  14904. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14905. * @param result the vector3 to store the result
  14906. * @returns this TransformNode.
  14907. */
  14908. getPivotPointToRef(result: Vector3): TransformNode;
  14909. /**
  14910. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14911. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14912. */
  14913. getAbsolutePivotPoint(): Vector3;
  14914. /**
  14915. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14916. * @param result vector3 to store the result
  14917. * @returns this TransformNode.
  14918. */
  14919. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14920. /**
  14921. * Defines the passed node as the parent of the current node.
  14922. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14923. * @see https://doc.babylonjs.com/how_to/parenting
  14924. * @param node the node ot set as the parent
  14925. * @returns this TransformNode.
  14926. */
  14927. setParent(node: Nullable<Node>): TransformNode;
  14928. private _nonUniformScaling;
  14929. /**
  14930. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14931. */
  14932. get nonUniformScaling(): boolean;
  14933. /** @hidden */
  14934. _updateNonUniformScalingState(value: boolean): boolean;
  14935. /**
  14936. * Attach the current TransformNode to another TransformNode associated with a bone
  14937. * @param bone Bone affecting the TransformNode
  14938. * @param affectedTransformNode TransformNode associated with the bone
  14939. * @returns this object
  14940. */
  14941. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14942. /**
  14943. * Detach the transform node if its associated with a bone
  14944. * @returns this object
  14945. */
  14946. detachFromBone(): TransformNode;
  14947. private static _rotationAxisCache;
  14948. /**
  14949. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14950. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14951. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14952. * The passed axis is also normalized.
  14953. * @param axis the axis to rotate around
  14954. * @param amount the amount to rotate in radians
  14955. * @param space Space to rotate in (Default: local)
  14956. * @returns the TransformNode.
  14957. */
  14958. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14959. /**
  14960. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14961. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14962. * The passed axis is also normalized. .
  14963. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14964. * @param point the point to rotate around
  14965. * @param axis the axis to rotate around
  14966. * @param amount the amount to rotate in radians
  14967. * @returns the TransformNode
  14968. */
  14969. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14970. /**
  14971. * Translates the mesh along the axis vector for the passed distance in the given space.
  14972. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14973. * @param axis the axis to translate in
  14974. * @param distance the distance to translate
  14975. * @param space Space to rotate in (Default: local)
  14976. * @returns the TransformNode.
  14977. */
  14978. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14979. /**
  14980. * Adds a rotation step to the mesh current rotation.
  14981. * x, y, z are Euler angles expressed in radians.
  14982. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14983. * This means this rotation is made in the mesh local space only.
  14984. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14985. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14986. * ```javascript
  14987. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14988. * ```
  14989. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14990. * 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.
  14991. * @param x Rotation to add
  14992. * @param y Rotation to add
  14993. * @param z Rotation to add
  14994. * @returns the TransformNode.
  14995. */
  14996. addRotation(x: number, y: number, z: number): TransformNode;
  14997. /**
  14998. * @hidden
  14999. */
  15000. protected _getEffectiveParent(): Nullable<Node>;
  15001. /**
  15002. * Computes the world matrix of the node
  15003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15004. * @returns the world matrix
  15005. */
  15006. computeWorldMatrix(force?: boolean): Matrix;
  15007. /**
  15008. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15009. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15010. */
  15011. resetLocalMatrix(independentOfChildren?: boolean): void;
  15012. protected _afterComputeWorldMatrix(): void;
  15013. /**
  15014. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15015. * @param func callback function to add
  15016. *
  15017. * @returns the TransformNode.
  15018. */
  15019. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15020. /**
  15021. * Removes a registered callback function.
  15022. * @param func callback function to remove
  15023. * @returns the TransformNode.
  15024. */
  15025. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15026. /**
  15027. * Gets the position of the current mesh in camera space
  15028. * @param camera defines the camera to use
  15029. * @returns a position
  15030. */
  15031. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15032. /**
  15033. * Returns the distance from the mesh to the active camera
  15034. * @param camera defines the camera to use
  15035. * @returns the distance
  15036. */
  15037. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15038. /**
  15039. * Clone the current transform node
  15040. * @param name Name of the new clone
  15041. * @param newParent New parent for the clone
  15042. * @param doNotCloneChildren Do not clone children hierarchy
  15043. * @returns the new transform node
  15044. */
  15045. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15046. /**
  15047. * Serializes the objects information.
  15048. * @param currentSerializationObject defines the object to serialize in
  15049. * @returns the serialized object
  15050. */
  15051. serialize(currentSerializationObject?: any): any;
  15052. /**
  15053. * Returns a new TransformNode object parsed from the source provided.
  15054. * @param parsedTransformNode is the source.
  15055. * @param scene the scne the object belongs to
  15056. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15057. * @returns a new TransformNode object parsed from the source provided.
  15058. */
  15059. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15060. /**
  15061. * Get all child-transformNodes of this node
  15062. * @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
  15063. * @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
  15064. * @returns an array of TransformNode
  15065. */
  15066. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15067. /**
  15068. * Releases resources associated with this transform node.
  15069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15071. */
  15072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15073. /**
  15074. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15075. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15076. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15077. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15078. * @returns the current mesh
  15079. */
  15080. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15081. private _syncAbsoluteScalingAndRotation;
  15082. }
  15083. }
  15084. declare module BABYLON {
  15085. /**
  15086. * Class used to override all child animations of a given target
  15087. */
  15088. export class AnimationPropertiesOverride {
  15089. /**
  15090. * Gets or sets a value indicating if animation blending must be used
  15091. */
  15092. enableBlending: boolean;
  15093. /**
  15094. * Gets or sets the blending speed to use when enableBlending is true
  15095. */
  15096. blendingSpeed: number;
  15097. /**
  15098. * Gets or sets the default loop mode to use
  15099. */
  15100. loopMode: number;
  15101. }
  15102. }
  15103. declare module BABYLON {
  15104. /**
  15105. * Class used to store bone information
  15106. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15107. */
  15108. export class Bone extends Node {
  15109. /**
  15110. * defines the bone name
  15111. */
  15112. name: string;
  15113. private static _tmpVecs;
  15114. private static _tmpQuat;
  15115. private static _tmpMats;
  15116. /**
  15117. * Gets the list of child bones
  15118. */
  15119. children: Bone[];
  15120. /** Gets the animations associated with this bone */
  15121. animations: Animation[];
  15122. /**
  15123. * Gets or sets bone length
  15124. */
  15125. length: number;
  15126. /**
  15127. * @hidden Internal only
  15128. * Set this value to map this bone to a different index in the transform matrices
  15129. * Set this value to -1 to exclude the bone from the transform matrices
  15130. */
  15131. _index: Nullable<number>;
  15132. private _skeleton;
  15133. private _localMatrix;
  15134. private _restPose;
  15135. private _bindPose;
  15136. private _baseMatrix;
  15137. private _absoluteTransform;
  15138. private _invertedAbsoluteTransform;
  15139. private _parent;
  15140. private _scalingDeterminant;
  15141. private _worldTransform;
  15142. private _localScaling;
  15143. private _localRotation;
  15144. private _localPosition;
  15145. private _needToDecompose;
  15146. private _needToCompose;
  15147. /** @hidden */
  15148. _linkedTransformNode: Nullable<TransformNode>;
  15149. /** @hidden */
  15150. _waitingTransformNodeId: Nullable<string>;
  15151. /** @hidden */
  15152. get _matrix(): Matrix;
  15153. /** @hidden */
  15154. set _matrix(value: Matrix);
  15155. /**
  15156. * Create a new bone
  15157. * @param name defines the bone name
  15158. * @param skeleton defines the parent skeleton
  15159. * @param parentBone defines the parent (can be null if the bone is the root)
  15160. * @param localMatrix defines the local matrix
  15161. * @param restPose defines the rest pose matrix
  15162. * @param baseMatrix defines the base matrix
  15163. * @param index defines index of the bone in the hiearchy
  15164. */
  15165. constructor(
  15166. /**
  15167. * defines the bone name
  15168. */
  15169. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15170. /**
  15171. * Gets the current object class name.
  15172. * @return the class name
  15173. */
  15174. getClassName(): string;
  15175. /**
  15176. * Gets the parent skeleton
  15177. * @returns a skeleton
  15178. */
  15179. getSkeleton(): Skeleton;
  15180. /**
  15181. * Gets parent bone
  15182. * @returns a bone or null if the bone is the root of the bone hierarchy
  15183. */
  15184. getParent(): Nullable<Bone>;
  15185. /**
  15186. * Returns an array containing the root bones
  15187. * @returns an array containing the root bones
  15188. */
  15189. getChildren(): Array<Bone>;
  15190. /**
  15191. * Gets the node index in matrix array generated for rendering
  15192. * @returns the node index
  15193. */
  15194. getIndex(): number;
  15195. /**
  15196. * Sets the parent bone
  15197. * @param parent defines the parent (can be null if the bone is the root)
  15198. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15199. */
  15200. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15201. /**
  15202. * Gets the local matrix
  15203. * @returns a matrix
  15204. */
  15205. getLocalMatrix(): Matrix;
  15206. /**
  15207. * Gets the base matrix (initial matrix which remains unchanged)
  15208. * @returns a matrix
  15209. */
  15210. getBaseMatrix(): Matrix;
  15211. /**
  15212. * Gets the rest pose matrix
  15213. * @returns a matrix
  15214. */
  15215. getRestPose(): Matrix;
  15216. /**
  15217. * Sets the rest pose matrix
  15218. * @param matrix the local-space rest pose to set for this bone
  15219. */
  15220. setRestPose(matrix: Matrix): void;
  15221. /**
  15222. * Gets the bind pose matrix
  15223. * @returns the bind pose matrix
  15224. */
  15225. getBindPose(): Matrix;
  15226. /**
  15227. * Sets the bind pose matrix
  15228. * @param matrix the local-space bind pose to set for this bone
  15229. */
  15230. setBindPose(matrix: Matrix): void;
  15231. /**
  15232. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15233. */
  15234. getWorldMatrix(): Matrix;
  15235. /**
  15236. * Sets the local matrix to rest pose matrix
  15237. */
  15238. returnToRest(): void;
  15239. /**
  15240. * Gets the inverse of the absolute transform matrix.
  15241. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15242. * @returns a matrix
  15243. */
  15244. getInvertedAbsoluteTransform(): Matrix;
  15245. /**
  15246. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15247. * @returns a matrix
  15248. */
  15249. getAbsoluteTransform(): Matrix;
  15250. /**
  15251. * Links with the given transform node.
  15252. * The local matrix of this bone is copied from the transform node every frame.
  15253. * @param transformNode defines the transform node to link to
  15254. */
  15255. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15256. /**
  15257. * Gets the node used to drive the bone's transformation
  15258. * @returns a transform node or null
  15259. */
  15260. getTransformNode(): Nullable<TransformNode>;
  15261. /** Gets or sets current position (in local space) */
  15262. get position(): Vector3;
  15263. set position(newPosition: Vector3);
  15264. /** Gets or sets current rotation (in local space) */
  15265. get rotation(): Vector3;
  15266. set rotation(newRotation: Vector3);
  15267. /** Gets or sets current rotation quaternion (in local space) */
  15268. get rotationQuaternion(): Quaternion;
  15269. set rotationQuaternion(newRotation: Quaternion);
  15270. /** Gets or sets current scaling (in local space) */
  15271. get scaling(): Vector3;
  15272. set scaling(newScaling: Vector3);
  15273. /**
  15274. * Gets the animation properties override
  15275. */
  15276. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15277. private _decompose;
  15278. private _compose;
  15279. /**
  15280. * Update the base and local matrices
  15281. * @param matrix defines the new base or local matrix
  15282. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15283. * @param updateLocalMatrix defines if the local matrix should be updated
  15284. */
  15285. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15286. /** @hidden */
  15287. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15288. /**
  15289. * Flag the bone as dirty (Forcing it to update everything)
  15290. */
  15291. markAsDirty(): void;
  15292. /** @hidden */
  15293. _markAsDirtyAndCompose(): void;
  15294. private _markAsDirtyAndDecompose;
  15295. /**
  15296. * Translate the bone in local or world space
  15297. * @param vec The amount to translate the bone
  15298. * @param space The space that the translation is in
  15299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15300. */
  15301. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15302. /**
  15303. * Set the postion of the bone in local or world space
  15304. * @param position The position to set the bone
  15305. * @param space The space that the position is in
  15306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15307. */
  15308. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15309. /**
  15310. * Set the absolute position of the bone (world space)
  15311. * @param position The position to set the bone
  15312. * @param mesh The mesh that this bone is attached to
  15313. */
  15314. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15315. /**
  15316. * Scale the bone on the x, y and z axes (in local space)
  15317. * @param x The amount to scale the bone on the x axis
  15318. * @param y The amount to scale the bone on the y axis
  15319. * @param z The amount to scale the bone on the z axis
  15320. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15321. */
  15322. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15323. /**
  15324. * Set the bone scaling in local space
  15325. * @param scale defines the scaling vector
  15326. */
  15327. setScale(scale: Vector3): void;
  15328. /**
  15329. * Gets the current scaling in local space
  15330. * @returns the current scaling vector
  15331. */
  15332. getScale(): Vector3;
  15333. /**
  15334. * Gets the current scaling in local space and stores it in a target vector
  15335. * @param result defines the target vector
  15336. */
  15337. getScaleToRef(result: Vector3): void;
  15338. /**
  15339. * Set the yaw, pitch, and roll of the bone in local or world space
  15340. * @param yaw The rotation of the bone on the y axis
  15341. * @param pitch The rotation of the bone on the x axis
  15342. * @param roll The rotation of the bone on the z axis
  15343. * @param space The space that the axes of rotation are in
  15344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15345. */
  15346. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15347. /**
  15348. * Add a rotation to the bone on an axis in local or world space
  15349. * @param axis The axis to rotate the bone on
  15350. * @param amount The amount to rotate the bone
  15351. * @param space The space that the axis is in
  15352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15353. */
  15354. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15355. /**
  15356. * Set the rotation of the bone to a particular axis angle in local or world space
  15357. * @param axis The axis to rotate the bone on
  15358. * @param angle The angle that the bone should be rotated to
  15359. * @param space The space that the axis is in
  15360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15361. */
  15362. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15363. /**
  15364. * Set the euler rotation of the bone in local of world space
  15365. * @param rotation The euler rotation that the bone should be set to
  15366. * @param space The space that the rotation is in
  15367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15368. */
  15369. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15370. /**
  15371. * Set the quaternion rotation of the bone in local of world space
  15372. * @param quat The quaternion rotation that the bone should be set to
  15373. * @param space The space that the rotation is in
  15374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15375. */
  15376. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15377. /**
  15378. * Set the rotation matrix of the bone in local of world space
  15379. * @param rotMat The rotation matrix that the bone should be set to
  15380. * @param space The space that the rotation is in
  15381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15382. */
  15383. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15384. private _rotateWithMatrix;
  15385. private _getNegativeRotationToRef;
  15386. /**
  15387. * Get the position of the bone in local or world space
  15388. * @param space The space that the returned position is in
  15389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15390. * @returns The position of the bone
  15391. */
  15392. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15393. /**
  15394. * Copy the position of the bone to a vector3 in local or world space
  15395. * @param space The space that the returned position is in
  15396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15397. * @param result The vector3 to copy the position to
  15398. */
  15399. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15400. /**
  15401. * Get the absolute position of the bone (world space)
  15402. * @param mesh The mesh that this bone is attached to
  15403. * @returns The absolute position of the bone
  15404. */
  15405. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15406. /**
  15407. * Copy the absolute position of the bone (world space) to the result param
  15408. * @param mesh The mesh that this bone is attached to
  15409. * @param result The vector3 to copy the absolute position to
  15410. */
  15411. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15412. /**
  15413. * Compute the absolute transforms of this bone and its children
  15414. */
  15415. computeAbsoluteTransforms(): void;
  15416. /**
  15417. * Get the world direction from an axis that is in the local space of the bone
  15418. * @param localAxis The local direction that is used to compute the world direction
  15419. * @param mesh The mesh that this bone is attached to
  15420. * @returns The world direction
  15421. */
  15422. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15423. /**
  15424. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15425. * @param localAxis The local direction that is used to compute the world direction
  15426. * @param mesh The mesh that this bone is attached to
  15427. * @param result The vector3 that the world direction will be copied to
  15428. */
  15429. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15430. /**
  15431. * Get the euler rotation of the bone in local or world space
  15432. * @param space The space that the rotation should be in
  15433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15434. * @returns The euler rotation
  15435. */
  15436. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15437. /**
  15438. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15439. * @param space The space that the rotation should be in
  15440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15441. * @param result The vector3 that the rotation should be copied to
  15442. */
  15443. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15444. /**
  15445. * Get the quaternion rotation of the bone in either local or world space
  15446. * @param space The space that the rotation should be in
  15447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15448. * @returns The quaternion rotation
  15449. */
  15450. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15451. /**
  15452. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15453. * @param space The space that the rotation should be in
  15454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15455. * @param result The quaternion that the rotation should be copied to
  15456. */
  15457. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15458. /**
  15459. * Get the rotation matrix of the bone in local or world space
  15460. * @param space The space that the rotation should be in
  15461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15462. * @returns The rotation matrix
  15463. */
  15464. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15465. /**
  15466. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15467. * @param space The space that the rotation should be in
  15468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15469. * @param result The quaternion that the rotation should be copied to
  15470. */
  15471. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15472. /**
  15473. * Get the world position of a point that is in the local space of the bone
  15474. * @param position The local position
  15475. * @param mesh The mesh that this bone is attached to
  15476. * @returns The world position
  15477. */
  15478. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15479. /**
  15480. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15481. * @param position The local position
  15482. * @param mesh The mesh that this bone is attached to
  15483. * @param result The vector3 that the world position should be copied to
  15484. */
  15485. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15486. /**
  15487. * Get the local position of a point that is in world space
  15488. * @param position The world position
  15489. * @param mesh The mesh that this bone is attached to
  15490. * @returns The local position
  15491. */
  15492. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15493. /**
  15494. * Get the local position of a point that is in world space and copy it to the result param
  15495. * @param position The world position
  15496. * @param mesh The mesh that this bone is attached to
  15497. * @param result The vector3 that the local position should be copied to
  15498. */
  15499. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15500. }
  15501. }
  15502. declare module BABYLON {
  15503. /**
  15504. * Defines a runtime animation
  15505. */
  15506. export class RuntimeAnimation {
  15507. private _events;
  15508. /**
  15509. * The current frame of the runtime animation
  15510. */
  15511. private _currentFrame;
  15512. /**
  15513. * The animation used by the runtime animation
  15514. */
  15515. private _animation;
  15516. /**
  15517. * The target of the runtime animation
  15518. */
  15519. private _target;
  15520. /**
  15521. * The initiating animatable
  15522. */
  15523. private _host;
  15524. /**
  15525. * The original value of the runtime animation
  15526. */
  15527. private _originalValue;
  15528. /**
  15529. * The original blend value of the runtime animation
  15530. */
  15531. private _originalBlendValue;
  15532. /**
  15533. * The offsets cache of the runtime animation
  15534. */
  15535. private _offsetsCache;
  15536. /**
  15537. * The high limits cache of the runtime animation
  15538. */
  15539. private _highLimitsCache;
  15540. /**
  15541. * Specifies if the runtime animation has been stopped
  15542. */
  15543. private _stopped;
  15544. /**
  15545. * The blending factor of the runtime animation
  15546. */
  15547. private _blendingFactor;
  15548. /**
  15549. * The BabylonJS scene
  15550. */
  15551. private _scene;
  15552. /**
  15553. * The current value of the runtime animation
  15554. */
  15555. private _currentValue;
  15556. /** @hidden */
  15557. _animationState: _IAnimationState;
  15558. /**
  15559. * The active target of the runtime animation
  15560. */
  15561. private _activeTargets;
  15562. private _currentActiveTarget;
  15563. private _directTarget;
  15564. /**
  15565. * The target path of the runtime animation
  15566. */
  15567. private _targetPath;
  15568. /**
  15569. * The weight of the runtime animation
  15570. */
  15571. private _weight;
  15572. /**
  15573. * The ratio offset of the runtime animation
  15574. */
  15575. private _ratioOffset;
  15576. /**
  15577. * The previous delay of the runtime animation
  15578. */
  15579. private _previousDelay;
  15580. /**
  15581. * The previous ratio of the runtime animation
  15582. */
  15583. private _previousRatio;
  15584. private _enableBlending;
  15585. private _keys;
  15586. private _minFrame;
  15587. private _maxFrame;
  15588. private _minValue;
  15589. private _maxValue;
  15590. private _targetIsArray;
  15591. /**
  15592. * Gets the current frame of the runtime animation
  15593. */
  15594. get currentFrame(): number;
  15595. /**
  15596. * Gets the weight of the runtime animation
  15597. */
  15598. get weight(): number;
  15599. /**
  15600. * Gets the current value of the runtime animation
  15601. */
  15602. get currentValue(): any;
  15603. /**
  15604. * Gets the target path of the runtime animation
  15605. */
  15606. get targetPath(): string;
  15607. /**
  15608. * Gets the actual target of the runtime animation
  15609. */
  15610. get target(): any;
  15611. /**
  15612. * Gets the additive state of the runtime animation
  15613. */
  15614. get isAdditive(): boolean;
  15615. /** @hidden */
  15616. _onLoop: () => void;
  15617. /**
  15618. * Create a new RuntimeAnimation object
  15619. * @param target defines the target of the animation
  15620. * @param animation defines the source animation object
  15621. * @param scene defines the hosting scene
  15622. * @param host defines the initiating Animatable
  15623. */
  15624. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15625. private _preparePath;
  15626. /**
  15627. * Gets the animation from the runtime animation
  15628. */
  15629. get animation(): Animation;
  15630. /**
  15631. * Resets the runtime animation to the beginning
  15632. * @param restoreOriginal defines whether to restore the target property to the original value
  15633. */
  15634. reset(restoreOriginal?: boolean): void;
  15635. /**
  15636. * Specifies if the runtime animation is stopped
  15637. * @returns Boolean specifying if the runtime animation is stopped
  15638. */
  15639. isStopped(): boolean;
  15640. /**
  15641. * Disposes of the runtime animation
  15642. */
  15643. dispose(): void;
  15644. /**
  15645. * Apply the interpolated value to the target
  15646. * @param currentValue defines the value computed by the animation
  15647. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15648. */
  15649. setValue(currentValue: any, weight: number): void;
  15650. private _getOriginalValues;
  15651. private _setValue;
  15652. /**
  15653. * Gets the loop pmode of the runtime animation
  15654. * @returns Loop Mode
  15655. */
  15656. private _getCorrectLoopMode;
  15657. /**
  15658. * Move the current animation to a given frame
  15659. * @param frame defines the frame to move to
  15660. */
  15661. goToFrame(frame: number): void;
  15662. /**
  15663. * @hidden Internal use only
  15664. */
  15665. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15666. /**
  15667. * Execute the current animation
  15668. * @param delay defines the delay to add to the current frame
  15669. * @param from defines the lower bound of the animation range
  15670. * @param to defines the upper bound of the animation range
  15671. * @param loop defines if the current animation must loop
  15672. * @param speedRatio defines the current speed ratio
  15673. * @param weight defines the weight of the animation (default is -1 so no weight)
  15674. * @param onLoop optional callback called when animation loops
  15675. * @returns a boolean indicating if the animation is running
  15676. */
  15677. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15678. }
  15679. }
  15680. declare module BABYLON {
  15681. /**
  15682. * Class used to store an actual running animation
  15683. */
  15684. export class Animatable {
  15685. /** defines the target object */
  15686. target: any;
  15687. /** defines the starting frame number (default is 0) */
  15688. fromFrame: number;
  15689. /** defines the ending frame number (default is 100) */
  15690. toFrame: number;
  15691. /** defines if the animation must loop (default is false) */
  15692. loopAnimation: boolean;
  15693. /** defines a callback to call when animation ends if it is not looping */
  15694. onAnimationEnd?: (() => void) | null | undefined;
  15695. /** defines a callback to call when animation loops */
  15696. onAnimationLoop?: (() => void) | null | undefined;
  15697. /** defines whether the animation should be evaluated additively */
  15698. isAdditive: boolean;
  15699. private _localDelayOffset;
  15700. private _pausedDelay;
  15701. private _runtimeAnimations;
  15702. private _paused;
  15703. private _scene;
  15704. private _speedRatio;
  15705. private _weight;
  15706. private _syncRoot;
  15707. /**
  15708. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15709. * This will only apply for non looping animation (default is true)
  15710. */
  15711. disposeOnEnd: boolean;
  15712. /**
  15713. * Gets a boolean indicating if the animation has started
  15714. */
  15715. animationStarted: boolean;
  15716. /**
  15717. * Observer raised when the animation ends
  15718. */
  15719. onAnimationEndObservable: Observable<Animatable>;
  15720. /**
  15721. * Observer raised when the animation loops
  15722. */
  15723. onAnimationLoopObservable: Observable<Animatable>;
  15724. /**
  15725. * Gets the root Animatable used to synchronize and normalize animations
  15726. */
  15727. get syncRoot(): Nullable<Animatable>;
  15728. /**
  15729. * Gets the current frame of the first RuntimeAnimation
  15730. * Used to synchronize Animatables
  15731. */
  15732. get masterFrame(): number;
  15733. /**
  15734. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15735. */
  15736. get weight(): number;
  15737. set weight(value: number);
  15738. /**
  15739. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15740. */
  15741. get speedRatio(): number;
  15742. set speedRatio(value: number);
  15743. /**
  15744. * Creates a new Animatable
  15745. * @param scene defines the hosting scene
  15746. * @param target defines the target object
  15747. * @param fromFrame defines the starting frame number (default is 0)
  15748. * @param toFrame defines the ending frame number (default is 100)
  15749. * @param loopAnimation defines if the animation must loop (default is false)
  15750. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15751. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15752. * @param animations defines a group of animation to add to the new Animatable
  15753. * @param onAnimationLoop defines a callback to call when animation loops
  15754. * @param isAdditive defines whether the animation should be evaluated additively
  15755. */
  15756. constructor(scene: Scene,
  15757. /** defines the target object */
  15758. target: any,
  15759. /** defines the starting frame number (default is 0) */
  15760. fromFrame?: number,
  15761. /** defines the ending frame number (default is 100) */
  15762. toFrame?: number,
  15763. /** defines if the animation must loop (default is false) */
  15764. loopAnimation?: boolean, speedRatio?: number,
  15765. /** defines a callback to call when animation ends if it is not looping */
  15766. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15767. /** defines a callback to call when animation loops */
  15768. onAnimationLoop?: (() => void) | null | undefined,
  15769. /** defines whether the animation should be evaluated additively */
  15770. isAdditive?: boolean);
  15771. /**
  15772. * Synchronize and normalize current Animatable with a source Animatable
  15773. * This is useful when using animation weights and when animations are not of the same length
  15774. * @param root defines the root Animatable to synchronize with
  15775. * @returns the current Animatable
  15776. */
  15777. syncWith(root: Animatable): Animatable;
  15778. /**
  15779. * Gets the list of runtime animations
  15780. * @returns an array of RuntimeAnimation
  15781. */
  15782. getAnimations(): RuntimeAnimation[];
  15783. /**
  15784. * Adds more animations to the current animatable
  15785. * @param target defines the target of the animations
  15786. * @param animations defines the new animations to add
  15787. */
  15788. appendAnimations(target: any, animations: Animation[]): void;
  15789. /**
  15790. * Gets the source animation for a specific property
  15791. * @param property defines the propertyu to look for
  15792. * @returns null or the source animation for the given property
  15793. */
  15794. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15795. /**
  15796. * Gets the runtime animation for a specific property
  15797. * @param property defines the propertyu to look for
  15798. * @returns null or the runtime animation for the given property
  15799. */
  15800. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15801. /**
  15802. * Resets the animatable to its original state
  15803. */
  15804. reset(): void;
  15805. /**
  15806. * Allows the animatable to blend with current running animations
  15807. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15808. * @param blendingSpeed defines the blending speed to use
  15809. */
  15810. enableBlending(blendingSpeed: number): void;
  15811. /**
  15812. * Disable animation blending
  15813. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15814. */
  15815. disableBlending(): void;
  15816. /**
  15817. * Jump directly to a given frame
  15818. * @param frame defines the frame to jump to
  15819. */
  15820. goToFrame(frame: number): void;
  15821. /**
  15822. * Pause the animation
  15823. */
  15824. pause(): void;
  15825. /**
  15826. * Restart the animation
  15827. */
  15828. restart(): void;
  15829. private _raiseOnAnimationEnd;
  15830. /**
  15831. * Stop and delete the current animation
  15832. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15833. * @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)
  15834. */
  15835. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15836. /**
  15837. * Wait asynchronously for the animation to end
  15838. * @returns a promise which will be fullfilled when the animation ends
  15839. */
  15840. waitAsync(): Promise<Animatable>;
  15841. /** @hidden */
  15842. _animate(delay: number): boolean;
  15843. }
  15844. interface Scene {
  15845. /** @hidden */
  15846. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15847. /** @hidden */
  15848. _processLateAnimationBindingsForMatrices(holder: {
  15849. totalWeight: number;
  15850. totalAdditiveWeight: number;
  15851. animations: RuntimeAnimation[];
  15852. additiveAnimations: RuntimeAnimation[];
  15853. originalValue: Matrix;
  15854. }): any;
  15855. /** @hidden */
  15856. _processLateAnimationBindingsForQuaternions(holder: {
  15857. totalWeight: number;
  15858. totalAdditiveWeight: number;
  15859. animations: RuntimeAnimation[];
  15860. additiveAnimations: RuntimeAnimation[];
  15861. originalValue: Quaternion;
  15862. }, refQuaternion: Quaternion): Quaternion;
  15863. /** @hidden */
  15864. _processLateAnimationBindings(): void;
  15865. /**
  15866. * Will start the animation sequence of a given target
  15867. * @param target defines the target
  15868. * @param from defines from which frame should animation start
  15869. * @param to defines until which frame should animation run.
  15870. * @param weight defines the weight to apply to the animation (1.0 by default)
  15871. * @param loop defines if the animation loops
  15872. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15873. * @param onAnimationEnd defines the function to be executed when the animation ends
  15874. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15875. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15876. * @param onAnimationLoop defines the callback to call when an animation loops
  15877. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15878. * @returns the animatable object created for this animation
  15879. */
  15880. 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;
  15881. /**
  15882. * Will start the animation sequence of a given target
  15883. * @param target defines the target
  15884. * @param from defines from which frame should animation start
  15885. * @param to defines until which frame should animation run.
  15886. * @param loop defines if the animation loops
  15887. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15888. * @param onAnimationEnd defines the function to be executed when the animation ends
  15889. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15890. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15891. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15892. * @param onAnimationLoop defines the callback to call when an animation loops
  15893. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15894. * @returns the animatable object created for this animation
  15895. */
  15896. 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;
  15897. /**
  15898. * Will start the animation sequence of a given target and its hierarchy
  15899. * @param target defines the target
  15900. * @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.
  15901. * @param from defines from which frame should animation start
  15902. * @param to defines until which frame should animation run.
  15903. * @param loop defines if the animation loops
  15904. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15905. * @param onAnimationEnd defines the function to be executed when the animation ends
  15906. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15907. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15908. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15909. * @param onAnimationLoop defines the callback to call when an animation loops
  15910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15911. * @returns the list of created animatables
  15912. */
  15913. 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[];
  15914. /**
  15915. * Begin a new animation on a given node
  15916. * @param target defines the target where the animation will take place
  15917. * @param animations defines the list of animations to start
  15918. * @param from defines the initial value
  15919. * @param to defines the final value
  15920. * @param loop defines if you want animation to loop (off by default)
  15921. * @param speedRatio defines the speed ratio to apply to all animations
  15922. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15923. * @param onAnimationLoop defines the callback to call when an animation loops
  15924. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15925. * @returns the list of created animatables
  15926. */
  15927. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15928. /**
  15929. * Begin a new animation on a given node and its hierarchy
  15930. * @param target defines the root node where the animation will take place
  15931. * @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.
  15932. * @param animations defines the list of animations to start
  15933. * @param from defines the initial value
  15934. * @param to defines the final value
  15935. * @param loop defines if you want animation to loop (off by default)
  15936. * @param speedRatio defines the speed ratio to apply to all animations
  15937. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15938. * @param onAnimationLoop defines the callback to call when an animation loops
  15939. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15940. * @returns the list of animatables created for all nodes
  15941. */
  15942. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15943. /**
  15944. * Gets the animatable associated with a specific target
  15945. * @param target defines the target of the animatable
  15946. * @returns the required animatable if found
  15947. */
  15948. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15949. /**
  15950. * Gets all animatables associated with a given target
  15951. * @param target defines the target to look animatables for
  15952. * @returns an array of Animatables
  15953. */
  15954. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15955. /**
  15956. * Stops and removes all animations that have been applied to the scene
  15957. */
  15958. stopAllAnimations(): void;
  15959. /**
  15960. * Gets the current delta time used by animation engine
  15961. */
  15962. deltaTime: number;
  15963. }
  15964. interface Bone {
  15965. /**
  15966. * Copy an animation range from another bone
  15967. * @param source defines the source bone
  15968. * @param rangeName defines the range name to copy
  15969. * @param frameOffset defines the frame offset
  15970. * @param rescaleAsRequired defines if rescaling must be applied if required
  15971. * @param skelDimensionsRatio defines the scaling ratio
  15972. * @returns true if operation was successful
  15973. */
  15974. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15975. }
  15976. }
  15977. declare module BABYLON {
  15978. /**
  15979. * Class used to handle skinning animations
  15980. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15981. */
  15982. export class Skeleton implements IAnimatable {
  15983. /** defines the skeleton name */
  15984. name: string;
  15985. /** defines the skeleton Id */
  15986. id: string;
  15987. /**
  15988. * Defines the list of child bones
  15989. */
  15990. bones: Bone[];
  15991. /**
  15992. * Defines an estimate of the dimension of the skeleton at rest
  15993. */
  15994. dimensionsAtRest: Vector3;
  15995. /**
  15996. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15997. */
  15998. needInitialSkinMatrix: boolean;
  15999. /**
  16000. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16001. */
  16002. overrideMesh: Nullable<AbstractMesh>;
  16003. /**
  16004. * Gets the list of animations attached to this skeleton
  16005. */
  16006. animations: Array<Animation>;
  16007. private _scene;
  16008. private _isDirty;
  16009. private _transformMatrices;
  16010. private _transformMatrixTexture;
  16011. private _meshesWithPoseMatrix;
  16012. private _animatables;
  16013. private _identity;
  16014. private _synchronizedWithMesh;
  16015. private _ranges;
  16016. private _lastAbsoluteTransformsUpdateId;
  16017. private _canUseTextureForBones;
  16018. private _uniqueId;
  16019. /** @hidden */
  16020. _numBonesWithLinkedTransformNode: number;
  16021. /** @hidden */
  16022. _hasWaitingData: Nullable<boolean>;
  16023. /**
  16024. * Specifies if the skeleton should be serialized
  16025. */
  16026. doNotSerialize: boolean;
  16027. private _useTextureToStoreBoneMatrices;
  16028. /**
  16029. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16030. * Please note that this option is not available if the hardware does not support it
  16031. */
  16032. get useTextureToStoreBoneMatrices(): boolean;
  16033. set useTextureToStoreBoneMatrices(value: boolean);
  16034. private _animationPropertiesOverride;
  16035. /**
  16036. * Gets or sets the animation properties override
  16037. */
  16038. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16039. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16040. /**
  16041. * List of inspectable custom properties (used by the Inspector)
  16042. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16043. */
  16044. inspectableCustomProperties: IInspectable[];
  16045. /**
  16046. * An observable triggered before computing the skeleton's matrices
  16047. */
  16048. onBeforeComputeObservable: Observable<Skeleton>;
  16049. /**
  16050. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16051. */
  16052. get isUsingTextureForMatrices(): boolean;
  16053. /**
  16054. * Gets the unique ID of this skeleton
  16055. */
  16056. get uniqueId(): number;
  16057. /**
  16058. * Creates a new skeleton
  16059. * @param name defines the skeleton name
  16060. * @param id defines the skeleton Id
  16061. * @param scene defines the hosting scene
  16062. */
  16063. constructor(
  16064. /** defines the skeleton name */
  16065. name: string,
  16066. /** defines the skeleton Id */
  16067. id: string, scene: Scene);
  16068. /**
  16069. * Gets the current object class name.
  16070. * @return the class name
  16071. */
  16072. getClassName(): string;
  16073. /**
  16074. * Returns an array containing the root bones
  16075. * @returns an array containing the root bones
  16076. */
  16077. getChildren(): Array<Bone>;
  16078. /**
  16079. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16080. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16081. * @returns a Float32Array containing matrices data
  16082. */
  16083. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16084. /**
  16085. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16086. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16087. * @returns a raw texture containing the data
  16088. */
  16089. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16090. /**
  16091. * Gets the current hosting scene
  16092. * @returns a scene object
  16093. */
  16094. getScene(): Scene;
  16095. /**
  16096. * Gets a string representing the current skeleton data
  16097. * @param fullDetails defines a boolean indicating if we want a verbose version
  16098. * @returns a string representing the current skeleton data
  16099. */
  16100. toString(fullDetails?: boolean): string;
  16101. /**
  16102. * Get bone's index searching by name
  16103. * @param name defines bone's name to search for
  16104. * @return the indice of the bone. Returns -1 if not found
  16105. */
  16106. getBoneIndexByName(name: string): number;
  16107. /**
  16108. * Creater a new animation range
  16109. * @param name defines the name of the range
  16110. * @param from defines the start key
  16111. * @param to defines the end key
  16112. */
  16113. createAnimationRange(name: string, from: number, to: number): void;
  16114. /**
  16115. * Delete a specific animation range
  16116. * @param name defines the name of the range
  16117. * @param deleteFrames defines if frames must be removed as well
  16118. */
  16119. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16120. /**
  16121. * Gets a specific animation range
  16122. * @param name defines the name of the range to look for
  16123. * @returns the requested animation range or null if not found
  16124. */
  16125. getAnimationRange(name: string): Nullable<AnimationRange>;
  16126. /**
  16127. * Gets the list of all animation ranges defined on this skeleton
  16128. * @returns an array
  16129. */
  16130. getAnimationRanges(): Nullable<AnimationRange>[];
  16131. /**
  16132. * Copy animation range from a source skeleton.
  16133. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16134. * @param source defines the source skeleton
  16135. * @param name defines the name of the range to copy
  16136. * @param rescaleAsRequired defines if rescaling must be applied if required
  16137. * @returns true if operation was successful
  16138. */
  16139. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16140. /**
  16141. * Forces the skeleton to go to rest pose
  16142. */
  16143. returnToRest(): void;
  16144. private _getHighestAnimationFrame;
  16145. /**
  16146. * Begin a specific animation range
  16147. * @param name defines the name of the range to start
  16148. * @param loop defines if looping must be turned on (false by default)
  16149. * @param speedRatio defines the speed ratio to apply (1 by default)
  16150. * @param onAnimationEnd defines a callback which will be called when animation will end
  16151. * @returns a new animatable
  16152. */
  16153. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16154. /**
  16155. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16156. * @param skeleton defines the Skeleton containing the animation range to convert
  16157. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16158. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16159. * @returns the original skeleton
  16160. */
  16161. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16162. /** @hidden */
  16163. _markAsDirty(): void;
  16164. /** @hidden */
  16165. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16166. /** @hidden */
  16167. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16168. private _computeTransformMatrices;
  16169. /**
  16170. * Build all resources required to render a skeleton
  16171. */
  16172. prepare(): void;
  16173. /**
  16174. * Gets the list of animatables currently running for this skeleton
  16175. * @returns an array of animatables
  16176. */
  16177. getAnimatables(): IAnimatable[];
  16178. /**
  16179. * Clone the current skeleton
  16180. * @param name defines the name of the new skeleton
  16181. * @param id defines the id of the new skeleton
  16182. * @returns the new skeleton
  16183. */
  16184. clone(name: string, id?: string): Skeleton;
  16185. /**
  16186. * Enable animation blending for this skeleton
  16187. * @param blendingSpeed defines the blending speed to apply
  16188. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16189. */
  16190. enableBlending(blendingSpeed?: number): void;
  16191. /**
  16192. * Releases all resources associated with the current skeleton
  16193. */
  16194. dispose(): void;
  16195. /**
  16196. * Serialize the skeleton in a JSON object
  16197. * @returns a JSON object
  16198. */
  16199. serialize(): any;
  16200. /**
  16201. * Creates a new skeleton from serialized data
  16202. * @param parsedSkeleton defines the serialized data
  16203. * @param scene defines the hosting scene
  16204. * @returns a new skeleton
  16205. */
  16206. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16207. /**
  16208. * Compute all node absolute transforms
  16209. * @param forceUpdate defines if computation must be done even if cache is up to date
  16210. */
  16211. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16212. /**
  16213. * Gets the root pose matrix
  16214. * @returns a matrix
  16215. */
  16216. getPoseMatrix(): Nullable<Matrix>;
  16217. /**
  16218. * Sorts bones per internal index
  16219. */
  16220. sortBones(): void;
  16221. private _sortBones;
  16222. }
  16223. }
  16224. declare module BABYLON {
  16225. /**
  16226. * Creates an instance based on a source mesh.
  16227. */
  16228. export class InstancedMesh extends AbstractMesh {
  16229. private _sourceMesh;
  16230. private _currentLOD;
  16231. /** @hidden */
  16232. _indexInSourceMeshInstanceArray: number;
  16233. constructor(name: string, source: Mesh);
  16234. /**
  16235. * Returns the string "InstancedMesh".
  16236. */
  16237. getClassName(): string;
  16238. /** Gets the list of lights affecting that mesh */
  16239. get lightSources(): Light[];
  16240. _resyncLightSources(): void;
  16241. _resyncLightSource(light: Light): void;
  16242. _removeLightSource(light: Light, dispose: boolean): void;
  16243. /**
  16244. * If the source mesh receives shadows
  16245. */
  16246. get receiveShadows(): boolean;
  16247. /**
  16248. * The material of the source mesh
  16249. */
  16250. get material(): Nullable<Material>;
  16251. /**
  16252. * Visibility of the source mesh
  16253. */
  16254. get visibility(): number;
  16255. /**
  16256. * Skeleton of the source mesh
  16257. */
  16258. get skeleton(): Nullable<Skeleton>;
  16259. /**
  16260. * Rendering ground id of the source mesh
  16261. */
  16262. get renderingGroupId(): number;
  16263. set renderingGroupId(value: number);
  16264. /**
  16265. * Returns the total number of vertices (integer).
  16266. */
  16267. getTotalVertices(): number;
  16268. /**
  16269. * Returns a positive integer : the total number of indices in this mesh geometry.
  16270. * @returns the numner of indices or zero if the mesh has no geometry.
  16271. */
  16272. getTotalIndices(): number;
  16273. /**
  16274. * The source mesh of the instance
  16275. */
  16276. get sourceMesh(): Mesh;
  16277. /**
  16278. * Creates a new InstancedMesh object from the mesh model.
  16279. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16280. * @param name defines the name of the new instance
  16281. * @returns a new InstancedMesh
  16282. */
  16283. createInstance(name: string): InstancedMesh;
  16284. /**
  16285. * Is this node ready to be used/rendered
  16286. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16287. * @return {boolean} is it ready
  16288. */
  16289. isReady(completeCheck?: boolean): boolean;
  16290. /**
  16291. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16292. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16293. * @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.
  16294. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16295. */
  16296. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16297. /**
  16298. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16299. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16300. * The `data` are either a numeric array either a Float32Array.
  16301. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16302. * 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).
  16303. * Note that a new underlying VertexBuffer object is created each call.
  16304. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16305. *
  16306. * Possible `kind` values :
  16307. * - VertexBuffer.PositionKind
  16308. * - VertexBuffer.UVKind
  16309. * - VertexBuffer.UV2Kind
  16310. * - VertexBuffer.UV3Kind
  16311. * - VertexBuffer.UV4Kind
  16312. * - VertexBuffer.UV5Kind
  16313. * - VertexBuffer.UV6Kind
  16314. * - VertexBuffer.ColorKind
  16315. * - VertexBuffer.MatricesIndicesKind
  16316. * - VertexBuffer.MatricesIndicesExtraKind
  16317. * - VertexBuffer.MatricesWeightsKind
  16318. * - VertexBuffer.MatricesWeightsExtraKind
  16319. *
  16320. * Returns the Mesh.
  16321. */
  16322. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16323. /**
  16324. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16325. * If the mesh has no geometry, it is simply returned as it is.
  16326. * The `data` are either a numeric array either a Float32Array.
  16327. * No new underlying VertexBuffer object is created.
  16328. * 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.
  16329. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16330. *
  16331. * Possible `kind` values :
  16332. * - VertexBuffer.PositionKind
  16333. * - VertexBuffer.UVKind
  16334. * - VertexBuffer.UV2Kind
  16335. * - VertexBuffer.UV3Kind
  16336. * - VertexBuffer.UV4Kind
  16337. * - VertexBuffer.UV5Kind
  16338. * - VertexBuffer.UV6Kind
  16339. * - VertexBuffer.ColorKind
  16340. * - VertexBuffer.MatricesIndicesKind
  16341. * - VertexBuffer.MatricesIndicesExtraKind
  16342. * - VertexBuffer.MatricesWeightsKind
  16343. * - VertexBuffer.MatricesWeightsExtraKind
  16344. *
  16345. * Returns the Mesh.
  16346. */
  16347. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16348. /**
  16349. * Sets the mesh indices.
  16350. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16351. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16352. * This method creates a new index buffer each call.
  16353. * Returns the Mesh.
  16354. */
  16355. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16356. /**
  16357. * Boolean : True if the mesh owns the requested kind of data.
  16358. */
  16359. isVerticesDataPresent(kind: string): boolean;
  16360. /**
  16361. * Returns an array of indices (IndicesArray).
  16362. */
  16363. getIndices(): Nullable<IndicesArray>;
  16364. get _positions(): Nullable<Vector3[]>;
  16365. /**
  16366. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16367. * This means the mesh underlying bounding box and sphere are recomputed.
  16368. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16369. * @returns the current mesh
  16370. */
  16371. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16372. /** @hidden */
  16373. _preActivate(): InstancedMesh;
  16374. /** @hidden */
  16375. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16376. /** @hidden */
  16377. _postActivate(): void;
  16378. getWorldMatrix(): Matrix;
  16379. get isAnInstance(): boolean;
  16380. /**
  16381. * Returns the current associated LOD AbstractMesh.
  16382. */
  16383. getLOD(camera: Camera): AbstractMesh;
  16384. /** @hidden */
  16385. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16386. /** @hidden */
  16387. _syncSubMeshes(): InstancedMesh;
  16388. /** @hidden */
  16389. _generatePointsArray(): boolean;
  16390. /** @hidden */
  16391. _updateBoundingInfo(): AbstractMesh;
  16392. /**
  16393. * Creates a new InstancedMesh from the current mesh.
  16394. * - name (string) : the cloned mesh name
  16395. * - newParent (optional Node) : the optional Node to parent the clone to.
  16396. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16397. *
  16398. * Returns the clone.
  16399. */
  16400. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16401. /**
  16402. * Disposes the InstancedMesh.
  16403. * Returns nothing.
  16404. */
  16405. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16406. }
  16407. interface Mesh {
  16408. /**
  16409. * Register a custom buffer that will be instanced
  16410. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16411. * @param kind defines the buffer kind
  16412. * @param stride defines the stride in floats
  16413. */
  16414. registerInstancedBuffer(kind: string, stride: number): void;
  16415. /**
  16416. * true to use the edge renderer for all instances of this mesh
  16417. */
  16418. edgesShareWithInstances: boolean;
  16419. /** @hidden */
  16420. _userInstancedBuffersStorage: {
  16421. data: {
  16422. [key: string]: Float32Array;
  16423. };
  16424. sizes: {
  16425. [key: string]: number;
  16426. };
  16427. vertexBuffers: {
  16428. [key: string]: Nullable<VertexBuffer>;
  16429. };
  16430. strides: {
  16431. [key: string]: number;
  16432. };
  16433. };
  16434. }
  16435. interface AbstractMesh {
  16436. /**
  16437. * Object used to store instanced buffers defined by user
  16438. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16439. */
  16440. instancedBuffers: {
  16441. [key: string]: any;
  16442. };
  16443. }
  16444. }
  16445. declare module BABYLON {
  16446. /**
  16447. * Defines the options associated with the creation of a shader material.
  16448. */
  16449. export interface IShaderMaterialOptions {
  16450. /**
  16451. * Does the material work in alpha blend mode
  16452. */
  16453. needAlphaBlending: boolean;
  16454. /**
  16455. * Does the material work in alpha test mode
  16456. */
  16457. needAlphaTesting: boolean;
  16458. /**
  16459. * The list of attribute names used in the shader
  16460. */
  16461. attributes: string[];
  16462. /**
  16463. * The list of unifrom names used in the shader
  16464. */
  16465. uniforms: string[];
  16466. /**
  16467. * The list of UBO names used in the shader
  16468. */
  16469. uniformBuffers: string[];
  16470. /**
  16471. * The list of sampler names used in the shader
  16472. */
  16473. samplers: string[];
  16474. /**
  16475. * The list of defines used in the shader
  16476. */
  16477. defines: string[];
  16478. }
  16479. /**
  16480. * 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.
  16481. *
  16482. * This returned material effects how the mesh will look based on the code in the shaders.
  16483. *
  16484. * @see https://doc.babylonjs.com/how_to/shader_material
  16485. */
  16486. export class ShaderMaterial extends Material {
  16487. private _shaderPath;
  16488. private _options;
  16489. private _textures;
  16490. private _textureArrays;
  16491. private _floats;
  16492. private _ints;
  16493. private _floatsArrays;
  16494. private _colors3;
  16495. private _colors3Arrays;
  16496. private _colors4;
  16497. private _colors4Arrays;
  16498. private _vectors2;
  16499. private _vectors3;
  16500. private _vectors4;
  16501. private _matrices;
  16502. private _matrixArrays;
  16503. private _matrices3x3;
  16504. private _matrices2x2;
  16505. private _vectors2Arrays;
  16506. private _vectors3Arrays;
  16507. private _vectors4Arrays;
  16508. private _cachedWorldViewMatrix;
  16509. private _cachedWorldViewProjectionMatrix;
  16510. private _renderId;
  16511. private _multiview;
  16512. private _cachedDefines;
  16513. /** Define the Url to load snippets */
  16514. static SnippetUrl: string;
  16515. /** Snippet ID if the material was created from the snippet server */
  16516. snippetId: string;
  16517. /**
  16518. * Instantiate a new shader material.
  16519. * 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.
  16520. * This returned material effects how the mesh will look based on the code in the shaders.
  16521. * @see https://doc.babylonjs.com/how_to/shader_material
  16522. * @param name Define the name of the material in the scene
  16523. * @param scene Define the scene the material belongs to
  16524. * @param shaderPath Defines the route to the shader code in one of three ways:
  16525. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16526. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16527. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16528. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16529. * @param options Define the options used to create the shader
  16530. */
  16531. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16532. /**
  16533. * Gets the shader path used to define the shader code
  16534. * It can be modified to trigger a new compilation
  16535. */
  16536. get shaderPath(): any;
  16537. /**
  16538. * Sets the shader path used to define the shader code
  16539. * It can be modified to trigger a new compilation
  16540. */
  16541. set shaderPath(shaderPath: any);
  16542. /**
  16543. * Gets the options used to compile the shader.
  16544. * They can be modified to trigger a new compilation
  16545. */
  16546. get options(): IShaderMaterialOptions;
  16547. /**
  16548. * Gets the current class name of the material e.g. "ShaderMaterial"
  16549. * Mainly use in serialization.
  16550. * @returns the class name
  16551. */
  16552. getClassName(): string;
  16553. /**
  16554. * Specifies if the material will require alpha blending
  16555. * @returns a boolean specifying if alpha blending is needed
  16556. */
  16557. needAlphaBlending(): boolean;
  16558. /**
  16559. * Specifies if this material should be rendered in alpha test mode
  16560. * @returns a boolean specifying if an alpha test is needed.
  16561. */
  16562. needAlphaTesting(): boolean;
  16563. private _checkUniform;
  16564. /**
  16565. * Set a texture in the shader.
  16566. * @param name Define the name of the uniform samplers as defined in the shader
  16567. * @param texture Define the texture to bind to this sampler
  16568. * @return the material itself allowing "fluent" like uniform updates
  16569. */
  16570. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16571. /**
  16572. * Set a texture array in the shader.
  16573. * @param name Define the name of the uniform sampler array as defined in the shader
  16574. * @param textures Define the list of textures to bind to this sampler
  16575. * @return the material itself allowing "fluent" like uniform updates
  16576. */
  16577. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16578. /**
  16579. * Set a float in the shader.
  16580. * @param name Define the name of the uniform as defined in the shader
  16581. * @param value Define the value to give to the uniform
  16582. * @return the material itself allowing "fluent" like uniform updates
  16583. */
  16584. setFloat(name: string, value: number): ShaderMaterial;
  16585. /**
  16586. * Set a int in the shader.
  16587. * @param name Define the name of the uniform as defined in the shader
  16588. * @param value Define the value to give to the uniform
  16589. * @return the material itself allowing "fluent" like uniform updates
  16590. */
  16591. setInt(name: string, value: number): ShaderMaterial;
  16592. /**
  16593. * Set an array of floats in the shader.
  16594. * @param name Define the name of the uniform as defined in the shader
  16595. * @param value Define the value to give to the uniform
  16596. * @return the material itself allowing "fluent" like uniform updates
  16597. */
  16598. setFloats(name: string, value: number[]): ShaderMaterial;
  16599. /**
  16600. * Set a vec3 in the shader from a Color3.
  16601. * @param name Define the name of the uniform as defined in the shader
  16602. * @param value Define the value to give to the uniform
  16603. * @return the material itself allowing "fluent" like uniform updates
  16604. */
  16605. setColor3(name: string, value: Color3): ShaderMaterial;
  16606. /**
  16607. * Set a vec3 array in the shader from a Color3 array.
  16608. * @param name Define the name of the uniform as defined in the shader
  16609. * @param value Define the value to give to the uniform
  16610. * @return the material itself allowing "fluent" like uniform updates
  16611. */
  16612. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16613. /**
  16614. * Set a vec4 in the shader from a Color4.
  16615. * @param name Define the name of the uniform as defined in the shader
  16616. * @param value Define the value to give to the uniform
  16617. * @return the material itself allowing "fluent" like uniform updates
  16618. */
  16619. setColor4(name: string, value: Color4): ShaderMaterial;
  16620. /**
  16621. * Set a vec4 array in the shader from a Color4 array.
  16622. * @param name Define the name of the uniform as defined in the shader
  16623. * @param value Define the value to give to the uniform
  16624. * @return the material itself allowing "fluent" like uniform updates
  16625. */
  16626. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16627. /**
  16628. * Set a vec2 in the shader from a Vector2.
  16629. * @param name Define the name of the uniform as defined in the shader
  16630. * @param value Define the value to give to the uniform
  16631. * @return the material itself allowing "fluent" like uniform updates
  16632. */
  16633. setVector2(name: string, value: Vector2): ShaderMaterial;
  16634. /**
  16635. * Set a vec3 in the shader from a Vector3.
  16636. * @param name Define the name of the uniform as defined in the shader
  16637. * @param value Define the value to give to the uniform
  16638. * @return the material itself allowing "fluent" like uniform updates
  16639. */
  16640. setVector3(name: string, value: Vector3): ShaderMaterial;
  16641. /**
  16642. * Set a vec4 in the shader from a Vector4.
  16643. * @param name Define the name of the uniform as defined in the shader
  16644. * @param value Define the value to give to the uniform
  16645. * @return the material itself allowing "fluent" like uniform updates
  16646. */
  16647. setVector4(name: string, value: Vector4): ShaderMaterial;
  16648. /**
  16649. * Set a mat4 in the shader from a Matrix.
  16650. * @param name Define the name of the uniform as defined in the shader
  16651. * @param value Define the value to give to the uniform
  16652. * @return the material itself allowing "fluent" like uniform updates
  16653. */
  16654. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16655. /**
  16656. * Set a float32Array in the shader from a matrix array.
  16657. * @param name Define the name of the uniform as defined in the shader
  16658. * @param value Define the value to give to the uniform
  16659. * @return the material itself allowing "fluent" like uniform updates
  16660. */
  16661. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16662. /**
  16663. * Set a mat3 in the shader from a Float32Array.
  16664. * @param name Define the name of the uniform as defined in the shader
  16665. * @param value Define the value to give to the uniform
  16666. * @return the material itself allowing "fluent" like uniform updates
  16667. */
  16668. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16669. /**
  16670. * Set a mat2 in the shader from a Float32Array.
  16671. * @param name Define the name of the uniform as defined in the shader
  16672. * @param value Define the value to give to the uniform
  16673. * @return the material itself allowing "fluent" like uniform updates
  16674. */
  16675. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16676. /**
  16677. * Set a vec2 array in the shader from a number array.
  16678. * @param name Define the name of the uniform as defined in the shader
  16679. * @param value Define the value to give to the uniform
  16680. * @return the material itself allowing "fluent" like uniform updates
  16681. */
  16682. setArray2(name: string, value: number[]): ShaderMaterial;
  16683. /**
  16684. * Set a vec3 array in the shader from a number array.
  16685. * @param name Define the name of the uniform as defined in the shader
  16686. * @param value Define the value to give to the uniform
  16687. * @return the material itself allowing "fluent" like uniform updates
  16688. */
  16689. setArray3(name: string, value: number[]): ShaderMaterial;
  16690. /**
  16691. * Set a vec4 array in the shader from a number array.
  16692. * @param name Define the name of the uniform as defined in the shader
  16693. * @param value Define the value to give to the uniform
  16694. * @return the material itself allowing "fluent" like uniform updates
  16695. */
  16696. setArray4(name: string, value: number[]): ShaderMaterial;
  16697. private _checkCache;
  16698. /**
  16699. * Specifies that the submesh is ready to be used
  16700. * @param mesh defines the mesh to check
  16701. * @param subMesh defines which submesh to check
  16702. * @param useInstances specifies that instances should be used
  16703. * @returns a boolean indicating that the submesh is ready or not
  16704. */
  16705. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16706. /**
  16707. * Checks if the material is ready to render the requested mesh
  16708. * @param mesh Define the mesh to render
  16709. * @param useInstances Define whether or not the material is used with instances
  16710. * @returns true if ready, otherwise false
  16711. */
  16712. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16713. /**
  16714. * Binds the world matrix to the material
  16715. * @param world defines the world transformation matrix
  16716. * @param effectOverride - If provided, use this effect instead of internal effect
  16717. */
  16718. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16719. /**
  16720. * Binds the submesh to this material by preparing the effect and shader to draw
  16721. * @param world defines the world transformation matrix
  16722. * @param mesh defines the mesh containing the submesh
  16723. * @param subMesh defines the submesh to bind the material to
  16724. */
  16725. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16726. /**
  16727. * Binds the material to the mesh
  16728. * @param world defines the world transformation matrix
  16729. * @param mesh defines the mesh to bind the material to
  16730. * @param effectOverride - If provided, use this effect instead of internal effect
  16731. */
  16732. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16733. protected _afterBind(mesh?: Mesh): void;
  16734. /**
  16735. * Gets the active textures from the material
  16736. * @returns an array of textures
  16737. */
  16738. getActiveTextures(): BaseTexture[];
  16739. /**
  16740. * Specifies if the material uses a texture
  16741. * @param texture defines the texture to check against the material
  16742. * @returns a boolean specifying if the material uses the texture
  16743. */
  16744. hasTexture(texture: BaseTexture): boolean;
  16745. /**
  16746. * Makes a duplicate of the material, and gives it a new name
  16747. * @param name defines the new name for the duplicated material
  16748. * @returns the cloned material
  16749. */
  16750. clone(name: string): ShaderMaterial;
  16751. /**
  16752. * Disposes the material
  16753. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16754. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16755. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16756. */
  16757. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16758. /**
  16759. * Serializes this material in a JSON representation
  16760. * @returns the serialized material object
  16761. */
  16762. serialize(): any;
  16763. /**
  16764. * Creates a shader material from parsed shader material data
  16765. * @param source defines the JSON represnetation of the material
  16766. * @param scene defines the hosting scene
  16767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16768. * @returns a new material
  16769. */
  16770. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16771. /**
  16772. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16773. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16774. * @param url defines the url to load from
  16775. * @param scene defines the hosting scene
  16776. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16777. * @returns a promise that will resolve to the new ShaderMaterial
  16778. */
  16779. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16780. /**
  16781. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16782. * @param snippetId defines the snippet to load
  16783. * @param scene defines the hosting scene
  16784. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16785. * @returns a promise that will resolve to the new ShaderMaterial
  16786. */
  16787. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16788. }
  16789. }
  16790. declare module BABYLON {
  16791. /** @hidden */
  16792. export var colorPixelShader: {
  16793. name: string;
  16794. shader: string;
  16795. };
  16796. }
  16797. declare module BABYLON {
  16798. /** @hidden */
  16799. export var colorVertexShader: {
  16800. name: string;
  16801. shader: string;
  16802. };
  16803. }
  16804. declare module BABYLON {
  16805. /**
  16806. * Line mesh
  16807. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16808. */
  16809. export class LinesMesh extends Mesh {
  16810. /**
  16811. * If vertex color should be applied to the mesh
  16812. */
  16813. readonly useVertexColor?: boolean | undefined;
  16814. /**
  16815. * If vertex alpha should be applied to the mesh
  16816. */
  16817. readonly useVertexAlpha?: boolean | undefined;
  16818. /**
  16819. * Color of the line (Default: White)
  16820. */
  16821. color: Color3;
  16822. /**
  16823. * Alpha of the line (Default: 1)
  16824. */
  16825. alpha: number;
  16826. /**
  16827. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16828. * This margin is expressed in world space coordinates, so its value may vary.
  16829. * Default value is 0.1
  16830. */
  16831. intersectionThreshold: number;
  16832. private _colorShader;
  16833. private color4;
  16834. /**
  16835. * Creates a new LinesMesh
  16836. * @param name defines the name
  16837. * @param scene defines the hosting scene
  16838. * @param parent defines the parent mesh if any
  16839. * @param source defines the optional source LinesMesh used to clone data from
  16840. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16841. * When false, achieved by calling a clone(), also passing False.
  16842. * This will make creation of children, recursive.
  16843. * @param useVertexColor defines if this LinesMesh supports vertex color
  16844. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16845. */
  16846. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16847. /**
  16848. * If vertex color should be applied to the mesh
  16849. */
  16850. useVertexColor?: boolean | undefined,
  16851. /**
  16852. * If vertex alpha should be applied to the mesh
  16853. */
  16854. useVertexAlpha?: boolean | undefined);
  16855. private _addClipPlaneDefine;
  16856. private _removeClipPlaneDefine;
  16857. isReady(): boolean;
  16858. /**
  16859. * Returns the string "LineMesh"
  16860. */
  16861. getClassName(): string;
  16862. /**
  16863. * @hidden
  16864. */
  16865. get material(): Material;
  16866. /**
  16867. * @hidden
  16868. */
  16869. set material(value: Material);
  16870. /**
  16871. * @hidden
  16872. */
  16873. get checkCollisions(): boolean;
  16874. /** @hidden */
  16875. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16876. /** @hidden */
  16877. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16878. /**
  16879. * Disposes of the line mesh
  16880. * @param doNotRecurse If children should be disposed
  16881. */
  16882. dispose(doNotRecurse?: boolean): void;
  16883. /**
  16884. * Returns a new LineMesh object cloned from the current one.
  16885. */
  16886. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16887. /**
  16888. * Creates a new InstancedLinesMesh object from the mesh model.
  16889. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16890. * @param name defines the name of the new instance
  16891. * @returns a new InstancedLinesMesh
  16892. */
  16893. createInstance(name: string): InstancedLinesMesh;
  16894. }
  16895. /**
  16896. * Creates an instance based on a source LinesMesh
  16897. */
  16898. export class InstancedLinesMesh extends InstancedMesh {
  16899. /**
  16900. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16901. * This margin is expressed in world space coordinates, so its value may vary.
  16902. * Initilized with the intersectionThreshold value of the source LinesMesh
  16903. */
  16904. intersectionThreshold: number;
  16905. constructor(name: string, source: LinesMesh);
  16906. /**
  16907. * Returns the string "InstancedLinesMesh".
  16908. */
  16909. getClassName(): string;
  16910. }
  16911. }
  16912. declare module BABYLON {
  16913. /** @hidden */
  16914. export var linePixelShader: {
  16915. name: string;
  16916. shader: string;
  16917. };
  16918. }
  16919. declare module BABYLON {
  16920. /** @hidden */
  16921. export var lineVertexShader: {
  16922. name: string;
  16923. shader: string;
  16924. };
  16925. }
  16926. declare module BABYLON {
  16927. interface Scene {
  16928. /** @hidden */
  16929. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16930. }
  16931. interface AbstractMesh {
  16932. /**
  16933. * Gets the edgesRenderer associated with the mesh
  16934. */
  16935. edgesRenderer: Nullable<EdgesRenderer>;
  16936. }
  16937. interface LinesMesh {
  16938. /**
  16939. * Enables the edge rendering mode on the mesh.
  16940. * This mode makes the mesh edges visible
  16941. * @param epsilon defines the maximal distance between two angles to detect a face
  16942. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16943. * @returns the currentAbstractMesh
  16944. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16945. */
  16946. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16947. }
  16948. interface InstancedLinesMesh {
  16949. /**
  16950. * Enables the edge rendering mode on the mesh.
  16951. * This mode makes the mesh edges visible
  16952. * @param epsilon defines the maximal distance between two angles to detect a face
  16953. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16954. * @returns the current InstancedLinesMesh
  16955. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16956. */
  16957. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16958. }
  16959. /**
  16960. * Defines the minimum contract an Edges renderer should follow.
  16961. */
  16962. export interface IEdgesRenderer extends IDisposable {
  16963. /**
  16964. * Gets or sets a boolean indicating if the edgesRenderer is active
  16965. */
  16966. isEnabled: boolean;
  16967. /**
  16968. * Renders the edges of the attached mesh,
  16969. */
  16970. render(): void;
  16971. /**
  16972. * Checks wether or not the edges renderer is ready to render.
  16973. * @return true if ready, otherwise false.
  16974. */
  16975. isReady(): boolean;
  16976. /**
  16977. * List of instances to render in case the source mesh has instances
  16978. */
  16979. customInstances: SmartArray<Matrix>;
  16980. }
  16981. /**
  16982. * Defines the additional options of the edges renderer
  16983. */
  16984. export interface IEdgesRendererOptions {
  16985. /**
  16986. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16987. * If not defined, the default value is true
  16988. */
  16989. useAlternateEdgeFinder?: boolean;
  16990. /**
  16991. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16992. * If not defined, the default value is true.
  16993. * 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)
  16994. * This option is used only if useAlternateEdgeFinder = true
  16995. */
  16996. useFastVertexMerger?: boolean;
  16997. /**
  16998. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16999. * The default value is 1e-6
  17000. * This option is used only if useAlternateEdgeFinder = true
  17001. */
  17002. epsilonVertexMerge?: number;
  17003. /**
  17004. * 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
  17005. * 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.
  17006. * This option is used only if useAlternateEdgeFinder = true
  17007. */
  17008. applyTessellation?: boolean;
  17009. /**
  17010. * 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
  17011. * The default value is 1e-6
  17012. * This option is used only if useAlternateEdgeFinder = true
  17013. */
  17014. epsilonVertexAligned?: number;
  17015. }
  17016. /**
  17017. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17018. */
  17019. export class EdgesRenderer implements IEdgesRenderer {
  17020. /**
  17021. * Define the size of the edges with an orthographic camera
  17022. */
  17023. edgesWidthScalerForOrthographic: number;
  17024. /**
  17025. * Define the size of the edges with a perspective camera
  17026. */
  17027. edgesWidthScalerForPerspective: number;
  17028. protected _source: AbstractMesh;
  17029. protected _linesPositions: number[];
  17030. protected _linesNormals: number[];
  17031. protected _linesIndices: number[];
  17032. protected _epsilon: number;
  17033. protected _indicesCount: number;
  17034. protected _lineShader: ShaderMaterial;
  17035. protected _ib: DataBuffer;
  17036. protected _buffers: {
  17037. [key: string]: Nullable<VertexBuffer>;
  17038. };
  17039. protected _buffersForInstances: {
  17040. [key: string]: Nullable<VertexBuffer>;
  17041. };
  17042. protected _checkVerticesInsteadOfIndices: boolean;
  17043. protected _options: Nullable<IEdgesRendererOptions>;
  17044. private _meshRebuildObserver;
  17045. private _meshDisposeObserver;
  17046. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17047. isEnabled: boolean;
  17048. /**
  17049. * List of instances to render in case the source mesh has instances
  17050. */
  17051. customInstances: SmartArray<Matrix>;
  17052. private static GetShader;
  17053. /**
  17054. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17055. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17056. * @param source Mesh used to create edges
  17057. * @param epsilon sum of angles in adjacency to check for edge
  17058. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17059. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17060. * @param options The options to apply when generating the edges
  17061. */
  17062. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17063. protected _prepareRessources(): void;
  17064. /** @hidden */
  17065. _rebuild(): void;
  17066. /**
  17067. * Releases the required resources for the edges renderer
  17068. */
  17069. dispose(): void;
  17070. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17071. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17072. /**
  17073. * Checks if the pair of p0 and p1 is en edge
  17074. * @param faceIndex
  17075. * @param edge
  17076. * @param faceNormals
  17077. * @param p0
  17078. * @param p1
  17079. * @private
  17080. */
  17081. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17082. /**
  17083. * push line into the position, normal and index buffer
  17084. * @protected
  17085. */
  17086. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17087. /**
  17088. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17089. */
  17090. private _tessellateTriangle;
  17091. private _generateEdgesLinesAlternate;
  17092. /**
  17093. * Generates lines edges from adjacencjes
  17094. * @private
  17095. */
  17096. _generateEdgesLines(): void;
  17097. /**
  17098. * Checks wether or not the edges renderer is ready to render.
  17099. * @return true if ready, otherwise false.
  17100. */
  17101. isReady(): boolean;
  17102. /**
  17103. * Renders the edges of the attached mesh,
  17104. */
  17105. render(): void;
  17106. }
  17107. /**
  17108. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17109. */
  17110. export class LineEdgesRenderer extends EdgesRenderer {
  17111. /**
  17112. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17113. * @param source LineMesh used to generate edges
  17114. * @param epsilon not important (specified angle for edge detection)
  17115. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17116. */
  17117. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17118. /**
  17119. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17120. */
  17121. _generateEdgesLines(): void;
  17122. }
  17123. }
  17124. declare module BABYLON {
  17125. /**
  17126. * This represents the object necessary to create a rendering group.
  17127. * This is exclusively used and created by the rendering manager.
  17128. * To modify the behavior, you use the available helpers in your scene or meshes.
  17129. * @hidden
  17130. */
  17131. export class RenderingGroup {
  17132. index: number;
  17133. private static _zeroVector;
  17134. private _scene;
  17135. private _opaqueSubMeshes;
  17136. private _transparentSubMeshes;
  17137. private _alphaTestSubMeshes;
  17138. private _depthOnlySubMeshes;
  17139. private _particleSystems;
  17140. private _spriteManagers;
  17141. private _opaqueSortCompareFn;
  17142. private _alphaTestSortCompareFn;
  17143. private _transparentSortCompareFn;
  17144. private _renderOpaque;
  17145. private _renderAlphaTest;
  17146. private _renderTransparent;
  17147. /** @hidden */
  17148. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17149. onBeforeTransparentRendering: () => void;
  17150. /**
  17151. * Set the opaque sort comparison function.
  17152. * If null the sub meshes will be render in the order they were created
  17153. */
  17154. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17155. /**
  17156. * Set the alpha test sort comparison function.
  17157. * If null the sub meshes will be render in the order they were created
  17158. */
  17159. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17160. /**
  17161. * Set the transparent sort comparison function.
  17162. * If null the sub meshes will be render in the order they were created
  17163. */
  17164. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17165. /**
  17166. * Creates a new rendering group.
  17167. * @param index The rendering group index
  17168. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17169. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17170. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17171. */
  17172. 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>);
  17173. /**
  17174. * Render all the sub meshes contained in the group.
  17175. * @param customRenderFunction Used to override the default render behaviour of the group.
  17176. * @returns true if rendered some submeshes.
  17177. */
  17178. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17179. /**
  17180. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17181. * @param subMeshes The submeshes to render
  17182. */
  17183. private renderOpaqueSorted;
  17184. /**
  17185. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17186. * @param subMeshes The submeshes to render
  17187. */
  17188. private renderAlphaTestSorted;
  17189. /**
  17190. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17191. * @param subMeshes The submeshes to render
  17192. */
  17193. private renderTransparentSorted;
  17194. /**
  17195. * Renders the submeshes in a specified order.
  17196. * @param subMeshes The submeshes to sort before render
  17197. * @param sortCompareFn The comparison function use to sort
  17198. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17199. * @param transparent Specifies to activate blending if true
  17200. */
  17201. private static renderSorted;
  17202. /**
  17203. * Renders the submeshes in the order they were dispatched (no sort applied).
  17204. * @param subMeshes The submeshes to render
  17205. */
  17206. private static renderUnsorted;
  17207. /**
  17208. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17209. * are rendered back to front if in the same alpha index.
  17210. *
  17211. * @param a The first submesh
  17212. * @param b The second submesh
  17213. * @returns The result of the comparison
  17214. */
  17215. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17216. /**
  17217. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17218. * are rendered back to front.
  17219. *
  17220. * @param a The first submesh
  17221. * @param b The second submesh
  17222. * @returns The result of the comparison
  17223. */
  17224. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17225. /**
  17226. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17227. * are rendered front to back (prevent overdraw).
  17228. *
  17229. * @param a The first submesh
  17230. * @param b The second submesh
  17231. * @returns The result of the comparison
  17232. */
  17233. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17234. /**
  17235. * Resets the different lists of submeshes to prepare a new frame.
  17236. */
  17237. prepare(): void;
  17238. dispose(): void;
  17239. /**
  17240. * Inserts the submesh in its correct queue depending on its material.
  17241. * @param subMesh The submesh to dispatch
  17242. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17243. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17244. */
  17245. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17246. dispatchSprites(spriteManager: ISpriteManager): void;
  17247. dispatchParticles(particleSystem: IParticleSystem): void;
  17248. private _renderParticles;
  17249. private _renderSprites;
  17250. }
  17251. }
  17252. declare module BABYLON {
  17253. /**
  17254. * Interface describing the different options available in the rendering manager
  17255. * regarding Auto Clear between groups.
  17256. */
  17257. export interface IRenderingManagerAutoClearSetup {
  17258. /**
  17259. * Defines whether or not autoclear is enable.
  17260. */
  17261. autoClear: boolean;
  17262. /**
  17263. * Defines whether or not to autoclear the depth buffer.
  17264. */
  17265. depth: boolean;
  17266. /**
  17267. * Defines whether or not to autoclear the stencil buffer.
  17268. */
  17269. stencil: boolean;
  17270. }
  17271. /**
  17272. * This class is used by the onRenderingGroupObservable
  17273. */
  17274. export class RenderingGroupInfo {
  17275. /**
  17276. * The Scene that being rendered
  17277. */
  17278. scene: Scene;
  17279. /**
  17280. * The camera currently used for the rendering pass
  17281. */
  17282. camera: Nullable<Camera>;
  17283. /**
  17284. * The ID of the renderingGroup being processed
  17285. */
  17286. renderingGroupId: number;
  17287. }
  17288. /**
  17289. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17290. * It is enable to manage the different groups as well as the different necessary sort functions.
  17291. * This should not be used directly aside of the few static configurations
  17292. */
  17293. export class RenderingManager {
  17294. /**
  17295. * The max id used for rendering groups (not included)
  17296. */
  17297. static MAX_RENDERINGGROUPS: number;
  17298. /**
  17299. * The min id used for rendering groups (included)
  17300. */
  17301. static MIN_RENDERINGGROUPS: number;
  17302. /**
  17303. * Used to globally prevent autoclearing scenes.
  17304. */
  17305. static AUTOCLEAR: boolean;
  17306. /**
  17307. * @hidden
  17308. */
  17309. _useSceneAutoClearSetup: boolean;
  17310. private _scene;
  17311. private _renderingGroups;
  17312. private _depthStencilBufferAlreadyCleaned;
  17313. private _autoClearDepthStencil;
  17314. private _customOpaqueSortCompareFn;
  17315. private _customAlphaTestSortCompareFn;
  17316. private _customTransparentSortCompareFn;
  17317. private _renderingGroupInfo;
  17318. /**
  17319. * Instantiates a new rendering group for a particular scene
  17320. * @param scene Defines the scene the groups belongs to
  17321. */
  17322. constructor(scene: Scene);
  17323. private _clearDepthStencilBuffer;
  17324. /**
  17325. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17326. * @hidden
  17327. */
  17328. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17329. /**
  17330. * Resets the different information of the group to prepare a new frame
  17331. * @hidden
  17332. */
  17333. reset(): void;
  17334. /**
  17335. * Dispose and release the group and its associated resources.
  17336. * @hidden
  17337. */
  17338. dispose(): void;
  17339. /**
  17340. * Clear the info related to rendering groups preventing retention points during dispose.
  17341. */
  17342. freeRenderingGroups(): void;
  17343. private _prepareRenderingGroup;
  17344. /**
  17345. * Add a sprite manager to the rendering manager in order to render it this frame.
  17346. * @param spriteManager Define the sprite manager to render
  17347. */
  17348. dispatchSprites(spriteManager: ISpriteManager): void;
  17349. /**
  17350. * Add a particle system to the rendering manager in order to render it this frame.
  17351. * @param particleSystem Define the particle system to render
  17352. */
  17353. dispatchParticles(particleSystem: IParticleSystem): void;
  17354. /**
  17355. * Add a submesh to the manager in order to render it this frame
  17356. * @param subMesh The submesh to dispatch
  17357. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17358. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17359. */
  17360. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17361. /**
  17362. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17363. * This allowed control for front to back rendering or reversly depending of the special needs.
  17364. *
  17365. * @param renderingGroupId The rendering group id corresponding to its index
  17366. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17367. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17368. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17369. */
  17370. 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;
  17371. /**
  17372. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17373. *
  17374. * @param renderingGroupId The rendering group id corresponding to its index
  17375. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17376. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17377. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17378. */
  17379. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17380. /**
  17381. * Gets the current auto clear configuration for one rendering group of the rendering
  17382. * manager.
  17383. * @param index the rendering group index to get the information for
  17384. * @returns The auto clear setup for the requested rendering group
  17385. */
  17386. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17387. }
  17388. }
  17389. declare module BABYLON {
  17390. /**
  17391. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17392. */
  17393. export interface ICustomShaderOptions {
  17394. /**
  17395. * Gets or sets the custom shader name to use
  17396. */
  17397. shaderName: string;
  17398. /**
  17399. * The list of attribute names used in the shader
  17400. */
  17401. attributes?: string[];
  17402. /**
  17403. * The list of unifrom names used in the shader
  17404. */
  17405. uniforms?: string[];
  17406. /**
  17407. * The list of sampler names used in the shader
  17408. */
  17409. samplers?: string[];
  17410. /**
  17411. * The list of defines used in the shader
  17412. */
  17413. defines?: string[];
  17414. }
  17415. /**
  17416. * Interface to implement to create a shadow generator compatible with BJS.
  17417. */
  17418. export interface IShadowGenerator {
  17419. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17420. id: string;
  17421. /**
  17422. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17423. * @returns The render target texture if present otherwise, null
  17424. */
  17425. getShadowMap(): Nullable<RenderTargetTexture>;
  17426. /**
  17427. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17428. * @param subMesh The submesh we want to render in the shadow map
  17429. * @param useInstances Defines wether will draw in the map using instances
  17430. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17431. * @returns true if ready otherwise, false
  17432. */
  17433. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17434. /**
  17435. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17436. * @param defines Defines of the material we want to update
  17437. * @param lightIndex Index of the light in the enabled light list of the material
  17438. */
  17439. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17440. /**
  17441. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17442. * defined in the generator but impacting the effect).
  17443. * It implies the unifroms available on the materials are the standard BJS ones.
  17444. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17445. * @param effect The effect we are binfing the information for
  17446. */
  17447. bindShadowLight(lightIndex: string, effect: Effect): void;
  17448. /**
  17449. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17450. * (eq to shadow prjection matrix * light transform matrix)
  17451. * @returns The transform matrix used to create the shadow map
  17452. */
  17453. getTransformMatrix(): Matrix;
  17454. /**
  17455. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17456. * Cube and 2D textures for instance.
  17457. */
  17458. recreateShadowMap(): void;
  17459. /**
  17460. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17461. * @param onCompiled Callback triggered at the and of the effects compilation
  17462. * @param options Sets of optional options forcing the compilation with different modes
  17463. */
  17464. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17465. useInstances: boolean;
  17466. }>): void;
  17467. /**
  17468. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17469. * @param options Sets of optional options forcing the compilation with different modes
  17470. * @returns A promise that resolves when the compilation completes
  17471. */
  17472. forceCompilationAsync(options?: Partial<{
  17473. useInstances: boolean;
  17474. }>): Promise<void>;
  17475. /**
  17476. * Serializes the shadow generator setup to a json object.
  17477. * @returns The serialized JSON object
  17478. */
  17479. serialize(): any;
  17480. /**
  17481. * Disposes the Shadow map and related Textures and effects.
  17482. */
  17483. dispose(): void;
  17484. }
  17485. /**
  17486. * Default implementation IShadowGenerator.
  17487. * This is the main object responsible of generating shadows in the framework.
  17488. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17489. */
  17490. export class ShadowGenerator implements IShadowGenerator {
  17491. /**
  17492. * Name of the shadow generator class
  17493. */
  17494. static CLASSNAME: string;
  17495. /**
  17496. * Shadow generator mode None: no filtering applied.
  17497. */
  17498. static readonly FILTER_NONE: number;
  17499. /**
  17500. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17501. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17502. */
  17503. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17504. /**
  17505. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17506. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17507. */
  17508. static readonly FILTER_POISSONSAMPLING: number;
  17509. /**
  17510. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17511. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17512. */
  17513. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17514. /**
  17515. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17516. * edge artifacts on steep falloff.
  17517. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17518. */
  17519. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17520. /**
  17521. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17522. * edge artifacts on steep falloff.
  17523. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17524. */
  17525. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17526. /**
  17527. * Shadow generator mode PCF: Percentage Closer Filtering
  17528. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17529. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17530. */
  17531. static readonly FILTER_PCF: number;
  17532. /**
  17533. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17534. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17535. * Contact Hardening
  17536. */
  17537. static readonly FILTER_PCSS: number;
  17538. /**
  17539. * Reserved for PCF and PCSS
  17540. * Highest Quality.
  17541. *
  17542. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17543. *
  17544. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17545. */
  17546. static readonly QUALITY_HIGH: number;
  17547. /**
  17548. * Reserved for PCF and PCSS
  17549. * Good tradeoff for quality/perf cross devices
  17550. *
  17551. * Execute PCF on a 3*3 kernel.
  17552. *
  17553. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17554. */
  17555. static readonly QUALITY_MEDIUM: number;
  17556. /**
  17557. * Reserved for PCF and PCSS
  17558. * The lowest quality but the fastest.
  17559. *
  17560. * Execute PCF on a 1*1 kernel.
  17561. *
  17562. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17563. */
  17564. static readonly QUALITY_LOW: number;
  17565. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17566. id: string;
  17567. /** Gets or sets the custom shader name to use */
  17568. customShaderOptions: ICustomShaderOptions;
  17569. /**
  17570. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17571. */
  17572. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17573. /**
  17574. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17575. */
  17576. onAfterShadowMapRenderObservable: Observable<Effect>;
  17577. /**
  17578. * Observable triggered before a mesh is rendered in the shadow map.
  17579. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17580. */
  17581. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17582. /**
  17583. * Observable triggered after a mesh is rendered in the shadow map.
  17584. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17585. */
  17586. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17587. protected _bias: number;
  17588. /**
  17589. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17590. */
  17591. get bias(): number;
  17592. /**
  17593. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17594. */
  17595. set bias(bias: number);
  17596. protected _normalBias: number;
  17597. /**
  17598. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17599. */
  17600. get normalBias(): number;
  17601. /**
  17602. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17603. */
  17604. set normalBias(normalBias: number);
  17605. protected _blurBoxOffset: number;
  17606. /**
  17607. * Gets the blur box offset: offset applied during the blur pass.
  17608. * Only useful if useKernelBlur = false
  17609. */
  17610. get blurBoxOffset(): number;
  17611. /**
  17612. * Sets the blur box offset: offset applied during the blur pass.
  17613. * Only useful if useKernelBlur = false
  17614. */
  17615. set blurBoxOffset(value: number);
  17616. protected _blurScale: number;
  17617. /**
  17618. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17619. * 2 means half of the size.
  17620. */
  17621. get blurScale(): number;
  17622. /**
  17623. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17624. * 2 means half of the size.
  17625. */
  17626. set blurScale(value: number);
  17627. protected _blurKernel: number;
  17628. /**
  17629. * Gets the blur kernel: kernel size of the blur pass.
  17630. * Only useful if useKernelBlur = true
  17631. */
  17632. get blurKernel(): number;
  17633. /**
  17634. * Sets the blur kernel: kernel size of the blur pass.
  17635. * Only useful if useKernelBlur = true
  17636. */
  17637. set blurKernel(value: number);
  17638. protected _useKernelBlur: boolean;
  17639. /**
  17640. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17641. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17642. */
  17643. get useKernelBlur(): boolean;
  17644. /**
  17645. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17646. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17647. */
  17648. set useKernelBlur(value: boolean);
  17649. protected _depthScale: number;
  17650. /**
  17651. * Gets the depth scale used in ESM mode.
  17652. */
  17653. get depthScale(): number;
  17654. /**
  17655. * Sets the depth scale used in ESM mode.
  17656. * This can override the scale stored on the light.
  17657. */
  17658. set depthScale(value: number);
  17659. protected _validateFilter(filter: number): number;
  17660. protected _filter: number;
  17661. /**
  17662. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17663. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17664. */
  17665. get filter(): number;
  17666. /**
  17667. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17668. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17669. */
  17670. set filter(value: number);
  17671. /**
  17672. * Gets if the current filter is set to Poisson Sampling.
  17673. */
  17674. get usePoissonSampling(): boolean;
  17675. /**
  17676. * Sets the current filter to Poisson Sampling.
  17677. */
  17678. set usePoissonSampling(value: boolean);
  17679. /**
  17680. * Gets if the current filter is set to ESM.
  17681. */
  17682. get useExponentialShadowMap(): boolean;
  17683. /**
  17684. * Sets the current filter is to ESM.
  17685. */
  17686. set useExponentialShadowMap(value: boolean);
  17687. /**
  17688. * Gets if the current filter is set to filtered ESM.
  17689. */
  17690. get useBlurExponentialShadowMap(): boolean;
  17691. /**
  17692. * Gets if the current filter is set to filtered ESM.
  17693. */
  17694. set useBlurExponentialShadowMap(value: boolean);
  17695. /**
  17696. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17697. * exponential to prevent steep falloff artifacts).
  17698. */
  17699. get useCloseExponentialShadowMap(): boolean;
  17700. /**
  17701. * Sets the current filter to "close ESM" (using the inverse of the
  17702. * exponential to prevent steep falloff artifacts).
  17703. */
  17704. set useCloseExponentialShadowMap(value: boolean);
  17705. /**
  17706. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17707. * exponential to prevent steep falloff artifacts).
  17708. */
  17709. get useBlurCloseExponentialShadowMap(): boolean;
  17710. /**
  17711. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17712. * exponential to prevent steep falloff artifacts).
  17713. */
  17714. set useBlurCloseExponentialShadowMap(value: boolean);
  17715. /**
  17716. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17717. */
  17718. get usePercentageCloserFiltering(): boolean;
  17719. /**
  17720. * Sets the current filter to "PCF" (percentage closer filtering).
  17721. */
  17722. set usePercentageCloserFiltering(value: boolean);
  17723. protected _filteringQuality: number;
  17724. /**
  17725. * Gets the PCF or PCSS Quality.
  17726. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17727. */
  17728. get filteringQuality(): number;
  17729. /**
  17730. * Sets the PCF or PCSS Quality.
  17731. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17732. */
  17733. set filteringQuality(filteringQuality: number);
  17734. /**
  17735. * Gets if the current filter is set to "PCSS" (contact hardening).
  17736. */
  17737. get useContactHardeningShadow(): boolean;
  17738. /**
  17739. * Sets the current filter to "PCSS" (contact hardening).
  17740. */
  17741. set useContactHardeningShadow(value: boolean);
  17742. protected _contactHardeningLightSizeUVRatio: number;
  17743. /**
  17744. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17745. * Using a ratio helps keeping shape stability independently of the map size.
  17746. *
  17747. * It does not account for the light projection as it was having too much
  17748. * instability during the light setup or during light position changes.
  17749. *
  17750. * Only valid if useContactHardeningShadow is true.
  17751. */
  17752. get contactHardeningLightSizeUVRatio(): number;
  17753. /**
  17754. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17755. * Using a ratio helps keeping shape stability independently of the map size.
  17756. *
  17757. * It does not account for the light projection as it was having too much
  17758. * instability during the light setup or during light position changes.
  17759. *
  17760. * Only valid if useContactHardeningShadow is true.
  17761. */
  17762. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17763. protected _darkness: number;
  17764. /** Gets or sets the actual darkness of a shadow */
  17765. get darkness(): number;
  17766. set darkness(value: number);
  17767. /**
  17768. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17769. * 0 means strongest and 1 would means no shadow.
  17770. * @returns the darkness.
  17771. */
  17772. getDarkness(): number;
  17773. /**
  17774. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17775. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17776. * @returns the shadow generator allowing fluent coding.
  17777. */
  17778. setDarkness(darkness: number): ShadowGenerator;
  17779. protected _transparencyShadow: boolean;
  17780. /** Gets or sets the ability to have transparent shadow */
  17781. get transparencyShadow(): boolean;
  17782. set transparencyShadow(value: boolean);
  17783. /**
  17784. * Sets the ability to have transparent shadow (boolean).
  17785. * @param transparent True if transparent else False
  17786. * @returns the shadow generator allowing fluent coding
  17787. */
  17788. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17789. /**
  17790. * Enables or disables shadows with varying strength based on the transparency
  17791. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17792. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17793. * mesh.visibility * alphaTexture.a
  17794. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17795. */
  17796. enableSoftTransparentShadow: boolean;
  17797. protected _shadowMap: Nullable<RenderTargetTexture>;
  17798. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17799. /**
  17800. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17801. * @returns The render target texture if present otherwise, null
  17802. */
  17803. getShadowMap(): Nullable<RenderTargetTexture>;
  17804. /**
  17805. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17806. * @returns The render target texture if the shadow map is present otherwise, null
  17807. */
  17808. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17809. /**
  17810. * Gets the class name of that object
  17811. * @returns "ShadowGenerator"
  17812. */
  17813. getClassName(): string;
  17814. /**
  17815. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17816. * @param mesh Mesh to add
  17817. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17818. * @returns the Shadow Generator itself
  17819. */
  17820. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17821. /**
  17822. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17823. * @param mesh Mesh to remove
  17824. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17825. * @returns the Shadow Generator itself
  17826. */
  17827. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17828. /**
  17829. * Controls the extent to which the shadows fade out at the edge of the frustum
  17830. */
  17831. frustumEdgeFalloff: number;
  17832. protected _light: IShadowLight;
  17833. /**
  17834. * Returns the associated light object.
  17835. * @returns the light generating the shadow
  17836. */
  17837. getLight(): IShadowLight;
  17838. /**
  17839. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17840. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17841. * It might on the other hand introduce peter panning.
  17842. */
  17843. forceBackFacesOnly: boolean;
  17844. protected _scene: Scene;
  17845. protected _lightDirection: Vector3;
  17846. protected _effect: Effect;
  17847. protected _viewMatrix: Matrix;
  17848. protected _projectionMatrix: Matrix;
  17849. protected _transformMatrix: Matrix;
  17850. protected _cachedPosition: Vector3;
  17851. protected _cachedDirection: Vector3;
  17852. protected _cachedDefines: string;
  17853. protected _currentRenderID: number;
  17854. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17855. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17856. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17857. protected _blurPostProcesses: PostProcess[];
  17858. protected _mapSize: number;
  17859. protected _currentFaceIndex: number;
  17860. protected _currentFaceIndexCache: number;
  17861. protected _textureType: number;
  17862. protected _defaultTextureMatrix: Matrix;
  17863. protected _storedUniqueId: Nullable<number>;
  17864. /** @hidden */
  17865. static _SceneComponentInitialization: (scene: Scene) => void;
  17866. /**
  17867. * Creates a ShadowGenerator object.
  17868. * A ShadowGenerator is the required tool to use the shadows.
  17869. * Each light casting shadows needs to use its own ShadowGenerator.
  17870. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17871. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17872. * @param light The light object generating the shadows.
  17873. * @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.
  17874. */
  17875. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17876. protected _initializeGenerator(): void;
  17877. protected _createTargetRenderTexture(): void;
  17878. protected _initializeShadowMap(): void;
  17879. protected _initializeBlurRTTAndPostProcesses(): void;
  17880. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17881. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17882. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17883. protected _applyFilterValues(): void;
  17884. /**
  17885. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17886. * @param onCompiled Callback triggered at the and of the effects compilation
  17887. * @param options Sets of optional options forcing the compilation with different modes
  17888. */
  17889. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17890. useInstances: boolean;
  17891. }>): void;
  17892. /**
  17893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17894. * @param options Sets of optional options forcing the compilation with different modes
  17895. * @returns A promise that resolves when the compilation completes
  17896. */
  17897. forceCompilationAsync(options?: Partial<{
  17898. useInstances: boolean;
  17899. }>): Promise<void>;
  17900. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17901. private _prepareShadowDefines;
  17902. /**
  17903. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17904. * @param subMesh The submesh we want to render in the shadow map
  17905. * @param useInstances Defines wether will draw in the map using instances
  17906. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17907. * @returns true if ready otherwise, false
  17908. */
  17909. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17910. /**
  17911. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17912. * @param defines Defines of the material we want to update
  17913. * @param lightIndex Index of the light in the enabled light list of the material
  17914. */
  17915. prepareDefines(defines: any, lightIndex: number): void;
  17916. /**
  17917. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17918. * defined in the generator but impacting the effect).
  17919. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17920. * @param effect The effect we are binfing the information for
  17921. */
  17922. bindShadowLight(lightIndex: string, effect: Effect): void;
  17923. /**
  17924. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17925. * (eq to shadow prjection matrix * light transform matrix)
  17926. * @returns The transform matrix used to create the shadow map
  17927. */
  17928. getTransformMatrix(): Matrix;
  17929. /**
  17930. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17931. * Cube and 2D textures for instance.
  17932. */
  17933. recreateShadowMap(): void;
  17934. protected _disposeBlurPostProcesses(): void;
  17935. protected _disposeRTTandPostProcesses(): void;
  17936. /**
  17937. * Disposes the ShadowGenerator.
  17938. * Returns nothing.
  17939. */
  17940. dispose(): void;
  17941. /**
  17942. * Serializes the shadow generator setup to a json object.
  17943. * @returns The serialized JSON object
  17944. */
  17945. serialize(): any;
  17946. /**
  17947. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17948. * @param parsedShadowGenerator The JSON object to parse
  17949. * @param scene The scene to create the shadow map for
  17950. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17951. * @returns The parsed shadow generator
  17952. */
  17953. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17954. }
  17955. }
  17956. declare module BABYLON {
  17957. /**
  17958. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17959. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17960. * 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.
  17961. */
  17962. export abstract class Light extends Node {
  17963. /**
  17964. * Falloff Default: light is falling off following the material specification:
  17965. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17966. */
  17967. static readonly FALLOFF_DEFAULT: number;
  17968. /**
  17969. * Falloff Physical: light is falling off following the inverse squared distance law.
  17970. */
  17971. static readonly FALLOFF_PHYSICAL: number;
  17972. /**
  17973. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17974. * to enhance interoperability with other engines.
  17975. */
  17976. static readonly FALLOFF_GLTF: number;
  17977. /**
  17978. * Falloff Standard: light is falling off like in the standard material
  17979. * to enhance interoperability with other materials.
  17980. */
  17981. static readonly FALLOFF_STANDARD: number;
  17982. /**
  17983. * If every light affecting the material is in this lightmapMode,
  17984. * material.lightmapTexture adds or multiplies
  17985. * (depends on material.useLightmapAsShadowmap)
  17986. * after every other light calculations.
  17987. */
  17988. static readonly LIGHTMAP_DEFAULT: number;
  17989. /**
  17990. * material.lightmapTexture as only diffuse lighting from this light
  17991. * adds only specular lighting from this light
  17992. * adds dynamic shadows
  17993. */
  17994. static readonly LIGHTMAP_SPECULAR: number;
  17995. /**
  17996. * material.lightmapTexture as only lighting
  17997. * no light calculation from this light
  17998. * only adds dynamic shadows from this light
  17999. */
  18000. static readonly LIGHTMAP_SHADOWSONLY: number;
  18001. /**
  18002. * Each light type uses the default quantity according to its type:
  18003. * point/spot lights use luminous intensity
  18004. * directional lights use illuminance
  18005. */
  18006. static readonly INTENSITYMODE_AUTOMATIC: number;
  18007. /**
  18008. * lumen (lm)
  18009. */
  18010. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18011. /**
  18012. * candela (lm/sr)
  18013. */
  18014. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18015. /**
  18016. * lux (lm/m^2)
  18017. */
  18018. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18019. /**
  18020. * nit (cd/m^2)
  18021. */
  18022. static readonly INTENSITYMODE_LUMINANCE: number;
  18023. /**
  18024. * Light type const id of the point light.
  18025. */
  18026. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18027. /**
  18028. * Light type const id of the directional light.
  18029. */
  18030. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18031. /**
  18032. * Light type const id of the spot light.
  18033. */
  18034. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18035. /**
  18036. * Light type const id of the hemispheric light.
  18037. */
  18038. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18039. /**
  18040. * Diffuse gives the basic color to an object.
  18041. */
  18042. diffuse: Color3;
  18043. /**
  18044. * Specular produces a highlight color on an object.
  18045. * Note: This is note affecting PBR materials.
  18046. */
  18047. specular: Color3;
  18048. /**
  18049. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18050. * falling off base on range or angle.
  18051. * This can be set to any values in Light.FALLOFF_x.
  18052. *
  18053. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18054. * other types of materials.
  18055. */
  18056. falloffType: number;
  18057. /**
  18058. * Strength of the light.
  18059. * Note: By default it is define in the framework own unit.
  18060. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18061. */
  18062. intensity: number;
  18063. private _range;
  18064. protected _inverseSquaredRange: number;
  18065. /**
  18066. * Defines how far from the source the light is impacting in scene units.
  18067. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18068. */
  18069. get range(): number;
  18070. /**
  18071. * Defines how far from the source the light is impacting in scene units.
  18072. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18073. */
  18074. set range(value: number);
  18075. /**
  18076. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18077. * of light.
  18078. */
  18079. private _photometricScale;
  18080. private _intensityMode;
  18081. /**
  18082. * Gets the photometric scale used to interpret the intensity.
  18083. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18084. */
  18085. get intensityMode(): number;
  18086. /**
  18087. * Sets the photometric scale used to interpret the intensity.
  18088. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18089. */
  18090. set intensityMode(value: number);
  18091. private _radius;
  18092. /**
  18093. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18094. */
  18095. get radius(): number;
  18096. /**
  18097. * sets the light radius used by PBR Materials to simulate soft area lights.
  18098. */
  18099. set radius(value: number);
  18100. private _renderPriority;
  18101. /**
  18102. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18103. * exceeding the number allowed of the materials.
  18104. */
  18105. renderPriority: number;
  18106. private _shadowEnabled;
  18107. /**
  18108. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18109. * the current shadow generator.
  18110. */
  18111. get shadowEnabled(): boolean;
  18112. /**
  18113. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18114. * the current shadow generator.
  18115. */
  18116. set shadowEnabled(value: boolean);
  18117. private _includedOnlyMeshes;
  18118. /**
  18119. * Gets the only meshes impacted by this light.
  18120. */
  18121. get includedOnlyMeshes(): AbstractMesh[];
  18122. /**
  18123. * Sets the only meshes impacted by this light.
  18124. */
  18125. set includedOnlyMeshes(value: AbstractMesh[]);
  18126. private _excludedMeshes;
  18127. /**
  18128. * Gets the meshes not impacted by this light.
  18129. */
  18130. get excludedMeshes(): AbstractMesh[];
  18131. /**
  18132. * Sets the meshes not impacted by this light.
  18133. */
  18134. set excludedMeshes(value: AbstractMesh[]);
  18135. private _excludeWithLayerMask;
  18136. /**
  18137. * Gets the layer id use to find what meshes are not impacted by the light.
  18138. * Inactive if 0
  18139. */
  18140. get excludeWithLayerMask(): number;
  18141. /**
  18142. * Sets the layer id use to find what meshes are not impacted by the light.
  18143. * Inactive if 0
  18144. */
  18145. set excludeWithLayerMask(value: number);
  18146. private _includeOnlyWithLayerMask;
  18147. /**
  18148. * Gets the layer id use to find what meshes are impacted by the light.
  18149. * Inactive if 0
  18150. */
  18151. get includeOnlyWithLayerMask(): number;
  18152. /**
  18153. * Sets the layer id use to find what meshes are impacted by the light.
  18154. * Inactive if 0
  18155. */
  18156. set includeOnlyWithLayerMask(value: number);
  18157. private _lightmapMode;
  18158. /**
  18159. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18160. */
  18161. get lightmapMode(): number;
  18162. /**
  18163. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18164. */
  18165. set lightmapMode(value: number);
  18166. /**
  18167. * Shadow generator associted to the light.
  18168. * @hidden Internal use only.
  18169. */
  18170. _shadowGenerator: Nullable<IShadowGenerator>;
  18171. /**
  18172. * @hidden Internal use only.
  18173. */
  18174. _excludedMeshesIds: string[];
  18175. /**
  18176. * @hidden Internal use only.
  18177. */
  18178. _includedOnlyMeshesIds: string[];
  18179. /**
  18180. * The current light unifom buffer.
  18181. * @hidden Internal use only.
  18182. */
  18183. _uniformBuffer: UniformBuffer;
  18184. /** @hidden */
  18185. _renderId: number;
  18186. /**
  18187. * Creates a Light object in the scene.
  18188. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18189. * @param name The firendly name of the light
  18190. * @param scene The scene the light belongs too
  18191. */
  18192. constructor(name: string, scene: Scene);
  18193. protected abstract _buildUniformLayout(): void;
  18194. /**
  18195. * Sets the passed Effect "effect" with the Light information.
  18196. * @param effect The effect to update
  18197. * @param lightIndex The index of the light in the effect to update
  18198. * @returns The light
  18199. */
  18200. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18201. /**
  18202. * Sets the passed Effect "effect" with the Light textures.
  18203. * @param effect The effect to update
  18204. * @param lightIndex The index of the light in the effect to update
  18205. * @returns The light
  18206. */
  18207. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18208. /**
  18209. * Binds the lights information from the scene to the effect for the given mesh.
  18210. * @param lightIndex Light index
  18211. * @param scene The scene where the light belongs to
  18212. * @param effect The effect we are binding the data to
  18213. * @param useSpecular Defines if specular is supported
  18214. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18215. */
  18216. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18217. /**
  18218. * Sets the passed Effect "effect" with the Light information.
  18219. * @param effect The effect to update
  18220. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18221. * @returns The light
  18222. */
  18223. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18224. /**
  18225. * Returns the string "Light".
  18226. * @returns the class name
  18227. */
  18228. getClassName(): string;
  18229. /** @hidden */
  18230. readonly _isLight: boolean;
  18231. /**
  18232. * Converts the light information to a readable string for debug purpose.
  18233. * @param fullDetails Supports for multiple levels of logging within scene loading
  18234. * @returns the human readable light info
  18235. */
  18236. toString(fullDetails?: boolean): string;
  18237. /** @hidden */
  18238. protected _syncParentEnabledState(): void;
  18239. /**
  18240. * Set the enabled state of this node.
  18241. * @param value - the new enabled state
  18242. */
  18243. setEnabled(value: boolean): void;
  18244. /**
  18245. * Returns the Light associated shadow generator if any.
  18246. * @return the associated shadow generator.
  18247. */
  18248. getShadowGenerator(): Nullable<IShadowGenerator>;
  18249. /**
  18250. * Returns a Vector3, the absolute light position in the World.
  18251. * @returns the world space position of the light
  18252. */
  18253. getAbsolutePosition(): Vector3;
  18254. /**
  18255. * Specifies if the light will affect the passed mesh.
  18256. * @param mesh The mesh to test against the light
  18257. * @return true the mesh is affected otherwise, false.
  18258. */
  18259. canAffectMesh(mesh: AbstractMesh): boolean;
  18260. /**
  18261. * Sort function to order lights for rendering.
  18262. * @param a First Light object to compare to second.
  18263. * @param b Second Light object to compare first.
  18264. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18265. */
  18266. static CompareLightsPriority(a: Light, b: Light): number;
  18267. /**
  18268. * Releases resources associated with this node.
  18269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18271. */
  18272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18273. /**
  18274. * Returns the light type ID (integer).
  18275. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18276. */
  18277. getTypeID(): number;
  18278. /**
  18279. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18280. * @returns the scaled intensity in intensity mode unit
  18281. */
  18282. getScaledIntensity(): number;
  18283. /**
  18284. * Returns a new Light object, named "name", from the current one.
  18285. * @param name The name of the cloned light
  18286. * @param newParent The parent of this light, if it has one
  18287. * @returns the new created light
  18288. */
  18289. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18290. /**
  18291. * Serializes the current light into a Serialization object.
  18292. * @returns the serialized object.
  18293. */
  18294. serialize(): any;
  18295. /**
  18296. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18297. * This new light is named "name" and added to the passed scene.
  18298. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18299. * @param name The friendly name of the light
  18300. * @param scene The scene the new light will belong to
  18301. * @returns the constructor function
  18302. */
  18303. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18304. /**
  18305. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18306. * @param parsedLight The JSON representation of the light
  18307. * @param scene The scene to create the parsed light in
  18308. * @returns the created light after parsing
  18309. */
  18310. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18311. private _hookArrayForExcluded;
  18312. private _hookArrayForIncludedOnly;
  18313. private _resyncMeshes;
  18314. /**
  18315. * Forces the meshes to update their light related information in their rendering used effects
  18316. * @hidden Internal Use Only
  18317. */
  18318. _markMeshesAsLightDirty(): void;
  18319. /**
  18320. * Recomputes the cached photometric scale if needed.
  18321. */
  18322. private _computePhotometricScale;
  18323. /**
  18324. * Returns the Photometric Scale according to the light type and intensity mode.
  18325. */
  18326. private _getPhotometricScale;
  18327. /**
  18328. * Reorder the light in the scene according to their defined priority.
  18329. * @hidden Internal Use Only
  18330. */
  18331. _reorderLightsInScene(): void;
  18332. /**
  18333. * Prepares the list of defines specific to the light type.
  18334. * @param defines the list of defines
  18335. * @param lightIndex defines the index of the light for the effect
  18336. */
  18337. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18338. }
  18339. }
  18340. declare module BABYLON {
  18341. /**
  18342. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18343. * This is the base of the follow, arc rotate cameras and Free camera
  18344. * @see https://doc.babylonjs.com/features/cameras
  18345. */
  18346. export class TargetCamera extends Camera {
  18347. private static _RigCamTransformMatrix;
  18348. private static _TargetTransformMatrix;
  18349. private static _TargetFocalPoint;
  18350. private _tmpUpVector;
  18351. private _tmpTargetVector;
  18352. /**
  18353. * Define the current direction the camera is moving to
  18354. */
  18355. cameraDirection: Vector3;
  18356. /**
  18357. * Define the current rotation the camera is rotating to
  18358. */
  18359. cameraRotation: Vector2;
  18360. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18361. ignoreParentScaling: boolean;
  18362. /**
  18363. * When set, the up vector of the camera will be updated by the rotation of the camera
  18364. */
  18365. updateUpVectorFromRotation: boolean;
  18366. private _tmpQuaternion;
  18367. /**
  18368. * Define the current rotation of the camera
  18369. */
  18370. rotation: Vector3;
  18371. /**
  18372. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18373. */
  18374. rotationQuaternion: Quaternion;
  18375. /**
  18376. * Define the current speed of the camera
  18377. */
  18378. speed: number;
  18379. /**
  18380. * Add constraint to the camera to prevent it to move freely in all directions and
  18381. * around all axis.
  18382. */
  18383. noRotationConstraint: boolean;
  18384. /**
  18385. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18386. * panning
  18387. */
  18388. invertRotation: boolean;
  18389. /**
  18390. * Speed multiplier for inverse camera panning
  18391. */
  18392. inverseRotationSpeed: number;
  18393. /**
  18394. * Define the current target of the camera as an object or a position.
  18395. */
  18396. lockedTarget: any;
  18397. /** @hidden */
  18398. _currentTarget: Vector3;
  18399. /** @hidden */
  18400. _initialFocalDistance: number;
  18401. /** @hidden */
  18402. _viewMatrix: Matrix;
  18403. /** @hidden */
  18404. _camMatrix: Matrix;
  18405. /** @hidden */
  18406. _cameraTransformMatrix: Matrix;
  18407. /** @hidden */
  18408. _cameraRotationMatrix: Matrix;
  18409. /** @hidden */
  18410. _referencePoint: Vector3;
  18411. /** @hidden */
  18412. _transformedReferencePoint: Vector3;
  18413. /** @hidden */
  18414. _reset: () => void;
  18415. private _defaultUp;
  18416. /**
  18417. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18418. * This is the base of the follow, arc rotate cameras and Free camera
  18419. * @see https://doc.babylonjs.com/features/cameras
  18420. * @param name Defines the name of the camera in the scene
  18421. * @param position Defines the start position of the camera in the scene
  18422. * @param scene Defines the scene the camera belongs to
  18423. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18424. */
  18425. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18426. /**
  18427. * Gets the position in front of the camera at a given distance.
  18428. * @param distance The distance from the camera we want the position to be
  18429. * @returns the position
  18430. */
  18431. getFrontPosition(distance: number): Vector3;
  18432. /** @hidden */
  18433. _getLockedTargetPosition(): Nullable<Vector3>;
  18434. private _storedPosition;
  18435. private _storedRotation;
  18436. private _storedRotationQuaternion;
  18437. /**
  18438. * Store current camera state of the camera (fov, position, rotation, etc..)
  18439. * @returns the camera
  18440. */
  18441. storeState(): Camera;
  18442. /**
  18443. * Restored camera state. You must call storeState() first
  18444. * @returns whether it was successful or not
  18445. * @hidden
  18446. */
  18447. _restoreStateValues(): boolean;
  18448. /** @hidden */
  18449. _initCache(): void;
  18450. /** @hidden */
  18451. _updateCache(ignoreParentClass?: boolean): void;
  18452. /** @hidden */
  18453. _isSynchronizedViewMatrix(): boolean;
  18454. /** @hidden */
  18455. _computeLocalCameraSpeed(): number;
  18456. /**
  18457. * Defines the target the camera should look at.
  18458. * @param target Defines the new target as a Vector or a mesh
  18459. */
  18460. setTarget(target: Vector3): void;
  18461. /**
  18462. * Defines the target point of the camera.
  18463. * The camera looks towards it form the radius distance.
  18464. */
  18465. get target(): Vector3;
  18466. set target(value: Vector3);
  18467. /**
  18468. * Return the current target position of the camera. This value is expressed in local space.
  18469. * @returns the target position
  18470. */
  18471. getTarget(): Vector3;
  18472. /** @hidden */
  18473. _decideIfNeedsToMove(): boolean;
  18474. /** @hidden */
  18475. _updatePosition(): void;
  18476. /** @hidden */
  18477. _checkInputs(): void;
  18478. protected _updateCameraRotationMatrix(): void;
  18479. /**
  18480. * 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)
  18481. * @returns the current camera
  18482. */
  18483. private _rotateUpVectorWithCameraRotationMatrix;
  18484. private _cachedRotationZ;
  18485. private _cachedQuaternionRotationZ;
  18486. /** @hidden */
  18487. _getViewMatrix(): Matrix;
  18488. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18489. /**
  18490. * @hidden
  18491. */
  18492. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18493. /**
  18494. * @hidden
  18495. */
  18496. _updateRigCameras(): void;
  18497. private _getRigCamPositionAndTarget;
  18498. /**
  18499. * Gets the current object class name.
  18500. * @return the class name
  18501. */
  18502. getClassName(): string;
  18503. }
  18504. }
  18505. declare module BABYLON {
  18506. /**
  18507. * Gather the list of keyboard event types as constants.
  18508. */
  18509. export class KeyboardEventTypes {
  18510. /**
  18511. * The keydown event is fired when a key becomes active (pressed).
  18512. */
  18513. static readonly KEYDOWN: number;
  18514. /**
  18515. * The keyup event is fired when a key has been released.
  18516. */
  18517. static readonly KEYUP: number;
  18518. }
  18519. /**
  18520. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18521. */
  18522. export class KeyboardInfo {
  18523. /**
  18524. * Defines the type of event (KeyboardEventTypes)
  18525. */
  18526. type: number;
  18527. /**
  18528. * Defines the related dom event
  18529. */
  18530. event: KeyboardEvent;
  18531. /**
  18532. * Instantiates a new keyboard info.
  18533. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18534. * @param type Defines the type of event (KeyboardEventTypes)
  18535. * @param event Defines the related dom event
  18536. */
  18537. constructor(
  18538. /**
  18539. * Defines the type of event (KeyboardEventTypes)
  18540. */
  18541. type: number,
  18542. /**
  18543. * Defines the related dom event
  18544. */
  18545. event: KeyboardEvent);
  18546. }
  18547. /**
  18548. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18549. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18550. */
  18551. export class KeyboardInfoPre extends KeyboardInfo {
  18552. /**
  18553. * Defines the type of event (KeyboardEventTypes)
  18554. */
  18555. type: number;
  18556. /**
  18557. * Defines the related dom event
  18558. */
  18559. event: KeyboardEvent;
  18560. /**
  18561. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18562. */
  18563. skipOnPointerObservable: boolean;
  18564. /**
  18565. * Instantiates a new keyboard pre info.
  18566. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18567. * @param type Defines the type of event (KeyboardEventTypes)
  18568. * @param event Defines the related dom event
  18569. */
  18570. constructor(
  18571. /**
  18572. * Defines the type of event (KeyboardEventTypes)
  18573. */
  18574. type: number,
  18575. /**
  18576. * Defines the related dom event
  18577. */
  18578. event: KeyboardEvent);
  18579. }
  18580. }
  18581. declare module BABYLON {
  18582. /**
  18583. * Manage the keyboard inputs to control the movement of a free camera.
  18584. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18585. */
  18586. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18587. /**
  18588. * Defines the camera the input is attached to.
  18589. */
  18590. camera: FreeCamera;
  18591. /**
  18592. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18593. */
  18594. keysUp: number[];
  18595. /**
  18596. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18597. */
  18598. keysUpward: number[];
  18599. /**
  18600. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18601. */
  18602. keysDown: number[];
  18603. /**
  18604. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18605. */
  18606. keysDownward: number[];
  18607. /**
  18608. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18609. */
  18610. keysLeft: number[];
  18611. /**
  18612. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18613. */
  18614. keysRight: number[];
  18615. private _keys;
  18616. private _onCanvasBlurObserver;
  18617. private _onKeyboardObserver;
  18618. private _engine;
  18619. private _scene;
  18620. /**
  18621. * Attach the input controls to a specific dom element to get the input from.
  18622. * @param element Defines the element the controls should be listened from
  18623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18624. */
  18625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18626. /**
  18627. * Detach the current controls from the specified dom element.
  18628. * @param element Defines the element to stop listening the inputs from
  18629. */
  18630. detachControl(element: Nullable<HTMLElement>): void;
  18631. /**
  18632. * Update the current camera state depending on the inputs that have been used this frame.
  18633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18634. */
  18635. checkInputs(): void;
  18636. /**
  18637. * Gets the class name of the current intput.
  18638. * @returns the class name
  18639. */
  18640. getClassName(): string;
  18641. /** @hidden */
  18642. _onLostFocus(): void;
  18643. /**
  18644. * Get the friendly name associated with the input class.
  18645. * @returns the input friendly name
  18646. */
  18647. getSimpleName(): string;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /**
  18652. * Gather the list of pointer event types as constants.
  18653. */
  18654. export class PointerEventTypes {
  18655. /**
  18656. * 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.
  18657. */
  18658. static readonly POINTERDOWN: number;
  18659. /**
  18660. * The pointerup event is fired when a pointer is no longer active.
  18661. */
  18662. static readonly POINTERUP: number;
  18663. /**
  18664. * The pointermove event is fired when a pointer changes coordinates.
  18665. */
  18666. static readonly POINTERMOVE: number;
  18667. /**
  18668. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18669. */
  18670. static readonly POINTERWHEEL: number;
  18671. /**
  18672. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18673. */
  18674. static readonly POINTERPICK: number;
  18675. /**
  18676. * The pointertap event is fired when a the object has been touched and released without drag.
  18677. */
  18678. static readonly POINTERTAP: number;
  18679. /**
  18680. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18681. */
  18682. static readonly POINTERDOUBLETAP: number;
  18683. }
  18684. /**
  18685. * Base class of pointer info types.
  18686. */
  18687. export class PointerInfoBase {
  18688. /**
  18689. * Defines the type of event (PointerEventTypes)
  18690. */
  18691. type: number;
  18692. /**
  18693. * Defines the related dom event
  18694. */
  18695. event: PointerEvent | MouseWheelEvent;
  18696. /**
  18697. * Instantiates the base class of pointers info.
  18698. * @param type Defines the type of event (PointerEventTypes)
  18699. * @param event Defines the related dom event
  18700. */
  18701. constructor(
  18702. /**
  18703. * Defines the type of event (PointerEventTypes)
  18704. */
  18705. type: number,
  18706. /**
  18707. * Defines the related dom event
  18708. */
  18709. event: PointerEvent | MouseWheelEvent);
  18710. }
  18711. /**
  18712. * This class is used to store pointer related info for the onPrePointerObservable event.
  18713. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18714. */
  18715. export class PointerInfoPre extends PointerInfoBase {
  18716. /**
  18717. * Ray from a pointer if availible (eg. 6dof controller)
  18718. */
  18719. ray: Nullable<Ray>;
  18720. /**
  18721. * Defines the local position of the pointer on the canvas.
  18722. */
  18723. localPosition: Vector2;
  18724. /**
  18725. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18726. */
  18727. skipOnPointerObservable: boolean;
  18728. /**
  18729. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18730. * @param type Defines the type of event (PointerEventTypes)
  18731. * @param event Defines the related dom event
  18732. * @param localX Defines the local x coordinates of the pointer when the event occured
  18733. * @param localY Defines the local y coordinates of the pointer when the event occured
  18734. */
  18735. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18736. }
  18737. /**
  18738. * This type contains all the data related to a pointer event in Babylon.js.
  18739. * 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.
  18740. */
  18741. export class PointerInfo extends PointerInfoBase {
  18742. /**
  18743. * Defines the picking info associated to the info (if any)\
  18744. */
  18745. pickInfo: Nullable<PickingInfo>;
  18746. /**
  18747. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18748. * @param type Defines the type of event (PointerEventTypes)
  18749. * @param event Defines the related dom event
  18750. * @param pickInfo Defines the picking info associated to the info (if any)\
  18751. */
  18752. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18753. /**
  18754. * Defines the picking info associated to the info (if any)\
  18755. */
  18756. pickInfo: Nullable<PickingInfo>);
  18757. }
  18758. /**
  18759. * Data relating to a touch event on the screen.
  18760. */
  18761. export interface PointerTouch {
  18762. /**
  18763. * X coordinate of touch.
  18764. */
  18765. x: number;
  18766. /**
  18767. * Y coordinate of touch.
  18768. */
  18769. y: number;
  18770. /**
  18771. * Id of touch. Unique for each finger.
  18772. */
  18773. pointerId: number;
  18774. /**
  18775. * Event type passed from DOM.
  18776. */
  18777. type: any;
  18778. }
  18779. }
  18780. declare module BABYLON {
  18781. /**
  18782. * Manage the mouse inputs to control the movement of a free camera.
  18783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18784. */
  18785. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18786. /**
  18787. * Define if touch is enabled in the mouse input
  18788. */
  18789. touchEnabled: boolean;
  18790. /**
  18791. * Defines the camera the input is attached to.
  18792. */
  18793. camera: FreeCamera;
  18794. /**
  18795. * Defines the buttons associated with the input to handle camera move.
  18796. */
  18797. buttons: number[];
  18798. /**
  18799. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18800. */
  18801. angularSensibility: number;
  18802. private _pointerInput;
  18803. private _onMouseMove;
  18804. private _observer;
  18805. private previousPosition;
  18806. /**
  18807. * Observable for when a pointer move event occurs containing the move offset
  18808. */
  18809. onPointerMovedObservable: Observable<{
  18810. offsetX: number;
  18811. offsetY: number;
  18812. }>;
  18813. /**
  18814. * @hidden
  18815. * If the camera should be rotated automatically based on pointer movement
  18816. */
  18817. _allowCameraRotation: boolean;
  18818. /**
  18819. * Manage the mouse inputs to control the movement of a free camera.
  18820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18821. * @param touchEnabled Defines if touch is enabled or not
  18822. */
  18823. constructor(
  18824. /**
  18825. * Define if touch is enabled in the mouse input
  18826. */
  18827. touchEnabled?: boolean);
  18828. /**
  18829. * Attach the input controls to a specific dom element to get the input from.
  18830. * @param element Defines the element the controls should be listened from
  18831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18832. */
  18833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18834. /**
  18835. * Called on JS contextmenu event.
  18836. * Override this method to provide functionality.
  18837. */
  18838. protected onContextMenu(evt: PointerEvent): void;
  18839. /**
  18840. * Detach the current controls from the specified dom element.
  18841. * @param element Defines the element to stop listening the inputs from
  18842. */
  18843. detachControl(element: Nullable<HTMLElement>): void;
  18844. /**
  18845. * Gets the class name of the current intput.
  18846. * @returns the class name
  18847. */
  18848. getClassName(): string;
  18849. /**
  18850. * Get the friendly name associated with the input class.
  18851. * @returns the input friendly name
  18852. */
  18853. getSimpleName(): string;
  18854. }
  18855. }
  18856. declare module BABYLON {
  18857. /**
  18858. * Manage the touch inputs to control the movement of a free camera.
  18859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18860. */
  18861. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18862. /**
  18863. * Define if mouse events can be treated as touch events
  18864. */
  18865. allowMouse: boolean;
  18866. /**
  18867. * Defines the camera the input is attached to.
  18868. */
  18869. camera: FreeCamera;
  18870. /**
  18871. * Defines the touch sensibility for rotation.
  18872. * The higher the faster.
  18873. */
  18874. touchAngularSensibility: number;
  18875. /**
  18876. * Defines the touch sensibility for move.
  18877. * The higher the faster.
  18878. */
  18879. touchMoveSensibility: number;
  18880. private _offsetX;
  18881. private _offsetY;
  18882. private _pointerPressed;
  18883. private _pointerInput;
  18884. private _observer;
  18885. private _onLostFocus;
  18886. /**
  18887. * Manage the touch inputs to control the movement of a free camera.
  18888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18889. * @param allowMouse Defines if mouse events can be treated as touch events
  18890. */
  18891. constructor(
  18892. /**
  18893. * Define if mouse events can be treated as touch events
  18894. */
  18895. allowMouse?: boolean);
  18896. /**
  18897. * Attach the input controls to a specific dom element to get the input from.
  18898. * @param element Defines the element the controls should be listened from
  18899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18900. */
  18901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18902. /**
  18903. * Detach the current controls from the specified dom element.
  18904. * @param element Defines the element to stop listening the inputs from
  18905. */
  18906. detachControl(element: Nullable<HTMLElement>): void;
  18907. /**
  18908. * Update the current camera state depending on the inputs that have been used this frame.
  18909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18910. */
  18911. checkInputs(): void;
  18912. /**
  18913. * Gets the class name of the current intput.
  18914. * @returns the class name
  18915. */
  18916. getClassName(): string;
  18917. /**
  18918. * Get the friendly name associated with the input class.
  18919. * @returns the input friendly name
  18920. */
  18921. getSimpleName(): string;
  18922. }
  18923. }
  18924. declare module BABYLON {
  18925. /**
  18926. * Default Inputs manager for the FreeCamera.
  18927. * It groups all the default supported inputs for ease of use.
  18928. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18929. */
  18930. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18931. /**
  18932. * @hidden
  18933. */
  18934. _mouseInput: Nullable<FreeCameraMouseInput>;
  18935. /**
  18936. * Instantiates a new FreeCameraInputsManager.
  18937. * @param camera Defines the camera the inputs belong to
  18938. */
  18939. constructor(camera: FreeCamera);
  18940. /**
  18941. * Add keyboard input support to the input manager.
  18942. * @returns the current input manager
  18943. */
  18944. addKeyboard(): FreeCameraInputsManager;
  18945. /**
  18946. * Add mouse input support to the input manager.
  18947. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18948. * @returns the current input manager
  18949. */
  18950. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18951. /**
  18952. * Removes the mouse input support from the manager
  18953. * @returns the current input manager
  18954. */
  18955. removeMouse(): FreeCameraInputsManager;
  18956. /**
  18957. * Add touch input support to the input manager.
  18958. * @returns the current input manager
  18959. */
  18960. addTouch(): FreeCameraInputsManager;
  18961. /**
  18962. * Remove all attached input methods from a camera
  18963. */
  18964. clear(): void;
  18965. }
  18966. }
  18967. declare module BABYLON {
  18968. /**
  18969. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18970. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18971. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18972. */
  18973. export class FreeCamera extends TargetCamera {
  18974. /**
  18975. * Define the collision ellipsoid of the camera.
  18976. * This is helpful to simulate a camera body like the player body around the camera
  18977. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18978. */
  18979. ellipsoid: Vector3;
  18980. /**
  18981. * Define an offset for the position of the ellipsoid around the camera.
  18982. * This can be helpful to determine the center of the body near the gravity center of the body
  18983. * instead of its head.
  18984. */
  18985. ellipsoidOffset: Vector3;
  18986. /**
  18987. * Enable or disable collisions of the camera with the rest of the scene objects.
  18988. */
  18989. checkCollisions: boolean;
  18990. /**
  18991. * Enable or disable gravity on the camera.
  18992. */
  18993. applyGravity: boolean;
  18994. /**
  18995. * Define the input manager associated to the camera.
  18996. */
  18997. inputs: FreeCameraInputsManager;
  18998. /**
  18999. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19000. * Higher values reduce sensitivity.
  19001. */
  19002. get angularSensibility(): number;
  19003. /**
  19004. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19005. * Higher values reduce sensitivity.
  19006. */
  19007. set angularSensibility(value: number);
  19008. /**
  19009. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19010. */
  19011. get keysUp(): number[];
  19012. set keysUp(value: number[]);
  19013. /**
  19014. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19015. */
  19016. get keysUpward(): number[];
  19017. set keysUpward(value: number[]);
  19018. /**
  19019. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19020. */
  19021. get keysDown(): number[];
  19022. set keysDown(value: number[]);
  19023. /**
  19024. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19025. */
  19026. get keysDownward(): number[];
  19027. set keysDownward(value: number[]);
  19028. /**
  19029. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19030. */
  19031. get keysLeft(): number[];
  19032. set keysLeft(value: number[]);
  19033. /**
  19034. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19035. */
  19036. get keysRight(): number[];
  19037. set keysRight(value: number[]);
  19038. /**
  19039. * Event raised when the camera collide with a mesh in the scene.
  19040. */
  19041. onCollide: (collidedMesh: AbstractMesh) => void;
  19042. private _collider;
  19043. private _needMoveForGravity;
  19044. private _oldPosition;
  19045. private _diffPosition;
  19046. private _newPosition;
  19047. /** @hidden */
  19048. _localDirection: Vector3;
  19049. /** @hidden */
  19050. _transformedDirection: Vector3;
  19051. /**
  19052. * Instantiates a Free Camera.
  19053. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19054. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19055. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19056. * @param name Define the name of the camera in the scene
  19057. * @param position Define the start position of the camera in the scene
  19058. * @param scene Define the scene the camera belongs to
  19059. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19060. */
  19061. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19062. /**
  19063. * Attached controls to the current camera.
  19064. * @param element Defines the element the controls should be listened from
  19065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19066. */
  19067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19068. /**
  19069. * Detach the current controls from the camera.
  19070. * The camera will stop reacting to inputs.
  19071. * @param element Defines the element to stop listening the inputs from
  19072. */
  19073. detachControl(element: HTMLElement): void;
  19074. private _collisionMask;
  19075. /**
  19076. * Define a collision mask to limit the list of object the camera can collide with
  19077. */
  19078. get collisionMask(): number;
  19079. set collisionMask(mask: number);
  19080. /** @hidden */
  19081. _collideWithWorld(displacement: Vector3): void;
  19082. private _onCollisionPositionChange;
  19083. /** @hidden */
  19084. _checkInputs(): void;
  19085. /** @hidden */
  19086. _decideIfNeedsToMove(): boolean;
  19087. /** @hidden */
  19088. _updatePosition(): void;
  19089. /**
  19090. * Destroy the camera and release the current resources hold by it.
  19091. */
  19092. dispose(): void;
  19093. /**
  19094. * Gets the current object class name.
  19095. * @return the class name
  19096. */
  19097. getClassName(): string;
  19098. }
  19099. }
  19100. declare module BABYLON {
  19101. /**
  19102. * Represents a gamepad control stick position
  19103. */
  19104. export class StickValues {
  19105. /**
  19106. * The x component of the control stick
  19107. */
  19108. x: number;
  19109. /**
  19110. * The y component of the control stick
  19111. */
  19112. y: number;
  19113. /**
  19114. * Initializes the gamepad x and y control stick values
  19115. * @param x The x component of the gamepad control stick value
  19116. * @param y The y component of the gamepad control stick value
  19117. */
  19118. constructor(
  19119. /**
  19120. * The x component of the control stick
  19121. */
  19122. x: number,
  19123. /**
  19124. * The y component of the control stick
  19125. */
  19126. y: number);
  19127. }
  19128. /**
  19129. * An interface which manages callbacks for gamepad button changes
  19130. */
  19131. export interface GamepadButtonChanges {
  19132. /**
  19133. * Called when a gamepad has been changed
  19134. */
  19135. changed: boolean;
  19136. /**
  19137. * Called when a gamepad press event has been triggered
  19138. */
  19139. pressChanged: boolean;
  19140. /**
  19141. * Called when a touch event has been triggered
  19142. */
  19143. touchChanged: boolean;
  19144. /**
  19145. * Called when a value has changed
  19146. */
  19147. valueChanged: boolean;
  19148. }
  19149. /**
  19150. * Represents a gamepad
  19151. */
  19152. export class Gamepad {
  19153. /**
  19154. * The id of the gamepad
  19155. */
  19156. id: string;
  19157. /**
  19158. * The index of the gamepad
  19159. */
  19160. index: number;
  19161. /**
  19162. * The browser gamepad
  19163. */
  19164. browserGamepad: any;
  19165. /**
  19166. * Specifies what type of gamepad this represents
  19167. */
  19168. type: number;
  19169. private _leftStick;
  19170. private _rightStick;
  19171. /** @hidden */
  19172. _isConnected: boolean;
  19173. private _leftStickAxisX;
  19174. private _leftStickAxisY;
  19175. private _rightStickAxisX;
  19176. private _rightStickAxisY;
  19177. /**
  19178. * Triggered when the left control stick has been changed
  19179. */
  19180. private _onleftstickchanged;
  19181. /**
  19182. * Triggered when the right control stick has been changed
  19183. */
  19184. private _onrightstickchanged;
  19185. /**
  19186. * Represents a gamepad controller
  19187. */
  19188. static GAMEPAD: number;
  19189. /**
  19190. * Represents a generic controller
  19191. */
  19192. static GENERIC: number;
  19193. /**
  19194. * Represents an XBox controller
  19195. */
  19196. static XBOX: number;
  19197. /**
  19198. * Represents a pose-enabled controller
  19199. */
  19200. static POSE_ENABLED: number;
  19201. /**
  19202. * Represents an Dual Shock controller
  19203. */
  19204. static DUALSHOCK: number;
  19205. /**
  19206. * Specifies whether the left control stick should be Y-inverted
  19207. */
  19208. protected _invertLeftStickY: boolean;
  19209. /**
  19210. * Specifies if the gamepad has been connected
  19211. */
  19212. get isConnected(): boolean;
  19213. /**
  19214. * Initializes the gamepad
  19215. * @param id The id of the gamepad
  19216. * @param index The index of the gamepad
  19217. * @param browserGamepad The browser gamepad
  19218. * @param leftStickX The x component of the left joystick
  19219. * @param leftStickY The y component of the left joystick
  19220. * @param rightStickX The x component of the right joystick
  19221. * @param rightStickY The y component of the right joystick
  19222. */
  19223. constructor(
  19224. /**
  19225. * The id of the gamepad
  19226. */
  19227. id: string,
  19228. /**
  19229. * The index of the gamepad
  19230. */
  19231. index: number,
  19232. /**
  19233. * The browser gamepad
  19234. */
  19235. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19236. /**
  19237. * Callback triggered when the left joystick has changed
  19238. * @param callback
  19239. */
  19240. onleftstickchanged(callback: (values: StickValues) => void): void;
  19241. /**
  19242. * Callback triggered when the right joystick has changed
  19243. * @param callback
  19244. */
  19245. onrightstickchanged(callback: (values: StickValues) => void): void;
  19246. /**
  19247. * Gets the left joystick
  19248. */
  19249. get leftStick(): StickValues;
  19250. /**
  19251. * Sets the left joystick values
  19252. */
  19253. set leftStick(newValues: StickValues);
  19254. /**
  19255. * Gets the right joystick
  19256. */
  19257. get rightStick(): StickValues;
  19258. /**
  19259. * Sets the right joystick value
  19260. */
  19261. set rightStick(newValues: StickValues);
  19262. /**
  19263. * Updates the gamepad joystick positions
  19264. */
  19265. update(): void;
  19266. /**
  19267. * Disposes the gamepad
  19268. */
  19269. dispose(): void;
  19270. }
  19271. /**
  19272. * Represents a generic gamepad
  19273. */
  19274. export class GenericPad extends Gamepad {
  19275. private _buttons;
  19276. private _onbuttondown;
  19277. private _onbuttonup;
  19278. /**
  19279. * Observable triggered when a button has been pressed
  19280. */
  19281. onButtonDownObservable: Observable<number>;
  19282. /**
  19283. * Observable triggered when a button has been released
  19284. */
  19285. onButtonUpObservable: Observable<number>;
  19286. /**
  19287. * Callback triggered when a button has been pressed
  19288. * @param callback Called when a button has been pressed
  19289. */
  19290. onbuttondown(callback: (buttonPressed: number) => void): void;
  19291. /**
  19292. * Callback triggered when a button has been released
  19293. * @param callback Called when a button has been released
  19294. */
  19295. onbuttonup(callback: (buttonReleased: number) => void): void;
  19296. /**
  19297. * Initializes the generic gamepad
  19298. * @param id The id of the generic gamepad
  19299. * @param index The index of the generic gamepad
  19300. * @param browserGamepad The browser gamepad
  19301. */
  19302. constructor(id: string, index: number, browserGamepad: any);
  19303. private _setButtonValue;
  19304. /**
  19305. * Updates the generic gamepad
  19306. */
  19307. update(): void;
  19308. /**
  19309. * Disposes the generic gamepad
  19310. */
  19311. dispose(): void;
  19312. }
  19313. }
  19314. declare module BABYLON {
  19315. /**
  19316. * Defines the types of pose enabled controllers that are supported
  19317. */
  19318. export enum PoseEnabledControllerType {
  19319. /**
  19320. * HTC Vive
  19321. */
  19322. VIVE = 0,
  19323. /**
  19324. * Oculus Rift
  19325. */
  19326. OCULUS = 1,
  19327. /**
  19328. * Windows mixed reality
  19329. */
  19330. WINDOWS = 2,
  19331. /**
  19332. * Samsung gear VR
  19333. */
  19334. GEAR_VR = 3,
  19335. /**
  19336. * Google Daydream
  19337. */
  19338. DAYDREAM = 4,
  19339. /**
  19340. * Generic
  19341. */
  19342. GENERIC = 5
  19343. }
  19344. /**
  19345. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19346. */
  19347. export interface MutableGamepadButton {
  19348. /**
  19349. * Value of the button/trigger
  19350. */
  19351. value: number;
  19352. /**
  19353. * If the button/trigger is currently touched
  19354. */
  19355. touched: boolean;
  19356. /**
  19357. * If the button/trigger is currently pressed
  19358. */
  19359. pressed: boolean;
  19360. }
  19361. /**
  19362. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19363. * @hidden
  19364. */
  19365. export interface ExtendedGamepadButton extends GamepadButton {
  19366. /**
  19367. * If the button/trigger is currently pressed
  19368. */
  19369. readonly pressed: boolean;
  19370. /**
  19371. * If the button/trigger is currently touched
  19372. */
  19373. readonly touched: boolean;
  19374. /**
  19375. * Value of the button/trigger
  19376. */
  19377. readonly value: number;
  19378. }
  19379. /** @hidden */
  19380. export interface _GamePadFactory {
  19381. /**
  19382. * Returns whether or not the current gamepad can be created for this type of controller.
  19383. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19384. * @returns true if it can be created, otherwise false
  19385. */
  19386. canCreate(gamepadInfo: any): boolean;
  19387. /**
  19388. * Creates a new instance of the Gamepad.
  19389. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19390. * @returns the new gamepad instance
  19391. */
  19392. create(gamepadInfo: any): Gamepad;
  19393. }
  19394. /**
  19395. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19396. */
  19397. export class PoseEnabledControllerHelper {
  19398. /** @hidden */
  19399. static _ControllerFactories: _GamePadFactory[];
  19400. /** @hidden */
  19401. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19402. /**
  19403. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19404. * @param vrGamepad the gamepad to initialized
  19405. * @returns a vr controller of the type the gamepad identified as
  19406. */
  19407. static InitiateController(vrGamepad: any): Gamepad;
  19408. }
  19409. /**
  19410. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19411. */
  19412. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19413. /**
  19414. * If the controller is used in a webXR session
  19415. */
  19416. isXR: boolean;
  19417. private _deviceRoomPosition;
  19418. private _deviceRoomRotationQuaternion;
  19419. /**
  19420. * The device position in babylon space
  19421. */
  19422. devicePosition: Vector3;
  19423. /**
  19424. * The device rotation in babylon space
  19425. */
  19426. deviceRotationQuaternion: Quaternion;
  19427. /**
  19428. * The scale factor of the device in babylon space
  19429. */
  19430. deviceScaleFactor: number;
  19431. /**
  19432. * (Likely devicePosition should be used instead) The device position in its room space
  19433. */
  19434. position: Vector3;
  19435. /**
  19436. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19437. */
  19438. rotationQuaternion: Quaternion;
  19439. /**
  19440. * The type of controller (Eg. Windows mixed reality)
  19441. */
  19442. controllerType: PoseEnabledControllerType;
  19443. protected _calculatedPosition: Vector3;
  19444. private _calculatedRotation;
  19445. /**
  19446. * The raw pose from the device
  19447. */
  19448. rawPose: DevicePose;
  19449. private _trackPosition;
  19450. private _maxRotationDistFromHeadset;
  19451. private _draggedRoomRotation;
  19452. /**
  19453. * @hidden
  19454. */
  19455. _disableTrackPosition(fixedPosition: Vector3): void;
  19456. /**
  19457. * Internal, the mesh attached to the controller
  19458. * @hidden
  19459. */
  19460. _mesh: Nullable<AbstractMesh>;
  19461. private _poseControlledCamera;
  19462. private _leftHandSystemQuaternion;
  19463. /**
  19464. * Internal, matrix used to convert room space to babylon space
  19465. * @hidden
  19466. */
  19467. _deviceToWorld: Matrix;
  19468. /**
  19469. * Node to be used when casting a ray from the controller
  19470. * @hidden
  19471. */
  19472. _pointingPoseNode: Nullable<TransformNode>;
  19473. /**
  19474. * Name of the child mesh that can be used to cast a ray from the controller
  19475. */
  19476. static readonly POINTING_POSE: string;
  19477. /**
  19478. * Creates a new PoseEnabledController from a gamepad
  19479. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19480. */
  19481. constructor(browserGamepad: any);
  19482. private _workingMatrix;
  19483. /**
  19484. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19485. */
  19486. update(): void;
  19487. /**
  19488. * Updates only the pose device and mesh without doing any button event checking
  19489. */
  19490. protected _updatePoseAndMesh(): void;
  19491. /**
  19492. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19493. * @param poseData raw pose fromthe device
  19494. */
  19495. updateFromDevice(poseData: DevicePose): void;
  19496. /**
  19497. * @hidden
  19498. */
  19499. _meshAttachedObservable: Observable<AbstractMesh>;
  19500. /**
  19501. * Attaches a mesh to the controller
  19502. * @param mesh the mesh to be attached
  19503. */
  19504. attachToMesh(mesh: AbstractMesh): void;
  19505. /**
  19506. * Attaches the controllers mesh to a camera
  19507. * @param camera the camera the mesh should be attached to
  19508. */
  19509. attachToPoseControlledCamera(camera: TargetCamera): void;
  19510. /**
  19511. * Disposes of the controller
  19512. */
  19513. dispose(): void;
  19514. /**
  19515. * The mesh that is attached to the controller
  19516. */
  19517. get mesh(): Nullable<AbstractMesh>;
  19518. /**
  19519. * Gets the ray of the controller in the direction the controller is pointing
  19520. * @param length the length the resulting ray should be
  19521. * @returns a ray in the direction the controller is pointing
  19522. */
  19523. getForwardRay(length?: number): Ray;
  19524. }
  19525. }
  19526. declare module BABYLON {
  19527. /**
  19528. * Defines the WebVRController object that represents controllers tracked in 3D space
  19529. */
  19530. export abstract class WebVRController extends PoseEnabledController {
  19531. /**
  19532. * Internal, the default controller model for the controller
  19533. */
  19534. protected _defaultModel: Nullable<AbstractMesh>;
  19535. /**
  19536. * Fired when the trigger state has changed
  19537. */
  19538. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19539. /**
  19540. * Fired when the main button state has changed
  19541. */
  19542. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19543. /**
  19544. * Fired when the secondary button state has changed
  19545. */
  19546. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19547. /**
  19548. * Fired when the pad state has changed
  19549. */
  19550. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19551. /**
  19552. * Fired when controllers stick values have changed
  19553. */
  19554. onPadValuesChangedObservable: Observable<StickValues>;
  19555. /**
  19556. * Array of button availible on the controller
  19557. */
  19558. protected _buttons: Array<MutableGamepadButton>;
  19559. private _onButtonStateChange;
  19560. /**
  19561. * Fired when a controller button's state has changed
  19562. * @param callback the callback containing the button that was modified
  19563. */
  19564. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19565. /**
  19566. * X and Y axis corresponding to the controllers joystick
  19567. */
  19568. pad: StickValues;
  19569. /**
  19570. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19571. */
  19572. hand: string;
  19573. /**
  19574. * The default controller model for the controller
  19575. */
  19576. get defaultModel(): Nullable<AbstractMesh>;
  19577. /**
  19578. * Creates a new WebVRController from a gamepad
  19579. * @param vrGamepad the gamepad that the WebVRController should be created from
  19580. */
  19581. constructor(vrGamepad: any);
  19582. /**
  19583. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19584. */
  19585. update(): void;
  19586. /**
  19587. * Function to be called when a button is modified
  19588. */
  19589. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19590. /**
  19591. * Loads a mesh and attaches it to the controller
  19592. * @param scene the scene the mesh should be added to
  19593. * @param meshLoaded callback for when the mesh has been loaded
  19594. */
  19595. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19596. private _setButtonValue;
  19597. private _changes;
  19598. private _checkChanges;
  19599. /**
  19600. * Disposes of th webVRCOntroller
  19601. */
  19602. dispose(): void;
  19603. }
  19604. }
  19605. declare module BABYLON {
  19606. /**
  19607. * The HemisphericLight simulates the ambient environment light,
  19608. * so the passed direction is the light reflection direction, not the incoming direction.
  19609. */
  19610. export class HemisphericLight extends Light {
  19611. /**
  19612. * The groundColor is the light in the opposite direction to the one specified during creation.
  19613. * 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.
  19614. */
  19615. groundColor: Color3;
  19616. /**
  19617. * The light reflection direction, not the incoming direction.
  19618. */
  19619. direction: Vector3;
  19620. /**
  19621. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19622. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19623. * The HemisphericLight can't cast shadows.
  19624. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19625. * @param name The friendly name of the light
  19626. * @param direction The direction of the light reflection
  19627. * @param scene The scene the light belongs to
  19628. */
  19629. constructor(name: string, direction: Vector3, scene: Scene);
  19630. protected _buildUniformLayout(): void;
  19631. /**
  19632. * Returns the string "HemisphericLight".
  19633. * @return The class name
  19634. */
  19635. getClassName(): string;
  19636. /**
  19637. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19638. * Returns the updated direction.
  19639. * @param target The target the direction should point to
  19640. * @return The computed direction
  19641. */
  19642. setDirectionToTarget(target: Vector3): Vector3;
  19643. /**
  19644. * Returns the shadow generator associated to the light.
  19645. * @returns Always null for hemispheric lights because it does not support shadows.
  19646. */
  19647. getShadowGenerator(): Nullable<IShadowGenerator>;
  19648. /**
  19649. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19650. * @param effect The effect to update
  19651. * @param lightIndex The index of the light in the effect to update
  19652. * @returns The hemispheric light
  19653. */
  19654. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19655. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19656. /**
  19657. * Computes the world matrix of the node
  19658. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19659. * @param useWasUpdatedFlag defines a reserved property
  19660. * @returns the world matrix
  19661. */
  19662. computeWorldMatrix(): Matrix;
  19663. /**
  19664. * Returns the integer 3.
  19665. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19666. */
  19667. getTypeID(): number;
  19668. /**
  19669. * Prepares the list of defines specific to the light type.
  19670. * @param defines the list of defines
  19671. * @param lightIndex defines the index of the light for the effect
  19672. */
  19673. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19674. }
  19675. }
  19676. declare module BABYLON {
  19677. /** @hidden */
  19678. export var vrMultiviewToSingleviewPixelShader: {
  19679. name: string;
  19680. shader: string;
  19681. };
  19682. }
  19683. declare module BABYLON {
  19684. /**
  19685. * Renders to multiple views with a single draw call
  19686. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19687. */
  19688. export class MultiviewRenderTarget extends RenderTargetTexture {
  19689. /**
  19690. * Creates a multiview render target
  19691. * @param scene scene used with the render target
  19692. * @param size the size of the render target (used for each view)
  19693. */
  19694. constructor(scene: Scene, size?: number | {
  19695. width: number;
  19696. height: number;
  19697. } | {
  19698. ratio: number;
  19699. });
  19700. /**
  19701. * @hidden
  19702. * @param faceIndex the face index, if its a cube texture
  19703. */
  19704. _bindFrameBuffer(faceIndex?: number): void;
  19705. /**
  19706. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19707. * @returns the view count
  19708. */
  19709. getViewCount(): number;
  19710. }
  19711. }
  19712. declare module BABYLON {
  19713. interface Engine {
  19714. /**
  19715. * Creates a new multiview render target
  19716. * @param width defines the width of the texture
  19717. * @param height defines the height of the texture
  19718. * @returns the created multiview texture
  19719. */
  19720. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19721. /**
  19722. * Binds a multiview framebuffer to be drawn to
  19723. * @param multiviewTexture texture to bind
  19724. */
  19725. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19726. }
  19727. interface Camera {
  19728. /**
  19729. * @hidden
  19730. * 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)
  19731. */
  19732. _useMultiviewToSingleView: boolean;
  19733. /**
  19734. * @hidden
  19735. * 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)
  19736. */
  19737. _multiviewTexture: Nullable<RenderTargetTexture>;
  19738. /**
  19739. * @hidden
  19740. * ensures the multiview texture of the camera exists and has the specified width/height
  19741. * @param width height to set on the multiview texture
  19742. * @param height width to set on the multiview texture
  19743. */
  19744. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19745. }
  19746. interface Scene {
  19747. /** @hidden */
  19748. _transformMatrixR: Matrix;
  19749. /** @hidden */
  19750. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19751. /** @hidden */
  19752. _createMultiviewUbo(): void;
  19753. /** @hidden */
  19754. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19755. /** @hidden */
  19756. _renderMultiviewToSingleView(camera: Camera): void;
  19757. }
  19758. }
  19759. declare module BABYLON {
  19760. /**
  19761. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19762. * This will not be used for webXR as it supports displaying texture arrays directly
  19763. */
  19764. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19765. /**
  19766. * Gets a string identifying the name of the class
  19767. * @returns "VRMultiviewToSingleviewPostProcess" string
  19768. */
  19769. getClassName(): string;
  19770. /**
  19771. * Initializes a VRMultiviewToSingleview
  19772. * @param name name of the post process
  19773. * @param camera camera to be applied to
  19774. * @param scaleFactor scaling factor to the size of the output texture
  19775. */
  19776. constructor(name: string, camera: Camera, scaleFactor: number);
  19777. }
  19778. }
  19779. declare module BABYLON {
  19780. /**
  19781. * Interface used to define additional presentation attributes
  19782. */
  19783. export interface IVRPresentationAttributes {
  19784. /**
  19785. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19786. */
  19787. highRefreshRate: boolean;
  19788. /**
  19789. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19790. */
  19791. foveationLevel: number;
  19792. }
  19793. interface Engine {
  19794. /** @hidden */
  19795. _vrDisplay: any;
  19796. /** @hidden */
  19797. _vrSupported: boolean;
  19798. /** @hidden */
  19799. _oldSize: Size;
  19800. /** @hidden */
  19801. _oldHardwareScaleFactor: number;
  19802. /** @hidden */
  19803. _vrExclusivePointerMode: boolean;
  19804. /** @hidden */
  19805. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19806. /** @hidden */
  19807. _onVRDisplayPointerRestricted: () => void;
  19808. /** @hidden */
  19809. _onVRDisplayPointerUnrestricted: () => void;
  19810. /** @hidden */
  19811. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19812. /** @hidden */
  19813. _onVrDisplayDisconnect: Nullable<() => void>;
  19814. /** @hidden */
  19815. _onVrDisplayPresentChange: Nullable<() => void>;
  19816. /**
  19817. * Observable signaled when VR display mode changes
  19818. */
  19819. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19820. /**
  19821. * Observable signaled when VR request present is complete
  19822. */
  19823. onVRRequestPresentComplete: Observable<boolean>;
  19824. /**
  19825. * Observable signaled when VR request present starts
  19826. */
  19827. onVRRequestPresentStart: Observable<Engine>;
  19828. /**
  19829. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19830. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19831. */
  19832. isInVRExclusivePointerMode: boolean;
  19833. /**
  19834. * Gets a boolean indicating if a webVR device was detected
  19835. * @returns true if a webVR device was detected
  19836. */
  19837. isVRDevicePresent(): boolean;
  19838. /**
  19839. * Gets the current webVR device
  19840. * @returns the current webVR device (or null)
  19841. */
  19842. getVRDevice(): any;
  19843. /**
  19844. * Initializes a webVR display and starts listening to display change events
  19845. * The onVRDisplayChangedObservable will be notified upon these changes
  19846. * @returns A promise containing a VRDisplay and if vr is supported
  19847. */
  19848. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19849. /** @hidden */
  19850. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19851. /**
  19852. * Gets or sets the presentation attributes used to configure VR rendering
  19853. */
  19854. vrPresentationAttributes?: IVRPresentationAttributes;
  19855. /**
  19856. * Call this function to switch to webVR mode
  19857. * Will do nothing if webVR is not supported or if there is no webVR device
  19858. * @param options the webvr options provided to the camera. mainly used for multiview
  19859. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19860. */
  19861. enableVR(options: WebVROptions): void;
  19862. /** @hidden */
  19863. _onVRFullScreenTriggered(): void;
  19864. }
  19865. }
  19866. declare module BABYLON {
  19867. /**
  19868. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19869. * IMPORTANT!! The data is right-hand data.
  19870. * @export
  19871. * @interface DevicePose
  19872. */
  19873. export interface DevicePose {
  19874. /**
  19875. * The position of the device, values in array are [x,y,z].
  19876. */
  19877. readonly position: Nullable<Float32Array>;
  19878. /**
  19879. * The linearVelocity of the device, values in array are [x,y,z].
  19880. */
  19881. readonly linearVelocity: Nullable<Float32Array>;
  19882. /**
  19883. * The linearAcceleration of the device, values in array are [x,y,z].
  19884. */
  19885. readonly linearAcceleration: Nullable<Float32Array>;
  19886. /**
  19887. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19888. */
  19889. readonly orientation: Nullable<Float32Array>;
  19890. /**
  19891. * The angularVelocity of the device, values in array are [x,y,z].
  19892. */
  19893. readonly angularVelocity: Nullable<Float32Array>;
  19894. /**
  19895. * The angularAcceleration of the device, values in array are [x,y,z].
  19896. */
  19897. readonly angularAcceleration: Nullable<Float32Array>;
  19898. }
  19899. /**
  19900. * Interface representing a pose controlled object in Babylon.
  19901. * A pose controlled object has both regular pose values as well as pose values
  19902. * from an external device such as a VR head mounted display
  19903. */
  19904. export interface PoseControlled {
  19905. /**
  19906. * The position of the object in babylon space.
  19907. */
  19908. position: Vector3;
  19909. /**
  19910. * The rotation quaternion of the object in babylon space.
  19911. */
  19912. rotationQuaternion: Quaternion;
  19913. /**
  19914. * The position of the device in babylon space.
  19915. */
  19916. devicePosition?: Vector3;
  19917. /**
  19918. * The rotation quaternion of the device in babylon space.
  19919. */
  19920. deviceRotationQuaternion: Quaternion;
  19921. /**
  19922. * The raw pose coming from the device.
  19923. */
  19924. rawPose: Nullable<DevicePose>;
  19925. /**
  19926. * The scale of the device to be used when translating from device space to babylon space.
  19927. */
  19928. deviceScaleFactor: number;
  19929. /**
  19930. * Updates the poseControlled values based on the input device pose.
  19931. * @param poseData the pose data to update the object with
  19932. */
  19933. updateFromDevice(poseData: DevicePose): void;
  19934. }
  19935. /**
  19936. * Set of options to customize the webVRCamera
  19937. */
  19938. export interface WebVROptions {
  19939. /**
  19940. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19941. */
  19942. trackPosition?: boolean;
  19943. /**
  19944. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19945. */
  19946. positionScale?: number;
  19947. /**
  19948. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19949. */
  19950. displayName?: string;
  19951. /**
  19952. * Should the native controller meshes be initialized. (default: true)
  19953. */
  19954. controllerMeshes?: boolean;
  19955. /**
  19956. * Creating a default HemiLight only on controllers. (default: true)
  19957. */
  19958. defaultLightingOnControllers?: boolean;
  19959. /**
  19960. * If you don't want to use the default VR button of the helper. (default: false)
  19961. */
  19962. useCustomVRButton?: boolean;
  19963. /**
  19964. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19965. */
  19966. customVRButton?: HTMLButtonElement;
  19967. /**
  19968. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19969. */
  19970. rayLength?: number;
  19971. /**
  19972. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19973. */
  19974. defaultHeight?: number;
  19975. /**
  19976. * If multiview should be used if availible (default: false)
  19977. */
  19978. useMultiview?: boolean;
  19979. }
  19980. /**
  19981. * This represents a WebVR camera.
  19982. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19983. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19984. */
  19985. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19986. private webVROptions;
  19987. /**
  19988. * @hidden
  19989. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19990. */
  19991. _vrDevice: any;
  19992. /**
  19993. * The rawPose of the vrDevice.
  19994. */
  19995. rawPose: Nullable<DevicePose>;
  19996. private _onVREnabled;
  19997. private _specsVersion;
  19998. private _attached;
  19999. private _frameData;
  20000. protected _descendants: Array<Node>;
  20001. private _deviceRoomPosition;
  20002. /** @hidden */
  20003. _deviceRoomRotationQuaternion: Quaternion;
  20004. private _standingMatrix;
  20005. /**
  20006. * Represents device position in babylon space.
  20007. */
  20008. devicePosition: Vector3;
  20009. /**
  20010. * Represents device rotation in babylon space.
  20011. */
  20012. deviceRotationQuaternion: Quaternion;
  20013. /**
  20014. * The scale of the device to be used when translating from device space to babylon space.
  20015. */
  20016. deviceScaleFactor: number;
  20017. private _deviceToWorld;
  20018. private _worldToDevice;
  20019. /**
  20020. * References to the webVR controllers for the vrDevice.
  20021. */
  20022. controllers: Array<WebVRController>;
  20023. /**
  20024. * Emits an event when a controller is attached.
  20025. */
  20026. onControllersAttachedObservable: Observable<WebVRController[]>;
  20027. /**
  20028. * Emits an event when a controller's mesh has been loaded;
  20029. */
  20030. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20031. /**
  20032. * Emits an event when the HMD's pose has been updated.
  20033. */
  20034. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20035. private _poseSet;
  20036. /**
  20037. * If the rig cameras be used as parent instead of this camera.
  20038. */
  20039. rigParenting: boolean;
  20040. private _lightOnControllers;
  20041. private _defaultHeight?;
  20042. /**
  20043. * Instantiates a WebVRFreeCamera.
  20044. * @param name The name of the WebVRFreeCamera
  20045. * @param position The starting anchor position for the camera
  20046. * @param scene The scene the camera belongs to
  20047. * @param webVROptions a set of customizable options for the webVRCamera
  20048. */
  20049. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20050. /**
  20051. * Gets the device distance from the ground in meters.
  20052. * @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.
  20053. */
  20054. deviceDistanceToRoomGround(): number;
  20055. /**
  20056. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20057. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20058. */
  20059. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20060. /**
  20061. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20062. * @returns A promise with a boolean set to if the standing matrix is supported.
  20063. */
  20064. useStandingMatrixAsync(): Promise<boolean>;
  20065. /**
  20066. * Disposes the camera
  20067. */
  20068. dispose(): void;
  20069. /**
  20070. * Gets a vrController by name.
  20071. * @param name The name of the controller to retreive
  20072. * @returns the controller matching the name specified or null if not found
  20073. */
  20074. getControllerByName(name: string): Nullable<WebVRController>;
  20075. private _leftController;
  20076. /**
  20077. * The controller corresponding to the users left hand.
  20078. */
  20079. get leftController(): Nullable<WebVRController>;
  20080. private _rightController;
  20081. /**
  20082. * The controller corresponding to the users right hand.
  20083. */
  20084. get rightController(): Nullable<WebVRController>;
  20085. /**
  20086. * Casts a ray forward from the vrCamera's gaze.
  20087. * @param length Length of the ray (default: 100)
  20088. * @returns the ray corresponding to the gaze
  20089. */
  20090. getForwardRay(length?: number): Ray;
  20091. /**
  20092. * @hidden
  20093. * Updates the camera based on device's frame data
  20094. */
  20095. _checkInputs(): void;
  20096. /**
  20097. * Updates the poseControlled values based on the input device pose.
  20098. * @param poseData Pose coming from the device
  20099. */
  20100. updateFromDevice(poseData: DevicePose): void;
  20101. private _htmlElementAttached;
  20102. private _detachIfAttached;
  20103. /**
  20104. * WebVR's attach control will start broadcasting frames to the device.
  20105. * Note that in certain browsers (chrome for example) this function must be called
  20106. * within a user-interaction callback. Example:
  20107. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20108. *
  20109. * @param element html element to attach the vrDevice to
  20110. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20111. */
  20112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20113. /**
  20114. * Detaches the camera from the html element and disables VR
  20115. *
  20116. * @param element html element to detach from
  20117. */
  20118. detachControl(element: HTMLElement): void;
  20119. /**
  20120. * @returns the name of this class
  20121. */
  20122. getClassName(): string;
  20123. /**
  20124. * Calls resetPose on the vrDisplay
  20125. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20126. */
  20127. resetToCurrentRotation(): void;
  20128. /**
  20129. * @hidden
  20130. * Updates the rig cameras (left and right eye)
  20131. */
  20132. _updateRigCameras(): void;
  20133. private _workingVector;
  20134. private _oneVector;
  20135. private _workingMatrix;
  20136. private updateCacheCalled;
  20137. private _correctPositionIfNotTrackPosition;
  20138. /**
  20139. * @hidden
  20140. * Updates the cached values of the camera
  20141. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20142. */
  20143. _updateCache(ignoreParentClass?: boolean): void;
  20144. /**
  20145. * @hidden
  20146. * Get current device position in babylon world
  20147. */
  20148. _computeDevicePosition(): void;
  20149. /**
  20150. * Updates the current device position and rotation in the babylon world
  20151. */
  20152. update(): void;
  20153. /**
  20154. * @hidden
  20155. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20156. * @returns an identity matrix
  20157. */
  20158. _getViewMatrix(): Matrix;
  20159. private _tmpMatrix;
  20160. /**
  20161. * This function is called by the two RIG cameras.
  20162. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20163. * @hidden
  20164. */
  20165. _getWebVRViewMatrix(): Matrix;
  20166. /** @hidden */
  20167. _getWebVRProjectionMatrix(): Matrix;
  20168. private _onGamepadConnectedObserver;
  20169. private _onGamepadDisconnectedObserver;
  20170. private _updateCacheWhenTrackingDisabledObserver;
  20171. /**
  20172. * Initializes the controllers and their meshes
  20173. */
  20174. initControllers(): void;
  20175. }
  20176. }
  20177. declare module BABYLON {
  20178. /**
  20179. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20180. *
  20181. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20182. *
  20183. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20184. */
  20185. export class MaterialHelper {
  20186. /**
  20187. * Bind the current view position to an effect.
  20188. * @param effect The effect to be bound
  20189. * @param scene The scene the eyes position is used from
  20190. * @param variableName name of the shader variable that will hold the eye position
  20191. */
  20192. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20193. /**
  20194. * Helps preparing the defines values about the UVs in used in the effect.
  20195. * UVs are shared as much as we can accross channels in the shaders.
  20196. * @param texture The texture we are preparing the UVs for
  20197. * @param defines The defines to update
  20198. * @param key The channel key "diffuse", "specular"... used in the shader
  20199. */
  20200. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20201. /**
  20202. * Binds a texture matrix value to its corrsponding uniform
  20203. * @param texture The texture to bind the matrix for
  20204. * @param uniformBuffer The uniform buffer receivin the data
  20205. * @param key The channel key "diffuse", "specular"... used in the shader
  20206. */
  20207. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20208. /**
  20209. * Gets the current status of the fog (should it be enabled?)
  20210. * @param mesh defines the mesh to evaluate for fog support
  20211. * @param scene defines the hosting scene
  20212. * @returns true if fog must be enabled
  20213. */
  20214. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20215. /**
  20216. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20217. * @param mesh defines the current mesh
  20218. * @param scene defines the current scene
  20219. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20220. * @param pointsCloud defines if point cloud rendering has to be turned on
  20221. * @param fogEnabled defines if fog has to be turned on
  20222. * @param alphaTest defines if alpha testing has to be turned on
  20223. * @param defines defines the current list of defines
  20224. */
  20225. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20226. /**
  20227. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20228. * @param scene defines the current scene
  20229. * @param engine defines the current engine
  20230. * @param defines specifies the list of active defines
  20231. * @param useInstances defines if instances have to be turned on
  20232. * @param useClipPlane defines if clip plane have to be turned on
  20233. * @param useInstances defines if instances have to be turned on
  20234. * @param useThinInstances defines if thin instances have to be turned on
  20235. */
  20236. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20237. /**
  20238. * Prepares the defines for bones
  20239. * @param mesh The mesh containing the geometry data we will draw
  20240. * @param defines The defines to update
  20241. */
  20242. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20243. /**
  20244. * Prepares the defines for morph targets
  20245. * @param mesh The mesh containing the geometry data we will draw
  20246. * @param defines The defines to update
  20247. */
  20248. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20249. /**
  20250. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20251. * @param mesh The mesh containing the geometry data we will draw
  20252. * @param defines The defines to update
  20253. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20254. * @param useBones Precise whether bones should be used or not (override mesh info)
  20255. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20256. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20257. * @returns false if defines are considered not dirty and have not been checked
  20258. */
  20259. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20260. /**
  20261. * Prepares the defines related to multiview
  20262. * @param scene The scene we are intending to draw
  20263. * @param defines The defines to update
  20264. */
  20265. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20266. /**
  20267. * Prepares the defines related to the prepass
  20268. * @param scene The scene we are intending to draw
  20269. * @param defines The defines to update
  20270. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20271. */
  20272. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20273. /**
  20274. * Prepares the defines related to the light information passed in parameter
  20275. * @param scene The scene we are intending to draw
  20276. * @param mesh The mesh the effect is compiling for
  20277. * @param light The light the effect is compiling for
  20278. * @param lightIndex The index of the light
  20279. * @param defines The defines to update
  20280. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20281. * @param state Defines the current state regarding what is needed (normals, etc...)
  20282. */
  20283. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20284. needNormals: boolean;
  20285. needRebuild: boolean;
  20286. shadowEnabled: boolean;
  20287. specularEnabled: boolean;
  20288. lightmapMode: boolean;
  20289. }): void;
  20290. /**
  20291. * Prepares the defines related to the light information passed in parameter
  20292. * @param scene The scene we are intending to draw
  20293. * @param mesh The mesh the effect is compiling for
  20294. * @param defines The defines to update
  20295. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20296. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20297. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20298. * @returns true if normals will be required for the rest of the effect
  20299. */
  20300. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20301. /**
  20302. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20303. * @param lightIndex defines the light index
  20304. * @param uniformsList The uniform list
  20305. * @param samplersList The sampler list
  20306. * @param projectedLightTexture defines if projected texture must be used
  20307. * @param uniformBuffersList defines an optional list of uniform buffers
  20308. */
  20309. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20310. /**
  20311. * Prepares the uniforms and samplers list to be used in the effect
  20312. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20313. * @param samplersList The sampler list
  20314. * @param defines The defines helping in the list generation
  20315. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20316. */
  20317. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20318. /**
  20319. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20320. * @param defines The defines to update while falling back
  20321. * @param fallbacks The authorized effect fallbacks
  20322. * @param maxSimultaneousLights The maximum number of lights allowed
  20323. * @param rank the current rank of the Effect
  20324. * @returns The newly affected rank
  20325. */
  20326. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20327. private static _TmpMorphInfluencers;
  20328. /**
  20329. * Prepares the list of attributes required for morph targets according to the effect defines.
  20330. * @param attribs The current list of supported attribs
  20331. * @param mesh The mesh to prepare the morph targets attributes for
  20332. * @param influencers The number of influencers
  20333. */
  20334. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20335. /**
  20336. * Prepares the list of attributes required for morph targets according to the effect defines.
  20337. * @param attribs The current list of supported attribs
  20338. * @param mesh The mesh to prepare the morph targets attributes for
  20339. * @param defines The current Defines of the effect
  20340. */
  20341. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20342. /**
  20343. * Prepares the list of attributes required for bones according to the effect defines.
  20344. * @param attribs The current list of supported attribs
  20345. * @param mesh The mesh to prepare the bones attributes for
  20346. * @param defines The current Defines of the effect
  20347. * @param fallbacks The current efffect fallback strategy
  20348. */
  20349. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20350. /**
  20351. * Check and prepare the list of attributes required for instances according to the effect defines.
  20352. * @param attribs The current list of supported attribs
  20353. * @param defines The current MaterialDefines of the effect
  20354. */
  20355. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20356. /**
  20357. * Add the list of attributes required for instances to the attribs array.
  20358. * @param attribs The current list of supported attribs
  20359. */
  20360. static PushAttributesForInstances(attribs: string[]): void;
  20361. /**
  20362. * Binds the light information to the effect.
  20363. * @param light The light containing the generator
  20364. * @param effect The effect we are binding the data to
  20365. * @param lightIndex The light index in the effect used to render
  20366. */
  20367. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20368. /**
  20369. * Binds the lights information from the scene to the effect for the given mesh.
  20370. * @param light Light to bind
  20371. * @param lightIndex Light index
  20372. * @param scene The scene where the light belongs to
  20373. * @param effect The effect we are binding the data to
  20374. * @param useSpecular Defines if specular is supported
  20375. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20376. */
  20377. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20378. /**
  20379. * Binds the lights information from the scene to the effect for the given mesh.
  20380. * @param scene The scene the lights belongs to
  20381. * @param mesh The mesh we are binding the information to render
  20382. * @param effect The effect we are binding the data to
  20383. * @param defines The generated defines for the effect
  20384. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20385. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20386. */
  20387. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20388. private static _tempFogColor;
  20389. /**
  20390. * Binds the fog information from the scene to the effect for the given mesh.
  20391. * @param scene The scene the lights belongs to
  20392. * @param mesh The mesh we are binding the information to render
  20393. * @param effect The effect we are binding the data to
  20394. * @param linearSpace Defines if the fog effect is applied in linear space
  20395. */
  20396. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20397. /**
  20398. * Binds the bones information from the mesh to the effect.
  20399. * @param mesh The mesh we are binding the information to render
  20400. * @param effect The effect we are binding the data to
  20401. */
  20402. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20403. /**
  20404. * Binds the morph targets information from the mesh to the effect.
  20405. * @param abstractMesh The mesh we are binding the information to render
  20406. * @param effect The effect we are binding the data to
  20407. */
  20408. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20409. /**
  20410. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20411. * @param defines The generated defines used in the effect
  20412. * @param effect The effect we are binding the data to
  20413. * @param scene The scene we are willing to render with logarithmic scale for
  20414. */
  20415. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20416. /**
  20417. * Binds the clip plane information from the scene to the effect.
  20418. * @param scene The scene the clip plane information are extracted from
  20419. * @param effect The effect we are binding the data to
  20420. */
  20421. static BindClipPlane(effect: Effect, scene: Scene): void;
  20422. }
  20423. }
  20424. declare module BABYLON {
  20425. /**
  20426. * Block used to expose an input value
  20427. */
  20428. export class InputBlock extends NodeMaterialBlock {
  20429. private _mode;
  20430. private _associatedVariableName;
  20431. private _storedValue;
  20432. private _valueCallback;
  20433. private _type;
  20434. private _animationType;
  20435. /** Gets or set a value used to limit the range of float values */
  20436. min: number;
  20437. /** Gets or set a value used to limit the range of float values */
  20438. max: number;
  20439. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20440. isBoolean: boolean;
  20441. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20442. matrixMode: number;
  20443. /** @hidden */
  20444. _systemValue: Nullable<NodeMaterialSystemValues>;
  20445. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20446. visibleInInspector: boolean;
  20447. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20448. isConstant: boolean;
  20449. /** Gets or sets the group to use to display this block in the Inspector */
  20450. groupInInspector: string;
  20451. /** Gets an observable raised when the value is changed */
  20452. onValueChangedObservable: Observable<InputBlock>;
  20453. /**
  20454. * Gets or sets the connection point type (default is float)
  20455. */
  20456. get type(): NodeMaterialBlockConnectionPointTypes;
  20457. /**
  20458. * Creates a new InputBlock
  20459. * @param name defines the block name
  20460. * @param target defines the target of that block (Vertex by default)
  20461. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20462. */
  20463. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20464. /**
  20465. * Validates if a name is a reserve word.
  20466. * @param newName the new name to be given to the node.
  20467. * @returns false if the name is a reserve word, else true.
  20468. */
  20469. validateBlockName(newName: string): boolean;
  20470. /**
  20471. * Gets the output component
  20472. */
  20473. get output(): NodeMaterialConnectionPoint;
  20474. /**
  20475. * Set the source of this connection point to a vertex attribute
  20476. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20477. * @returns the current connection point
  20478. */
  20479. setAsAttribute(attributeName?: string): InputBlock;
  20480. /**
  20481. * Set the source of this connection point to a system value
  20482. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20483. * @returns the current connection point
  20484. */
  20485. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20486. /**
  20487. * Gets or sets the value of that point.
  20488. * Please note that this value will be ignored if valueCallback is defined
  20489. */
  20490. get value(): any;
  20491. set value(value: any);
  20492. /**
  20493. * Gets or sets a callback used to get the value of that point.
  20494. * Please note that setting this value will force the connection point to ignore the value property
  20495. */
  20496. get valueCallback(): () => any;
  20497. set valueCallback(value: () => any);
  20498. /**
  20499. * Gets or sets the associated variable name in the shader
  20500. */
  20501. get associatedVariableName(): string;
  20502. set associatedVariableName(value: string);
  20503. /** Gets or sets the type of animation applied to the input */
  20504. get animationType(): AnimatedInputBlockTypes;
  20505. set animationType(value: AnimatedInputBlockTypes);
  20506. /**
  20507. * Gets a boolean indicating that this connection point not defined yet
  20508. */
  20509. get isUndefined(): boolean;
  20510. /**
  20511. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20512. * In this case the connection point name must be the name of the uniform to use.
  20513. * Can only be set on inputs
  20514. */
  20515. get isUniform(): boolean;
  20516. set isUniform(value: boolean);
  20517. /**
  20518. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20519. * In this case the connection point name must be the name of the attribute to use
  20520. * Can only be set on inputs
  20521. */
  20522. get isAttribute(): boolean;
  20523. set isAttribute(value: boolean);
  20524. /**
  20525. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20526. * Can only be set on exit points
  20527. */
  20528. get isVarying(): boolean;
  20529. set isVarying(value: boolean);
  20530. /**
  20531. * Gets a boolean indicating that the current connection point is a system value
  20532. */
  20533. get isSystemValue(): boolean;
  20534. /**
  20535. * Gets or sets the current well known value or null if not defined as a system value
  20536. */
  20537. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20538. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20539. /**
  20540. * Gets the current class name
  20541. * @returns the class name
  20542. */
  20543. getClassName(): string;
  20544. /**
  20545. * Animate the input if animationType !== None
  20546. * @param scene defines the rendering scene
  20547. */
  20548. animate(scene: Scene): void;
  20549. private _emitDefine;
  20550. initialize(state: NodeMaterialBuildState): void;
  20551. /**
  20552. * Set the input block to its default value (based on its type)
  20553. */
  20554. setDefaultValue(): void;
  20555. private _emitConstant;
  20556. /** @hidden */
  20557. get _noContextSwitch(): boolean;
  20558. private _emit;
  20559. /** @hidden */
  20560. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20561. /** @hidden */
  20562. _transmit(effect: Effect, scene: Scene): void;
  20563. protected _buildBlock(state: NodeMaterialBuildState): void;
  20564. protected _dumpPropertiesCode(): string;
  20565. dispose(): void;
  20566. serialize(): any;
  20567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20568. }
  20569. }
  20570. declare module BABYLON {
  20571. /**
  20572. * Enum used to define the compatibility state between two connection points
  20573. */
  20574. export enum NodeMaterialConnectionPointCompatibilityStates {
  20575. /** Points are compatibles */
  20576. Compatible = 0,
  20577. /** Points are incompatible because of their types */
  20578. TypeIncompatible = 1,
  20579. /** Points are incompatible because of their targets (vertex vs fragment) */
  20580. TargetIncompatible = 2
  20581. }
  20582. /**
  20583. * Defines the direction of a connection point
  20584. */
  20585. export enum NodeMaterialConnectionPointDirection {
  20586. /** Input */
  20587. Input = 0,
  20588. /** Output */
  20589. Output = 1
  20590. }
  20591. /**
  20592. * Defines a connection point for a block
  20593. */
  20594. export class NodeMaterialConnectionPoint {
  20595. /** @hidden */
  20596. _ownerBlock: NodeMaterialBlock;
  20597. /** @hidden */
  20598. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20599. private _endpoints;
  20600. private _associatedVariableName;
  20601. private _direction;
  20602. /** @hidden */
  20603. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20604. /** @hidden */
  20605. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20606. private _type;
  20607. /** @hidden */
  20608. _enforceAssociatedVariableName: boolean;
  20609. /** Gets the direction of the point */
  20610. get direction(): NodeMaterialConnectionPointDirection;
  20611. /** Indicates that this connection point needs dual validation before being connected to another point */
  20612. needDualDirectionValidation: boolean;
  20613. /**
  20614. * Gets or sets the additional types supported by this connection point
  20615. */
  20616. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20617. /**
  20618. * Gets or sets the additional types excluded by this connection point
  20619. */
  20620. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20621. /**
  20622. * Observable triggered when this point is connected
  20623. */
  20624. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20625. /**
  20626. * Gets or sets the associated variable name in the shader
  20627. */
  20628. get associatedVariableName(): string;
  20629. set associatedVariableName(value: string);
  20630. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20631. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20632. /**
  20633. * Gets or sets the connection point type (default is float)
  20634. */
  20635. get type(): NodeMaterialBlockConnectionPointTypes;
  20636. set type(value: NodeMaterialBlockConnectionPointTypes);
  20637. /**
  20638. * Gets or sets the connection point name
  20639. */
  20640. name: string;
  20641. /**
  20642. * Gets or sets the connection point name
  20643. */
  20644. displayName: string;
  20645. /**
  20646. * Gets or sets a boolean indicating that this connection point can be omitted
  20647. */
  20648. isOptional: boolean;
  20649. /**
  20650. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20651. */
  20652. isExposedOnFrame: boolean;
  20653. /**
  20654. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20655. */
  20656. define: string;
  20657. /** @hidden */
  20658. _prioritizeVertex: boolean;
  20659. private _target;
  20660. /** Gets or sets the target of that connection point */
  20661. get target(): NodeMaterialBlockTargets;
  20662. set target(value: NodeMaterialBlockTargets);
  20663. /**
  20664. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20665. */
  20666. get isConnected(): boolean;
  20667. /**
  20668. * Gets a boolean indicating that the current point is connected to an input block
  20669. */
  20670. get isConnectedToInputBlock(): boolean;
  20671. /**
  20672. * Gets a the connected input block (if any)
  20673. */
  20674. get connectInputBlock(): Nullable<InputBlock>;
  20675. /** Get the other side of the connection (if any) */
  20676. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20677. /** Get the block that owns this connection point */
  20678. get ownerBlock(): NodeMaterialBlock;
  20679. /** Get the block connected on the other side of this connection (if any) */
  20680. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20681. /** Get the block connected on the endpoints of this connection (if any) */
  20682. get connectedBlocks(): Array<NodeMaterialBlock>;
  20683. /** Gets the list of connected endpoints */
  20684. get endpoints(): NodeMaterialConnectionPoint[];
  20685. /** Gets a boolean indicating if that output point is connected to at least one input */
  20686. get hasEndpoints(): boolean;
  20687. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20688. get isConnectedInVertexShader(): boolean;
  20689. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20690. get isConnectedInFragmentShader(): boolean;
  20691. /**
  20692. * Creates a block suitable to be used as an input for this input point.
  20693. * If null is returned, a block based on the point type will be created.
  20694. * @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
  20695. */
  20696. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20697. /**
  20698. * Creates a new connection point
  20699. * @param name defines the connection point name
  20700. * @param ownerBlock defines the block hosting this connection point
  20701. * @param direction defines the direction of the connection point
  20702. */
  20703. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20704. /**
  20705. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20706. * @returns the class name
  20707. */
  20708. getClassName(): string;
  20709. /**
  20710. * Gets a boolean indicating if the current point can be connected to another point
  20711. * @param connectionPoint defines the other connection point
  20712. * @returns a boolean
  20713. */
  20714. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20715. /**
  20716. * Gets a number indicating if the current point can be connected to another point
  20717. * @param connectionPoint defines the other connection point
  20718. * @returns a number defining the compatibility state
  20719. */
  20720. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20721. /**
  20722. * Connect this point to another connection point
  20723. * @param connectionPoint defines the other connection point
  20724. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20725. * @returns the current connection point
  20726. */
  20727. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20728. /**
  20729. * Disconnect this point from one of his endpoint
  20730. * @param endpoint defines the other connection point
  20731. * @returns the current connection point
  20732. */
  20733. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20734. /**
  20735. * Serializes this point in a JSON representation
  20736. * @param isInput defines if the connection point is an input (default is true)
  20737. * @returns the serialized point object
  20738. */
  20739. serialize(isInput?: boolean): any;
  20740. /**
  20741. * Release resources
  20742. */
  20743. dispose(): void;
  20744. }
  20745. }
  20746. declare module BABYLON {
  20747. /**
  20748. * Enum used to define the material modes
  20749. */
  20750. export enum NodeMaterialModes {
  20751. /** Regular material */
  20752. Material = 0,
  20753. /** For post process */
  20754. PostProcess = 1,
  20755. /** For particle system */
  20756. Particle = 2
  20757. }
  20758. }
  20759. declare module BABYLON {
  20760. /**
  20761. * Block used to read a texture from a sampler
  20762. */
  20763. export class TextureBlock extends NodeMaterialBlock {
  20764. private _defineName;
  20765. private _linearDefineName;
  20766. private _gammaDefineName;
  20767. private _tempTextureRead;
  20768. private _samplerName;
  20769. private _transformedUVName;
  20770. private _textureTransformName;
  20771. private _textureInfoName;
  20772. private _mainUVName;
  20773. private _mainUVDefineName;
  20774. private _fragmentOnly;
  20775. /**
  20776. * Gets or sets the texture associated with the node
  20777. */
  20778. texture: Nullable<Texture>;
  20779. /**
  20780. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20781. */
  20782. convertToGammaSpace: boolean;
  20783. /**
  20784. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20785. */
  20786. convertToLinearSpace: boolean;
  20787. /**
  20788. * Create a new TextureBlock
  20789. * @param name defines the block name
  20790. */
  20791. constructor(name: string, fragmentOnly?: boolean);
  20792. /**
  20793. * Gets the current class name
  20794. * @returns the class name
  20795. */
  20796. getClassName(): string;
  20797. /**
  20798. * Gets the uv input component
  20799. */
  20800. get uv(): NodeMaterialConnectionPoint;
  20801. /**
  20802. * Gets the rgba output component
  20803. */
  20804. get rgba(): NodeMaterialConnectionPoint;
  20805. /**
  20806. * Gets the rgb output component
  20807. */
  20808. get rgb(): NodeMaterialConnectionPoint;
  20809. /**
  20810. * Gets the r output component
  20811. */
  20812. get r(): NodeMaterialConnectionPoint;
  20813. /**
  20814. * Gets the g output component
  20815. */
  20816. get g(): NodeMaterialConnectionPoint;
  20817. /**
  20818. * Gets the b output component
  20819. */
  20820. get b(): NodeMaterialConnectionPoint;
  20821. /**
  20822. * Gets the a output component
  20823. */
  20824. get a(): NodeMaterialConnectionPoint;
  20825. get target(): NodeMaterialBlockTargets;
  20826. autoConfigure(material: NodeMaterial): void;
  20827. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20829. isReady(): boolean;
  20830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20831. private get _isMixed();
  20832. private _injectVertexCode;
  20833. private _writeTextureRead;
  20834. private _writeOutput;
  20835. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20836. protected _dumpPropertiesCode(): string;
  20837. serialize(): any;
  20838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20839. }
  20840. }
  20841. declare module BABYLON {
  20842. /** @hidden */
  20843. export var reflectionFunction: {
  20844. name: string;
  20845. shader: string;
  20846. };
  20847. }
  20848. declare module BABYLON {
  20849. /**
  20850. * Base block used to read a reflection texture from a sampler
  20851. */
  20852. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20853. /** @hidden */
  20854. _define3DName: string;
  20855. /** @hidden */
  20856. _defineCubicName: string;
  20857. /** @hidden */
  20858. _defineExplicitName: string;
  20859. /** @hidden */
  20860. _defineProjectionName: string;
  20861. /** @hidden */
  20862. _defineLocalCubicName: string;
  20863. /** @hidden */
  20864. _defineSphericalName: string;
  20865. /** @hidden */
  20866. _definePlanarName: string;
  20867. /** @hidden */
  20868. _defineEquirectangularName: string;
  20869. /** @hidden */
  20870. _defineMirroredEquirectangularFixedName: string;
  20871. /** @hidden */
  20872. _defineEquirectangularFixedName: string;
  20873. /** @hidden */
  20874. _defineSkyboxName: string;
  20875. /** @hidden */
  20876. _defineOppositeZ: string;
  20877. /** @hidden */
  20878. _cubeSamplerName: string;
  20879. /** @hidden */
  20880. _2DSamplerName: string;
  20881. protected _positionUVWName: string;
  20882. protected _directionWName: string;
  20883. protected _reflectionVectorName: string;
  20884. /** @hidden */
  20885. _reflectionCoordsName: string;
  20886. /** @hidden */
  20887. _reflectionMatrixName: string;
  20888. protected _reflectionColorName: string;
  20889. /**
  20890. * Gets or sets the texture associated with the node
  20891. */
  20892. texture: Nullable<BaseTexture>;
  20893. /**
  20894. * Create a new ReflectionTextureBaseBlock
  20895. * @param name defines the block name
  20896. */
  20897. constructor(name: string);
  20898. /**
  20899. * Gets the current class name
  20900. * @returns the class name
  20901. */
  20902. getClassName(): string;
  20903. /**
  20904. * Gets the world position input component
  20905. */
  20906. abstract get position(): NodeMaterialConnectionPoint;
  20907. /**
  20908. * Gets the world position input component
  20909. */
  20910. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Gets the world normal input component
  20913. */
  20914. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20915. /**
  20916. * Gets the world input component
  20917. */
  20918. abstract get world(): NodeMaterialConnectionPoint;
  20919. /**
  20920. * Gets the camera (or eye) position component
  20921. */
  20922. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20923. /**
  20924. * Gets the view input component
  20925. */
  20926. abstract get view(): NodeMaterialConnectionPoint;
  20927. protected _getTexture(): Nullable<BaseTexture>;
  20928. autoConfigure(material: NodeMaterial): void;
  20929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20930. isReady(): boolean;
  20931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20932. /**
  20933. * Gets the code to inject in the vertex shader
  20934. * @param state current state of the node material building
  20935. * @returns the shader code
  20936. */
  20937. handleVertexSide(state: NodeMaterialBuildState): string;
  20938. /**
  20939. * Handles the inits for the fragment code path
  20940. * @param state node material build state
  20941. */
  20942. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20943. /**
  20944. * Generates the reflection coords code for the fragment code path
  20945. * @param worldNormalVarName name of the world normal variable
  20946. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20947. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20948. * @returns the shader code
  20949. */
  20950. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20951. /**
  20952. * Generates the reflection color code for the fragment code path
  20953. * @param lodVarName name of the lod variable
  20954. * @param swizzleLookupTexture swizzle to use for the final color variable
  20955. * @returns the shader code
  20956. */
  20957. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20958. /**
  20959. * Generates the code corresponding to the connected output points
  20960. * @param state node material build state
  20961. * @param varName name of the variable to output
  20962. * @returns the shader code
  20963. */
  20964. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20965. protected _buildBlock(state: NodeMaterialBuildState): this;
  20966. protected _dumpPropertiesCode(): string;
  20967. serialize(): any;
  20968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20969. }
  20970. }
  20971. declare module BABYLON {
  20972. /**
  20973. * Defines a connection point to be used for points with a custom object type
  20974. */
  20975. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20976. private _blockType;
  20977. private _blockName;
  20978. private _nameForCheking?;
  20979. /**
  20980. * Creates a new connection point
  20981. * @param name defines the connection point name
  20982. * @param ownerBlock defines the block hosting this connection point
  20983. * @param direction defines the direction of the connection point
  20984. */
  20985. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20986. /**
  20987. * Gets a number indicating if the current point can be connected to another point
  20988. * @param connectionPoint defines the other connection point
  20989. * @returns a number defining the compatibility state
  20990. */
  20991. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20992. /**
  20993. * Creates a block suitable to be used as an input for this input point.
  20994. * If null is returned, a block based on the point type will be created.
  20995. * @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
  20996. */
  20997. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20998. }
  20999. }
  21000. declare module BABYLON {
  21001. /**
  21002. * Enum defining the type of properties that can be edited in the property pages in the NME
  21003. */
  21004. export enum PropertyTypeForEdition {
  21005. /** property is a boolean */
  21006. Boolean = 0,
  21007. /** property is a float */
  21008. Float = 1,
  21009. /** property is a Vector2 */
  21010. Vector2 = 2,
  21011. /** property is a list of values */
  21012. List = 3
  21013. }
  21014. /**
  21015. * Interface that defines an option in a variable of type list
  21016. */
  21017. export interface IEditablePropertyListOption {
  21018. /** label of the option */
  21019. "label": string;
  21020. /** value of the option */
  21021. "value": number;
  21022. }
  21023. /**
  21024. * Interface that defines the options available for an editable property
  21025. */
  21026. export interface IEditablePropertyOption {
  21027. /** min value */
  21028. "min"?: number;
  21029. /** max value */
  21030. "max"?: number;
  21031. /** notifiers: indicates which actions to take when the property is changed */
  21032. "notifiers"?: {
  21033. /** the material should be rebuilt */
  21034. "rebuild"?: boolean;
  21035. /** the preview should be updated */
  21036. "update"?: boolean;
  21037. };
  21038. /** list of the options for a variable of type list */
  21039. "options"?: IEditablePropertyListOption[];
  21040. }
  21041. /**
  21042. * Interface that describes an editable property
  21043. */
  21044. export interface IPropertyDescriptionForEdition {
  21045. /** name of the property */
  21046. "propertyName": string;
  21047. /** display name of the property */
  21048. "displayName": string;
  21049. /** type of the property */
  21050. "type": PropertyTypeForEdition;
  21051. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21052. "groupName": string;
  21053. /** options for the property */
  21054. "options": IEditablePropertyOption;
  21055. }
  21056. /**
  21057. * Decorator that flags a property in a node material block as being editable
  21058. */
  21059. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21060. }
  21061. declare module BABYLON {
  21062. /**
  21063. * Block used to implement the refraction part of the sub surface module of the PBR material
  21064. */
  21065. export class RefractionBlock extends NodeMaterialBlock {
  21066. /** @hidden */
  21067. _define3DName: string;
  21068. /** @hidden */
  21069. _refractionMatrixName: string;
  21070. /** @hidden */
  21071. _defineLODRefractionAlpha: string;
  21072. /** @hidden */
  21073. _defineLinearSpecularRefraction: string;
  21074. /** @hidden */
  21075. _defineOppositeZ: string;
  21076. /** @hidden */
  21077. _cubeSamplerName: string;
  21078. /** @hidden */
  21079. _2DSamplerName: string;
  21080. /** @hidden */
  21081. _vRefractionMicrosurfaceInfosName: string;
  21082. /** @hidden */
  21083. _vRefractionInfosName: string;
  21084. private _scene;
  21085. /**
  21086. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21087. * Materials half opaque for instance using refraction could benefit from this control.
  21088. */
  21089. linkRefractionWithTransparency: boolean;
  21090. /**
  21091. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21092. */
  21093. invertRefractionY: boolean;
  21094. /**
  21095. * Gets or sets the texture associated with the node
  21096. */
  21097. texture: Nullable<BaseTexture>;
  21098. /**
  21099. * Create a new RefractionBlock
  21100. * @param name defines the block name
  21101. */
  21102. constructor(name: string);
  21103. /**
  21104. * Gets the current class name
  21105. * @returns the class name
  21106. */
  21107. getClassName(): string;
  21108. /**
  21109. * Gets the intensity input component
  21110. */
  21111. get intensity(): NodeMaterialConnectionPoint;
  21112. /**
  21113. * Gets the index of refraction input component
  21114. */
  21115. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21116. /**
  21117. * Gets the tint at distance input component
  21118. */
  21119. get tintAtDistance(): NodeMaterialConnectionPoint;
  21120. /**
  21121. * Gets the view input component
  21122. */
  21123. get view(): NodeMaterialConnectionPoint;
  21124. /**
  21125. * Gets the refraction object output component
  21126. */
  21127. get refraction(): NodeMaterialConnectionPoint;
  21128. /**
  21129. * Returns true if the block has a texture
  21130. */
  21131. get hasTexture(): boolean;
  21132. protected _getTexture(): Nullable<BaseTexture>;
  21133. autoConfigure(material: NodeMaterial): void;
  21134. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21135. isReady(): boolean;
  21136. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21137. /**
  21138. * Gets the main code of the block (fragment side)
  21139. * @param state current state of the node material building
  21140. * @returns the shader code
  21141. */
  21142. getCode(state: NodeMaterialBuildState): string;
  21143. protected _buildBlock(state: NodeMaterialBuildState): this;
  21144. protected _dumpPropertiesCode(): string;
  21145. serialize(): any;
  21146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21147. }
  21148. }
  21149. declare module BABYLON {
  21150. /**
  21151. * Base block used as input for post process
  21152. */
  21153. export class CurrentScreenBlock extends NodeMaterialBlock {
  21154. private _samplerName;
  21155. private _linearDefineName;
  21156. private _gammaDefineName;
  21157. private _mainUVName;
  21158. private _tempTextureRead;
  21159. /**
  21160. * Gets or sets the texture associated with the node
  21161. */
  21162. texture: Nullable<BaseTexture>;
  21163. /**
  21164. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21165. */
  21166. convertToGammaSpace: boolean;
  21167. /**
  21168. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21169. */
  21170. convertToLinearSpace: boolean;
  21171. /**
  21172. * Create a new CurrentScreenBlock
  21173. * @param name defines the block name
  21174. */
  21175. constructor(name: string);
  21176. /**
  21177. * Gets the current class name
  21178. * @returns the class name
  21179. */
  21180. getClassName(): string;
  21181. /**
  21182. * Gets the uv input component
  21183. */
  21184. get uv(): NodeMaterialConnectionPoint;
  21185. /**
  21186. * Gets the rgba output component
  21187. */
  21188. get rgba(): NodeMaterialConnectionPoint;
  21189. /**
  21190. * Gets the rgb output component
  21191. */
  21192. get rgb(): NodeMaterialConnectionPoint;
  21193. /**
  21194. * Gets the r output component
  21195. */
  21196. get r(): NodeMaterialConnectionPoint;
  21197. /**
  21198. * Gets the g output component
  21199. */
  21200. get g(): NodeMaterialConnectionPoint;
  21201. /**
  21202. * Gets the b output component
  21203. */
  21204. get b(): NodeMaterialConnectionPoint;
  21205. /**
  21206. * Gets the a output component
  21207. */
  21208. get a(): NodeMaterialConnectionPoint;
  21209. /**
  21210. * Initialize the block and prepare the context for build
  21211. * @param state defines the state that will be used for the build
  21212. */
  21213. initialize(state: NodeMaterialBuildState): void;
  21214. get target(): NodeMaterialBlockTargets;
  21215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21216. isReady(): boolean;
  21217. private _injectVertexCode;
  21218. private _writeTextureRead;
  21219. private _writeOutput;
  21220. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21221. serialize(): any;
  21222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21223. }
  21224. }
  21225. declare module BABYLON {
  21226. /**
  21227. * Base block used for the particle texture
  21228. */
  21229. export class ParticleTextureBlock extends NodeMaterialBlock {
  21230. private _samplerName;
  21231. private _linearDefineName;
  21232. private _gammaDefineName;
  21233. private _tempTextureRead;
  21234. /**
  21235. * Gets or sets the texture associated with the node
  21236. */
  21237. texture: Nullable<BaseTexture>;
  21238. /**
  21239. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21240. */
  21241. convertToGammaSpace: boolean;
  21242. /**
  21243. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21244. */
  21245. convertToLinearSpace: boolean;
  21246. /**
  21247. * Create a new ParticleTextureBlock
  21248. * @param name defines the block name
  21249. */
  21250. constructor(name: string);
  21251. /**
  21252. * Gets the current class name
  21253. * @returns the class name
  21254. */
  21255. getClassName(): string;
  21256. /**
  21257. * Gets the uv input component
  21258. */
  21259. get uv(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the rgba output component
  21262. */
  21263. get rgba(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Gets the rgb output component
  21266. */
  21267. get rgb(): NodeMaterialConnectionPoint;
  21268. /**
  21269. * Gets the r output component
  21270. */
  21271. get r(): NodeMaterialConnectionPoint;
  21272. /**
  21273. * Gets the g output component
  21274. */
  21275. get g(): NodeMaterialConnectionPoint;
  21276. /**
  21277. * Gets the b output component
  21278. */
  21279. get b(): NodeMaterialConnectionPoint;
  21280. /**
  21281. * Gets the a output component
  21282. */
  21283. get a(): NodeMaterialConnectionPoint;
  21284. /**
  21285. * Initialize the block and prepare the context for build
  21286. * @param state defines the state that will be used for the build
  21287. */
  21288. initialize(state: NodeMaterialBuildState): void;
  21289. autoConfigure(material: NodeMaterial): void;
  21290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21291. isReady(): boolean;
  21292. private _writeOutput;
  21293. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21294. serialize(): any;
  21295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21296. }
  21297. }
  21298. declare module BABYLON {
  21299. /**
  21300. * Class used to store shared data between 2 NodeMaterialBuildState
  21301. */
  21302. export class NodeMaterialBuildStateSharedData {
  21303. /**
  21304. * Gets the list of emitted varyings
  21305. */
  21306. temps: string[];
  21307. /**
  21308. * Gets the list of emitted varyings
  21309. */
  21310. varyings: string[];
  21311. /**
  21312. * Gets the varying declaration string
  21313. */
  21314. varyingDeclaration: string;
  21315. /**
  21316. * Input blocks
  21317. */
  21318. inputBlocks: InputBlock[];
  21319. /**
  21320. * Input blocks
  21321. */
  21322. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21323. /**
  21324. * Bindable blocks (Blocks that need to set data to the effect)
  21325. */
  21326. bindableBlocks: NodeMaterialBlock[];
  21327. /**
  21328. * List of blocks that can provide a compilation fallback
  21329. */
  21330. blocksWithFallbacks: NodeMaterialBlock[];
  21331. /**
  21332. * List of blocks that can provide a define update
  21333. */
  21334. blocksWithDefines: NodeMaterialBlock[];
  21335. /**
  21336. * List of blocks that can provide a repeatable content
  21337. */
  21338. repeatableContentBlocks: NodeMaterialBlock[];
  21339. /**
  21340. * List of blocks that can provide a dynamic list of uniforms
  21341. */
  21342. dynamicUniformBlocks: NodeMaterialBlock[];
  21343. /**
  21344. * List of blocks that can block the isReady function for the material
  21345. */
  21346. blockingBlocks: NodeMaterialBlock[];
  21347. /**
  21348. * Gets the list of animated inputs
  21349. */
  21350. animatedInputs: InputBlock[];
  21351. /**
  21352. * Build Id used to avoid multiple recompilations
  21353. */
  21354. buildId: number;
  21355. /** List of emitted variables */
  21356. variableNames: {
  21357. [key: string]: number;
  21358. };
  21359. /** List of emitted defines */
  21360. defineNames: {
  21361. [key: string]: number;
  21362. };
  21363. /** Should emit comments? */
  21364. emitComments: boolean;
  21365. /** Emit build activity */
  21366. verbose: boolean;
  21367. /** Gets or sets the hosting scene */
  21368. scene: Scene;
  21369. /**
  21370. * Gets the compilation hints emitted at compilation time
  21371. */
  21372. hints: {
  21373. needWorldViewMatrix: boolean;
  21374. needWorldViewProjectionMatrix: boolean;
  21375. needAlphaBlending: boolean;
  21376. needAlphaTesting: boolean;
  21377. };
  21378. /**
  21379. * List of compilation checks
  21380. */
  21381. checks: {
  21382. emitVertex: boolean;
  21383. emitFragment: boolean;
  21384. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21385. };
  21386. /**
  21387. * Is vertex program allowed to be empty?
  21388. */
  21389. allowEmptyVertexProgram: boolean;
  21390. /** Creates a new shared data */
  21391. constructor();
  21392. /**
  21393. * Emits console errors and exceptions if there is a failing check
  21394. */
  21395. emitErrors(): void;
  21396. }
  21397. }
  21398. declare module BABYLON {
  21399. /**
  21400. * Class used to store node based material build state
  21401. */
  21402. export class NodeMaterialBuildState {
  21403. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21404. supportUniformBuffers: boolean;
  21405. /**
  21406. * Gets the list of emitted attributes
  21407. */
  21408. attributes: string[];
  21409. /**
  21410. * Gets the list of emitted uniforms
  21411. */
  21412. uniforms: string[];
  21413. /**
  21414. * Gets the list of emitted constants
  21415. */
  21416. constants: string[];
  21417. /**
  21418. * Gets the list of emitted samplers
  21419. */
  21420. samplers: string[];
  21421. /**
  21422. * Gets the list of emitted functions
  21423. */
  21424. functions: {
  21425. [key: string]: string;
  21426. };
  21427. /**
  21428. * Gets the list of emitted extensions
  21429. */
  21430. extensions: {
  21431. [key: string]: string;
  21432. };
  21433. /**
  21434. * Gets the target of the compilation state
  21435. */
  21436. target: NodeMaterialBlockTargets;
  21437. /**
  21438. * Gets the list of emitted counters
  21439. */
  21440. counters: {
  21441. [key: string]: number;
  21442. };
  21443. /**
  21444. * Shared data between multiple NodeMaterialBuildState instances
  21445. */
  21446. sharedData: NodeMaterialBuildStateSharedData;
  21447. /** @hidden */
  21448. _vertexState: NodeMaterialBuildState;
  21449. /** @hidden */
  21450. _attributeDeclaration: string;
  21451. /** @hidden */
  21452. _uniformDeclaration: string;
  21453. /** @hidden */
  21454. _constantDeclaration: string;
  21455. /** @hidden */
  21456. _samplerDeclaration: string;
  21457. /** @hidden */
  21458. _varyingTransfer: string;
  21459. /** @hidden */
  21460. _injectAtEnd: string;
  21461. private _repeatableContentAnchorIndex;
  21462. /** @hidden */
  21463. _builtCompilationString: string;
  21464. /**
  21465. * Gets the emitted compilation strings
  21466. */
  21467. compilationString: string;
  21468. /**
  21469. * Finalize the compilation strings
  21470. * @param state defines the current compilation state
  21471. */
  21472. finalize(state: NodeMaterialBuildState): void;
  21473. /** @hidden */
  21474. get _repeatableContentAnchor(): string;
  21475. /** @hidden */
  21476. _getFreeVariableName(prefix: string): string;
  21477. /** @hidden */
  21478. _getFreeDefineName(prefix: string): string;
  21479. /** @hidden */
  21480. _excludeVariableName(name: string): void;
  21481. /** @hidden */
  21482. _emit2DSampler(name: string): void;
  21483. /** @hidden */
  21484. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21485. /** @hidden */
  21486. _emitExtension(name: string, extension: string, define?: string): void;
  21487. /** @hidden */
  21488. _emitFunction(name: string, code: string, comments: string): void;
  21489. /** @hidden */
  21490. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21491. replaceStrings?: {
  21492. search: RegExp;
  21493. replace: string;
  21494. }[];
  21495. repeatKey?: string;
  21496. }): string;
  21497. /** @hidden */
  21498. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21499. repeatKey?: string;
  21500. removeAttributes?: boolean;
  21501. removeUniforms?: boolean;
  21502. removeVaryings?: boolean;
  21503. removeIfDef?: boolean;
  21504. replaceStrings?: {
  21505. search: RegExp;
  21506. replace: string;
  21507. }[];
  21508. }, storeKey?: string): void;
  21509. /** @hidden */
  21510. _registerTempVariable(name: string): boolean;
  21511. /** @hidden */
  21512. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21513. /** @hidden */
  21514. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21515. /** @hidden */
  21516. _emitFloat(value: number): string;
  21517. }
  21518. }
  21519. declare module BABYLON {
  21520. /**
  21521. * Helper class used to generate session unique ID
  21522. */
  21523. export class UniqueIdGenerator {
  21524. private static _UniqueIdCounter;
  21525. /**
  21526. * Gets an unique (relatively to the current scene) Id
  21527. */
  21528. static get UniqueId(): number;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * Defines a block that can be used inside a node based material
  21534. */
  21535. export class NodeMaterialBlock {
  21536. private _buildId;
  21537. private _buildTarget;
  21538. private _target;
  21539. private _isFinalMerger;
  21540. private _isInput;
  21541. private _name;
  21542. protected _isUnique: boolean;
  21543. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21544. inputsAreExclusive: boolean;
  21545. /** @hidden */
  21546. _codeVariableName: string;
  21547. /** @hidden */
  21548. _inputs: NodeMaterialConnectionPoint[];
  21549. /** @hidden */
  21550. _outputs: NodeMaterialConnectionPoint[];
  21551. /** @hidden */
  21552. _preparationId: number;
  21553. /**
  21554. * Gets the name of the block
  21555. */
  21556. get name(): string;
  21557. /**
  21558. * Sets the name of the block. Will check if the name is valid.
  21559. */
  21560. set name(newName: string);
  21561. /**
  21562. * Gets or sets the unique id of the node
  21563. */
  21564. uniqueId: number;
  21565. /**
  21566. * Gets or sets the comments associated with this block
  21567. */
  21568. comments: string;
  21569. /**
  21570. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21571. */
  21572. get isUnique(): boolean;
  21573. /**
  21574. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21575. */
  21576. get isFinalMerger(): boolean;
  21577. /**
  21578. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21579. */
  21580. get isInput(): boolean;
  21581. /**
  21582. * Gets or sets the build Id
  21583. */
  21584. get buildId(): number;
  21585. set buildId(value: number);
  21586. /**
  21587. * Gets or sets the target of the block
  21588. */
  21589. get target(): NodeMaterialBlockTargets;
  21590. set target(value: NodeMaterialBlockTargets);
  21591. /**
  21592. * Gets the list of input points
  21593. */
  21594. get inputs(): NodeMaterialConnectionPoint[];
  21595. /** Gets the list of output points */
  21596. get outputs(): NodeMaterialConnectionPoint[];
  21597. /**
  21598. * Find an input by its name
  21599. * @param name defines the name of the input to look for
  21600. * @returns the input or null if not found
  21601. */
  21602. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21603. /**
  21604. * Find an output by its name
  21605. * @param name defines the name of the outputto look for
  21606. * @returns the output or null if not found
  21607. */
  21608. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21609. /**
  21610. * Creates a new NodeMaterialBlock
  21611. * @param name defines the block name
  21612. * @param target defines the target of that block (Vertex by default)
  21613. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21614. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21615. */
  21616. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21617. /**
  21618. * Initialize the block and prepare the context for build
  21619. * @param state defines the state that will be used for the build
  21620. */
  21621. initialize(state: NodeMaterialBuildState): void;
  21622. /**
  21623. * Bind data to effect. Will only be called for blocks with isBindable === true
  21624. * @param effect defines the effect to bind data to
  21625. * @param nodeMaterial defines the hosting NodeMaterial
  21626. * @param mesh defines the mesh that will be rendered
  21627. * @param subMesh defines the submesh that will be rendered
  21628. */
  21629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21630. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21631. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21632. protected _writeFloat(value: number): string;
  21633. /**
  21634. * Gets the current class name e.g. "NodeMaterialBlock"
  21635. * @returns the class name
  21636. */
  21637. getClassName(): string;
  21638. /**
  21639. * Register a new input. Must be called inside a block constructor
  21640. * @param name defines the connection point name
  21641. * @param type defines the connection point type
  21642. * @param isOptional defines a boolean indicating that this input can be omitted
  21643. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21644. * @param point an already created connection point. If not provided, create a new one
  21645. * @returns the current block
  21646. */
  21647. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21648. /**
  21649. * Register a new output. Must be called inside a block constructor
  21650. * @param name defines the connection point name
  21651. * @param type defines the connection point type
  21652. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21653. * @param point an already created connection point. If not provided, create a new one
  21654. * @returns the current block
  21655. */
  21656. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21657. /**
  21658. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21659. * @param forOutput defines an optional connection point to check compatibility with
  21660. * @returns the first available input or null
  21661. */
  21662. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21663. /**
  21664. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21665. * @param forBlock defines an optional block to check compatibility with
  21666. * @returns the first available input or null
  21667. */
  21668. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21669. /**
  21670. * Gets the sibling of the given output
  21671. * @param current defines the current output
  21672. * @returns the next output in the list or null
  21673. */
  21674. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21675. /**
  21676. * Connect current block with another block
  21677. * @param other defines the block to connect with
  21678. * @param options define the various options to help pick the right connections
  21679. * @returns the current block
  21680. */
  21681. connectTo(other: NodeMaterialBlock, options?: {
  21682. input?: string;
  21683. output?: string;
  21684. outputSwizzle?: string;
  21685. }): this | undefined;
  21686. protected _buildBlock(state: NodeMaterialBuildState): void;
  21687. /**
  21688. * Add uniforms, samplers and uniform buffers at compilation time
  21689. * @param state defines the state to update
  21690. * @param nodeMaterial defines the node material requesting the update
  21691. * @param defines defines the material defines to update
  21692. * @param uniformBuffers defines the list of uniform buffer names
  21693. */
  21694. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21695. /**
  21696. * Add potential fallbacks if shader compilation fails
  21697. * @param mesh defines the mesh to be rendered
  21698. * @param fallbacks defines the current prioritized list of fallbacks
  21699. */
  21700. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21701. /**
  21702. * Initialize defines for shader compilation
  21703. * @param mesh defines the mesh to be rendered
  21704. * @param nodeMaterial defines the node material requesting the update
  21705. * @param defines defines the material defines to update
  21706. * @param useInstances specifies that instances should be used
  21707. */
  21708. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21709. /**
  21710. * Update defines for shader compilation
  21711. * @param mesh defines the mesh to be rendered
  21712. * @param nodeMaterial defines the node material requesting the update
  21713. * @param defines defines the material defines to update
  21714. * @param useInstances specifies that instances should be used
  21715. * @param subMesh defines which submesh to render
  21716. */
  21717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21718. /**
  21719. * Lets the block try to connect some inputs automatically
  21720. * @param material defines the hosting NodeMaterial
  21721. */
  21722. autoConfigure(material: NodeMaterial): void;
  21723. /**
  21724. * Function called when a block is declared as repeatable content generator
  21725. * @param vertexShaderState defines the current compilation state for the vertex shader
  21726. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21727. * @param mesh defines the mesh to be rendered
  21728. * @param defines defines the material defines to update
  21729. */
  21730. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21731. /**
  21732. * Checks if the block is ready
  21733. * @param mesh defines the mesh to be rendered
  21734. * @param nodeMaterial defines the node material requesting the update
  21735. * @param defines defines the material defines to update
  21736. * @param useInstances specifies that instances should be used
  21737. * @returns true if the block is ready
  21738. */
  21739. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21740. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21741. private _processBuild;
  21742. /**
  21743. * Validates the new name for the block node.
  21744. * @param newName the new name to be given to the node.
  21745. * @returns false if the name is a reserve word, else true.
  21746. */
  21747. validateBlockName(newName: string): boolean;
  21748. /**
  21749. * Compile the current node and generate the shader code
  21750. * @param state defines the current compilation state (uniforms, samplers, current string)
  21751. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21752. * @returns true if already built
  21753. */
  21754. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21755. protected _inputRename(name: string): string;
  21756. protected _outputRename(name: string): string;
  21757. protected _dumpPropertiesCode(): string;
  21758. /** @hidden */
  21759. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21760. /** @hidden */
  21761. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21762. /**
  21763. * Clone the current block to a new identical block
  21764. * @param scene defines the hosting scene
  21765. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21766. * @returns a copy of the current block
  21767. */
  21768. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21769. /**
  21770. * Serializes this block in a JSON representation
  21771. * @returns the serialized block object
  21772. */
  21773. serialize(): any;
  21774. /** @hidden */
  21775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21776. private _deserializePortDisplayNamesAndExposedOnFrame;
  21777. /**
  21778. * Release resources
  21779. */
  21780. dispose(): void;
  21781. }
  21782. }
  21783. declare module BABYLON {
  21784. /**
  21785. * Base class of materials working in push mode in babylon JS
  21786. * @hidden
  21787. */
  21788. export class PushMaterial extends Material {
  21789. protected _activeEffect: Effect;
  21790. protected _normalMatrix: Matrix;
  21791. constructor(name: string, scene: Scene);
  21792. getEffect(): Effect;
  21793. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21794. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21795. /**
  21796. * Binds the given world matrix to the active effect
  21797. *
  21798. * @param world the matrix to bind
  21799. */
  21800. bindOnlyWorldMatrix(world: Matrix): void;
  21801. /**
  21802. * Binds the given normal matrix to the active effect
  21803. *
  21804. * @param normalMatrix the matrix to bind
  21805. */
  21806. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21807. bind(world: Matrix, mesh?: Mesh): void;
  21808. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21809. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21810. }
  21811. }
  21812. declare module BABYLON {
  21813. /**
  21814. * Root class for all node material optimizers
  21815. */
  21816. export class NodeMaterialOptimizer {
  21817. /**
  21818. * Function used to optimize a NodeMaterial graph
  21819. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21820. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21821. */
  21822. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21823. }
  21824. }
  21825. declare module BABYLON {
  21826. /**
  21827. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21828. */
  21829. export class TransformBlock extends NodeMaterialBlock {
  21830. /**
  21831. * Defines the value to use to complement W value to transform it to a Vector4
  21832. */
  21833. complementW: number;
  21834. /**
  21835. * Defines the value to use to complement z value to transform it to a Vector4
  21836. */
  21837. complementZ: number;
  21838. /**
  21839. * Creates a new TransformBlock
  21840. * @param name defines the block name
  21841. */
  21842. constructor(name: string);
  21843. /**
  21844. * Gets the current class name
  21845. * @returns the class name
  21846. */
  21847. getClassName(): string;
  21848. /**
  21849. * Gets the vector input
  21850. */
  21851. get vector(): NodeMaterialConnectionPoint;
  21852. /**
  21853. * Gets the output component
  21854. */
  21855. get output(): NodeMaterialConnectionPoint;
  21856. /**
  21857. * Gets the xyz output component
  21858. */
  21859. get xyz(): NodeMaterialConnectionPoint;
  21860. /**
  21861. * Gets the matrix transform input
  21862. */
  21863. get transform(): NodeMaterialConnectionPoint;
  21864. protected _buildBlock(state: NodeMaterialBuildState): this;
  21865. /**
  21866. * Update defines for shader compilation
  21867. * @param mesh defines the mesh to be rendered
  21868. * @param nodeMaterial defines the node material requesting the update
  21869. * @param defines defines the material defines to update
  21870. * @param useInstances specifies that instances should be used
  21871. * @param subMesh defines which submesh to render
  21872. */
  21873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21874. serialize(): any;
  21875. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21876. protected _dumpPropertiesCode(): string;
  21877. }
  21878. }
  21879. declare module BABYLON {
  21880. /**
  21881. * Block used to output the vertex position
  21882. */
  21883. export class VertexOutputBlock extends NodeMaterialBlock {
  21884. /**
  21885. * Creates a new VertexOutputBlock
  21886. * @param name defines the block name
  21887. */
  21888. constructor(name: string);
  21889. /**
  21890. * Gets the current class name
  21891. * @returns the class name
  21892. */
  21893. getClassName(): string;
  21894. /**
  21895. * Gets the vector input component
  21896. */
  21897. get vector(): NodeMaterialConnectionPoint;
  21898. protected _buildBlock(state: NodeMaterialBuildState): this;
  21899. }
  21900. }
  21901. declare module BABYLON {
  21902. /**
  21903. * Block used to output the final color
  21904. */
  21905. export class FragmentOutputBlock extends NodeMaterialBlock {
  21906. /**
  21907. * Create a new FragmentOutputBlock
  21908. * @param name defines the block name
  21909. */
  21910. constructor(name: string);
  21911. /**
  21912. * Gets the current class name
  21913. * @returns the class name
  21914. */
  21915. getClassName(): string;
  21916. /**
  21917. * Gets the rgba input component
  21918. */
  21919. get rgba(): NodeMaterialConnectionPoint;
  21920. /**
  21921. * Gets the rgb input component
  21922. */
  21923. get rgb(): NodeMaterialConnectionPoint;
  21924. /**
  21925. * Gets the a input component
  21926. */
  21927. get a(): NodeMaterialConnectionPoint;
  21928. protected _buildBlock(state: NodeMaterialBuildState): this;
  21929. }
  21930. }
  21931. declare module BABYLON {
  21932. /**
  21933. * Block used for the particle ramp gradient section
  21934. */
  21935. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21936. /**
  21937. * Create a new ParticleRampGradientBlock
  21938. * @param name defines the block name
  21939. */
  21940. constructor(name: string);
  21941. /**
  21942. * Gets the current class name
  21943. * @returns the class name
  21944. */
  21945. getClassName(): string;
  21946. /**
  21947. * Gets the color input component
  21948. */
  21949. get color(): NodeMaterialConnectionPoint;
  21950. /**
  21951. * Gets the rampColor output component
  21952. */
  21953. get rampColor(): NodeMaterialConnectionPoint;
  21954. /**
  21955. * Initialize the block and prepare the context for build
  21956. * @param state defines the state that will be used for the build
  21957. */
  21958. initialize(state: NodeMaterialBuildState): void;
  21959. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21960. }
  21961. }
  21962. declare module BABYLON {
  21963. /**
  21964. * Block used for the particle blend multiply section
  21965. */
  21966. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21967. /**
  21968. * Create a new ParticleBlendMultiplyBlock
  21969. * @param name defines the block name
  21970. */
  21971. constructor(name: string);
  21972. /**
  21973. * Gets the current class name
  21974. * @returns the class name
  21975. */
  21976. getClassName(): string;
  21977. /**
  21978. * Gets the color input component
  21979. */
  21980. get color(): NodeMaterialConnectionPoint;
  21981. /**
  21982. * Gets the alphaTexture input component
  21983. */
  21984. get alphaTexture(): NodeMaterialConnectionPoint;
  21985. /**
  21986. * Gets the alphaColor input component
  21987. */
  21988. get alphaColor(): NodeMaterialConnectionPoint;
  21989. /**
  21990. * Gets the blendColor output component
  21991. */
  21992. get blendColor(): NodeMaterialConnectionPoint;
  21993. /**
  21994. * Initialize the block and prepare the context for build
  21995. * @param state defines the state that will be used for the build
  21996. */
  21997. initialize(state: NodeMaterialBuildState): void;
  21998. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21999. }
  22000. }
  22001. declare module BABYLON {
  22002. /**
  22003. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22004. */
  22005. export class VectorMergerBlock extends NodeMaterialBlock {
  22006. /**
  22007. * Create a new VectorMergerBlock
  22008. * @param name defines the block name
  22009. */
  22010. constructor(name: string);
  22011. /**
  22012. * Gets the current class name
  22013. * @returns the class name
  22014. */
  22015. getClassName(): string;
  22016. /**
  22017. * Gets the xyz component (input)
  22018. */
  22019. get xyzIn(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the xy component (input)
  22022. */
  22023. get xyIn(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the x component (input)
  22026. */
  22027. get x(): NodeMaterialConnectionPoint;
  22028. /**
  22029. * Gets the y component (input)
  22030. */
  22031. get y(): NodeMaterialConnectionPoint;
  22032. /**
  22033. * Gets the z component (input)
  22034. */
  22035. get z(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Gets the w component (input)
  22038. */
  22039. get w(): NodeMaterialConnectionPoint;
  22040. /**
  22041. * Gets the xyzw component (output)
  22042. */
  22043. get xyzw(): NodeMaterialConnectionPoint;
  22044. /**
  22045. * Gets the xyz component (output)
  22046. */
  22047. get xyzOut(): NodeMaterialConnectionPoint;
  22048. /**
  22049. * Gets the xy component (output)
  22050. */
  22051. get xyOut(): NodeMaterialConnectionPoint;
  22052. /**
  22053. * Gets the xy component (output)
  22054. * @deprecated Please use xyOut instead.
  22055. */
  22056. get xy(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the xyz component (output)
  22059. * @deprecated Please use xyzOut instead.
  22060. */
  22061. get xyz(): NodeMaterialConnectionPoint;
  22062. protected _buildBlock(state: NodeMaterialBuildState): this;
  22063. }
  22064. }
  22065. declare module BABYLON {
  22066. /**
  22067. * Block used to remap a float from a range to a new one
  22068. */
  22069. export class RemapBlock extends NodeMaterialBlock {
  22070. /**
  22071. * Gets or sets the source range
  22072. */
  22073. sourceRange: Vector2;
  22074. /**
  22075. * Gets or sets the target range
  22076. */
  22077. targetRange: Vector2;
  22078. /**
  22079. * Creates a new RemapBlock
  22080. * @param name defines the block name
  22081. */
  22082. constructor(name: string);
  22083. /**
  22084. * Gets the current class name
  22085. * @returns the class name
  22086. */
  22087. getClassName(): string;
  22088. /**
  22089. * Gets the input component
  22090. */
  22091. get input(): NodeMaterialConnectionPoint;
  22092. /**
  22093. * Gets the source min input component
  22094. */
  22095. get sourceMin(): NodeMaterialConnectionPoint;
  22096. /**
  22097. * Gets the source max input component
  22098. */
  22099. get sourceMax(): NodeMaterialConnectionPoint;
  22100. /**
  22101. * Gets the target min input component
  22102. */
  22103. get targetMin(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the target max input component
  22106. */
  22107. get targetMax(): NodeMaterialConnectionPoint;
  22108. /**
  22109. * Gets the output component
  22110. */
  22111. get output(): NodeMaterialConnectionPoint;
  22112. protected _buildBlock(state: NodeMaterialBuildState): this;
  22113. protected _dumpPropertiesCode(): string;
  22114. serialize(): any;
  22115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22116. }
  22117. }
  22118. declare module BABYLON {
  22119. /**
  22120. * Block used to multiply 2 values
  22121. */
  22122. export class MultiplyBlock extends NodeMaterialBlock {
  22123. /**
  22124. * Creates a new MultiplyBlock
  22125. * @param name defines the block name
  22126. */
  22127. constructor(name: string);
  22128. /**
  22129. * Gets the current class name
  22130. * @returns the class name
  22131. */
  22132. getClassName(): string;
  22133. /**
  22134. * Gets the left operand input component
  22135. */
  22136. get left(): NodeMaterialConnectionPoint;
  22137. /**
  22138. * Gets the right operand input component
  22139. */
  22140. get right(): NodeMaterialConnectionPoint;
  22141. /**
  22142. * Gets the output component
  22143. */
  22144. get output(): NodeMaterialConnectionPoint;
  22145. protected _buildBlock(state: NodeMaterialBuildState): this;
  22146. }
  22147. }
  22148. declare module BABYLON {
  22149. /**
  22150. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22151. */
  22152. export class ColorSplitterBlock extends NodeMaterialBlock {
  22153. /**
  22154. * Create a new ColorSplitterBlock
  22155. * @param name defines the block name
  22156. */
  22157. constructor(name: string);
  22158. /**
  22159. * Gets the current class name
  22160. * @returns the class name
  22161. */
  22162. getClassName(): string;
  22163. /**
  22164. * Gets the rgba component (input)
  22165. */
  22166. get rgba(): NodeMaterialConnectionPoint;
  22167. /**
  22168. * Gets the rgb component (input)
  22169. */
  22170. get rgbIn(): NodeMaterialConnectionPoint;
  22171. /**
  22172. * Gets the rgb component (output)
  22173. */
  22174. get rgbOut(): NodeMaterialConnectionPoint;
  22175. /**
  22176. * Gets the r component (output)
  22177. */
  22178. get r(): NodeMaterialConnectionPoint;
  22179. /**
  22180. * Gets the g component (output)
  22181. */
  22182. get g(): NodeMaterialConnectionPoint;
  22183. /**
  22184. * Gets the b component (output)
  22185. */
  22186. get b(): NodeMaterialConnectionPoint;
  22187. /**
  22188. * Gets the a component (output)
  22189. */
  22190. get a(): NodeMaterialConnectionPoint;
  22191. protected _inputRename(name: string): string;
  22192. protected _outputRename(name: string): string;
  22193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22194. }
  22195. }
  22196. declare module BABYLON {
  22197. /**
  22198. * Interface used to configure the node material editor
  22199. */
  22200. export interface INodeMaterialEditorOptions {
  22201. /** Define the URl to load node editor script */
  22202. editorURL?: string;
  22203. }
  22204. /** @hidden */
  22205. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22206. NORMAL: boolean;
  22207. TANGENT: boolean;
  22208. UV1: boolean;
  22209. /** BONES */
  22210. NUM_BONE_INFLUENCERS: number;
  22211. BonesPerMesh: number;
  22212. BONETEXTURE: boolean;
  22213. /** MORPH TARGETS */
  22214. MORPHTARGETS: boolean;
  22215. MORPHTARGETS_NORMAL: boolean;
  22216. MORPHTARGETS_TANGENT: boolean;
  22217. MORPHTARGETS_UV: boolean;
  22218. NUM_MORPH_INFLUENCERS: number;
  22219. /** IMAGE PROCESSING */
  22220. IMAGEPROCESSING: boolean;
  22221. VIGNETTE: boolean;
  22222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22223. VIGNETTEBLENDMODEOPAQUE: boolean;
  22224. TONEMAPPING: boolean;
  22225. TONEMAPPING_ACES: boolean;
  22226. CONTRAST: boolean;
  22227. EXPOSURE: boolean;
  22228. COLORCURVES: boolean;
  22229. COLORGRADING: boolean;
  22230. COLORGRADING3D: boolean;
  22231. SAMPLER3DGREENDEPTH: boolean;
  22232. SAMPLER3DBGRMAP: boolean;
  22233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22234. /** MISC. */
  22235. BUMPDIRECTUV: number;
  22236. constructor();
  22237. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22238. }
  22239. /**
  22240. * Class used to configure NodeMaterial
  22241. */
  22242. export interface INodeMaterialOptions {
  22243. /**
  22244. * Defines if blocks should emit comments
  22245. */
  22246. emitComments: boolean;
  22247. }
  22248. /**
  22249. * Class used to create a node based material built by assembling shader blocks
  22250. */
  22251. export class NodeMaterial extends PushMaterial {
  22252. private static _BuildIdGenerator;
  22253. private _options;
  22254. private _vertexCompilationState;
  22255. private _fragmentCompilationState;
  22256. private _sharedData;
  22257. private _buildId;
  22258. private _buildWasSuccessful;
  22259. private _cachedWorldViewMatrix;
  22260. private _cachedWorldViewProjectionMatrix;
  22261. private _optimizers;
  22262. private _animationFrame;
  22263. /** Define the Url to load node editor script */
  22264. static EditorURL: string;
  22265. /** Define the Url to load snippets */
  22266. static SnippetUrl: string;
  22267. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22268. static IgnoreTexturesAtLoadTime: boolean;
  22269. private BJSNODEMATERIALEDITOR;
  22270. /** Get the inspector from bundle or global */
  22271. private _getGlobalNodeMaterialEditor;
  22272. /**
  22273. * Snippet ID if the material was created from the snippet server
  22274. */
  22275. snippetId: string;
  22276. /**
  22277. * Gets or sets data used by visual editor
  22278. * @see https://nme.babylonjs.com
  22279. */
  22280. editorData: any;
  22281. /**
  22282. * 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)
  22283. */
  22284. ignoreAlpha: boolean;
  22285. /**
  22286. * Defines the maximum number of lights that can be used in the material
  22287. */
  22288. maxSimultaneousLights: number;
  22289. /**
  22290. * Observable raised when the material is built
  22291. */
  22292. onBuildObservable: Observable<NodeMaterial>;
  22293. /**
  22294. * Gets or sets the root nodes of the material vertex shader
  22295. */
  22296. _vertexOutputNodes: NodeMaterialBlock[];
  22297. /**
  22298. * Gets or sets the root nodes of the material fragment (pixel) shader
  22299. */
  22300. _fragmentOutputNodes: NodeMaterialBlock[];
  22301. /** Gets or sets options to control the node material overall behavior */
  22302. get options(): INodeMaterialOptions;
  22303. set options(options: INodeMaterialOptions);
  22304. /**
  22305. * Default configuration related to image processing available in the standard Material.
  22306. */
  22307. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22308. /**
  22309. * Gets the image processing configuration used either in this material.
  22310. */
  22311. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22312. /**
  22313. * Sets the Default image processing configuration used either in the this material.
  22314. *
  22315. * If sets to null, the scene one is in use.
  22316. */
  22317. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22318. /**
  22319. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22320. */
  22321. attachedBlocks: NodeMaterialBlock[];
  22322. /**
  22323. * Specifies the mode of the node material
  22324. * @hidden
  22325. */
  22326. _mode: NodeMaterialModes;
  22327. /**
  22328. * Gets the mode property
  22329. */
  22330. get mode(): NodeMaterialModes;
  22331. /**
  22332. * Create a new node based material
  22333. * @param name defines the material name
  22334. * @param scene defines the hosting scene
  22335. * @param options defines creation option
  22336. */
  22337. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22338. /**
  22339. * Gets the current class name of the material e.g. "NodeMaterial"
  22340. * @returns the class name
  22341. */
  22342. getClassName(): string;
  22343. /**
  22344. * Keep track of the image processing observer to allow dispose and replace.
  22345. */
  22346. private _imageProcessingObserver;
  22347. /**
  22348. * Attaches a new image processing configuration to the Standard Material.
  22349. * @param configuration
  22350. */
  22351. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22352. /**
  22353. * Get a block by its name
  22354. * @param name defines the name of the block to retrieve
  22355. * @returns the required block or null if not found
  22356. */
  22357. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22358. /**
  22359. * Get a block by its name
  22360. * @param predicate defines the predicate used to find the good candidate
  22361. * @returns the required block or null if not found
  22362. */
  22363. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22364. /**
  22365. * Get an input block by its name
  22366. * @param predicate defines the predicate used to find the good candidate
  22367. * @returns the required input block or null if not found
  22368. */
  22369. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22370. /**
  22371. * Gets the list of input blocks attached to this material
  22372. * @returns an array of InputBlocks
  22373. */
  22374. getInputBlocks(): InputBlock[];
  22375. /**
  22376. * Adds a new optimizer to the list of optimizers
  22377. * @param optimizer defines the optimizers to add
  22378. * @returns the current material
  22379. */
  22380. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22381. /**
  22382. * Remove an optimizer from the list of optimizers
  22383. * @param optimizer defines the optimizers to remove
  22384. * @returns the current material
  22385. */
  22386. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22387. /**
  22388. * Add a new block to the list of output nodes
  22389. * @param node defines the node to add
  22390. * @returns the current material
  22391. */
  22392. addOutputNode(node: NodeMaterialBlock): this;
  22393. /**
  22394. * Remove a block from the list of root nodes
  22395. * @param node defines the node to remove
  22396. * @returns the current material
  22397. */
  22398. removeOutputNode(node: NodeMaterialBlock): this;
  22399. private _addVertexOutputNode;
  22400. private _removeVertexOutputNode;
  22401. private _addFragmentOutputNode;
  22402. private _removeFragmentOutputNode;
  22403. /**
  22404. * Specifies if the material will require alpha blending
  22405. * @returns a boolean specifying if alpha blending is needed
  22406. */
  22407. needAlphaBlending(): boolean;
  22408. /**
  22409. * Specifies if this material should be rendered in alpha test mode
  22410. * @returns a boolean specifying if an alpha test is needed.
  22411. */
  22412. needAlphaTesting(): boolean;
  22413. private _initializeBlock;
  22414. private _resetDualBlocks;
  22415. /**
  22416. * Remove a block from the current node material
  22417. * @param block defines the block to remove
  22418. */
  22419. removeBlock(block: NodeMaterialBlock): void;
  22420. /**
  22421. * Build the material and generates the inner effect
  22422. * @param verbose defines if the build should log activity
  22423. */
  22424. build(verbose?: boolean): void;
  22425. /**
  22426. * Runs an otpimization phase to try to improve the shader code
  22427. */
  22428. optimize(): void;
  22429. private _prepareDefinesForAttributes;
  22430. /**
  22431. * Create a post process from the material
  22432. * @param camera The camera to apply the render pass to.
  22433. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22435. * @param engine The engine which the post process will be applied. (default: current engine)
  22436. * @param reusable If the post process can be reused on the same frame. (default: false)
  22437. * @param textureType Type of textures used when performing the post process. (default: 0)
  22438. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22439. * @returns the post process created
  22440. */
  22441. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22442. /**
  22443. * Create the post process effect from the material
  22444. * @param postProcess The post process to create the effect for
  22445. */
  22446. createEffectForPostProcess(postProcess: PostProcess): void;
  22447. private _createEffectOrPostProcess;
  22448. private _createEffectForParticles;
  22449. /**
  22450. * Create the effect to be used as the custom effect for a particle system
  22451. * @param particleSystem Particle system to create the effect for
  22452. * @param onCompiled defines a function to call when the effect creation is successful
  22453. * @param onError defines a function to call when the effect creation has failed
  22454. */
  22455. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22456. private _processDefines;
  22457. /**
  22458. * Get if the submesh is ready to be used and all its information available.
  22459. * Child classes can use it to update shaders
  22460. * @param mesh defines the mesh to check
  22461. * @param subMesh defines which submesh to check
  22462. * @param useInstances specifies that instances should be used
  22463. * @returns a boolean indicating that the submesh is ready or not
  22464. */
  22465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22466. /**
  22467. * Get a string representing the shaders built by the current node graph
  22468. */
  22469. get compiledShaders(): string;
  22470. /**
  22471. * Binds the world matrix to the material
  22472. * @param world defines the world transformation matrix
  22473. */
  22474. bindOnlyWorldMatrix(world: Matrix): void;
  22475. /**
  22476. * Binds the submesh to this material by preparing the effect and shader to draw
  22477. * @param world defines the world transformation matrix
  22478. * @param mesh defines the mesh containing the submesh
  22479. * @param subMesh defines the submesh to bind the material to
  22480. */
  22481. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22482. /**
  22483. * Gets the active textures from the material
  22484. * @returns an array of textures
  22485. */
  22486. getActiveTextures(): BaseTexture[];
  22487. /**
  22488. * Gets the list of texture blocks
  22489. * @returns an array of texture blocks
  22490. */
  22491. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22492. /**
  22493. * Specifies if the material uses a texture
  22494. * @param texture defines the texture to check against the material
  22495. * @returns a boolean specifying if the material uses the texture
  22496. */
  22497. hasTexture(texture: BaseTexture): boolean;
  22498. /**
  22499. * Disposes the material
  22500. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22501. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22502. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22503. */
  22504. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22505. /** Creates the node editor window. */
  22506. private _createNodeEditor;
  22507. /**
  22508. * Launch the node material editor
  22509. * @param config Define the configuration of the editor
  22510. * @return a promise fulfilled when the node editor is visible
  22511. */
  22512. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22513. /**
  22514. * Clear the current material
  22515. */
  22516. clear(): void;
  22517. /**
  22518. * Clear the current material and set it to a default state
  22519. */
  22520. setToDefault(): void;
  22521. /**
  22522. * Clear the current material and set it to a default state for post process
  22523. */
  22524. setToDefaultPostProcess(): void;
  22525. /**
  22526. * Clear the current material and set it to a default state for particle
  22527. */
  22528. setToDefaultParticle(): void;
  22529. /**
  22530. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22531. * @param url defines the url to load from
  22532. * @returns a promise that will fullfil when the material is fully loaded
  22533. */
  22534. loadAsync(url: string): Promise<void>;
  22535. private _gatherBlocks;
  22536. /**
  22537. * Generate a string containing the code declaration required to create an equivalent of this material
  22538. * @returns a string
  22539. */
  22540. generateCode(): string;
  22541. /**
  22542. * Serializes this material in a JSON representation
  22543. * @returns the serialized material object
  22544. */
  22545. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22546. private _restoreConnections;
  22547. /**
  22548. * Clear the current graph and load a new one from a serialization object
  22549. * @param source defines the JSON representation of the material
  22550. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22551. * @param merge defines whether or not the source must be merged or replace the current content
  22552. */
  22553. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22554. /**
  22555. * Makes a duplicate of the current material.
  22556. * @param name - name to use for the new material.
  22557. */
  22558. clone(name: string): NodeMaterial;
  22559. /**
  22560. * Creates a node material from parsed material data
  22561. * @param source defines the JSON representation of the material
  22562. * @param scene defines the hosting scene
  22563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22564. * @returns a new node material
  22565. */
  22566. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22567. /**
  22568. * Creates a node material from a snippet saved in a remote file
  22569. * @param name defines the name of the material to create
  22570. * @param url defines the url to load from
  22571. * @param scene defines the hosting scene
  22572. * @returns a promise that will resolve to the new node material
  22573. */
  22574. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22575. /**
  22576. * Creates a node material from a snippet saved by the node material editor
  22577. * @param snippetId defines the snippet to load
  22578. * @param scene defines the hosting scene
  22579. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22580. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22581. * @returns a promise that will resolve to the new node material
  22582. */
  22583. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22584. /**
  22585. * Creates a new node material set to default basic configuration
  22586. * @param name defines the name of the material
  22587. * @param scene defines the hosting scene
  22588. * @returns a new NodeMaterial
  22589. */
  22590. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22591. }
  22592. }
  22593. declare module BABYLON {
  22594. /**
  22595. * Size options for a post process
  22596. */
  22597. export type PostProcessOptions = {
  22598. width: number;
  22599. height: number;
  22600. };
  22601. /**
  22602. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22603. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22604. */
  22605. export class PostProcess {
  22606. /**
  22607. * Gets or sets the unique id of the post process
  22608. */
  22609. uniqueId: number;
  22610. /** Name of the PostProcess. */
  22611. name: string;
  22612. /**
  22613. * Width of the texture to apply the post process on
  22614. */
  22615. width: number;
  22616. /**
  22617. * Height of the texture to apply the post process on
  22618. */
  22619. height: number;
  22620. /**
  22621. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22622. */
  22623. nodeMaterialSource: Nullable<NodeMaterial>;
  22624. /**
  22625. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22626. * @hidden
  22627. */
  22628. _outputTexture: Nullable<InternalTexture>;
  22629. /**
  22630. * Sampling mode used by the shader
  22631. * See https://doc.babylonjs.com/classes/3.1/texture
  22632. */
  22633. renderTargetSamplingMode: number;
  22634. /**
  22635. * Clear color to use when screen clearing
  22636. */
  22637. clearColor: Color4;
  22638. /**
  22639. * If the buffer needs to be cleared before applying the post process. (default: true)
  22640. * Should be set to false if shader will overwrite all previous pixels.
  22641. */
  22642. autoClear: boolean;
  22643. /**
  22644. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22645. */
  22646. alphaMode: number;
  22647. /**
  22648. * Sets the setAlphaBlendConstants of the babylon engine
  22649. */
  22650. alphaConstants: Color4;
  22651. /**
  22652. * Animations to be used for the post processing
  22653. */
  22654. animations: Animation[];
  22655. /**
  22656. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22657. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22658. */
  22659. enablePixelPerfectMode: boolean;
  22660. /**
  22661. * Force the postprocess to be applied without taking in account viewport
  22662. */
  22663. forceFullscreenViewport: boolean;
  22664. /**
  22665. * List of inspectable custom properties (used by the Inspector)
  22666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22667. */
  22668. inspectableCustomProperties: IInspectable[];
  22669. /**
  22670. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22671. *
  22672. * | Value | Type | Description |
  22673. * | ----- | ----------------------------------- | ----------- |
  22674. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22675. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22676. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22677. *
  22678. */
  22679. scaleMode: number;
  22680. /**
  22681. * Force textures to be a power of two (default: false)
  22682. */
  22683. alwaysForcePOT: boolean;
  22684. private _samples;
  22685. /**
  22686. * Number of sample textures (default: 1)
  22687. */
  22688. get samples(): number;
  22689. set samples(n: number);
  22690. /**
  22691. * Modify the scale of the post process to be the same as the viewport (default: false)
  22692. */
  22693. adaptScaleToCurrentViewport: boolean;
  22694. private _camera;
  22695. protected _scene: Scene;
  22696. private _engine;
  22697. private _options;
  22698. private _reusable;
  22699. private _textureType;
  22700. private _textureFormat;
  22701. /**
  22702. * Smart array of input and output textures for the post process.
  22703. * @hidden
  22704. */
  22705. _textures: SmartArray<InternalTexture>;
  22706. /**
  22707. * The index in _textures that corresponds to the output texture.
  22708. * @hidden
  22709. */
  22710. _currentRenderTextureInd: number;
  22711. private _effect;
  22712. private _samplers;
  22713. private _fragmentUrl;
  22714. private _vertexUrl;
  22715. private _parameters;
  22716. private _scaleRatio;
  22717. protected _indexParameters: any;
  22718. private _shareOutputWithPostProcess;
  22719. private _texelSize;
  22720. private _forcedOutputTexture;
  22721. /**
  22722. * Returns the fragment url or shader name used in the post process.
  22723. * @returns the fragment url or name in the shader store.
  22724. */
  22725. getEffectName(): string;
  22726. /**
  22727. * An event triggered when the postprocess is activated.
  22728. */
  22729. onActivateObservable: Observable<Camera>;
  22730. private _onActivateObserver;
  22731. /**
  22732. * A function that is added to the onActivateObservable
  22733. */
  22734. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22735. /**
  22736. * An event triggered when the postprocess changes its size.
  22737. */
  22738. onSizeChangedObservable: Observable<PostProcess>;
  22739. private _onSizeChangedObserver;
  22740. /**
  22741. * A function that is added to the onSizeChangedObservable
  22742. */
  22743. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22744. /**
  22745. * An event triggered when the postprocess applies its effect.
  22746. */
  22747. onApplyObservable: Observable<Effect>;
  22748. private _onApplyObserver;
  22749. /**
  22750. * A function that is added to the onApplyObservable
  22751. */
  22752. set onApply(callback: (effect: Effect) => void);
  22753. /**
  22754. * An event triggered before rendering the postprocess
  22755. */
  22756. onBeforeRenderObservable: Observable<Effect>;
  22757. private _onBeforeRenderObserver;
  22758. /**
  22759. * A function that is added to the onBeforeRenderObservable
  22760. */
  22761. set onBeforeRender(callback: (effect: Effect) => void);
  22762. /**
  22763. * An event triggered after rendering the postprocess
  22764. */
  22765. onAfterRenderObservable: Observable<Effect>;
  22766. private _onAfterRenderObserver;
  22767. /**
  22768. * A function that is added to the onAfterRenderObservable
  22769. */
  22770. set onAfterRender(callback: (efect: Effect) => void);
  22771. /**
  22772. * 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
  22773. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22774. */
  22775. get inputTexture(): InternalTexture;
  22776. set inputTexture(value: InternalTexture);
  22777. /**
  22778. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22779. * the only way to unset it is to use this function to restore its internal state
  22780. */
  22781. restoreDefaultInputTexture(): void;
  22782. /**
  22783. * Gets the camera which post process is applied to.
  22784. * @returns The camera the post process is applied to.
  22785. */
  22786. getCamera(): Camera;
  22787. /**
  22788. * Gets the texel size of the postprocess.
  22789. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22790. */
  22791. get texelSize(): Vector2;
  22792. /**
  22793. * Creates a new instance PostProcess
  22794. * @param name The name of the PostProcess.
  22795. * @param fragmentUrl The url of the fragment shader to be used.
  22796. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22797. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22798. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22799. * @param camera The camera to apply the render pass to.
  22800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22801. * @param engine The engine which the post process will be applied. (default: current engine)
  22802. * @param reusable If the post process can be reused on the same frame. (default: false)
  22803. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22804. * @param textureType Type of textures used when performing the post process. (default: 0)
  22805. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22806. * @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
  22807. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22808. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22809. */
  22810. 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);
  22811. /**
  22812. * Gets a string identifying the name of the class
  22813. * @returns "PostProcess" string
  22814. */
  22815. getClassName(): string;
  22816. /**
  22817. * Gets the engine which this post process belongs to.
  22818. * @returns The engine the post process was enabled with.
  22819. */
  22820. getEngine(): Engine;
  22821. /**
  22822. * The effect that is created when initializing the post process.
  22823. * @returns The created effect corresponding the the postprocess.
  22824. */
  22825. getEffect(): Effect;
  22826. /**
  22827. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22828. * @param postProcess The post process to share the output with.
  22829. * @returns This post process.
  22830. */
  22831. shareOutputWith(postProcess: PostProcess): PostProcess;
  22832. /**
  22833. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22834. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22835. */
  22836. useOwnOutput(): void;
  22837. /**
  22838. * Updates the effect with the current post process compile time values and recompiles the shader.
  22839. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22840. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22841. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22842. * @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
  22843. * @param onCompiled Called when the shader has been compiled.
  22844. * @param onError Called if there is an error when compiling a shader.
  22845. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22846. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22847. */
  22848. 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;
  22849. /**
  22850. * The post process is reusable if it can be used multiple times within one frame.
  22851. * @returns If the post process is reusable
  22852. */
  22853. isReusable(): boolean;
  22854. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22855. markTextureDirty(): void;
  22856. /**
  22857. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22858. * 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.
  22859. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22860. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22861. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22862. * @returns The target texture that was bound to be written to.
  22863. */
  22864. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22865. /**
  22866. * If the post process is supported.
  22867. */
  22868. get isSupported(): boolean;
  22869. /**
  22870. * The aspect ratio of the output texture.
  22871. */
  22872. get aspectRatio(): number;
  22873. /**
  22874. * Get a value indicating if the post-process is ready to be used
  22875. * @returns true if the post-process is ready (shader is compiled)
  22876. */
  22877. isReady(): boolean;
  22878. /**
  22879. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22880. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22881. */
  22882. apply(): Nullable<Effect>;
  22883. private _disposeTextures;
  22884. /**
  22885. * Disposes the post process.
  22886. * @param camera The camera to dispose the post process on.
  22887. */
  22888. dispose(camera?: Camera): void;
  22889. /**
  22890. * Serializes the particle system to a JSON object
  22891. * @returns the JSON object
  22892. */
  22893. serialize(): any;
  22894. /**
  22895. * Creates a material from parsed material data
  22896. * @param parsedPostProcess defines parsed post process data
  22897. * @param scene defines the hosting scene
  22898. * @param rootUrl defines the root URL to use to load textures
  22899. * @returns a new post process
  22900. */
  22901. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22902. }
  22903. }
  22904. declare module BABYLON {
  22905. /** @hidden */
  22906. export var kernelBlurVaryingDeclaration: {
  22907. name: string;
  22908. shader: string;
  22909. };
  22910. }
  22911. declare module BABYLON {
  22912. /** @hidden */
  22913. export var kernelBlurFragment: {
  22914. name: string;
  22915. shader: string;
  22916. };
  22917. }
  22918. declare module BABYLON {
  22919. /** @hidden */
  22920. export var kernelBlurFragment2: {
  22921. name: string;
  22922. shader: string;
  22923. };
  22924. }
  22925. declare module BABYLON {
  22926. /** @hidden */
  22927. export var kernelBlurPixelShader: {
  22928. name: string;
  22929. shader: string;
  22930. };
  22931. }
  22932. declare module BABYLON {
  22933. /** @hidden */
  22934. export var kernelBlurVertex: {
  22935. name: string;
  22936. shader: string;
  22937. };
  22938. }
  22939. declare module BABYLON {
  22940. /** @hidden */
  22941. export var kernelBlurVertexShader: {
  22942. name: string;
  22943. shader: string;
  22944. };
  22945. }
  22946. declare module BABYLON {
  22947. /**
  22948. * The Blur Post Process which blurs an image based on a kernel and direction.
  22949. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22950. */
  22951. export class BlurPostProcess extends PostProcess {
  22952. private blockCompilation;
  22953. protected _kernel: number;
  22954. protected _idealKernel: number;
  22955. protected _packedFloat: boolean;
  22956. private _staticDefines;
  22957. /** The direction in which to blur the image. */
  22958. direction: Vector2;
  22959. /**
  22960. * Sets the length in pixels of the blur sample region
  22961. */
  22962. set kernel(v: number);
  22963. /**
  22964. * Gets the length in pixels of the blur sample region
  22965. */
  22966. get kernel(): number;
  22967. /**
  22968. * Sets wether or not the blur needs to unpack/repack floats
  22969. */
  22970. set packedFloat(v: boolean);
  22971. /**
  22972. * Gets wether or not the blur is unpacking/repacking floats
  22973. */
  22974. get packedFloat(): boolean;
  22975. /**
  22976. * Gets a string identifying the name of the class
  22977. * @returns "BlurPostProcess" string
  22978. */
  22979. getClassName(): string;
  22980. /**
  22981. * Creates a new instance BlurPostProcess
  22982. * @param name The name of the effect.
  22983. * @param direction The direction in which to blur the image.
  22984. * @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.
  22985. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22986. * @param camera The camera to apply the render pass to.
  22987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22988. * @param engine The engine which the post process will be applied. (default: current engine)
  22989. * @param reusable If the post process can be reused on the same frame. (default: false)
  22990. * @param textureType Type of textures used when performing the post process. (default: 0)
  22991. * @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)
  22992. */
  22993. 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);
  22994. /**
  22995. * Updates the effect with the current post process compile time values and recompiles the shader.
  22996. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22997. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22998. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22999. * @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
  23000. * @param onCompiled Called when the shader has been compiled.
  23001. * @param onError Called if there is an error when compiling a shader.
  23002. */
  23003. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23004. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23005. /**
  23006. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23007. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23008. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23009. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23010. * The gaps between physical kernels are compensated for in the weighting of the samples
  23011. * @param idealKernel Ideal blur kernel.
  23012. * @return Nearest best kernel.
  23013. */
  23014. protected _nearestBestKernel(idealKernel: number): number;
  23015. /**
  23016. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23017. * @param x The point on the Gaussian distribution to sample.
  23018. * @return the value of the Gaussian function at x.
  23019. */
  23020. protected _gaussianWeight(x: number): number;
  23021. /**
  23022. * Generates a string that can be used as a floating point number in GLSL.
  23023. * @param x Value to print.
  23024. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23025. * @return GLSL float string.
  23026. */
  23027. protected _glslFloat(x: number, decimalFigures?: number): string;
  23028. /** @hidden */
  23029. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23030. }
  23031. }
  23032. declare module BABYLON {
  23033. /**
  23034. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23035. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23036. * You can then easily use it as a reflectionTexture on a flat surface.
  23037. * In case the surface is not a plane, please consider relying on reflection probes.
  23038. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23039. */
  23040. export class MirrorTexture extends RenderTargetTexture {
  23041. private scene;
  23042. /**
  23043. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23044. * 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.
  23045. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23046. */
  23047. mirrorPlane: Plane;
  23048. /**
  23049. * Define the blur ratio used to blur the reflection if needed.
  23050. */
  23051. set blurRatio(value: number);
  23052. get blurRatio(): number;
  23053. /**
  23054. * Define the adaptive blur kernel used to blur the reflection if needed.
  23055. * This will autocompute the closest best match for the `blurKernel`
  23056. */
  23057. set adaptiveBlurKernel(value: number);
  23058. /**
  23059. * Define the blur kernel used to blur the reflection if needed.
  23060. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23061. */
  23062. set blurKernel(value: number);
  23063. /**
  23064. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23065. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23066. */
  23067. set blurKernelX(value: number);
  23068. get blurKernelX(): number;
  23069. /**
  23070. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23071. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23072. */
  23073. set blurKernelY(value: number);
  23074. get blurKernelY(): number;
  23075. private _autoComputeBlurKernel;
  23076. protected _onRatioRescale(): void;
  23077. private _updateGammaSpace;
  23078. private _imageProcessingConfigChangeObserver;
  23079. private _transformMatrix;
  23080. private _mirrorMatrix;
  23081. private _savedViewMatrix;
  23082. private _blurX;
  23083. private _blurY;
  23084. private _adaptiveBlurKernel;
  23085. private _blurKernelX;
  23086. private _blurKernelY;
  23087. private _blurRatio;
  23088. /**
  23089. * Instantiates a Mirror Texture.
  23090. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23091. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23092. * You can then easily use it as a reflectionTexture on a flat surface.
  23093. * In case the surface is not a plane, please consider relying on reflection probes.
  23094. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23095. * @param name
  23096. * @param size
  23097. * @param scene
  23098. * @param generateMipMaps
  23099. * @param type
  23100. * @param samplingMode
  23101. * @param generateDepthBuffer
  23102. */
  23103. constructor(name: string, size: number | {
  23104. width: number;
  23105. height: number;
  23106. } | {
  23107. ratio: number;
  23108. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23109. private _preparePostProcesses;
  23110. /**
  23111. * Clone the mirror texture.
  23112. * @returns the cloned texture
  23113. */
  23114. clone(): MirrorTexture;
  23115. /**
  23116. * Serialize the texture to a JSON representation you could use in Parse later on
  23117. * @returns the serialized JSON representation
  23118. */
  23119. serialize(): any;
  23120. /**
  23121. * Dispose the texture and release its associated resources.
  23122. */
  23123. dispose(): void;
  23124. }
  23125. }
  23126. declare module BABYLON {
  23127. /**
  23128. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23129. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23130. */
  23131. export class Texture extends BaseTexture {
  23132. /**
  23133. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23134. */
  23135. static SerializeBuffers: boolean;
  23136. /** @hidden */
  23137. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23138. /** @hidden */
  23139. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23140. /** @hidden */
  23141. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23142. /** nearest is mag = nearest and min = nearest and mip = linear */
  23143. static readonly NEAREST_SAMPLINGMODE: number;
  23144. /** nearest is mag = nearest and min = nearest and mip = linear */
  23145. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23146. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23147. static readonly BILINEAR_SAMPLINGMODE: number;
  23148. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23149. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23150. /** Trilinear is mag = linear and min = linear and mip = linear */
  23151. static readonly TRILINEAR_SAMPLINGMODE: number;
  23152. /** Trilinear is mag = linear and min = linear and mip = linear */
  23153. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23154. /** mag = nearest and min = nearest and mip = nearest */
  23155. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23156. /** mag = nearest and min = linear and mip = nearest */
  23157. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23158. /** mag = nearest and min = linear and mip = linear */
  23159. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23160. /** mag = nearest and min = linear and mip = none */
  23161. static readonly NEAREST_LINEAR: number;
  23162. /** mag = nearest and min = nearest and mip = none */
  23163. static readonly NEAREST_NEAREST: number;
  23164. /** mag = linear and min = nearest and mip = nearest */
  23165. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23166. /** mag = linear and min = nearest and mip = linear */
  23167. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23168. /** mag = linear and min = linear and mip = none */
  23169. static readonly LINEAR_LINEAR: number;
  23170. /** mag = linear and min = nearest and mip = none */
  23171. static readonly LINEAR_NEAREST: number;
  23172. /** Explicit coordinates mode */
  23173. static readonly EXPLICIT_MODE: number;
  23174. /** Spherical coordinates mode */
  23175. static readonly SPHERICAL_MODE: number;
  23176. /** Planar coordinates mode */
  23177. static readonly PLANAR_MODE: number;
  23178. /** Cubic coordinates mode */
  23179. static readonly CUBIC_MODE: number;
  23180. /** Projection coordinates mode */
  23181. static readonly PROJECTION_MODE: number;
  23182. /** Inverse Cubic coordinates mode */
  23183. static readonly SKYBOX_MODE: number;
  23184. /** Inverse Cubic coordinates mode */
  23185. static readonly INVCUBIC_MODE: number;
  23186. /** Equirectangular coordinates mode */
  23187. static readonly EQUIRECTANGULAR_MODE: number;
  23188. /** Equirectangular Fixed coordinates mode */
  23189. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23190. /** Equirectangular Fixed Mirrored coordinates mode */
  23191. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23192. /** Texture is not repeating outside of 0..1 UVs */
  23193. static readonly CLAMP_ADDRESSMODE: number;
  23194. /** Texture is repeating outside of 0..1 UVs */
  23195. static readonly WRAP_ADDRESSMODE: number;
  23196. /** Texture is repeating and mirrored */
  23197. static readonly MIRROR_ADDRESSMODE: number;
  23198. /**
  23199. * 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
  23200. */
  23201. static UseSerializedUrlIfAny: boolean;
  23202. /**
  23203. * Define the url of the texture.
  23204. */
  23205. url: Nullable<string>;
  23206. /**
  23207. * Define an offset on the texture to offset the u coordinates of the UVs
  23208. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23209. */
  23210. uOffset: number;
  23211. /**
  23212. * Define an offset on the texture to offset the v coordinates of the UVs
  23213. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23214. */
  23215. vOffset: number;
  23216. /**
  23217. * Define an offset on the texture to scale the u coordinates of the UVs
  23218. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23219. */
  23220. uScale: number;
  23221. /**
  23222. * Define an offset on the texture to scale the v coordinates of the UVs
  23223. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23224. */
  23225. vScale: number;
  23226. /**
  23227. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23228. * @see https://doc.babylonjs.com/how_to/more_materials
  23229. */
  23230. uAng: number;
  23231. /**
  23232. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23233. * @see https://doc.babylonjs.com/how_to/more_materials
  23234. */
  23235. vAng: number;
  23236. /**
  23237. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23238. * @see https://doc.babylonjs.com/how_to/more_materials
  23239. */
  23240. wAng: number;
  23241. /**
  23242. * Defines the center of rotation (U)
  23243. */
  23244. uRotationCenter: number;
  23245. /**
  23246. * Defines the center of rotation (V)
  23247. */
  23248. vRotationCenter: number;
  23249. /**
  23250. * Defines the center of rotation (W)
  23251. */
  23252. wRotationCenter: number;
  23253. /**
  23254. * Are mip maps generated for this texture or not.
  23255. */
  23256. get noMipmap(): boolean;
  23257. /**
  23258. * List of inspectable custom properties (used by the Inspector)
  23259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23260. */
  23261. inspectableCustomProperties: Nullable<IInspectable[]>;
  23262. private _noMipmap;
  23263. /** @hidden */
  23264. _invertY: boolean;
  23265. private _rowGenerationMatrix;
  23266. private _cachedTextureMatrix;
  23267. private _projectionModeMatrix;
  23268. private _t0;
  23269. private _t1;
  23270. private _t2;
  23271. private _cachedUOffset;
  23272. private _cachedVOffset;
  23273. private _cachedUScale;
  23274. private _cachedVScale;
  23275. private _cachedUAng;
  23276. private _cachedVAng;
  23277. private _cachedWAng;
  23278. private _cachedProjectionMatrixId;
  23279. private _cachedCoordinatesMode;
  23280. /** @hidden */
  23281. protected _initialSamplingMode: number;
  23282. /** @hidden */
  23283. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23284. private _deleteBuffer;
  23285. protected _format: Nullable<number>;
  23286. private _delayedOnLoad;
  23287. private _delayedOnError;
  23288. private _mimeType?;
  23289. /**
  23290. * Observable triggered once the texture has been loaded.
  23291. */
  23292. onLoadObservable: Observable<Texture>;
  23293. protected _isBlocking: boolean;
  23294. /**
  23295. * Is the texture preventing material to render while loading.
  23296. * If false, a default texture will be used instead of the loading one during the preparation step.
  23297. */
  23298. set isBlocking(value: boolean);
  23299. get isBlocking(): boolean;
  23300. /**
  23301. * Get the current sampling mode associated with the texture.
  23302. */
  23303. get samplingMode(): number;
  23304. /**
  23305. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23306. */
  23307. get invertY(): boolean;
  23308. /**
  23309. * Instantiates a new texture.
  23310. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23311. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23312. * @param url defines the url of the picture to load as a texture
  23313. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23314. * @param noMipmap defines if the texture will require mip maps or not
  23315. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23316. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23317. * @param onLoad defines a callback triggered when the texture has been loaded
  23318. * @param onError defines a callback triggered when an error occurred during the loading session
  23319. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23320. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23321. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23322. * @param mimeType defines an optional mime type information
  23323. */
  23324. 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);
  23325. /**
  23326. * Update the url (and optional buffer) of this texture if url was null during construction.
  23327. * @param url the url of the texture
  23328. * @param buffer the buffer of the texture (defaults to null)
  23329. * @param onLoad callback called when the texture is loaded (defaults to null)
  23330. */
  23331. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23332. /**
  23333. * Finish the loading sequence of a texture flagged as delayed load.
  23334. * @hidden
  23335. */
  23336. delayLoad(): void;
  23337. private _prepareRowForTextureGeneration;
  23338. /**
  23339. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23340. * @returns the transform matrix of the texture.
  23341. */
  23342. getTextureMatrix(uBase?: number): Matrix;
  23343. /**
  23344. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23345. * @returns The reflection texture transform
  23346. */
  23347. getReflectionTextureMatrix(): Matrix;
  23348. /**
  23349. * Clones the texture.
  23350. * @returns the cloned texture
  23351. */
  23352. clone(): Texture;
  23353. /**
  23354. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23355. * @returns The JSON representation of the texture
  23356. */
  23357. serialize(): any;
  23358. /**
  23359. * Get the current class name of the texture useful for serialization or dynamic coding.
  23360. * @returns "Texture"
  23361. */
  23362. getClassName(): string;
  23363. /**
  23364. * Dispose the texture and release its associated resources.
  23365. */
  23366. dispose(): void;
  23367. /**
  23368. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23369. * @param parsedTexture Define the JSON representation of the texture
  23370. * @param scene Define the scene the parsed texture should be instantiated in
  23371. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23372. * @returns The parsed texture if successful
  23373. */
  23374. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23375. /**
  23376. * Creates a texture from its base 64 representation.
  23377. * @param data Define the base64 payload without the data: prefix
  23378. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23379. * @param scene Define the scene the texture should belong to
  23380. * @param noMipmap Forces the texture to not create mip map information if true
  23381. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23382. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23383. * @param onLoad define a callback triggered when the texture has been loaded
  23384. * @param onError define a callback triggered when an error occurred during the loading session
  23385. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23386. * @returns the created texture
  23387. */
  23388. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23389. /**
  23390. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23391. * @param data Define the base64 payload without the data: prefix
  23392. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23393. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23394. * @param scene Define the scene the texture should belong to
  23395. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23396. * @param noMipmap Forces the texture to not create mip map information if true
  23397. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23398. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23399. * @param onLoad define a callback triggered when the texture has been loaded
  23400. * @param onError define a callback triggered when an error occurred during the loading session
  23401. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23402. * @returns the created texture
  23403. */
  23404. 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;
  23405. }
  23406. }
  23407. declare module BABYLON {
  23408. /**
  23409. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23410. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23411. */
  23412. export class PostProcessManager {
  23413. private _scene;
  23414. private _indexBuffer;
  23415. private _vertexBuffers;
  23416. /**
  23417. * Creates a new instance PostProcess
  23418. * @param scene The scene that the post process is associated with.
  23419. */
  23420. constructor(scene: Scene);
  23421. private _prepareBuffers;
  23422. private _buildIndexBuffer;
  23423. /**
  23424. * Rebuilds the vertex buffers of the manager.
  23425. * @hidden
  23426. */
  23427. _rebuild(): void;
  23428. /**
  23429. * Prepares a frame to be run through a post process.
  23430. * @param sourceTexture The input texture to the post procesess. (default: null)
  23431. * @param postProcesses An array of post processes to be run. (default: null)
  23432. * @returns True if the post processes were able to be run.
  23433. * @hidden
  23434. */
  23435. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23436. /**
  23437. * Manually render a set of post processes to a texture.
  23438. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23439. * @param postProcesses An array of post processes to be run.
  23440. * @param targetTexture The target texture to render to.
  23441. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23442. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23443. * @param lodLevel defines which lod of the texture to render to
  23444. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23445. */
  23446. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23447. /**
  23448. * Finalize the result of the output of the postprocesses.
  23449. * @param doNotPresent If true the result will not be displayed to the screen.
  23450. * @param targetTexture The target texture to render to.
  23451. * @param faceIndex The index of the face to bind the target texture to.
  23452. * @param postProcesses The array of post processes to render.
  23453. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23454. * @hidden
  23455. */
  23456. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23457. /**
  23458. * Disposes of the post process manager.
  23459. */
  23460. dispose(): void;
  23461. }
  23462. }
  23463. declare module BABYLON {
  23464. /**
  23465. * This Helps creating a texture that will be created from a camera in your scene.
  23466. * It is basically a dynamic texture that could be used to create special effects for instance.
  23467. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23468. */
  23469. export class RenderTargetTexture extends Texture {
  23470. /**
  23471. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23472. */
  23473. static readonly REFRESHRATE_RENDER_ONCE: number;
  23474. /**
  23475. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23476. */
  23477. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23478. /**
  23479. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23480. * the central point of your effect and can save a lot of performances.
  23481. */
  23482. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23483. /**
  23484. * Use this predicate to dynamically define the list of mesh you want to render.
  23485. * If set, the renderList property will be overwritten.
  23486. */
  23487. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23488. private _renderList;
  23489. /**
  23490. * Use this list to define the list of mesh you want to render.
  23491. */
  23492. get renderList(): Nullable<Array<AbstractMesh>>;
  23493. set renderList(value: Nullable<Array<AbstractMesh>>);
  23494. /**
  23495. * Use this function to overload the renderList array at rendering time.
  23496. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23497. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23498. * the cube (if the RTT is a cube, else layerOrFace=0).
  23499. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23500. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23501. * hold dummy elements!
  23502. */
  23503. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23504. private _hookArray;
  23505. /**
  23506. * Define if particles should be rendered in your texture.
  23507. */
  23508. renderParticles: boolean;
  23509. /**
  23510. * Define if sprites should be rendered in your texture.
  23511. */
  23512. renderSprites: boolean;
  23513. /**
  23514. * Define the camera used to render the texture.
  23515. */
  23516. activeCamera: Nullable<Camera>;
  23517. /**
  23518. * Override the mesh isReady function with your own one.
  23519. */
  23520. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23521. /**
  23522. * Override the render function of the texture with your own one.
  23523. */
  23524. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23525. /**
  23526. * Define if camera post processes should be use while rendering the texture.
  23527. */
  23528. useCameraPostProcesses: boolean;
  23529. /**
  23530. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23531. */
  23532. ignoreCameraViewport: boolean;
  23533. private _postProcessManager;
  23534. private _postProcesses;
  23535. private _resizeObserver;
  23536. /**
  23537. * An event triggered when the texture is unbind.
  23538. */
  23539. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23540. /**
  23541. * An event triggered when the texture is unbind.
  23542. */
  23543. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23544. private _onAfterUnbindObserver;
  23545. /**
  23546. * Set a after unbind callback in the texture.
  23547. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23548. */
  23549. set onAfterUnbind(callback: () => void);
  23550. /**
  23551. * An event triggered before rendering the texture
  23552. */
  23553. onBeforeRenderObservable: Observable<number>;
  23554. private _onBeforeRenderObserver;
  23555. /**
  23556. * Set a before render callback in the texture.
  23557. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23558. */
  23559. set onBeforeRender(callback: (faceIndex: number) => void);
  23560. /**
  23561. * An event triggered after rendering the texture
  23562. */
  23563. onAfterRenderObservable: Observable<number>;
  23564. private _onAfterRenderObserver;
  23565. /**
  23566. * Set a after render callback in the texture.
  23567. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23568. */
  23569. set onAfterRender(callback: (faceIndex: number) => void);
  23570. /**
  23571. * An event triggered after the texture clear
  23572. */
  23573. onClearObservable: Observable<Engine>;
  23574. private _onClearObserver;
  23575. /**
  23576. * Set a clear callback in the texture.
  23577. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23578. */
  23579. set onClear(callback: (Engine: Engine) => void);
  23580. /**
  23581. * An event triggered when the texture is resized.
  23582. */
  23583. onResizeObservable: Observable<RenderTargetTexture>;
  23584. /**
  23585. * Define the clear color of the Render Target if it should be different from the scene.
  23586. */
  23587. clearColor: Color4;
  23588. protected _size: number | {
  23589. width: number;
  23590. height: number;
  23591. layers?: number;
  23592. };
  23593. protected _initialSizeParameter: number | {
  23594. width: number;
  23595. height: number;
  23596. } | {
  23597. ratio: number;
  23598. };
  23599. protected _sizeRatio: Nullable<number>;
  23600. /** @hidden */
  23601. _generateMipMaps: boolean;
  23602. protected _renderingManager: RenderingManager;
  23603. /** @hidden */
  23604. _waitingRenderList?: string[];
  23605. protected _doNotChangeAspectRatio: boolean;
  23606. protected _currentRefreshId: number;
  23607. protected _refreshRate: number;
  23608. protected _textureMatrix: Matrix;
  23609. protected _samples: number;
  23610. protected _renderTargetOptions: RenderTargetCreationOptions;
  23611. /**
  23612. * Gets render target creation options that were used.
  23613. */
  23614. get renderTargetOptions(): RenderTargetCreationOptions;
  23615. protected _onRatioRescale(): void;
  23616. /**
  23617. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23618. * It must define where the camera used to render the texture is set
  23619. */
  23620. boundingBoxPosition: Vector3;
  23621. private _boundingBoxSize;
  23622. /**
  23623. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23624. * When defined, the cubemap will switch to local mode
  23625. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23626. * @example https://www.babylonjs-playground.com/#RNASML
  23627. */
  23628. set boundingBoxSize(value: Vector3);
  23629. get boundingBoxSize(): Vector3;
  23630. /**
  23631. * In case the RTT has been created with a depth texture, get the associated
  23632. * depth texture.
  23633. * Otherwise, return null.
  23634. */
  23635. get depthStencilTexture(): Nullable<InternalTexture>;
  23636. /**
  23637. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23638. * or used a shadow, depth texture...
  23639. * @param name The friendly name of the texture
  23640. * @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)
  23641. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23642. * @param generateMipMaps True if mip maps need to be generated after render.
  23643. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23644. * @param type The type of the buffer in the RTT (int, half float, float...)
  23645. * @param isCube True if a cube texture needs to be created
  23646. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23647. * @param generateDepthBuffer True to generate a depth buffer
  23648. * @param generateStencilBuffer True to generate a stencil buffer
  23649. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23650. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23651. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23652. */
  23653. constructor(name: string, size: number | {
  23654. width: number;
  23655. height: number;
  23656. layers?: number;
  23657. } | {
  23658. ratio: number;
  23659. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23660. /**
  23661. * Creates a depth stencil texture.
  23662. * This is only available in WebGL 2 or with the depth texture extension available.
  23663. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23664. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23665. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23666. */
  23667. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23668. private _processSizeParameter;
  23669. /**
  23670. * Define the number of samples to use in case of MSAA.
  23671. * It defaults to one meaning no MSAA has been enabled.
  23672. */
  23673. get samples(): number;
  23674. set samples(value: number);
  23675. /**
  23676. * Resets the refresh counter of the texture and start bak from scratch.
  23677. * Could be useful to regenerate the texture if it is setup to render only once.
  23678. */
  23679. resetRefreshCounter(): void;
  23680. /**
  23681. * Define the refresh rate of the texture or the rendering frequency.
  23682. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23683. */
  23684. get refreshRate(): number;
  23685. set refreshRate(value: number);
  23686. /**
  23687. * Adds a post process to the render target rendering passes.
  23688. * @param postProcess define the post process to add
  23689. */
  23690. addPostProcess(postProcess: PostProcess): void;
  23691. /**
  23692. * Clear all the post processes attached to the render target
  23693. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23694. */
  23695. clearPostProcesses(dispose?: boolean): void;
  23696. /**
  23697. * Remove one of the post process from the list of attached post processes to the texture
  23698. * @param postProcess define the post process to remove from the list
  23699. */
  23700. removePostProcess(postProcess: PostProcess): void;
  23701. /** @hidden */
  23702. _shouldRender(): boolean;
  23703. /**
  23704. * Gets the actual render size of the texture.
  23705. * @returns the width of the render size
  23706. */
  23707. getRenderSize(): number;
  23708. /**
  23709. * Gets the actual render width of the texture.
  23710. * @returns the width of the render size
  23711. */
  23712. getRenderWidth(): number;
  23713. /**
  23714. * Gets the actual render height of the texture.
  23715. * @returns the height of the render size
  23716. */
  23717. getRenderHeight(): number;
  23718. /**
  23719. * Gets the actual number of layers of the texture.
  23720. * @returns the number of layers
  23721. */
  23722. getRenderLayers(): number;
  23723. /**
  23724. * Get if the texture can be rescaled or not.
  23725. */
  23726. get canRescale(): boolean;
  23727. /**
  23728. * Resize the texture using a ratio.
  23729. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23730. */
  23731. scale(ratio: number): void;
  23732. /**
  23733. * Get the texture reflection matrix used to rotate/transform the reflection.
  23734. * @returns the reflection matrix
  23735. */
  23736. getReflectionTextureMatrix(): Matrix;
  23737. /**
  23738. * Resize the texture to a new desired size.
  23739. * Be carrefull as it will recreate all the data in the new texture.
  23740. * @param size Define the new size. It can be:
  23741. * - a number for squared texture,
  23742. * - an object containing { width: number, height: number }
  23743. * - or an object containing a ratio { ratio: number }
  23744. */
  23745. resize(size: number | {
  23746. width: number;
  23747. height: number;
  23748. } | {
  23749. ratio: number;
  23750. }): void;
  23751. private _defaultRenderListPrepared;
  23752. /**
  23753. * Renders all the objects from the render list into the texture.
  23754. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23755. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23756. */
  23757. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23758. private _bestReflectionRenderTargetDimension;
  23759. private _prepareRenderingManager;
  23760. /**
  23761. * @hidden
  23762. * @param faceIndex face index to bind to if this is a cubetexture
  23763. * @param layer defines the index of the texture to bind in the array
  23764. */
  23765. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23766. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23767. private renderToTarget;
  23768. /**
  23769. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23770. * This allowed control for front to back rendering or reversly depending of the special needs.
  23771. *
  23772. * @param renderingGroupId The rendering group id corresponding to its index
  23773. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23774. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23775. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23776. */
  23777. 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;
  23778. /**
  23779. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23780. *
  23781. * @param renderingGroupId The rendering group id corresponding to its index
  23782. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23783. */
  23784. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23785. /**
  23786. * Clones the texture.
  23787. * @returns the cloned texture
  23788. */
  23789. clone(): RenderTargetTexture;
  23790. /**
  23791. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23792. * @returns The JSON representation of the texture
  23793. */
  23794. serialize(): any;
  23795. /**
  23796. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23797. */
  23798. disposeFramebufferObjects(): void;
  23799. /**
  23800. * Dispose the texture and release its associated resources.
  23801. */
  23802. dispose(): void;
  23803. /** @hidden */
  23804. _rebuild(): void;
  23805. /**
  23806. * Clear the info related to rendering groups preventing retention point in material dispose.
  23807. */
  23808. freeRenderingGroups(): void;
  23809. /**
  23810. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23811. * @returns the view count
  23812. */
  23813. getViewCount(): number;
  23814. }
  23815. }
  23816. declare module BABYLON {
  23817. /**
  23818. * Class used to manipulate GUIDs
  23819. */
  23820. export class GUID {
  23821. /**
  23822. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23823. * Be aware Math.random() could cause collisions, but:
  23824. * "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"
  23825. * @returns a pseudo random id
  23826. */
  23827. static RandomId(): string;
  23828. }
  23829. }
  23830. declare module BABYLON {
  23831. /**
  23832. * Options to be used when creating a shadow depth material
  23833. */
  23834. export interface IIOptionShadowDepthMaterial {
  23835. /** Variables in the vertex shader code that need to have their names remapped.
  23836. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23837. * "var_name" should be either: worldPos or vNormalW
  23838. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23839. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23840. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23841. */
  23842. remappedVariables?: string[];
  23843. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23844. standalone?: boolean;
  23845. }
  23846. /**
  23847. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23848. */
  23849. export class ShadowDepthWrapper {
  23850. private _scene;
  23851. private _options?;
  23852. private _baseMaterial;
  23853. private _onEffectCreatedObserver;
  23854. private _subMeshToEffect;
  23855. private _subMeshToDepthEffect;
  23856. private _meshes;
  23857. /** @hidden */
  23858. _matriceNames: any;
  23859. /** Gets the standalone status of the wrapper */
  23860. get standalone(): boolean;
  23861. /** Gets the base material the wrapper is built upon */
  23862. get baseMaterial(): Material;
  23863. /**
  23864. * Instantiate a new shadow depth wrapper.
  23865. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23866. * generate the shadow depth map. For more information, please refer to the documentation:
  23867. * https://doc.babylonjs.com/babylon101/shadows
  23868. * @param baseMaterial Material to wrap
  23869. * @param scene Define the scene the material belongs to
  23870. * @param options Options used to create the wrapper
  23871. */
  23872. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23873. /**
  23874. * Gets the effect to use to generate the depth map
  23875. * @param subMesh subMesh to get the effect for
  23876. * @param shadowGenerator shadow generator to get the effect for
  23877. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23878. */
  23879. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23880. /**
  23881. * Specifies that the submesh is ready to be used for depth rendering
  23882. * @param subMesh submesh to check
  23883. * @param defines the list of defines to take into account when checking the effect
  23884. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23885. * @param useInstances specifies that instances should be used
  23886. * @returns a boolean indicating that the submesh is ready or not
  23887. */
  23888. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23889. /**
  23890. * Disposes the resources
  23891. */
  23892. dispose(): void;
  23893. private _makeEffect;
  23894. }
  23895. }
  23896. declare module BABYLON {
  23897. interface ThinEngine {
  23898. /**
  23899. * Unbind a list of render target textures from the webGL context
  23900. * This is used only when drawBuffer extension or webGL2 are active
  23901. * @param textures defines the render target textures to unbind
  23902. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23903. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23904. */
  23905. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23906. /**
  23907. * Create a multi render target texture
  23908. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23909. * @param size defines the size of the texture
  23910. * @param options defines the creation options
  23911. * @returns the cube texture as an InternalTexture
  23912. */
  23913. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23914. /**
  23915. * Update the sample count for a given multiple render target texture
  23916. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23917. * @param textures defines the textures to update
  23918. * @param samples defines the sample count to set
  23919. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23920. */
  23921. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23922. /**
  23923. * Select a subsets of attachments to draw to.
  23924. * @param attachments gl attachments
  23925. */
  23926. bindAttachments(attachments: number[]): void;
  23927. }
  23928. }
  23929. declare module BABYLON {
  23930. /**
  23931. * Creation options of the multi render target texture.
  23932. */
  23933. export interface IMultiRenderTargetOptions {
  23934. /**
  23935. * Define if the texture needs to create mip maps after render.
  23936. */
  23937. generateMipMaps?: boolean;
  23938. /**
  23939. * Define the types of all the draw buffers we want to create
  23940. */
  23941. types?: number[];
  23942. /**
  23943. * Define the sampling modes of all the draw buffers we want to create
  23944. */
  23945. samplingModes?: number[];
  23946. /**
  23947. * Define if a depth buffer is required
  23948. */
  23949. generateDepthBuffer?: boolean;
  23950. /**
  23951. * Define if a stencil buffer is required
  23952. */
  23953. generateStencilBuffer?: boolean;
  23954. /**
  23955. * Define if a depth texture is required instead of a depth buffer
  23956. */
  23957. generateDepthTexture?: boolean;
  23958. /**
  23959. * Define the number of desired draw buffers
  23960. */
  23961. textureCount?: number;
  23962. /**
  23963. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23964. */
  23965. doNotChangeAspectRatio?: boolean;
  23966. /**
  23967. * Define the default type of the buffers we are creating
  23968. */
  23969. defaultType?: number;
  23970. }
  23971. /**
  23972. * A multi render target, like a render target provides the ability to render to a texture.
  23973. * Unlike the render target, it can render to several draw buffers in one draw.
  23974. * This is specially interesting in deferred rendering or for any effects requiring more than
  23975. * just one color from a single pass.
  23976. */
  23977. export class MultiRenderTarget extends RenderTargetTexture {
  23978. private _internalTextures;
  23979. private _textures;
  23980. private _multiRenderTargetOptions;
  23981. private _count;
  23982. /**
  23983. * Get if draw buffers are currently supported by the used hardware and browser.
  23984. */
  23985. get isSupported(): boolean;
  23986. /**
  23987. * Get the list of textures generated by the multi render target.
  23988. */
  23989. get textures(): Texture[];
  23990. /**
  23991. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23992. */
  23993. get count(): number;
  23994. /**
  23995. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23996. */
  23997. get depthTexture(): Texture;
  23998. /**
  23999. * Set the wrapping mode on U of all the textures we are rendering to.
  24000. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24001. */
  24002. set wrapU(wrap: number);
  24003. /**
  24004. * Set the wrapping mode on V of all the textures we are rendering to.
  24005. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24006. */
  24007. set wrapV(wrap: number);
  24008. /**
  24009. * Instantiate a new multi render target texture.
  24010. * A multi render target, like a render target provides the ability to render to a texture.
  24011. * Unlike the render target, it can render to several draw buffers in one draw.
  24012. * This is specially interesting in deferred rendering or for any effects requiring more than
  24013. * just one color from a single pass.
  24014. * @param name Define the name of the texture
  24015. * @param size Define the size of the buffers to render to
  24016. * @param count Define the number of target we are rendering into
  24017. * @param scene Define the scene the texture belongs to
  24018. * @param options Define the options used to create the multi render target
  24019. */
  24020. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24021. /** @hidden */
  24022. _rebuild(): void;
  24023. private _createInternalTextures;
  24024. private _createTextures;
  24025. /**
  24026. * Define the number of samples used if MSAA is enabled.
  24027. */
  24028. get samples(): number;
  24029. set samples(value: number);
  24030. /**
  24031. * Resize all the textures in the multi render target.
  24032. * Be carrefull as it will recreate all the data in the new texture.
  24033. * @param size Define the new size
  24034. */
  24035. resize(size: any): void;
  24036. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24037. /**
  24038. * Dispose the render targets and their associated resources
  24039. */
  24040. dispose(): void;
  24041. /**
  24042. * Release all the underlying texture used as draw buffers.
  24043. */
  24044. releaseInternalTextures(): void;
  24045. }
  24046. }
  24047. declare module BABYLON {
  24048. /** @hidden */
  24049. export var imageProcessingPixelShader: {
  24050. name: string;
  24051. shader: string;
  24052. };
  24053. }
  24054. declare module BABYLON {
  24055. /**
  24056. * ImageProcessingPostProcess
  24057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24058. */
  24059. export class ImageProcessingPostProcess extends PostProcess {
  24060. /**
  24061. * Default configuration related to image processing available in the PBR Material.
  24062. */
  24063. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24064. /**
  24065. * Gets the image processing configuration used either in this material.
  24066. */
  24067. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24068. /**
  24069. * Sets the Default image processing configuration used either in the this material.
  24070. *
  24071. * If sets to null, the scene one is in use.
  24072. */
  24073. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24074. /**
  24075. * Keep track of the image processing observer to allow dispose and replace.
  24076. */
  24077. private _imageProcessingObserver;
  24078. /**
  24079. * Attaches a new image processing configuration to the PBR Material.
  24080. * @param configuration
  24081. */
  24082. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24083. /**
  24084. * If the post process is supported.
  24085. */
  24086. get isSupported(): boolean;
  24087. /**
  24088. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24089. */
  24090. get colorCurves(): Nullable<ColorCurves>;
  24091. /**
  24092. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24093. */
  24094. set colorCurves(value: Nullable<ColorCurves>);
  24095. /**
  24096. * Gets wether the color curves effect is enabled.
  24097. */
  24098. get colorCurvesEnabled(): boolean;
  24099. /**
  24100. * Sets wether the color curves effect is enabled.
  24101. */
  24102. set colorCurvesEnabled(value: boolean);
  24103. /**
  24104. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24105. */
  24106. get colorGradingTexture(): Nullable<BaseTexture>;
  24107. /**
  24108. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24109. */
  24110. set colorGradingTexture(value: Nullable<BaseTexture>);
  24111. /**
  24112. * Gets wether the color grading effect is enabled.
  24113. */
  24114. get colorGradingEnabled(): boolean;
  24115. /**
  24116. * Gets wether the color grading effect is enabled.
  24117. */
  24118. set colorGradingEnabled(value: boolean);
  24119. /**
  24120. * Gets exposure used in the effect.
  24121. */
  24122. get exposure(): number;
  24123. /**
  24124. * Sets exposure used in the effect.
  24125. */
  24126. set exposure(value: number);
  24127. /**
  24128. * Gets wether tonemapping is enabled or not.
  24129. */
  24130. get toneMappingEnabled(): boolean;
  24131. /**
  24132. * Sets wether tonemapping is enabled or not
  24133. */
  24134. set toneMappingEnabled(value: boolean);
  24135. /**
  24136. * Gets the type of tone mapping effect.
  24137. */
  24138. get toneMappingType(): number;
  24139. /**
  24140. * Sets the type of tone mapping effect.
  24141. */
  24142. set toneMappingType(value: number);
  24143. /**
  24144. * Gets contrast used in the effect.
  24145. */
  24146. get contrast(): number;
  24147. /**
  24148. * Sets contrast used in the effect.
  24149. */
  24150. set contrast(value: number);
  24151. /**
  24152. * Gets Vignette stretch size.
  24153. */
  24154. get vignetteStretch(): number;
  24155. /**
  24156. * Sets Vignette stretch size.
  24157. */
  24158. set vignetteStretch(value: number);
  24159. /**
  24160. * Gets Vignette centre X Offset.
  24161. */
  24162. get vignetteCentreX(): number;
  24163. /**
  24164. * Sets Vignette centre X Offset.
  24165. */
  24166. set vignetteCentreX(value: number);
  24167. /**
  24168. * Gets Vignette centre Y Offset.
  24169. */
  24170. get vignetteCentreY(): number;
  24171. /**
  24172. * Sets Vignette centre Y Offset.
  24173. */
  24174. set vignetteCentreY(value: number);
  24175. /**
  24176. * Gets Vignette weight or intensity of the vignette effect.
  24177. */
  24178. get vignetteWeight(): number;
  24179. /**
  24180. * Sets Vignette weight or intensity of the vignette effect.
  24181. */
  24182. set vignetteWeight(value: number);
  24183. /**
  24184. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24185. * if vignetteEnabled is set to true.
  24186. */
  24187. get vignetteColor(): Color4;
  24188. /**
  24189. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24190. * if vignetteEnabled is set to true.
  24191. */
  24192. set vignetteColor(value: Color4);
  24193. /**
  24194. * Gets Camera field of view used by the Vignette effect.
  24195. */
  24196. get vignetteCameraFov(): number;
  24197. /**
  24198. * Sets Camera field of view used by the Vignette effect.
  24199. */
  24200. set vignetteCameraFov(value: number);
  24201. /**
  24202. * Gets the vignette blend mode allowing different kind of effect.
  24203. */
  24204. get vignetteBlendMode(): number;
  24205. /**
  24206. * Sets the vignette blend mode allowing different kind of effect.
  24207. */
  24208. set vignetteBlendMode(value: number);
  24209. /**
  24210. * Gets wether the vignette effect is enabled.
  24211. */
  24212. get vignetteEnabled(): boolean;
  24213. /**
  24214. * Sets wether the vignette effect is enabled.
  24215. */
  24216. set vignetteEnabled(value: boolean);
  24217. private _fromLinearSpace;
  24218. /**
  24219. * Gets wether the input of the processing is in Gamma or Linear Space.
  24220. */
  24221. get fromLinearSpace(): boolean;
  24222. /**
  24223. * Sets wether the input of the processing is in Gamma or Linear Space.
  24224. */
  24225. set fromLinearSpace(value: boolean);
  24226. /**
  24227. * Defines cache preventing GC.
  24228. */
  24229. private _defines;
  24230. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24231. /**
  24232. * "ImageProcessingPostProcess"
  24233. * @returns "ImageProcessingPostProcess"
  24234. */
  24235. getClassName(): string;
  24236. /**
  24237. * @hidden
  24238. */
  24239. _updateParameters(): void;
  24240. dispose(camera?: Camera): void;
  24241. }
  24242. }
  24243. declare module BABYLON {
  24244. /** @hidden */
  24245. export var fibonacci: {
  24246. name: string;
  24247. shader: string;
  24248. };
  24249. }
  24250. declare module BABYLON {
  24251. /** @hidden */
  24252. export var subSurfaceScatteringFunctions: {
  24253. name: string;
  24254. shader: string;
  24255. };
  24256. }
  24257. declare module BABYLON {
  24258. /** @hidden */
  24259. export var diffusionProfile: {
  24260. name: string;
  24261. shader: string;
  24262. };
  24263. }
  24264. declare module BABYLON {
  24265. /** @hidden */
  24266. export var subSurfaceScatteringPixelShader: {
  24267. name: string;
  24268. shader: string;
  24269. };
  24270. }
  24271. declare module BABYLON {
  24272. /**
  24273. * Sub surface scattering post process
  24274. */
  24275. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24276. /**
  24277. * Gets a string identifying the name of the class
  24278. * @returns "SubSurfaceScatteringPostProcess" string
  24279. */
  24280. getClassName(): string;
  24281. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24282. }
  24283. }
  24284. declare module BABYLON {
  24285. /**
  24286. * Interface for defining prepass effects in the prepass post-process pipeline
  24287. */
  24288. export interface PrePassEffectConfiguration {
  24289. /**
  24290. * Post process to attach for this effect
  24291. */
  24292. postProcess: PostProcess;
  24293. /**
  24294. * Is the effect enabled
  24295. */
  24296. enabled: boolean;
  24297. /**
  24298. * Disposes the effect configuration
  24299. */
  24300. dispose(): void;
  24301. /**
  24302. * Disposes the effect configuration
  24303. */
  24304. createPostProcess: () => PostProcess;
  24305. }
  24306. }
  24307. declare module BABYLON {
  24308. /**
  24309. * Contains all parameters needed for the prepass to perform
  24310. * screen space subsurface scattering
  24311. */
  24312. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24313. private _ssDiffusionS;
  24314. private _ssFilterRadii;
  24315. private _ssDiffusionD;
  24316. /**
  24317. * Post process to attach for screen space subsurface scattering
  24318. */
  24319. postProcess: SubSurfaceScatteringPostProcess;
  24320. /**
  24321. * Diffusion profile color for subsurface scattering
  24322. */
  24323. get ssDiffusionS(): number[];
  24324. /**
  24325. * Diffusion profile max color channel value for subsurface scattering
  24326. */
  24327. get ssDiffusionD(): number[];
  24328. /**
  24329. * Diffusion profile filter radius for subsurface scattering
  24330. */
  24331. get ssFilterRadii(): number[];
  24332. /**
  24333. * Is subsurface enabled
  24334. */
  24335. enabled: boolean;
  24336. /**
  24337. * Diffusion profile colors for subsurface scattering
  24338. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24339. * See ...
  24340. * Note that you can only store up to 5 of them
  24341. */
  24342. ssDiffusionProfileColors: Color3[];
  24343. /**
  24344. * Defines the ratio real world => scene units.
  24345. * Used for subsurface scattering
  24346. */
  24347. metersPerUnit: number;
  24348. private _scene;
  24349. /**
  24350. * Builds a subsurface configuration object
  24351. * @param scene The scene
  24352. */
  24353. constructor(scene: Scene);
  24354. /**
  24355. * Adds a new diffusion profile.
  24356. * Useful for more realistic subsurface scattering on diverse materials.
  24357. * @param color The color of the diffusion profile. Should be the average color of the material.
  24358. * @return The index of the diffusion profile for the material subsurface configuration
  24359. */
  24360. addDiffusionProfile(color: Color3): number;
  24361. /**
  24362. * Creates the sss post process
  24363. * @return The created post process
  24364. */
  24365. createPostProcess(): SubSurfaceScatteringPostProcess;
  24366. /**
  24367. * Deletes all diffusion profiles.
  24368. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24369. */
  24370. clearAllDiffusionProfiles(): void;
  24371. /**
  24372. * Disposes this object
  24373. */
  24374. dispose(): void;
  24375. /**
  24376. * @hidden
  24377. * https://zero-radiance.github.io/post/sampling-diffusion/
  24378. *
  24379. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24380. * ------------------------------------------------------------------------------------
  24381. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24382. * PDF[r, phi, s] = r * R[r, phi, s]
  24383. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24384. * ------------------------------------------------------------------------------------
  24385. * We importance sample the color channel with the widest scattering distance.
  24386. */
  24387. getDiffusionProfileParameters(color: Color3): number;
  24388. /**
  24389. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24390. * 'u' is the random number (the value of the CDF): [0, 1).
  24391. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24392. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24393. */
  24394. private _sampleBurleyDiffusionProfile;
  24395. }
  24396. }
  24397. declare module BABYLON {
  24398. /**
  24399. * Renders a pre pass of the scene
  24400. * This means every mesh in the scene will be rendered to a render target texture
  24401. * And then this texture will be composited to the rendering canvas with post processes
  24402. * It is necessary for effects like subsurface scattering or deferred shading
  24403. */
  24404. export class PrePassRenderer {
  24405. /** @hidden */
  24406. static _SceneComponentInitialization: (scene: Scene) => void;
  24407. private _scene;
  24408. private _engine;
  24409. private _isDirty;
  24410. /**
  24411. * Number of textures in the multi render target texture where the scene is directly rendered
  24412. */
  24413. readonly mrtCount: number;
  24414. /**
  24415. * The render target where the scene is directly rendered
  24416. */
  24417. prePassRT: MultiRenderTarget;
  24418. private _mrtTypes;
  24419. private _multiRenderAttachments;
  24420. private _defaultAttachments;
  24421. private _clearAttachments;
  24422. private _postProcesses;
  24423. private readonly _clearColor;
  24424. /**
  24425. * Image processing post process for composition
  24426. */
  24427. imageProcessingPostProcess: ImageProcessingPostProcess;
  24428. /**
  24429. * Configuration for sub surface scattering post process
  24430. */
  24431. subSurfaceConfiguration: SubSurfaceConfiguration;
  24432. /**
  24433. * Should materials render their geometry on the MRT
  24434. */
  24435. materialsShouldRenderGeometry: boolean;
  24436. /**
  24437. * Should materials render the irradiance information on the MRT
  24438. */
  24439. materialsShouldRenderIrradiance: boolean;
  24440. private _enabled;
  24441. /**
  24442. * Indicates if the prepass is enabled
  24443. */
  24444. get enabled(): boolean;
  24445. /**
  24446. * How many samples are used for MSAA of the scene render target
  24447. */
  24448. get samples(): number;
  24449. set samples(n: number);
  24450. /**
  24451. * Instanciates a prepass renderer
  24452. * @param scene The scene
  24453. */
  24454. constructor(scene: Scene);
  24455. private _initializeAttachments;
  24456. private _createCompositionEffect;
  24457. /**
  24458. * Indicates if rendering a prepass is supported
  24459. */
  24460. get isSupported(): boolean;
  24461. /**
  24462. * Sets the proper output textures to draw in the engine.
  24463. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24464. */
  24465. bindAttachmentsForEffect(effect: Effect): void;
  24466. /**
  24467. * @hidden
  24468. */
  24469. _beforeCameraDraw(): void;
  24470. /**
  24471. * @hidden
  24472. */
  24473. _afterCameraDraw(): void;
  24474. private _checkRTSize;
  24475. private _bindFrameBuffer;
  24476. /**
  24477. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24478. */
  24479. clear(): void;
  24480. private _setState;
  24481. private _enable;
  24482. private _disable;
  24483. private _resetPostProcessChain;
  24484. private _bindPostProcessChain;
  24485. /**
  24486. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24487. */
  24488. markAsDirty(): void;
  24489. private _update;
  24490. /**
  24491. * Disposes the prepass renderer.
  24492. */
  24493. dispose(): void;
  24494. }
  24495. }
  24496. declare module BABYLON {
  24497. /**
  24498. * Options for compiling materials.
  24499. */
  24500. export interface IMaterialCompilationOptions {
  24501. /**
  24502. * Defines whether clip planes are enabled.
  24503. */
  24504. clipPlane: boolean;
  24505. /**
  24506. * Defines whether instances are enabled.
  24507. */
  24508. useInstances: boolean;
  24509. }
  24510. /**
  24511. * Options passed when calling customShaderNameResolve
  24512. */
  24513. export interface ICustomShaderNameResolveOptions {
  24514. /**
  24515. * 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
  24516. */
  24517. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24518. }
  24519. /**
  24520. * Base class for the main features of a material in Babylon.js
  24521. */
  24522. export class Material implements IAnimatable {
  24523. /**
  24524. * Returns the triangle fill mode
  24525. */
  24526. static readonly TriangleFillMode: number;
  24527. /**
  24528. * Returns the wireframe mode
  24529. */
  24530. static readonly WireFrameFillMode: number;
  24531. /**
  24532. * Returns the point fill mode
  24533. */
  24534. static readonly PointFillMode: number;
  24535. /**
  24536. * Returns the point list draw mode
  24537. */
  24538. static readonly PointListDrawMode: number;
  24539. /**
  24540. * Returns the line list draw mode
  24541. */
  24542. static readonly LineListDrawMode: number;
  24543. /**
  24544. * Returns the line loop draw mode
  24545. */
  24546. static readonly LineLoopDrawMode: number;
  24547. /**
  24548. * Returns the line strip draw mode
  24549. */
  24550. static readonly LineStripDrawMode: number;
  24551. /**
  24552. * Returns the triangle strip draw mode
  24553. */
  24554. static readonly TriangleStripDrawMode: number;
  24555. /**
  24556. * Returns the triangle fan draw mode
  24557. */
  24558. static readonly TriangleFanDrawMode: number;
  24559. /**
  24560. * Stores the clock-wise side orientation
  24561. */
  24562. static readonly ClockWiseSideOrientation: number;
  24563. /**
  24564. * Stores the counter clock-wise side orientation
  24565. */
  24566. static readonly CounterClockWiseSideOrientation: number;
  24567. /**
  24568. * The dirty texture flag value
  24569. */
  24570. static readonly TextureDirtyFlag: number;
  24571. /**
  24572. * The dirty light flag value
  24573. */
  24574. static readonly LightDirtyFlag: number;
  24575. /**
  24576. * The dirty fresnel flag value
  24577. */
  24578. static readonly FresnelDirtyFlag: number;
  24579. /**
  24580. * The dirty attribute flag value
  24581. */
  24582. static readonly AttributesDirtyFlag: number;
  24583. /**
  24584. * The dirty misc flag value
  24585. */
  24586. static readonly MiscDirtyFlag: number;
  24587. /**
  24588. * The all dirty flag value
  24589. */
  24590. static readonly AllDirtyFlag: number;
  24591. /**
  24592. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24593. */
  24594. static readonly MATERIAL_OPAQUE: number;
  24595. /**
  24596. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24597. */
  24598. static readonly MATERIAL_ALPHATEST: number;
  24599. /**
  24600. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24601. */
  24602. static readonly MATERIAL_ALPHABLEND: number;
  24603. /**
  24604. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24605. * They are also discarded below the alpha cutoff threshold to improve performances.
  24606. */
  24607. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24608. /**
  24609. * The Whiteout method is used to blend normals.
  24610. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24611. */
  24612. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24613. /**
  24614. * The Reoriented Normal Mapping method is used to blend normals.
  24615. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24616. */
  24617. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24618. /**
  24619. * Custom callback helping to override the default shader used in the material.
  24620. */
  24621. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24622. /**
  24623. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24624. */
  24625. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24626. /**
  24627. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24628. * This means that the material can keep using a previous shader while a new one is being compiled.
  24629. * This is mostly used when shader parallel compilation is supported (true by default)
  24630. */
  24631. allowShaderHotSwapping: boolean;
  24632. /**
  24633. * The ID of the material
  24634. */
  24635. id: string;
  24636. /**
  24637. * Gets or sets the unique id of the material
  24638. */
  24639. uniqueId: number;
  24640. /**
  24641. * The name of the material
  24642. */
  24643. name: string;
  24644. /**
  24645. * Gets or sets user defined metadata
  24646. */
  24647. metadata: any;
  24648. /**
  24649. * For internal use only. Please do not use.
  24650. */
  24651. reservedDataStore: any;
  24652. /**
  24653. * Specifies if the ready state should be checked on each call
  24654. */
  24655. checkReadyOnEveryCall: boolean;
  24656. /**
  24657. * Specifies if the ready state should be checked once
  24658. */
  24659. checkReadyOnlyOnce: boolean;
  24660. /**
  24661. * The state of the material
  24662. */
  24663. state: string;
  24664. /**
  24665. * If the material can be rendered to several textures with MRT extension
  24666. */
  24667. get canRenderToMRT(): boolean;
  24668. /**
  24669. * The alpha value of the material
  24670. */
  24671. protected _alpha: number;
  24672. /**
  24673. * List of inspectable custom properties (used by the Inspector)
  24674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24675. */
  24676. inspectableCustomProperties: IInspectable[];
  24677. /**
  24678. * Sets the alpha value of the material
  24679. */
  24680. set alpha(value: number);
  24681. /**
  24682. * Gets the alpha value of the material
  24683. */
  24684. get alpha(): number;
  24685. /**
  24686. * Specifies if back face culling is enabled
  24687. */
  24688. protected _backFaceCulling: boolean;
  24689. /**
  24690. * Sets the back-face culling state
  24691. */
  24692. set backFaceCulling(value: boolean);
  24693. /**
  24694. * Gets the back-face culling state
  24695. */
  24696. get backFaceCulling(): boolean;
  24697. /**
  24698. * Stores the value for side orientation
  24699. */
  24700. sideOrientation: number;
  24701. /**
  24702. * Callback triggered when the material is compiled
  24703. */
  24704. onCompiled: Nullable<(effect: Effect) => void>;
  24705. /**
  24706. * Callback triggered when an error occurs
  24707. */
  24708. onError: Nullable<(effect: Effect, errors: string) => void>;
  24709. /**
  24710. * Callback triggered to get the render target textures
  24711. */
  24712. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24713. /**
  24714. * Gets a boolean indicating that current material needs to register RTT
  24715. */
  24716. get hasRenderTargetTextures(): boolean;
  24717. /**
  24718. * Specifies if the material should be serialized
  24719. */
  24720. doNotSerialize: boolean;
  24721. /**
  24722. * @hidden
  24723. */
  24724. _storeEffectOnSubMeshes: boolean;
  24725. /**
  24726. * Stores the animations for the material
  24727. */
  24728. animations: Nullable<Array<Animation>>;
  24729. /**
  24730. * An event triggered when the material is disposed
  24731. */
  24732. onDisposeObservable: Observable<Material>;
  24733. /**
  24734. * An observer which watches for dispose events
  24735. */
  24736. private _onDisposeObserver;
  24737. private _onUnBindObservable;
  24738. /**
  24739. * Called during a dispose event
  24740. */
  24741. set onDispose(callback: () => void);
  24742. private _onBindObservable;
  24743. /**
  24744. * An event triggered when the material is bound
  24745. */
  24746. get onBindObservable(): Observable<AbstractMesh>;
  24747. /**
  24748. * An observer which watches for bind events
  24749. */
  24750. private _onBindObserver;
  24751. /**
  24752. * Called during a bind event
  24753. */
  24754. set onBind(callback: (Mesh: AbstractMesh) => void);
  24755. /**
  24756. * An event triggered when the material is unbound
  24757. */
  24758. get onUnBindObservable(): Observable<Material>;
  24759. protected _onEffectCreatedObservable: Nullable<Observable<{
  24760. effect: Effect;
  24761. subMesh: Nullable<SubMesh>;
  24762. }>>;
  24763. /**
  24764. * An event triggered when the effect is (re)created
  24765. */
  24766. get onEffectCreatedObservable(): Observable<{
  24767. effect: Effect;
  24768. subMesh: Nullable<SubMesh>;
  24769. }>;
  24770. /**
  24771. * Stores the value of the alpha mode
  24772. */
  24773. private _alphaMode;
  24774. /**
  24775. * Sets the value of the alpha mode.
  24776. *
  24777. * | Value | Type | Description |
  24778. * | --- | --- | --- |
  24779. * | 0 | ALPHA_DISABLE | |
  24780. * | 1 | ALPHA_ADD | |
  24781. * | 2 | ALPHA_COMBINE | |
  24782. * | 3 | ALPHA_SUBTRACT | |
  24783. * | 4 | ALPHA_MULTIPLY | |
  24784. * | 5 | ALPHA_MAXIMIZED | |
  24785. * | 6 | ALPHA_ONEONE | |
  24786. * | 7 | ALPHA_PREMULTIPLIED | |
  24787. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24788. * | 9 | ALPHA_INTERPOLATE | |
  24789. * | 10 | ALPHA_SCREENMODE | |
  24790. *
  24791. */
  24792. set alphaMode(value: number);
  24793. /**
  24794. * Gets the value of the alpha mode
  24795. */
  24796. get alphaMode(): number;
  24797. /**
  24798. * Stores the state of the need depth pre-pass value
  24799. */
  24800. private _needDepthPrePass;
  24801. /**
  24802. * Sets the need depth pre-pass value
  24803. */
  24804. set needDepthPrePass(value: boolean);
  24805. /**
  24806. * Gets the depth pre-pass value
  24807. */
  24808. get needDepthPrePass(): boolean;
  24809. /**
  24810. * Specifies if depth writing should be disabled
  24811. */
  24812. disableDepthWrite: boolean;
  24813. /**
  24814. * Specifies if color writing should be disabled
  24815. */
  24816. disableColorWrite: boolean;
  24817. /**
  24818. * Specifies if depth writing should be forced
  24819. */
  24820. forceDepthWrite: boolean;
  24821. /**
  24822. * Specifies the depth function that should be used. 0 means the default engine function
  24823. */
  24824. depthFunction: number;
  24825. /**
  24826. * Specifies if there should be a separate pass for culling
  24827. */
  24828. separateCullingPass: boolean;
  24829. /**
  24830. * Stores the state specifing if fog should be enabled
  24831. */
  24832. private _fogEnabled;
  24833. /**
  24834. * Sets the state for enabling fog
  24835. */
  24836. set fogEnabled(value: boolean);
  24837. /**
  24838. * Gets the value of the fog enabled state
  24839. */
  24840. get fogEnabled(): boolean;
  24841. /**
  24842. * Stores the size of points
  24843. */
  24844. pointSize: number;
  24845. /**
  24846. * Stores the z offset value
  24847. */
  24848. zOffset: number;
  24849. get wireframe(): boolean;
  24850. /**
  24851. * Sets the state of wireframe mode
  24852. */
  24853. set wireframe(value: boolean);
  24854. /**
  24855. * Gets the value specifying if point clouds are enabled
  24856. */
  24857. get pointsCloud(): boolean;
  24858. /**
  24859. * Sets the state of point cloud mode
  24860. */
  24861. set pointsCloud(value: boolean);
  24862. /**
  24863. * Gets the material fill mode
  24864. */
  24865. get fillMode(): number;
  24866. /**
  24867. * Sets the material fill mode
  24868. */
  24869. set fillMode(value: number);
  24870. /**
  24871. * @hidden
  24872. * Stores the effects for the material
  24873. */
  24874. _effect: Nullable<Effect>;
  24875. /**
  24876. * Specifies if uniform buffers should be used
  24877. */
  24878. private _useUBO;
  24879. /**
  24880. * Stores a reference to the scene
  24881. */
  24882. private _scene;
  24883. /**
  24884. * Stores the fill mode state
  24885. */
  24886. private _fillMode;
  24887. /**
  24888. * Specifies if the depth write state should be cached
  24889. */
  24890. private _cachedDepthWriteState;
  24891. /**
  24892. * Specifies if the color write state should be cached
  24893. */
  24894. private _cachedColorWriteState;
  24895. /**
  24896. * Specifies if the depth function state should be cached
  24897. */
  24898. private _cachedDepthFunctionState;
  24899. /**
  24900. * Stores the uniform buffer
  24901. */
  24902. protected _uniformBuffer: UniformBuffer;
  24903. /** @hidden */
  24904. _indexInSceneMaterialArray: number;
  24905. /** @hidden */
  24906. meshMap: Nullable<{
  24907. [id: string]: AbstractMesh | undefined;
  24908. }>;
  24909. /**
  24910. * Creates a material instance
  24911. * @param name defines the name of the material
  24912. * @param scene defines the scene to reference
  24913. * @param doNotAdd specifies if the material should be added to the scene
  24914. */
  24915. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24916. /**
  24917. * Returns a string representation of the current material
  24918. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24919. * @returns a string with material information
  24920. */
  24921. toString(fullDetails?: boolean): string;
  24922. /**
  24923. * Gets the class name of the material
  24924. * @returns a string with the class name of the material
  24925. */
  24926. getClassName(): string;
  24927. /**
  24928. * Specifies if updates for the material been locked
  24929. */
  24930. get isFrozen(): boolean;
  24931. /**
  24932. * Locks updates for the material
  24933. */
  24934. freeze(): void;
  24935. /**
  24936. * Unlocks updates for the material
  24937. */
  24938. unfreeze(): void;
  24939. /**
  24940. * Specifies if the material is ready to be used
  24941. * @param mesh defines the mesh to check
  24942. * @param useInstances specifies if instances should be used
  24943. * @returns a boolean indicating if the material is ready to be used
  24944. */
  24945. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24946. /**
  24947. * Specifies that the submesh is ready to be used
  24948. * @param mesh defines the mesh to check
  24949. * @param subMesh defines which submesh to check
  24950. * @param useInstances specifies that instances should be used
  24951. * @returns a boolean indicating that the submesh is ready or not
  24952. */
  24953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24954. /**
  24955. * Returns the material effect
  24956. * @returns the effect associated with the material
  24957. */
  24958. getEffect(): Nullable<Effect>;
  24959. /**
  24960. * Returns the current scene
  24961. * @returns a Scene
  24962. */
  24963. getScene(): Scene;
  24964. /**
  24965. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24966. */
  24967. protected _forceAlphaTest: boolean;
  24968. /**
  24969. * The transparency mode of the material.
  24970. */
  24971. protected _transparencyMode: Nullable<number>;
  24972. /**
  24973. * Gets the current transparency mode.
  24974. */
  24975. get transparencyMode(): Nullable<number>;
  24976. /**
  24977. * Sets the transparency mode of the material.
  24978. *
  24979. * | Value | Type | Description |
  24980. * | ----- | ----------------------------------- | ----------- |
  24981. * | 0 | OPAQUE | |
  24982. * | 1 | ALPHATEST | |
  24983. * | 2 | ALPHABLEND | |
  24984. * | 3 | ALPHATESTANDBLEND | |
  24985. *
  24986. */
  24987. set transparencyMode(value: Nullable<number>);
  24988. /**
  24989. * Returns true if alpha blending should be disabled.
  24990. */
  24991. protected get _disableAlphaBlending(): boolean;
  24992. /**
  24993. * Specifies whether or not this material should be rendered in alpha blend mode.
  24994. * @returns a boolean specifying if alpha blending is needed
  24995. */
  24996. needAlphaBlending(): boolean;
  24997. /**
  24998. * Specifies if the mesh will require alpha blending
  24999. * @param mesh defines the mesh to check
  25000. * @returns a boolean specifying if alpha blending is needed for the mesh
  25001. */
  25002. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25003. /**
  25004. * Specifies whether or not this material should be rendered in alpha test mode.
  25005. * @returns a boolean specifying if an alpha test is needed.
  25006. */
  25007. needAlphaTesting(): boolean;
  25008. /**
  25009. * Specifies if material alpha testing should be turned on for the mesh
  25010. * @param mesh defines the mesh to check
  25011. */
  25012. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25013. /**
  25014. * Gets the texture used for the alpha test
  25015. * @returns the texture to use for alpha testing
  25016. */
  25017. getAlphaTestTexture(): Nullable<BaseTexture>;
  25018. /**
  25019. * Marks the material to indicate that it needs to be re-calculated
  25020. */
  25021. markDirty(): void;
  25022. /** @hidden */
  25023. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25024. /**
  25025. * Binds the material to the mesh
  25026. * @param world defines the world transformation matrix
  25027. * @param mesh defines the mesh to bind the material to
  25028. */
  25029. bind(world: Matrix, mesh?: Mesh): void;
  25030. /**
  25031. * Binds the submesh to the material
  25032. * @param world defines the world transformation matrix
  25033. * @param mesh defines the mesh containing the submesh
  25034. * @param subMesh defines the submesh to bind the material to
  25035. */
  25036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25037. /**
  25038. * Binds the world matrix to the material
  25039. * @param world defines the world transformation matrix
  25040. */
  25041. bindOnlyWorldMatrix(world: Matrix): void;
  25042. /**
  25043. * Binds the scene's uniform buffer to the effect.
  25044. * @param effect defines the effect to bind to the scene uniform buffer
  25045. * @param sceneUbo defines the uniform buffer storing scene data
  25046. */
  25047. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25048. /**
  25049. * Binds the view matrix to the effect
  25050. * @param effect defines the effect to bind the view matrix to
  25051. */
  25052. bindView(effect: Effect): void;
  25053. /**
  25054. * Binds the view projection matrix to the effect
  25055. * @param effect defines the effect to bind the view projection matrix to
  25056. */
  25057. bindViewProjection(effect: Effect): void;
  25058. /**
  25059. * Processes to execute after binding the material to a mesh
  25060. * @param mesh defines the rendered mesh
  25061. */
  25062. protected _afterBind(mesh?: Mesh): void;
  25063. /**
  25064. * Unbinds the material from the mesh
  25065. */
  25066. unbind(): void;
  25067. /**
  25068. * Gets the active textures from the material
  25069. * @returns an array of textures
  25070. */
  25071. getActiveTextures(): BaseTexture[];
  25072. /**
  25073. * Specifies if the material uses a texture
  25074. * @param texture defines the texture to check against the material
  25075. * @returns a boolean specifying if the material uses the texture
  25076. */
  25077. hasTexture(texture: BaseTexture): boolean;
  25078. /**
  25079. * Makes a duplicate of the material, and gives it a new name
  25080. * @param name defines the new name for the duplicated material
  25081. * @returns the cloned material
  25082. */
  25083. clone(name: string): Nullable<Material>;
  25084. /**
  25085. * Gets the meshes bound to the material
  25086. * @returns an array of meshes bound to the material
  25087. */
  25088. getBindedMeshes(): AbstractMesh[];
  25089. /**
  25090. * Force shader compilation
  25091. * @param mesh defines the mesh associated with this material
  25092. * @param onCompiled defines a function to execute once the material is compiled
  25093. * @param options defines the options to configure the compilation
  25094. * @param onError defines a function to execute if the material fails compiling
  25095. */
  25096. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25097. /**
  25098. * Force shader compilation
  25099. * @param mesh defines the mesh that will use this material
  25100. * @param options defines additional options for compiling the shaders
  25101. * @returns a promise that resolves when the compilation completes
  25102. */
  25103. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25104. private static readonly _AllDirtyCallBack;
  25105. private static readonly _ImageProcessingDirtyCallBack;
  25106. private static readonly _TextureDirtyCallBack;
  25107. private static readonly _FresnelDirtyCallBack;
  25108. private static readonly _MiscDirtyCallBack;
  25109. private static readonly _LightsDirtyCallBack;
  25110. private static readonly _AttributeDirtyCallBack;
  25111. private static _FresnelAndMiscDirtyCallBack;
  25112. private static _TextureAndMiscDirtyCallBack;
  25113. private static readonly _DirtyCallbackArray;
  25114. private static readonly _RunDirtyCallBacks;
  25115. /**
  25116. * Marks a define in the material to indicate that it needs to be re-computed
  25117. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25118. */
  25119. markAsDirty(flag: number): void;
  25120. /**
  25121. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25122. * @param func defines a function which checks material defines against the submeshes
  25123. */
  25124. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25125. /**
  25126. * Indicates that the scene should check if the rendering now needs a prepass
  25127. */
  25128. protected _markScenePrePassDirty(): void;
  25129. /**
  25130. * Indicates that we need to re-calculated for all submeshes
  25131. */
  25132. protected _markAllSubMeshesAsAllDirty(): void;
  25133. /**
  25134. * Indicates that image processing needs to be re-calculated for all submeshes
  25135. */
  25136. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25137. /**
  25138. * Indicates that textures need to be re-calculated for all submeshes
  25139. */
  25140. protected _markAllSubMeshesAsTexturesDirty(): void;
  25141. /**
  25142. * Indicates that fresnel needs to be re-calculated for all submeshes
  25143. */
  25144. protected _markAllSubMeshesAsFresnelDirty(): void;
  25145. /**
  25146. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25147. */
  25148. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25149. /**
  25150. * Indicates that lights need to be re-calculated for all submeshes
  25151. */
  25152. protected _markAllSubMeshesAsLightsDirty(): void;
  25153. /**
  25154. * Indicates that attributes need to be re-calculated for all submeshes
  25155. */
  25156. protected _markAllSubMeshesAsAttributesDirty(): void;
  25157. /**
  25158. * Indicates that misc needs to be re-calculated for all submeshes
  25159. */
  25160. protected _markAllSubMeshesAsMiscDirty(): void;
  25161. /**
  25162. * Indicates that textures and misc need to be re-calculated for all submeshes
  25163. */
  25164. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25165. /**
  25166. * Sets the required values to the prepass renderer.
  25167. * @param prePassRenderer defines the prepass renderer to setup.
  25168. * @returns true if the pre pass is needed.
  25169. */
  25170. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25171. /**
  25172. * Disposes the material
  25173. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25174. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25175. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25176. */
  25177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25178. /** @hidden */
  25179. private releaseVertexArrayObject;
  25180. /**
  25181. * Serializes this material
  25182. * @returns the serialized material object
  25183. */
  25184. serialize(): any;
  25185. /**
  25186. * Creates a material from parsed material data
  25187. * @param parsedMaterial defines parsed material data
  25188. * @param scene defines the hosting scene
  25189. * @param rootUrl defines the root URL to use to load textures
  25190. * @returns a new material
  25191. */
  25192. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25193. }
  25194. }
  25195. declare module BABYLON {
  25196. /**
  25197. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25198. * separate meshes. This can be use to improve performances.
  25199. * @see https://doc.babylonjs.com/how_to/multi_materials
  25200. */
  25201. export class MultiMaterial extends Material {
  25202. private _subMaterials;
  25203. /**
  25204. * Gets or Sets the list of Materials used within the multi material.
  25205. * They need to be ordered according to the submeshes order in the associated mesh
  25206. */
  25207. get subMaterials(): Nullable<Material>[];
  25208. set subMaterials(value: Nullable<Material>[]);
  25209. /**
  25210. * Function used to align with Node.getChildren()
  25211. * @returns the list of Materials used within the multi material
  25212. */
  25213. getChildren(): Nullable<Material>[];
  25214. /**
  25215. * Instantiates a new Multi Material
  25216. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25217. * separate meshes. This can be use to improve performances.
  25218. * @see https://doc.babylonjs.com/how_to/multi_materials
  25219. * @param name Define the name in the scene
  25220. * @param scene Define the scene the material belongs to
  25221. */
  25222. constructor(name: string, scene: Scene);
  25223. private _hookArray;
  25224. /**
  25225. * Get one of the submaterial by its index in the submaterials array
  25226. * @param index The index to look the sub material at
  25227. * @returns The Material if the index has been defined
  25228. */
  25229. getSubMaterial(index: number): Nullable<Material>;
  25230. /**
  25231. * Get the list of active textures for the whole sub materials list.
  25232. * @returns All the textures that will be used during the rendering
  25233. */
  25234. getActiveTextures(): BaseTexture[];
  25235. /**
  25236. * Gets the current class name of the material e.g. "MultiMaterial"
  25237. * Mainly use in serialization.
  25238. * @returns the class name
  25239. */
  25240. getClassName(): string;
  25241. /**
  25242. * Checks if the material is ready to render the requested sub mesh
  25243. * @param mesh Define the mesh the submesh belongs to
  25244. * @param subMesh Define the sub mesh to look readyness for
  25245. * @param useInstances Define whether or not the material is used with instances
  25246. * @returns true if ready, otherwise false
  25247. */
  25248. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25249. /**
  25250. * Clones the current material and its related sub materials
  25251. * @param name Define the name of the newly cloned material
  25252. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25253. * @returns the cloned material
  25254. */
  25255. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25256. /**
  25257. * Serializes the materials into a JSON representation.
  25258. * @returns the JSON representation
  25259. */
  25260. serialize(): any;
  25261. /**
  25262. * Dispose the material and release its associated resources
  25263. * @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)
  25264. * @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)
  25265. * @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)
  25266. */
  25267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25268. /**
  25269. * Creates a MultiMaterial from parsed MultiMaterial data.
  25270. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25271. * @param scene defines the hosting scene
  25272. * @returns a new MultiMaterial
  25273. */
  25274. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25275. }
  25276. }
  25277. declare module BABYLON {
  25278. /**
  25279. * Defines a subdivision inside a mesh
  25280. */
  25281. export class SubMesh implements ICullable {
  25282. /** the material index to use */
  25283. materialIndex: number;
  25284. /** vertex index start */
  25285. verticesStart: number;
  25286. /** vertices count */
  25287. verticesCount: number;
  25288. /** index start */
  25289. indexStart: number;
  25290. /** indices count */
  25291. indexCount: number;
  25292. /** @hidden */
  25293. _materialDefines: Nullable<MaterialDefines>;
  25294. /** @hidden */
  25295. _materialEffect: Nullable<Effect>;
  25296. /** @hidden */
  25297. _effectOverride: Nullable<Effect>;
  25298. /**
  25299. * Gets material defines used by the effect associated to the sub mesh
  25300. */
  25301. get materialDefines(): Nullable<MaterialDefines>;
  25302. /**
  25303. * Sets material defines used by the effect associated to the sub mesh
  25304. */
  25305. set materialDefines(defines: Nullable<MaterialDefines>);
  25306. /**
  25307. * Gets associated effect
  25308. */
  25309. get effect(): Nullable<Effect>;
  25310. /**
  25311. * Sets associated effect (effect used to render this submesh)
  25312. * @param effect defines the effect to associate with
  25313. * @param defines defines the set of defines used to compile this effect
  25314. */
  25315. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25316. /** @hidden */
  25317. _linesIndexCount: number;
  25318. private _mesh;
  25319. private _renderingMesh;
  25320. private _boundingInfo;
  25321. private _linesIndexBuffer;
  25322. /** @hidden */
  25323. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25324. /** @hidden */
  25325. _trianglePlanes: Plane[];
  25326. /** @hidden */
  25327. _lastColliderTransformMatrix: Nullable<Matrix>;
  25328. /** @hidden */
  25329. _renderId: number;
  25330. /** @hidden */
  25331. _alphaIndex: number;
  25332. /** @hidden */
  25333. _distanceToCamera: number;
  25334. /** @hidden */
  25335. _id: number;
  25336. private _currentMaterial;
  25337. /**
  25338. * Add a new submesh to a mesh
  25339. * @param materialIndex defines the material index to use
  25340. * @param verticesStart defines vertex index start
  25341. * @param verticesCount defines vertices count
  25342. * @param indexStart defines index start
  25343. * @param indexCount defines indices count
  25344. * @param mesh defines the parent mesh
  25345. * @param renderingMesh defines an optional rendering mesh
  25346. * @param createBoundingBox defines if bounding box should be created for this submesh
  25347. * @returns the new submesh
  25348. */
  25349. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25350. /**
  25351. * Creates a new submesh
  25352. * @param materialIndex defines the material index to use
  25353. * @param verticesStart defines vertex index start
  25354. * @param verticesCount defines vertices count
  25355. * @param indexStart defines index start
  25356. * @param indexCount defines indices count
  25357. * @param mesh defines the parent mesh
  25358. * @param renderingMesh defines an optional rendering mesh
  25359. * @param createBoundingBox defines if bounding box should be created for this submesh
  25360. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25361. */
  25362. constructor(
  25363. /** the material index to use */
  25364. materialIndex: number,
  25365. /** vertex index start */
  25366. verticesStart: number,
  25367. /** vertices count */
  25368. verticesCount: number,
  25369. /** index start */
  25370. indexStart: number,
  25371. /** indices count */
  25372. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25373. /**
  25374. * Returns true if this submesh covers the entire parent mesh
  25375. * @ignorenaming
  25376. */
  25377. get IsGlobal(): boolean;
  25378. /**
  25379. * Returns the submesh BoudingInfo object
  25380. * @returns current bounding info (or mesh's one if the submesh is global)
  25381. */
  25382. getBoundingInfo(): BoundingInfo;
  25383. /**
  25384. * Sets the submesh BoundingInfo
  25385. * @param boundingInfo defines the new bounding info to use
  25386. * @returns the SubMesh
  25387. */
  25388. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25389. /**
  25390. * Returns the mesh of the current submesh
  25391. * @return the parent mesh
  25392. */
  25393. getMesh(): AbstractMesh;
  25394. /**
  25395. * Returns the rendering mesh of the submesh
  25396. * @returns the rendering mesh (could be different from parent mesh)
  25397. */
  25398. getRenderingMesh(): Mesh;
  25399. /**
  25400. * Returns the replacement mesh of the submesh
  25401. * @returns the replacement mesh (could be different from parent mesh)
  25402. */
  25403. getReplacementMesh(): Nullable<AbstractMesh>;
  25404. /**
  25405. * Returns the effective mesh of the submesh
  25406. * @returns the effective mesh (could be different from parent mesh)
  25407. */
  25408. getEffectiveMesh(): AbstractMesh;
  25409. /**
  25410. * Returns the submesh material
  25411. * @returns null or the current material
  25412. */
  25413. getMaterial(): Nullable<Material>;
  25414. private _IsMultiMaterial;
  25415. /**
  25416. * Sets a new updated BoundingInfo object to the submesh
  25417. * @param data defines an optional position array to use to determine the bounding info
  25418. * @returns the SubMesh
  25419. */
  25420. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25421. /** @hidden */
  25422. _checkCollision(collider: Collider): boolean;
  25423. /**
  25424. * Updates the submesh BoundingInfo
  25425. * @param world defines the world matrix to use to update the bounding info
  25426. * @returns the submesh
  25427. */
  25428. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25429. /**
  25430. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25431. * @param frustumPlanes defines the frustum planes
  25432. * @returns true if the submesh is intersecting with the frustum
  25433. */
  25434. isInFrustum(frustumPlanes: Plane[]): boolean;
  25435. /**
  25436. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25437. * @param frustumPlanes defines the frustum planes
  25438. * @returns true if the submesh is inside the frustum
  25439. */
  25440. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25441. /**
  25442. * Renders the submesh
  25443. * @param enableAlphaMode defines if alpha needs to be used
  25444. * @returns the submesh
  25445. */
  25446. render(enableAlphaMode: boolean): SubMesh;
  25447. /**
  25448. * @hidden
  25449. */
  25450. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25451. /**
  25452. * Checks if the submesh intersects with a ray
  25453. * @param ray defines the ray to test
  25454. * @returns true is the passed ray intersects the submesh bounding box
  25455. */
  25456. canIntersects(ray: Ray): boolean;
  25457. /**
  25458. * Intersects current submesh with a ray
  25459. * @param ray defines the ray to test
  25460. * @param positions defines mesh's positions array
  25461. * @param indices defines mesh's indices array
  25462. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25463. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25464. * @returns intersection info or null if no intersection
  25465. */
  25466. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25467. /** @hidden */
  25468. private _intersectLines;
  25469. /** @hidden */
  25470. private _intersectUnIndexedLines;
  25471. /** @hidden */
  25472. private _intersectTriangles;
  25473. /** @hidden */
  25474. private _intersectUnIndexedTriangles;
  25475. /** @hidden */
  25476. _rebuild(): void;
  25477. /**
  25478. * Creates a new submesh from the passed mesh
  25479. * @param newMesh defines the new hosting mesh
  25480. * @param newRenderingMesh defines an optional rendering mesh
  25481. * @returns the new submesh
  25482. */
  25483. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25484. /**
  25485. * Release associated resources
  25486. */
  25487. dispose(): void;
  25488. /**
  25489. * Gets the class name
  25490. * @returns the string "SubMesh".
  25491. */
  25492. getClassName(): string;
  25493. /**
  25494. * Creates a new submesh from indices data
  25495. * @param materialIndex the index of the main mesh material
  25496. * @param startIndex the index where to start the copy in the mesh indices array
  25497. * @param indexCount the number of indices to copy then from the startIndex
  25498. * @param mesh the main mesh to create the submesh from
  25499. * @param renderingMesh the optional rendering mesh
  25500. * @returns a new submesh
  25501. */
  25502. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25503. }
  25504. }
  25505. declare module BABYLON {
  25506. /**
  25507. * Class used to represent data loading progression
  25508. */
  25509. export class SceneLoaderFlags {
  25510. private static _ForceFullSceneLoadingForIncremental;
  25511. private static _ShowLoadingScreen;
  25512. private static _CleanBoneMatrixWeights;
  25513. private static _loggingLevel;
  25514. /**
  25515. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25516. */
  25517. static get ForceFullSceneLoadingForIncremental(): boolean;
  25518. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25519. /**
  25520. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25521. */
  25522. static get ShowLoadingScreen(): boolean;
  25523. static set ShowLoadingScreen(value: boolean);
  25524. /**
  25525. * Defines the current logging level (while loading the scene)
  25526. * @ignorenaming
  25527. */
  25528. static get loggingLevel(): number;
  25529. static set loggingLevel(value: number);
  25530. /**
  25531. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25532. */
  25533. static get CleanBoneMatrixWeights(): boolean;
  25534. static set CleanBoneMatrixWeights(value: boolean);
  25535. }
  25536. }
  25537. declare module BABYLON {
  25538. /**
  25539. * Class used to store geometry data (vertex buffers + index buffer)
  25540. */
  25541. export class Geometry implements IGetSetVerticesData {
  25542. /**
  25543. * Gets or sets the ID of the geometry
  25544. */
  25545. id: string;
  25546. /**
  25547. * Gets or sets the unique ID of the geometry
  25548. */
  25549. uniqueId: number;
  25550. /**
  25551. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25552. */
  25553. delayLoadState: number;
  25554. /**
  25555. * Gets the file containing the data to load when running in delay load state
  25556. */
  25557. delayLoadingFile: Nullable<string>;
  25558. /**
  25559. * Callback called when the geometry is updated
  25560. */
  25561. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25562. private _scene;
  25563. private _engine;
  25564. private _meshes;
  25565. private _totalVertices;
  25566. /** @hidden */
  25567. _indices: IndicesArray;
  25568. /** @hidden */
  25569. _vertexBuffers: {
  25570. [key: string]: VertexBuffer;
  25571. };
  25572. private _isDisposed;
  25573. private _extend;
  25574. private _boundingBias;
  25575. /** @hidden */
  25576. _delayInfo: Array<string>;
  25577. private _indexBuffer;
  25578. private _indexBufferIsUpdatable;
  25579. /** @hidden */
  25580. _boundingInfo: Nullable<BoundingInfo>;
  25581. /** @hidden */
  25582. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25583. /** @hidden */
  25584. _softwareSkinningFrameId: number;
  25585. private _vertexArrayObjects;
  25586. private _updatable;
  25587. /** @hidden */
  25588. _positions: Nullable<Vector3[]>;
  25589. /**
  25590. * 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
  25591. */
  25592. get boundingBias(): Vector2;
  25593. /**
  25594. * 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
  25595. */
  25596. set boundingBias(value: Vector2);
  25597. /**
  25598. * Static function used to attach a new empty geometry to a mesh
  25599. * @param mesh defines the mesh to attach the geometry to
  25600. * @returns the new Geometry
  25601. */
  25602. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25603. /** Get the list of meshes using this geometry */
  25604. get meshes(): Mesh[];
  25605. /**
  25606. * 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
  25607. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25608. */
  25609. useBoundingInfoFromGeometry: boolean;
  25610. /**
  25611. * Creates a new geometry
  25612. * @param id defines the unique ID
  25613. * @param scene defines the hosting scene
  25614. * @param vertexData defines the VertexData used to get geometry data
  25615. * @param updatable defines if geometry must be updatable (false by default)
  25616. * @param mesh defines the mesh that will be associated with the geometry
  25617. */
  25618. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25619. /**
  25620. * Gets the current extend of the geometry
  25621. */
  25622. get extend(): {
  25623. minimum: Vector3;
  25624. maximum: Vector3;
  25625. };
  25626. /**
  25627. * Gets the hosting scene
  25628. * @returns the hosting Scene
  25629. */
  25630. getScene(): Scene;
  25631. /**
  25632. * Gets the hosting engine
  25633. * @returns the hosting Engine
  25634. */
  25635. getEngine(): Engine;
  25636. /**
  25637. * Defines if the geometry is ready to use
  25638. * @returns true if the geometry is ready to be used
  25639. */
  25640. isReady(): boolean;
  25641. /**
  25642. * Gets a value indicating that the geometry should not be serialized
  25643. */
  25644. get doNotSerialize(): boolean;
  25645. /** @hidden */
  25646. _rebuild(): void;
  25647. /**
  25648. * Affects all geometry data in one call
  25649. * @param vertexData defines the geometry data
  25650. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25651. */
  25652. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25653. /**
  25654. * Set specific vertex data
  25655. * @param kind defines the data kind (Position, normal, etc...)
  25656. * @param data defines the vertex data to use
  25657. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25658. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25659. */
  25660. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25661. /**
  25662. * Removes a specific vertex data
  25663. * @param kind defines the data kind (Position, normal, etc...)
  25664. */
  25665. removeVerticesData(kind: string): void;
  25666. /**
  25667. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25668. * @param buffer defines the vertex buffer to use
  25669. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25670. */
  25671. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25672. /**
  25673. * Update a specific vertex buffer
  25674. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25675. * It will do nothing if the buffer is not updatable
  25676. * @param kind defines the data kind (Position, normal, etc...)
  25677. * @param data defines the data to use
  25678. * @param offset defines the offset in the target buffer where to store the data
  25679. * @param useBytes set to true if the offset is in bytes
  25680. */
  25681. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25682. /**
  25683. * Update a specific vertex buffer
  25684. * This function will create a new buffer if the current one is not updatable
  25685. * @param kind defines the data kind (Position, normal, etc...)
  25686. * @param data defines the data to use
  25687. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25688. */
  25689. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25690. private _updateBoundingInfo;
  25691. /** @hidden */
  25692. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25693. /**
  25694. * Gets total number of vertices
  25695. * @returns the total number of vertices
  25696. */
  25697. getTotalVertices(): number;
  25698. /**
  25699. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25700. * @param kind defines the data kind (Position, normal, etc...)
  25701. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25703. * @returns a float array containing vertex data
  25704. */
  25705. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25706. /**
  25707. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25708. * @param kind defines the data kind (Position, normal, etc...)
  25709. * @returns true if the vertex buffer with the specified kind is updatable
  25710. */
  25711. isVertexBufferUpdatable(kind: string): boolean;
  25712. /**
  25713. * Gets a specific vertex buffer
  25714. * @param kind defines the data kind (Position, normal, etc...)
  25715. * @returns a VertexBuffer
  25716. */
  25717. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25718. /**
  25719. * Returns all vertex buffers
  25720. * @return an object holding all vertex buffers indexed by kind
  25721. */
  25722. getVertexBuffers(): Nullable<{
  25723. [key: string]: VertexBuffer;
  25724. }>;
  25725. /**
  25726. * Gets a boolean indicating if specific vertex buffer is present
  25727. * @param kind defines the data kind (Position, normal, etc...)
  25728. * @returns true if data is present
  25729. */
  25730. isVerticesDataPresent(kind: string): boolean;
  25731. /**
  25732. * Gets a list of all attached data kinds (Position, normal, etc...)
  25733. * @returns a list of string containing all kinds
  25734. */
  25735. getVerticesDataKinds(): string[];
  25736. /**
  25737. * Update index buffer
  25738. * @param indices defines the indices to store in the index buffer
  25739. * @param offset defines the offset in the target buffer where to store the data
  25740. * @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)
  25741. */
  25742. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25743. /**
  25744. * Creates a new index buffer
  25745. * @param indices defines the indices to store in the index buffer
  25746. * @param totalVertices defines the total number of vertices (could be null)
  25747. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25748. */
  25749. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25750. /**
  25751. * Return the total number of indices
  25752. * @returns the total number of indices
  25753. */
  25754. getTotalIndices(): number;
  25755. /**
  25756. * Gets the index buffer array
  25757. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25758. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25759. * @returns the index buffer array
  25760. */
  25761. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25762. /**
  25763. * Gets the index buffer
  25764. * @return the index buffer
  25765. */
  25766. getIndexBuffer(): Nullable<DataBuffer>;
  25767. /** @hidden */
  25768. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25769. /**
  25770. * Release the associated resources for a specific mesh
  25771. * @param mesh defines the source mesh
  25772. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25773. */
  25774. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25775. /**
  25776. * Apply current geometry to a given mesh
  25777. * @param mesh defines the mesh to apply geometry to
  25778. */
  25779. applyToMesh(mesh: Mesh): void;
  25780. private _updateExtend;
  25781. private _applyToMesh;
  25782. private notifyUpdate;
  25783. /**
  25784. * Load the geometry if it was flagged as delay loaded
  25785. * @param scene defines the hosting scene
  25786. * @param onLoaded defines a callback called when the geometry is loaded
  25787. */
  25788. load(scene: Scene, onLoaded?: () => void): void;
  25789. private _queueLoad;
  25790. /**
  25791. * Invert the geometry to move from a right handed system to a left handed one.
  25792. */
  25793. toLeftHanded(): void;
  25794. /** @hidden */
  25795. _resetPointsArrayCache(): void;
  25796. /** @hidden */
  25797. _generatePointsArray(): boolean;
  25798. /**
  25799. * Gets a value indicating if the geometry is disposed
  25800. * @returns true if the geometry was disposed
  25801. */
  25802. isDisposed(): boolean;
  25803. private _disposeVertexArrayObjects;
  25804. /**
  25805. * Free all associated resources
  25806. */
  25807. dispose(): void;
  25808. /**
  25809. * Clone the current geometry into a new geometry
  25810. * @param id defines the unique ID of the new geometry
  25811. * @returns a new geometry object
  25812. */
  25813. copy(id: string): Geometry;
  25814. /**
  25815. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25816. * @return a JSON representation of the current geometry data (without the vertices data)
  25817. */
  25818. serialize(): any;
  25819. private toNumberArray;
  25820. /**
  25821. * Serialize all vertices data into a JSON oject
  25822. * @returns a JSON representation of the current geometry data
  25823. */
  25824. serializeVerticeData(): any;
  25825. /**
  25826. * Extracts a clone of a mesh geometry
  25827. * @param mesh defines the source mesh
  25828. * @param id defines the unique ID of the new geometry object
  25829. * @returns the new geometry object
  25830. */
  25831. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25832. /**
  25833. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25834. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25835. * Be aware Math.random() could cause collisions, but:
  25836. * "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"
  25837. * @returns a string containing a new GUID
  25838. */
  25839. static RandomId(): string;
  25840. /** @hidden */
  25841. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25842. private static _CleanMatricesWeights;
  25843. /**
  25844. * Create a new geometry from persisted data (Using .babylon file format)
  25845. * @param parsedVertexData defines the persisted data
  25846. * @param scene defines the hosting scene
  25847. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25848. * @returns the new geometry object
  25849. */
  25850. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25851. }
  25852. }
  25853. declare module BABYLON {
  25854. /**
  25855. * Define an interface for all classes that will get and set the data on vertices
  25856. */
  25857. export interface IGetSetVerticesData {
  25858. /**
  25859. * Gets a boolean indicating if specific vertex data is present
  25860. * @param kind defines the vertex data kind to use
  25861. * @returns true is data kind is present
  25862. */
  25863. isVerticesDataPresent(kind: string): boolean;
  25864. /**
  25865. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25866. * @param kind defines the data kind (Position, normal, etc...)
  25867. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25868. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25869. * @returns a float array containing vertex data
  25870. */
  25871. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25872. /**
  25873. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25874. * @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.
  25875. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25876. * @returns the indices array or an empty array if the mesh has no geometry
  25877. */
  25878. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25879. /**
  25880. * Set specific vertex data
  25881. * @param kind defines the data kind (Position, normal, etc...)
  25882. * @param data defines the vertex data to use
  25883. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25884. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25885. */
  25886. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25887. /**
  25888. * Update a specific associated vertex buffer
  25889. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25890. * - VertexBuffer.PositionKind
  25891. * - VertexBuffer.UVKind
  25892. * - VertexBuffer.UV2Kind
  25893. * - VertexBuffer.UV3Kind
  25894. * - VertexBuffer.UV4Kind
  25895. * - VertexBuffer.UV5Kind
  25896. * - VertexBuffer.UV6Kind
  25897. * - VertexBuffer.ColorKind
  25898. * - VertexBuffer.MatricesIndicesKind
  25899. * - VertexBuffer.MatricesIndicesExtraKind
  25900. * - VertexBuffer.MatricesWeightsKind
  25901. * - VertexBuffer.MatricesWeightsExtraKind
  25902. * @param data defines the data source
  25903. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25904. * @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)
  25905. */
  25906. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25907. /**
  25908. * Creates a new index buffer
  25909. * @param indices defines the indices to store in the index buffer
  25910. * @param totalVertices defines the total number of vertices (could be null)
  25911. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25912. */
  25913. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25914. }
  25915. /**
  25916. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25917. */
  25918. export class VertexData {
  25919. /**
  25920. * Mesh side orientation : usually the external or front surface
  25921. */
  25922. static readonly FRONTSIDE: number;
  25923. /**
  25924. * Mesh side orientation : usually the internal or back surface
  25925. */
  25926. static readonly BACKSIDE: number;
  25927. /**
  25928. * Mesh side orientation : both internal and external or front and back surfaces
  25929. */
  25930. static readonly DOUBLESIDE: number;
  25931. /**
  25932. * Mesh side orientation : by default, `FRONTSIDE`
  25933. */
  25934. static readonly DEFAULTSIDE: number;
  25935. /**
  25936. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25937. */
  25938. positions: Nullable<FloatArray>;
  25939. /**
  25940. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25941. */
  25942. normals: Nullable<FloatArray>;
  25943. /**
  25944. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25945. */
  25946. tangents: Nullable<FloatArray>;
  25947. /**
  25948. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25949. */
  25950. uvs: Nullable<FloatArray>;
  25951. /**
  25952. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25953. */
  25954. uvs2: Nullable<FloatArray>;
  25955. /**
  25956. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25957. */
  25958. uvs3: Nullable<FloatArray>;
  25959. /**
  25960. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25961. */
  25962. uvs4: Nullable<FloatArray>;
  25963. /**
  25964. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25965. */
  25966. uvs5: Nullable<FloatArray>;
  25967. /**
  25968. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25969. */
  25970. uvs6: Nullable<FloatArray>;
  25971. /**
  25972. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25973. */
  25974. colors: Nullable<FloatArray>;
  25975. /**
  25976. * 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).
  25977. */
  25978. matricesIndices: Nullable<FloatArray>;
  25979. /**
  25980. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25981. */
  25982. matricesWeights: Nullable<FloatArray>;
  25983. /**
  25984. * An array extending the number of possible indices
  25985. */
  25986. matricesIndicesExtra: Nullable<FloatArray>;
  25987. /**
  25988. * An array extending the number of possible weights when the number of indices is extended
  25989. */
  25990. matricesWeightsExtra: Nullable<FloatArray>;
  25991. /**
  25992. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25993. */
  25994. indices: Nullable<IndicesArray>;
  25995. /**
  25996. * Uses the passed data array to set the set the values for the specified kind of data
  25997. * @param data a linear array of floating numbers
  25998. * @param kind the type of data that is being set, eg positions, colors etc
  25999. */
  26000. set(data: FloatArray, kind: string): void;
  26001. /**
  26002. * Associates the vertexData to the passed Mesh.
  26003. * Sets it as updatable or not (default `false`)
  26004. * @param mesh the mesh the vertexData is applied to
  26005. * @param updatable when used and having the value true allows new data to update the vertexData
  26006. * @returns the VertexData
  26007. */
  26008. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26009. /**
  26010. * Associates the vertexData to the passed Geometry.
  26011. * Sets it as updatable or not (default `false`)
  26012. * @param geometry the geometry the vertexData is applied to
  26013. * @param updatable when used and having the value true allows new data to update the vertexData
  26014. * @returns VertexData
  26015. */
  26016. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26017. /**
  26018. * Updates the associated mesh
  26019. * @param mesh the mesh to be updated
  26020. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26021. * @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
  26022. * @returns VertexData
  26023. */
  26024. updateMesh(mesh: Mesh): VertexData;
  26025. /**
  26026. * Updates the associated geometry
  26027. * @param geometry the geometry to be updated
  26028. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26029. * @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
  26030. * @returns VertexData.
  26031. */
  26032. updateGeometry(geometry: Geometry): VertexData;
  26033. private _applyTo;
  26034. private _update;
  26035. /**
  26036. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26037. * @param matrix the transforming matrix
  26038. * @returns the VertexData
  26039. */
  26040. transform(matrix: Matrix): VertexData;
  26041. /**
  26042. * Merges the passed VertexData into the current one
  26043. * @param other the VertexData to be merged into the current one
  26044. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26045. * @returns the modified VertexData
  26046. */
  26047. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26048. private _mergeElement;
  26049. private _validate;
  26050. /**
  26051. * Serializes the VertexData
  26052. * @returns a serialized object
  26053. */
  26054. serialize(): any;
  26055. /**
  26056. * Extracts the vertexData from a mesh
  26057. * @param mesh the mesh from which to extract the VertexData
  26058. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26059. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26060. * @returns the object VertexData associated to the passed mesh
  26061. */
  26062. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26063. /**
  26064. * Extracts the vertexData from the geometry
  26065. * @param geometry the geometry from which to extract the VertexData
  26066. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26067. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26068. * @returns the object VertexData associated to the passed mesh
  26069. */
  26070. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26071. private static _ExtractFrom;
  26072. /**
  26073. * Creates the VertexData for a Ribbon
  26074. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26075. * * pathArray array of paths, each of which an array of successive Vector3
  26076. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26077. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26078. * * 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
  26079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26080. * * 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)
  26081. * * 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)
  26082. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26083. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26084. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26085. * @returns the VertexData of the ribbon
  26086. */
  26087. static CreateRibbon(options: {
  26088. pathArray: Vector3[][];
  26089. closeArray?: boolean;
  26090. closePath?: boolean;
  26091. offset?: number;
  26092. sideOrientation?: number;
  26093. frontUVs?: Vector4;
  26094. backUVs?: Vector4;
  26095. invertUV?: boolean;
  26096. uvs?: Vector2[];
  26097. colors?: Color4[];
  26098. }): VertexData;
  26099. /**
  26100. * Creates the VertexData for a box
  26101. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26102. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26103. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26104. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26105. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26106. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26107. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26109. * * 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)
  26110. * * 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)
  26111. * @returns the VertexData of the box
  26112. */
  26113. static CreateBox(options: {
  26114. size?: number;
  26115. width?: number;
  26116. height?: number;
  26117. depth?: number;
  26118. faceUV?: Vector4[];
  26119. faceColors?: Color4[];
  26120. sideOrientation?: number;
  26121. frontUVs?: Vector4;
  26122. backUVs?: Vector4;
  26123. }): VertexData;
  26124. /**
  26125. * Creates the VertexData for a tiled box
  26126. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26127. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26128. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26129. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26130. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26131. * @returns the VertexData of the box
  26132. */
  26133. static CreateTiledBox(options: {
  26134. pattern?: number;
  26135. width?: number;
  26136. height?: number;
  26137. depth?: number;
  26138. tileSize?: number;
  26139. tileWidth?: number;
  26140. tileHeight?: number;
  26141. alignHorizontal?: number;
  26142. alignVertical?: number;
  26143. faceUV?: Vector4[];
  26144. faceColors?: Color4[];
  26145. sideOrientation?: number;
  26146. }): VertexData;
  26147. /**
  26148. * Creates the VertexData for a tiled plane
  26149. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26150. * * pattern a limited pattern arrangement depending on the number
  26151. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26152. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26153. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26155. * * 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)
  26156. * * 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)
  26157. * @returns the VertexData of the tiled plane
  26158. */
  26159. static CreateTiledPlane(options: {
  26160. pattern?: number;
  26161. tileSize?: number;
  26162. tileWidth?: number;
  26163. tileHeight?: number;
  26164. size?: number;
  26165. width?: number;
  26166. height?: number;
  26167. alignHorizontal?: number;
  26168. alignVertical?: number;
  26169. sideOrientation?: number;
  26170. frontUVs?: Vector4;
  26171. backUVs?: Vector4;
  26172. }): VertexData;
  26173. /**
  26174. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26175. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26176. * * segments sets the number of horizontal strips optional, default 32
  26177. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26178. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26179. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26180. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26181. * * 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
  26182. * * 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
  26183. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26184. * * 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)
  26185. * * 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)
  26186. * @returns the VertexData of the ellipsoid
  26187. */
  26188. static CreateSphere(options: {
  26189. segments?: number;
  26190. diameter?: number;
  26191. diameterX?: number;
  26192. diameterY?: number;
  26193. diameterZ?: number;
  26194. arc?: number;
  26195. slice?: number;
  26196. sideOrientation?: number;
  26197. frontUVs?: Vector4;
  26198. backUVs?: Vector4;
  26199. }): VertexData;
  26200. /**
  26201. * Creates the VertexData for a cylinder, cone or prism
  26202. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26203. * * height sets the height (y direction) of the cylinder, optional, default 2
  26204. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26205. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26206. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26207. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26208. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26209. * * 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
  26210. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26211. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26212. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26213. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26215. * * 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)
  26216. * * 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)
  26217. * @returns the VertexData of the cylinder, cone or prism
  26218. */
  26219. static CreateCylinder(options: {
  26220. height?: number;
  26221. diameterTop?: number;
  26222. diameterBottom?: number;
  26223. diameter?: number;
  26224. tessellation?: number;
  26225. subdivisions?: number;
  26226. arc?: number;
  26227. faceColors?: Color4[];
  26228. faceUV?: Vector4[];
  26229. hasRings?: boolean;
  26230. enclose?: boolean;
  26231. sideOrientation?: number;
  26232. frontUVs?: Vector4;
  26233. backUVs?: Vector4;
  26234. }): VertexData;
  26235. /**
  26236. * Creates the VertexData for a torus
  26237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26238. * * diameter the diameter of the torus, optional default 1
  26239. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26240. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26241. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26242. * * 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)
  26243. * * 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)
  26244. * @returns the VertexData of the torus
  26245. */
  26246. static CreateTorus(options: {
  26247. diameter?: number;
  26248. thickness?: number;
  26249. tessellation?: number;
  26250. sideOrientation?: number;
  26251. frontUVs?: Vector4;
  26252. backUVs?: Vector4;
  26253. }): VertexData;
  26254. /**
  26255. * Creates the VertexData of the LineSystem
  26256. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26257. * - lines an array of lines, each line being an array of successive Vector3
  26258. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26259. * @returns the VertexData of the LineSystem
  26260. */
  26261. static CreateLineSystem(options: {
  26262. lines: Vector3[][];
  26263. colors?: Nullable<Color4[][]>;
  26264. }): VertexData;
  26265. /**
  26266. * Create the VertexData for a DashedLines
  26267. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26268. * - points an array successive Vector3
  26269. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26270. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26271. * - dashNb the intended total number of dashes, optional, default 200
  26272. * @returns the VertexData for the DashedLines
  26273. */
  26274. static CreateDashedLines(options: {
  26275. points: Vector3[];
  26276. dashSize?: number;
  26277. gapSize?: number;
  26278. dashNb?: number;
  26279. }): VertexData;
  26280. /**
  26281. * Creates the VertexData for a Ground
  26282. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26283. * - width the width (x direction) of the ground, optional, default 1
  26284. * - height the height (z direction) of the ground, optional, default 1
  26285. * - subdivisions the number of subdivisions per side, optional, default 1
  26286. * @returns the VertexData of the Ground
  26287. */
  26288. static CreateGround(options: {
  26289. width?: number;
  26290. height?: number;
  26291. subdivisions?: number;
  26292. subdivisionsX?: number;
  26293. subdivisionsY?: number;
  26294. }): VertexData;
  26295. /**
  26296. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26297. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26298. * * xmin the ground minimum X coordinate, optional, default -1
  26299. * * zmin the ground minimum Z coordinate, optional, default -1
  26300. * * xmax the ground maximum X coordinate, optional, default 1
  26301. * * zmax the ground maximum Z coordinate, optional, default 1
  26302. * * 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}
  26303. * * 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}
  26304. * @returns the VertexData of the TiledGround
  26305. */
  26306. static CreateTiledGround(options: {
  26307. xmin: number;
  26308. zmin: number;
  26309. xmax: number;
  26310. zmax: number;
  26311. subdivisions?: {
  26312. w: number;
  26313. h: number;
  26314. };
  26315. precision?: {
  26316. w: number;
  26317. h: number;
  26318. };
  26319. }): VertexData;
  26320. /**
  26321. * Creates the VertexData of the Ground designed from a heightmap
  26322. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26323. * * width the width (x direction) of the ground
  26324. * * height the height (z direction) of the ground
  26325. * * subdivisions the number of subdivisions per side
  26326. * * minHeight the minimum altitude on the ground, optional, default 0
  26327. * * maxHeight the maximum altitude on the ground, optional default 1
  26328. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26329. * * buffer the array holding the image color data
  26330. * * bufferWidth the width of image
  26331. * * bufferHeight the height of image
  26332. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26333. * @returns the VertexData of the Ground designed from a heightmap
  26334. */
  26335. static CreateGroundFromHeightMap(options: {
  26336. width: number;
  26337. height: number;
  26338. subdivisions: number;
  26339. minHeight: number;
  26340. maxHeight: number;
  26341. colorFilter: Color3;
  26342. buffer: Uint8Array;
  26343. bufferWidth: number;
  26344. bufferHeight: number;
  26345. alphaFilter: number;
  26346. }): VertexData;
  26347. /**
  26348. * Creates the VertexData for a Plane
  26349. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26350. * * size sets the width and height of the plane to the value of size, optional default 1
  26351. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26352. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26354. * * 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)
  26355. * * 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)
  26356. * @returns the VertexData of the box
  26357. */
  26358. static CreatePlane(options: {
  26359. size?: number;
  26360. width?: number;
  26361. height?: number;
  26362. sideOrientation?: number;
  26363. frontUVs?: Vector4;
  26364. backUVs?: Vector4;
  26365. }): VertexData;
  26366. /**
  26367. * Creates the VertexData of the Disc or regular Polygon
  26368. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26369. * * radius the radius of the disc, optional default 0.5
  26370. * * tessellation the number of polygon sides, optional, default 64
  26371. * * 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
  26372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26373. * * 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)
  26374. * * 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)
  26375. * @returns the VertexData of the box
  26376. */
  26377. static CreateDisc(options: {
  26378. radius?: number;
  26379. tessellation?: number;
  26380. arc?: number;
  26381. sideOrientation?: number;
  26382. frontUVs?: Vector4;
  26383. backUVs?: Vector4;
  26384. }): VertexData;
  26385. /**
  26386. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26387. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26388. * @param polygon a mesh built from polygonTriangulation.build()
  26389. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26390. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26391. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26392. * @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)
  26393. * @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)
  26394. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26395. * @returns the VertexData of the Polygon
  26396. */
  26397. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26398. /**
  26399. * Creates the VertexData of the IcoSphere
  26400. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26401. * * radius the radius of the IcoSphere, optional default 1
  26402. * * radiusX allows stretching in the x direction, optional, default radius
  26403. * * radiusY allows stretching in the y direction, optional, default radius
  26404. * * radiusZ allows stretching in the z direction, optional, default radius
  26405. * * flat when true creates a flat shaded mesh, optional, default true
  26406. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26408. * * 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)
  26409. * * 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)
  26410. * @returns the VertexData of the IcoSphere
  26411. */
  26412. static CreateIcoSphere(options: {
  26413. radius?: number;
  26414. radiusX?: number;
  26415. radiusY?: number;
  26416. radiusZ?: number;
  26417. flat?: boolean;
  26418. subdivisions?: number;
  26419. sideOrientation?: number;
  26420. frontUVs?: Vector4;
  26421. backUVs?: Vector4;
  26422. }): VertexData;
  26423. /**
  26424. * Creates the VertexData for a Polyhedron
  26425. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26426. * * type provided types are:
  26427. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26428. * * 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)
  26429. * * size the size of the IcoSphere, optional default 1
  26430. * * sizeX allows stretching in the x direction, optional, default size
  26431. * * sizeY allows stretching in the y direction, optional, default size
  26432. * * sizeZ allows stretching in the z direction, optional, default size
  26433. * * 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
  26434. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26435. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26436. * * flat when true creates a flat shaded mesh, optional, default true
  26437. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26439. * * 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)
  26440. * * 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)
  26441. * @returns the VertexData of the Polyhedron
  26442. */
  26443. static CreatePolyhedron(options: {
  26444. type?: number;
  26445. size?: number;
  26446. sizeX?: number;
  26447. sizeY?: number;
  26448. sizeZ?: number;
  26449. custom?: any;
  26450. faceUV?: Vector4[];
  26451. faceColors?: Color4[];
  26452. flat?: boolean;
  26453. sideOrientation?: number;
  26454. frontUVs?: Vector4;
  26455. backUVs?: Vector4;
  26456. }): VertexData;
  26457. /**
  26458. * Creates the VertexData for a TorusKnot
  26459. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26460. * * radius the radius of the torus knot, optional, default 2
  26461. * * tube the thickness of the tube, optional, default 0.5
  26462. * * radialSegments the number of sides on each tube segments, optional, default 32
  26463. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26464. * * p the number of windings around the z axis, optional, default 2
  26465. * * q the number of windings around the x axis, optional, default 3
  26466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26467. * * 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)
  26468. * * 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)
  26469. * @returns the VertexData of the Torus Knot
  26470. */
  26471. static CreateTorusKnot(options: {
  26472. radius?: number;
  26473. tube?: number;
  26474. radialSegments?: number;
  26475. tubularSegments?: number;
  26476. p?: number;
  26477. q?: number;
  26478. sideOrientation?: number;
  26479. frontUVs?: Vector4;
  26480. backUVs?: Vector4;
  26481. }): VertexData;
  26482. /**
  26483. * Compute normals for given positions and indices
  26484. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26485. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26486. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26487. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26488. * * facetNormals : optional array of facet normals (vector3)
  26489. * * facetPositions : optional array of facet positions (vector3)
  26490. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26491. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26492. * * bInfo : optional bounding info, required for facetPartitioning computation
  26493. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26494. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26495. * * useRightHandedSystem: optional boolean to for right handed system computation
  26496. * * depthSort : optional boolean to enable the facet depth sort computation
  26497. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26498. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26499. */
  26500. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26501. facetNormals?: any;
  26502. facetPositions?: any;
  26503. facetPartitioning?: any;
  26504. ratio?: number;
  26505. bInfo?: any;
  26506. bbSize?: Vector3;
  26507. subDiv?: any;
  26508. useRightHandedSystem?: boolean;
  26509. depthSort?: boolean;
  26510. distanceTo?: Vector3;
  26511. depthSortedFacets?: any;
  26512. }): void;
  26513. /** @hidden */
  26514. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26515. /**
  26516. * Applies VertexData created from the imported parameters to the geometry
  26517. * @param parsedVertexData the parsed data from an imported file
  26518. * @param geometry the geometry to apply the VertexData to
  26519. */
  26520. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26521. }
  26522. }
  26523. declare module BABYLON {
  26524. /**
  26525. * Defines a target to use with MorphTargetManager
  26526. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26527. */
  26528. export class MorphTarget implements IAnimatable {
  26529. /** defines the name of the target */
  26530. name: string;
  26531. /**
  26532. * Gets or sets the list of animations
  26533. */
  26534. animations: Animation[];
  26535. private _scene;
  26536. private _positions;
  26537. private _normals;
  26538. private _tangents;
  26539. private _uvs;
  26540. private _influence;
  26541. private _uniqueId;
  26542. /**
  26543. * Observable raised when the influence changes
  26544. */
  26545. onInfluenceChanged: Observable<boolean>;
  26546. /** @hidden */
  26547. _onDataLayoutChanged: Observable<void>;
  26548. /**
  26549. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26550. */
  26551. get influence(): number;
  26552. set influence(influence: number);
  26553. /**
  26554. * Gets or sets the id of the morph Target
  26555. */
  26556. id: string;
  26557. private _animationPropertiesOverride;
  26558. /**
  26559. * Gets or sets the animation properties override
  26560. */
  26561. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26562. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26563. /**
  26564. * Creates a new MorphTarget
  26565. * @param name defines the name of the target
  26566. * @param influence defines the influence to use
  26567. * @param scene defines the scene the morphtarget belongs to
  26568. */
  26569. constructor(
  26570. /** defines the name of the target */
  26571. name: string, influence?: number, scene?: Nullable<Scene>);
  26572. /**
  26573. * Gets the unique ID of this manager
  26574. */
  26575. get uniqueId(): number;
  26576. /**
  26577. * Gets a boolean defining if the target contains position data
  26578. */
  26579. get hasPositions(): boolean;
  26580. /**
  26581. * Gets a boolean defining if the target contains normal data
  26582. */
  26583. get hasNormals(): boolean;
  26584. /**
  26585. * Gets a boolean defining if the target contains tangent data
  26586. */
  26587. get hasTangents(): boolean;
  26588. /**
  26589. * Gets a boolean defining if the target contains texture coordinates data
  26590. */
  26591. get hasUVs(): boolean;
  26592. /**
  26593. * Affects position data to this target
  26594. * @param data defines the position data to use
  26595. */
  26596. setPositions(data: Nullable<FloatArray>): void;
  26597. /**
  26598. * Gets the position data stored in this target
  26599. * @returns a FloatArray containing the position data (or null if not present)
  26600. */
  26601. getPositions(): Nullable<FloatArray>;
  26602. /**
  26603. * Affects normal data to this target
  26604. * @param data defines the normal data to use
  26605. */
  26606. setNormals(data: Nullable<FloatArray>): void;
  26607. /**
  26608. * Gets the normal data stored in this target
  26609. * @returns a FloatArray containing the normal data (or null if not present)
  26610. */
  26611. getNormals(): Nullable<FloatArray>;
  26612. /**
  26613. * Affects tangent data to this target
  26614. * @param data defines the tangent data to use
  26615. */
  26616. setTangents(data: Nullable<FloatArray>): void;
  26617. /**
  26618. * Gets the tangent data stored in this target
  26619. * @returns a FloatArray containing the tangent data (or null if not present)
  26620. */
  26621. getTangents(): Nullable<FloatArray>;
  26622. /**
  26623. * Affects texture coordinates data to this target
  26624. * @param data defines the texture coordinates data to use
  26625. */
  26626. setUVs(data: Nullable<FloatArray>): void;
  26627. /**
  26628. * Gets the texture coordinates data stored in this target
  26629. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26630. */
  26631. getUVs(): Nullable<FloatArray>;
  26632. /**
  26633. * Clone the current target
  26634. * @returns a new MorphTarget
  26635. */
  26636. clone(): MorphTarget;
  26637. /**
  26638. * Serializes the current target into a Serialization object
  26639. * @returns the serialized object
  26640. */
  26641. serialize(): any;
  26642. /**
  26643. * Returns the string "MorphTarget"
  26644. * @returns "MorphTarget"
  26645. */
  26646. getClassName(): string;
  26647. /**
  26648. * Creates a new target from serialized data
  26649. * @param serializationObject defines the serialized data to use
  26650. * @returns a new MorphTarget
  26651. */
  26652. static Parse(serializationObject: any): MorphTarget;
  26653. /**
  26654. * Creates a MorphTarget from mesh data
  26655. * @param mesh defines the source mesh
  26656. * @param name defines the name to use for the new target
  26657. * @param influence defines the influence to attach to the target
  26658. * @returns a new MorphTarget
  26659. */
  26660. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26661. }
  26662. }
  26663. declare module BABYLON {
  26664. /**
  26665. * This class is used to deform meshes using morphing between different targets
  26666. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26667. */
  26668. export class MorphTargetManager {
  26669. private _targets;
  26670. private _targetInfluenceChangedObservers;
  26671. private _targetDataLayoutChangedObservers;
  26672. private _activeTargets;
  26673. private _scene;
  26674. private _influences;
  26675. private _supportsNormals;
  26676. private _supportsTangents;
  26677. private _supportsUVs;
  26678. private _vertexCount;
  26679. private _uniqueId;
  26680. private _tempInfluences;
  26681. /**
  26682. * Gets or sets a boolean indicating if normals must be morphed
  26683. */
  26684. enableNormalMorphing: boolean;
  26685. /**
  26686. * Gets or sets a boolean indicating if tangents must be morphed
  26687. */
  26688. enableTangentMorphing: boolean;
  26689. /**
  26690. * Gets or sets a boolean indicating if UV must be morphed
  26691. */
  26692. enableUVMorphing: boolean;
  26693. /**
  26694. * Creates a new MorphTargetManager
  26695. * @param scene defines the current scene
  26696. */
  26697. constructor(scene?: Nullable<Scene>);
  26698. /**
  26699. * Gets the unique ID of this manager
  26700. */
  26701. get uniqueId(): number;
  26702. /**
  26703. * Gets the number of vertices handled by this manager
  26704. */
  26705. get vertexCount(): number;
  26706. /**
  26707. * Gets a boolean indicating if this manager supports morphing of normals
  26708. */
  26709. get supportsNormals(): boolean;
  26710. /**
  26711. * Gets a boolean indicating if this manager supports morphing of tangents
  26712. */
  26713. get supportsTangents(): boolean;
  26714. /**
  26715. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26716. */
  26717. get supportsUVs(): boolean;
  26718. /**
  26719. * Gets the number of targets stored in this manager
  26720. */
  26721. get numTargets(): number;
  26722. /**
  26723. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26724. */
  26725. get numInfluencers(): number;
  26726. /**
  26727. * Gets the list of influences (one per target)
  26728. */
  26729. get influences(): Float32Array;
  26730. /**
  26731. * Gets the active target at specified index. An active target is a target with an influence > 0
  26732. * @param index defines the index to check
  26733. * @returns the requested target
  26734. */
  26735. getActiveTarget(index: number): MorphTarget;
  26736. /**
  26737. * Gets the target at specified index
  26738. * @param index defines the index to check
  26739. * @returns the requested target
  26740. */
  26741. getTarget(index: number): MorphTarget;
  26742. /**
  26743. * Add a new target to this manager
  26744. * @param target defines the target to add
  26745. */
  26746. addTarget(target: MorphTarget): void;
  26747. /**
  26748. * Removes a target from the manager
  26749. * @param target defines the target to remove
  26750. */
  26751. removeTarget(target: MorphTarget): void;
  26752. /**
  26753. * Clone the current manager
  26754. * @returns a new MorphTargetManager
  26755. */
  26756. clone(): MorphTargetManager;
  26757. /**
  26758. * Serializes the current manager into a Serialization object
  26759. * @returns the serialized object
  26760. */
  26761. serialize(): any;
  26762. private _syncActiveTargets;
  26763. /**
  26764. * Syncrhonize the targets with all the meshes using this morph target manager
  26765. */
  26766. synchronize(): void;
  26767. /**
  26768. * Creates a new MorphTargetManager from serialized data
  26769. * @param serializationObject defines the serialized data
  26770. * @param scene defines the hosting scene
  26771. * @returns the new MorphTargetManager
  26772. */
  26773. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26774. }
  26775. }
  26776. declare module BABYLON {
  26777. /**
  26778. * Class used to represent a specific level of detail of a mesh
  26779. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26780. */
  26781. export class MeshLODLevel {
  26782. /** Defines the distance where this level should start being displayed */
  26783. distance: number;
  26784. /** Defines the mesh to use to render this level */
  26785. mesh: Nullable<Mesh>;
  26786. /**
  26787. * Creates a new LOD level
  26788. * @param distance defines the distance where this level should star being displayed
  26789. * @param mesh defines the mesh to use to render this level
  26790. */
  26791. constructor(
  26792. /** Defines the distance where this level should start being displayed */
  26793. distance: number,
  26794. /** Defines the mesh to use to render this level */
  26795. mesh: Nullable<Mesh>);
  26796. }
  26797. }
  26798. declare module BABYLON {
  26799. /**
  26800. * Helper class used to generate a canvas to manipulate images
  26801. */
  26802. export class CanvasGenerator {
  26803. /**
  26804. * Create a new canvas (or offscreen canvas depending on the context)
  26805. * @param width defines the expected width
  26806. * @param height defines the expected height
  26807. * @return a new canvas or offscreen canvas
  26808. */
  26809. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26810. }
  26811. }
  26812. declare module BABYLON {
  26813. /**
  26814. * Mesh representing the gorund
  26815. */
  26816. export class GroundMesh extends Mesh {
  26817. /** If octree should be generated */
  26818. generateOctree: boolean;
  26819. private _heightQuads;
  26820. /** @hidden */
  26821. _subdivisionsX: number;
  26822. /** @hidden */
  26823. _subdivisionsY: number;
  26824. /** @hidden */
  26825. _width: number;
  26826. /** @hidden */
  26827. _height: number;
  26828. /** @hidden */
  26829. _minX: number;
  26830. /** @hidden */
  26831. _maxX: number;
  26832. /** @hidden */
  26833. _minZ: number;
  26834. /** @hidden */
  26835. _maxZ: number;
  26836. constructor(name: string, scene: Scene);
  26837. /**
  26838. * "GroundMesh"
  26839. * @returns "GroundMesh"
  26840. */
  26841. getClassName(): string;
  26842. /**
  26843. * The minimum of x and y subdivisions
  26844. */
  26845. get subdivisions(): number;
  26846. /**
  26847. * X subdivisions
  26848. */
  26849. get subdivisionsX(): number;
  26850. /**
  26851. * Y subdivisions
  26852. */
  26853. get subdivisionsY(): number;
  26854. /**
  26855. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26856. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26857. * @param chunksCount the number of subdivisions for x and y
  26858. * @param octreeBlocksSize (Default: 32)
  26859. */
  26860. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26861. /**
  26862. * Returns a height (y) value in the Worl system :
  26863. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26864. * @param x x coordinate
  26865. * @param z z coordinate
  26866. * @returns the ground y position if (x, z) are outside the ground surface.
  26867. */
  26868. getHeightAtCoordinates(x: number, z: number): number;
  26869. /**
  26870. * Returns a normalized vector (Vector3) orthogonal to the ground
  26871. * at the ground coordinates (x, z) expressed in the World system.
  26872. * @param x x coordinate
  26873. * @param z z coordinate
  26874. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26875. */
  26876. getNormalAtCoordinates(x: number, z: number): Vector3;
  26877. /**
  26878. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26879. * at the ground coordinates (x, z) expressed in the World system.
  26880. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26881. * @param x x coordinate
  26882. * @param z z coordinate
  26883. * @param ref vector to store the result
  26884. * @returns the GroundMesh.
  26885. */
  26886. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26887. /**
  26888. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26889. * if the ground has been updated.
  26890. * This can be used in the render loop.
  26891. * @returns the GroundMesh.
  26892. */
  26893. updateCoordinateHeights(): GroundMesh;
  26894. private _getFacetAt;
  26895. private _initHeightQuads;
  26896. private _computeHeightQuads;
  26897. /**
  26898. * Serializes this ground mesh
  26899. * @param serializationObject object to write serialization to
  26900. */
  26901. serialize(serializationObject: any): void;
  26902. /**
  26903. * Parses a serialized ground mesh
  26904. * @param parsedMesh the serialized mesh
  26905. * @param scene the scene to create the ground mesh in
  26906. * @returns the created ground mesh
  26907. */
  26908. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26909. }
  26910. }
  26911. declare module BABYLON {
  26912. /**
  26913. * Interface for Physics-Joint data
  26914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26915. */
  26916. export interface PhysicsJointData {
  26917. /**
  26918. * The main pivot of the joint
  26919. */
  26920. mainPivot?: Vector3;
  26921. /**
  26922. * The connected pivot of the joint
  26923. */
  26924. connectedPivot?: Vector3;
  26925. /**
  26926. * The main axis of the joint
  26927. */
  26928. mainAxis?: Vector3;
  26929. /**
  26930. * The connected axis of the joint
  26931. */
  26932. connectedAxis?: Vector3;
  26933. /**
  26934. * The collision of the joint
  26935. */
  26936. collision?: boolean;
  26937. /**
  26938. * Native Oimo/Cannon/Energy data
  26939. */
  26940. nativeParams?: any;
  26941. }
  26942. /**
  26943. * This is a holder class for the physics joint created by the physics plugin
  26944. * It holds a set of functions to control the underlying joint
  26945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26946. */
  26947. export class PhysicsJoint {
  26948. /**
  26949. * The type of the physics joint
  26950. */
  26951. type: number;
  26952. /**
  26953. * The data for the physics joint
  26954. */
  26955. jointData: PhysicsJointData;
  26956. private _physicsJoint;
  26957. protected _physicsPlugin: IPhysicsEnginePlugin;
  26958. /**
  26959. * Initializes the physics joint
  26960. * @param type The type of the physics joint
  26961. * @param jointData The data for the physics joint
  26962. */
  26963. constructor(
  26964. /**
  26965. * The type of the physics joint
  26966. */
  26967. type: number,
  26968. /**
  26969. * The data for the physics joint
  26970. */
  26971. jointData: PhysicsJointData);
  26972. /**
  26973. * Gets the physics joint
  26974. */
  26975. get physicsJoint(): any;
  26976. /**
  26977. * Sets the physics joint
  26978. */
  26979. set physicsJoint(newJoint: any);
  26980. /**
  26981. * Sets the physics plugin
  26982. */
  26983. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26984. /**
  26985. * Execute a function that is physics-plugin specific.
  26986. * @param {Function} func the function that will be executed.
  26987. * It accepts two parameters: the physics world and the physics joint
  26988. */
  26989. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26990. /**
  26991. * Distance-Joint type
  26992. */
  26993. static DistanceJoint: number;
  26994. /**
  26995. * Hinge-Joint type
  26996. */
  26997. static HingeJoint: number;
  26998. /**
  26999. * Ball-and-Socket joint type
  27000. */
  27001. static BallAndSocketJoint: number;
  27002. /**
  27003. * Wheel-Joint type
  27004. */
  27005. static WheelJoint: number;
  27006. /**
  27007. * Slider-Joint type
  27008. */
  27009. static SliderJoint: number;
  27010. /**
  27011. * Prismatic-Joint type
  27012. */
  27013. static PrismaticJoint: number;
  27014. /**
  27015. * Universal-Joint type
  27016. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27017. */
  27018. static UniversalJoint: number;
  27019. /**
  27020. * Hinge-Joint 2 type
  27021. */
  27022. static Hinge2Joint: number;
  27023. /**
  27024. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27025. */
  27026. static PointToPointJoint: number;
  27027. /**
  27028. * Spring-Joint type
  27029. */
  27030. static SpringJoint: number;
  27031. /**
  27032. * Lock-Joint type
  27033. */
  27034. static LockJoint: number;
  27035. }
  27036. /**
  27037. * A class representing a physics distance joint
  27038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27039. */
  27040. export class DistanceJoint extends PhysicsJoint {
  27041. /**
  27042. *
  27043. * @param jointData The data for the Distance-Joint
  27044. */
  27045. constructor(jointData: DistanceJointData);
  27046. /**
  27047. * Update the predefined distance.
  27048. * @param maxDistance The maximum preferred distance
  27049. * @param minDistance The minimum preferred distance
  27050. */
  27051. updateDistance(maxDistance: number, minDistance?: number): void;
  27052. }
  27053. /**
  27054. * Represents a Motor-Enabled Joint
  27055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27056. */
  27057. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27058. /**
  27059. * Initializes the Motor-Enabled Joint
  27060. * @param type The type of the joint
  27061. * @param jointData The physica joint data for the joint
  27062. */
  27063. constructor(type: number, jointData: PhysicsJointData);
  27064. /**
  27065. * Set the motor values.
  27066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27067. * @param force the force to apply
  27068. * @param maxForce max force for this motor.
  27069. */
  27070. setMotor(force?: number, maxForce?: number): void;
  27071. /**
  27072. * Set the motor's limits.
  27073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27074. * @param upperLimit The upper limit of the motor
  27075. * @param lowerLimit The lower limit of the motor
  27076. */
  27077. setLimit(upperLimit: number, lowerLimit?: number): void;
  27078. }
  27079. /**
  27080. * This class represents a single physics Hinge-Joint
  27081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27082. */
  27083. export class HingeJoint extends MotorEnabledJoint {
  27084. /**
  27085. * Initializes the Hinge-Joint
  27086. * @param jointData The joint data for the Hinge-Joint
  27087. */
  27088. constructor(jointData: PhysicsJointData);
  27089. /**
  27090. * Set the motor values.
  27091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27092. * @param {number} force the force to apply
  27093. * @param {number} maxForce max force for this motor.
  27094. */
  27095. setMotor(force?: number, maxForce?: number): void;
  27096. /**
  27097. * Set the motor's limits.
  27098. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27099. * @param upperLimit The upper limit of the motor
  27100. * @param lowerLimit The lower limit of the motor
  27101. */
  27102. setLimit(upperLimit: number, lowerLimit?: number): void;
  27103. }
  27104. /**
  27105. * This class represents a dual hinge physics joint (same as wheel joint)
  27106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27107. */
  27108. export class Hinge2Joint extends MotorEnabledJoint {
  27109. /**
  27110. * Initializes the Hinge2-Joint
  27111. * @param jointData The joint data for the Hinge2-Joint
  27112. */
  27113. constructor(jointData: PhysicsJointData);
  27114. /**
  27115. * Set the motor values.
  27116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27117. * @param {number} targetSpeed the speed the motor is to reach
  27118. * @param {number} maxForce max force for this motor.
  27119. * @param {motorIndex} the motor's index, 0 or 1.
  27120. */
  27121. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27122. /**
  27123. * Set the motor limits.
  27124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27125. * @param {number} upperLimit the upper limit
  27126. * @param {number} lowerLimit lower limit
  27127. * @param {motorIndex} the motor's index, 0 or 1.
  27128. */
  27129. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27130. }
  27131. /**
  27132. * Interface for a motor enabled joint
  27133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27134. */
  27135. export interface IMotorEnabledJoint {
  27136. /**
  27137. * Physics joint
  27138. */
  27139. physicsJoint: any;
  27140. /**
  27141. * Sets the motor of the motor-enabled joint
  27142. * @param force The force of the motor
  27143. * @param maxForce The maximum force of the motor
  27144. * @param motorIndex The index of the motor
  27145. */
  27146. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27147. /**
  27148. * Sets the limit of the motor
  27149. * @param upperLimit The upper limit of the motor
  27150. * @param lowerLimit The lower limit of the motor
  27151. * @param motorIndex The index of the motor
  27152. */
  27153. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27154. }
  27155. /**
  27156. * Joint data for a Distance-Joint
  27157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27158. */
  27159. export interface DistanceJointData extends PhysicsJointData {
  27160. /**
  27161. * Max distance the 2 joint objects can be apart
  27162. */
  27163. maxDistance: number;
  27164. }
  27165. /**
  27166. * Joint data from a spring joint
  27167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27168. */
  27169. export interface SpringJointData extends PhysicsJointData {
  27170. /**
  27171. * Length of the spring
  27172. */
  27173. length: number;
  27174. /**
  27175. * Stiffness of the spring
  27176. */
  27177. stiffness: number;
  27178. /**
  27179. * Damping of the spring
  27180. */
  27181. damping: number;
  27182. /** this callback will be called when applying the force to the impostors. */
  27183. forceApplicationCallback: () => void;
  27184. }
  27185. }
  27186. declare module BABYLON {
  27187. /**
  27188. * Holds the data for the raycast result
  27189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27190. */
  27191. export class PhysicsRaycastResult {
  27192. private _hasHit;
  27193. private _hitDistance;
  27194. private _hitNormalWorld;
  27195. private _hitPointWorld;
  27196. private _rayFromWorld;
  27197. private _rayToWorld;
  27198. /**
  27199. * Gets if there was a hit
  27200. */
  27201. get hasHit(): boolean;
  27202. /**
  27203. * Gets the distance from the hit
  27204. */
  27205. get hitDistance(): number;
  27206. /**
  27207. * Gets the hit normal/direction in the world
  27208. */
  27209. get hitNormalWorld(): Vector3;
  27210. /**
  27211. * Gets the hit point in the world
  27212. */
  27213. get hitPointWorld(): Vector3;
  27214. /**
  27215. * Gets the ray "start point" of the ray in the world
  27216. */
  27217. get rayFromWorld(): Vector3;
  27218. /**
  27219. * Gets the ray "end point" of the ray in the world
  27220. */
  27221. get rayToWorld(): Vector3;
  27222. /**
  27223. * Sets the hit data (normal & point in world space)
  27224. * @param hitNormalWorld defines the normal in world space
  27225. * @param hitPointWorld defines the point in world space
  27226. */
  27227. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27228. /**
  27229. * Sets the distance from the start point to the hit point
  27230. * @param distance
  27231. */
  27232. setHitDistance(distance: number): void;
  27233. /**
  27234. * Calculates the distance manually
  27235. */
  27236. calculateHitDistance(): void;
  27237. /**
  27238. * Resets all the values to default
  27239. * @param from The from point on world space
  27240. * @param to The to point on world space
  27241. */
  27242. reset(from?: Vector3, to?: Vector3): void;
  27243. }
  27244. /**
  27245. * Interface for the size containing width and height
  27246. */
  27247. interface IXYZ {
  27248. /**
  27249. * X
  27250. */
  27251. x: number;
  27252. /**
  27253. * Y
  27254. */
  27255. y: number;
  27256. /**
  27257. * Z
  27258. */
  27259. z: number;
  27260. }
  27261. }
  27262. declare module BABYLON {
  27263. /**
  27264. * Interface used to describe a physics joint
  27265. */
  27266. export interface PhysicsImpostorJoint {
  27267. /** Defines the main impostor to which the joint is linked */
  27268. mainImpostor: PhysicsImpostor;
  27269. /** Defines the impostor that is connected to the main impostor using this joint */
  27270. connectedImpostor: PhysicsImpostor;
  27271. /** Defines the joint itself */
  27272. joint: PhysicsJoint;
  27273. }
  27274. /** @hidden */
  27275. export interface IPhysicsEnginePlugin {
  27276. world: any;
  27277. name: string;
  27278. setGravity(gravity: Vector3): void;
  27279. setTimeStep(timeStep: number): void;
  27280. getTimeStep(): number;
  27281. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27282. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27283. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27284. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27285. removePhysicsBody(impostor: PhysicsImpostor): void;
  27286. generateJoint(joint: PhysicsImpostorJoint): void;
  27287. removeJoint(joint: PhysicsImpostorJoint): void;
  27288. isSupported(): boolean;
  27289. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27291. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27292. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27293. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27294. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27295. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27296. getBodyMass(impostor: PhysicsImpostor): number;
  27297. getBodyFriction(impostor: PhysicsImpostor): number;
  27298. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27299. getBodyRestitution(impostor: PhysicsImpostor): number;
  27300. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27301. getBodyPressure?(impostor: PhysicsImpostor): number;
  27302. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27303. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27304. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27305. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27306. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27307. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27308. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27309. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27310. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27311. sleepBody(impostor: PhysicsImpostor): void;
  27312. wakeUpBody(impostor: PhysicsImpostor): void;
  27313. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27314. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27315. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27316. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27317. getRadius(impostor: PhysicsImpostor): number;
  27318. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27319. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27320. dispose(): void;
  27321. }
  27322. /**
  27323. * Interface used to define a physics engine
  27324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27325. */
  27326. export interface IPhysicsEngine {
  27327. /**
  27328. * Gets the gravity vector used by the simulation
  27329. */
  27330. gravity: Vector3;
  27331. /**
  27332. * Sets the gravity vector used by the simulation
  27333. * @param gravity defines the gravity vector to use
  27334. */
  27335. setGravity(gravity: Vector3): void;
  27336. /**
  27337. * Set the time step of the physics engine.
  27338. * Default is 1/60.
  27339. * To slow it down, enter 1/600 for example.
  27340. * To speed it up, 1/30
  27341. * @param newTimeStep the new timestep to apply to this world.
  27342. */
  27343. setTimeStep(newTimeStep: number): void;
  27344. /**
  27345. * Get the time step of the physics engine.
  27346. * @returns the current time step
  27347. */
  27348. getTimeStep(): number;
  27349. /**
  27350. * Set the sub time step of the physics engine.
  27351. * Default is 0 meaning there is no sub steps
  27352. * To increase physics resolution precision, set a small value (like 1 ms)
  27353. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27354. */
  27355. setSubTimeStep(subTimeStep: number): void;
  27356. /**
  27357. * Get the sub time step of the physics engine.
  27358. * @returns the current sub time step
  27359. */
  27360. getSubTimeStep(): number;
  27361. /**
  27362. * Release all resources
  27363. */
  27364. dispose(): void;
  27365. /**
  27366. * Gets the name of the current physics plugin
  27367. * @returns the name of the plugin
  27368. */
  27369. getPhysicsPluginName(): string;
  27370. /**
  27371. * Adding a new impostor for the impostor tracking.
  27372. * This will be done by the impostor itself.
  27373. * @param impostor the impostor to add
  27374. */
  27375. addImpostor(impostor: PhysicsImpostor): void;
  27376. /**
  27377. * Remove an impostor from the engine.
  27378. * This impostor and its mesh will not longer be updated by the physics engine.
  27379. * @param impostor the impostor to remove
  27380. */
  27381. removeImpostor(impostor: PhysicsImpostor): void;
  27382. /**
  27383. * Add a joint to the physics engine
  27384. * @param mainImpostor defines the main impostor to which the joint is added.
  27385. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27386. * @param joint defines the joint that will connect both impostors.
  27387. */
  27388. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27389. /**
  27390. * Removes a joint from the simulation
  27391. * @param mainImpostor defines the impostor used with the joint
  27392. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27393. * @param joint defines the joint to remove
  27394. */
  27395. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27396. /**
  27397. * Gets the current plugin used to run the simulation
  27398. * @returns current plugin
  27399. */
  27400. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27401. /**
  27402. * Gets the list of physic impostors
  27403. * @returns an array of PhysicsImpostor
  27404. */
  27405. getImpostors(): Array<PhysicsImpostor>;
  27406. /**
  27407. * Gets the impostor for a physics enabled object
  27408. * @param object defines the object impersonated by the impostor
  27409. * @returns the PhysicsImpostor or null if not found
  27410. */
  27411. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27412. /**
  27413. * Gets the impostor for a physics body object
  27414. * @param body defines physics body used by the impostor
  27415. * @returns the PhysicsImpostor or null if not found
  27416. */
  27417. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27418. /**
  27419. * Does a raycast in the physics world
  27420. * @param from when should the ray start?
  27421. * @param to when should the ray end?
  27422. * @returns PhysicsRaycastResult
  27423. */
  27424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27425. /**
  27426. * Called by the scene. No need to call it.
  27427. * @param delta defines the timespam between frames
  27428. */
  27429. _step(delta: number): void;
  27430. }
  27431. }
  27432. declare module BABYLON {
  27433. /**
  27434. * The interface for the physics imposter parameters
  27435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27436. */
  27437. export interface PhysicsImpostorParameters {
  27438. /**
  27439. * The mass of the physics imposter
  27440. */
  27441. mass: number;
  27442. /**
  27443. * The friction of the physics imposter
  27444. */
  27445. friction?: number;
  27446. /**
  27447. * The coefficient of restitution of the physics imposter
  27448. */
  27449. restitution?: number;
  27450. /**
  27451. * The native options of the physics imposter
  27452. */
  27453. nativeOptions?: any;
  27454. /**
  27455. * Specifies if the parent should be ignored
  27456. */
  27457. ignoreParent?: boolean;
  27458. /**
  27459. * Specifies if bi-directional transformations should be disabled
  27460. */
  27461. disableBidirectionalTransformation?: boolean;
  27462. /**
  27463. * The pressure inside the physics imposter, soft object only
  27464. */
  27465. pressure?: number;
  27466. /**
  27467. * The stiffness the physics imposter, soft object only
  27468. */
  27469. stiffness?: number;
  27470. /**
  27471. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27472. */
  27473. velocityIterations?: number;
  27474. /**
  27475. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27476. */
  27477. positionIterations?: number;
  27478. /**
  27479. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27480. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27481. * Add to fix multiple points
  27482. */
  27483. fixedPoints?: number;
  27484. /**
  27485. * The collision margin around a soft object
  27486. */
  27487. margin?: number;
  27488. /**
  27489. * The collision margin around a soft object
  27490. */
  27491. damping?: number;
  27492. /**
  27493. * The path for a rope based on an extrusion
  27494. */
  27495. path?: any;
  27496. /**
  27497. * The shape of an extrusion used for a rope based on an extrusion
  27498. */
  27499. shape?: any;
  27500. }
  27501. /**
  27502. * Interface for a physics-enabled object
  27503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27504. */
  27505. export interface IPhysicsEnabledObject {
  27506. /**
  27507. * The position of the physics-enabled object
  27508. */
  27509. position: Vector3;
  27510. /**
  27511. * The rotation of the physics-enabled object
  27512. */
  27513. rotationQuaternion: Nullable<Quaternion>;
  27514. /**
  27515. * The scale of the physics-enabled object
  27516. */
  27517. scaling: Vector3;
  27518. /**
  27519. * The rotation of the physics-enabled object
  27520. */
  27521. rotation?: Vector3;
  27522. /**
  27523. * The parent of the physics-enabled object
  27524. */
  27525. parent?: any;
  27526. /**
  27527. * The bounding info of the physics-enabled object
  27528. * @returns The bounding info of the physics-enabled object
  27529. */
  27530. getBoundingInfo(): BoundingInfo;
  27531. /**
  27532. * Computes the world matrix
  27533. * @param force Specifies if the world matrix should be computed by force
  27534. * @returns A world matrix
  27535. */
  27536. computeWorldMatrix(force: boolean): Matrix;
  27537. /**
  27538. * Gets the world matrix
  27539. * @returns A world matrix
  27540. */
  27541. getWorldMatrix?(): Matrix;
  27542. /**
  27543. * Gets the child meshes
  27544. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27545. * @returns An array of abstract meshes
  27546. */
  27547. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27548. /**
  27549. * Gets the vertex data
  27550. * @param kind The type of vertex data
  27551. * @returns A nullable array of numbers, or a float32 array
  27552. */
  27553. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27554. /**
  27555. * Gets the indices from the mesh
  27556. * @returns A nullable array of index arrays
  27557. */
  27558. getIndices?(): Nullable<IndicesArray>;
  27559. /**
  27560. * Gets the scene from the mesh
  27561. * @returns the indices array or null
  27562. */
  27563. getScene?(): Scene;
  27564. /**
  27565. * Gets the absolute position from the mesh
  27566. * @returns the absolute position
  27567. */
  27568. getAbsolutePosition(): Vector3;
  27569. /**
  27570. * Gets the absolute pivot point from the mesh
  27571. * @returns the absolute pivot point
  27572. */
  27573. getAbsolutePivotPoint(): Vector3;
  27574. /**
  27575. * Rotates the mesh
  27576. * @param axis The axis of rotation
  27577. * @param amount The amount of rotation
  27578. * @param space The space of the rotation
  27579. * @returns The rotation transform node
  27580. */
  27581. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27582. /**
  27583. * Translates the mesh
  27584. * @param axis The axis of translation
  27585. * @param distance The distance of translation
  27586. * @param space The space of the translation
  27587. * @returns The transform node
  27588. */
  27589. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27590. /**
  27591. * Sets the absolute position of the mesh
  27592. * @param absolutePosition The absolute position of the mesh
  27593. * @returns The transform node
  27594. */
  27595. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27596. /**
  27597. * Gets the class name of the mesh
  27598. * @returns The class name
  27599. */
  27600. getClassName(): string;
  27601. }
  27602. /**
  27603. * Represents a physics imposter
  27604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27605. */
  27606. export class PhysicsImpostor {
  27607. /**
  27608. * The physics-enabled object used as the physics imposter
  27609. */
  27610. object: IPhysicsEnabledObject;
  27611. /**
  27612. * The type of the physics imposter
  27613. */
  27614. type: number;
  27615. private _options;
  27616. private _scene?;
  27617. /**
  27618. * The default object size of the imposter
  27619. */
  27620. static DEFAULT_OBJECT_SIZE: Vector3;
  27621. /**
  27622. * The identity quaternion of the imposter
  27623. */
  27624. static IDENTITY_QUATERNION: Quaternion;
  27625. /** @hidden */
  27626. _pluginData: any;
  27627. private _physicsEngine;
  27628. private _physicsBody;
  27629. private _bodyUpdateRequired;
  27630. private _onBeforePhysicsStepCallbacks;
  27631. private _onAfterPhysicsStepCallbacks;
  27632. /** @hidden */
  27633. _onPhysicsCollideCallbacks: Array<{
  27634. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27635. otherImpostors: Array<PhysicsImpostor>;
  27636. }>;
  27637. private _deltaPosition;
  27638. private _deltaRotation;
  27639. private _deltaRotationConjugated;
  27640. /** @hidden */
  27641. _isFromLine: boolean;
  27642. private _parent;
  27643. private _isDisposed;
  27644. private static _tmpVecs;
  27645. private static _tmpQuat;
  27646. /**
  27647. * Specifies if the physics imposter is disposed
  27648. */
  27649. get isDisposed(): boolean;
  27650. /**
  27651. * Gets the mass of the physics imposter
  27652. */
  27653. get mass(): number;
  27654. set mass(value: number);
  27655. /**
  27656. * Gets the coefficient of friction
  27657. */
  27658. get friction(): number;
  27659. /**
  27660. * Sets the coefficient of friction
  27661. */
  27662. set friction(value: number);
  27663. /**
  27664. * Gets the coefficient of restitution
  27665. */
  27666. get restitution(): number;
  27667. /**
  27668. * Sets the coefficient of restitution
  27669. */
  27670. set restitution(value: number);
  27671. /**
  27672. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27673. */
  27674. get pressure(): number;
  27675. /**
  27676. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27677. */
  27678. set pressure(value: number);
  27679. /**
  27680. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27681. */
  27682. get stiffness(): number;
  27683. /**
  27684. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27685. */
  27686. set stiffness(value: number);
  27687. /**
  27688. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27689. */
  27690. get velocityIterations(): number;
  27691. /**
  27692. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27693. */
  27694. set velocityIterations(value: number);
  27695. /**
  27696. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27697. */
  27698. get positionIterations(): number;
  27699. /**
  27700. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27701. */
  27702. set positionIterations(value: number);
  27703. /**
  27704. * The unique id of the physics imposter
  27705. * set by the physics engine when adding this impostor to the array
  27706. */
  27707. uniqueId: number;
  27708. /**
  27709. * @hidden
  27710. */
  27711. soft: boolean;
  27712. /**
  27713. * @hidden
  27714. */
  27715. segments: number;
  27716. private _joints;
  27717. /**
  27718. * Initializes the physics imposter
  27719. * @param object The physics-enabled object used as the physics imposter
  27720. * @param type The type of the physics imposter
  27721. * @param _options The options for the physics imposter
  27722. * @param _scene The Babylon scene
  27723. */
  27724. constructor(
  27725. /**
  27726. * The physics-enabled object used as the physics imposter
  27727. */
  27728. object: IPhysicsEnabledObject,
  27729. /**
  27730. * The type of the physics imposter
  27731. */
  27732. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27733. /**
  27734. * This function will completly initialize this impostor.
  27735. * It will create a new body - but only if this mesh has no parent.
  27736. * If it has, this impostor will not be used other than to define the impostor
  27737. * of the child mesh.
  27738. * @hidden
  27739. */
  27740. _init(): void;
  27741. private _getPhysicsParent;
  27742. /**
  27743. * Should a new body be generated.
  27744. * @returns boolean specifying if body initialization is required
  27745. */
  27746. isBodyInitRequired(): boolean;
  27747. /**
  27748. * Sets the updated scaling
  27749. * @param updated Specifies if the scaling is updated
  27750. */
  27751. setScalingUpdated(): void;
  27752. /**
  27753. * Force a regeneration of this or the parent's impostor's body.
  27754. * Use under cautious - This will remove all joints already implemented.
  27755. */
  27756. forceUpdate(): void;
  27757. /**
  27758. * Gets the body that holds this impostor. Either its own, or its parent.
  27759. */
  27760. get physicsBody(): any;
  27761. /**
  27762. * Get the parent of the physics imposter
  27763. * @returns Physics imposter or null
  27764. */
  27765. get parent(): Nullable<PhysicsImpostor>;
  27766. /**
  27767. * Sets the parent of the physics imposter
  27768. */
  27769. set parent(value: Nullable<PhysicsImpostor>);
  27770. /**
  27771. * Set the physics body. Used mainly by the physics engine/plugin
  27772. */
  27773. set physicsBody(physicsBody: any);
  27774. /**
  27775. * Resets the update flags
  27776. */
  27777. resetUpdateFlags(): void;
  27778. /**
  27779. * Gets the object extend size
  27780. * @returns the object extend size
  27781. */
  27782. getObjectExtendSize(): Vector3;
  27783. /**
  27784. * Gets the object center
  27785. * @returns The object center
  27786. */
  27787. getObjectCenter(): Vector3;
  27788. /**
  27789. * Get a specific parameter from the options parameters
  27790. * @param paramName The object parameter name
  27791. * @returns The object parameter
  27792. */
  27793. getParam(paramName: string): any;
  27794. /**
  27795. * Sets a specific parameter in the options given to the physics plugin
  27796. * @param paramName The parameter name
  27797. * @param value The value of the parameter
  27798. */
  27799. setParam(paramName: string, value: number): void;
  27800. /**
  27801. * Specifically change the body's mass option. Won't recreate the physics body object
  27802. * @param mass The mass of the physics imposter
  27803. */
  27804. setMass(mass: number): void;
  27805. /**
  27806. * Gets the linear velocity
  27807. * @returns linear velocity or null
  27808. */
  27809. getLinearVelocity(): Nullable<Vector3>;
  27810. /**
  27811. * Sets the linear velocity
  27812. * @param velocity linear velocity or null
  27813. */
  27814. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27815. /**
  27816. * Gets the angular velocity
  27817. * @returns angular velocity or null
  27818. */
  27819. getAngularVelocity(): Nullable<Vector3>;
  27820. /**
  27821. * Sets the angular velocity
  27822. * @param velocity The velocity or null
  27823. */
  27824. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27825. /**
  27826. * Execute a function with the physics plugin native code
  27827. * Provide a function the will have two variables - the world object and the physics body object
  27828. * @param func The function to execute with the physics plugin native code
  27829. */
  27830. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27831. /**
  27832. * Register a function that will be executed before the physics world is stepping forward
  27833. * @param func The function to execute before the physics world is stepped forward
  27834. */
  27835. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27836. /**
  27837. * Unregister a function that will be executed before the physics world is stepping forward
  27838. * @param func The function to execute before the physics world is stepped forward
  27839. */
  27840. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27841. /**
  27842. * Register a function that will be executed after the physics step
  27843. * @param func The function to execute after physics step
  27844. */
  27845. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27846. /**
  27847. * Unregisters a function that will be executed after the physics step
  27848. * @param func The function to execute after physics step
  27849. */
  27850. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27851. /**
  27852. * register a function that will be executed when this impostor collides against a different body
  27853. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27854. * @param func Callback that is executed on collision
  27855. */
  27856. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27857. /**
  27858. * Unregisters the physics imposter on contact
  27859. * @param collideAgainst The physics object to collide against
  27860. * @param func Callback to execute on collision
  27861. */
  27862. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27863. private _tmpQuat;
  27864. private _tmpQuat2;
  27865. /**
  27866. * Get the parent rotation
  27867. * @returns The parent rotation
  27868. */
  27869. getParentsRotation(): Quaternion;
  27870. /**
  27871. * this function is executed by the physics engine.
  27872. */
  27873. beforeStep: () => void;
  27874. /**
  27875. * this function is executed by the physics engine
  27876. */
  27877. afterStep: () => void;
  27878. /**
  27879. * Legacy collision detection event support
  27880. */
  27881. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27882. /**
  27883. * event and body object due to cannon's event-based architecture.
  27884. */
  27885. onCollide: (e: {
  27886. body: any;
  27887. }) => void;
  27888. /**
  27889. * Apply a force
  27890. * @param force The force to apply
  27891. * @param contactPoint The contact point for the force
  27892. * @returns The physics imposter
  27893. */
  27894. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27895. /**
  27896. * Apply an impulse
  27897. * @param force The impulse force
  27898. * @param contactPoint The contact point for the impulse force
  27899. * @returns The physics imposter
  27900. */
  27901. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27902. /**
  27903. * A help function to create a joint
  27904. * @param otherImpostor A physics imposter used to create a joint
  27905. * @param jointType The type of joint
  27906. * @param jointData The data for the joint
  27907. * @returns The physics imposter
  27908. */
  27909. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27910. /**
  27911. * Add a joint to this impostor with a different impostor
  27912. * @param otherImpostor A physics imposter used to add a joint
  27913. * @param joint The joint to add
  27914. * @returns The physics imposter
  27915. */
  27916. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27917. /**
  27918. * Add an anchor to a cloth impostor
  27919. * @param otherImpostor rigid impostor to anchor to
  27920. * @param width ratio across width from 0 to 1
  27921. * @param height ratio up height from 0 to 1
  27922. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27923. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27924. * @returns impostor the soft imposter
  27925. */
  27926. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27927. /**
  27928. * Add a hook to a rope impostor
  27929. * @param otherImpostor rigid impostor to anchor to
  27930. * @param length ratio across rope from 0 to 1
  27931. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27932. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27933. * @returns impostor the rope imposter
  27934. */
  27935. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27936. /**
  27937. * Will keep this body still, in a sleep mode.
  27938. * @returns the physics imposter
  27939. */
  27940. sleep(): PhysicsImpostor;
  27941. /**
  27942. * Wake the body up.
  27943. * @returns The physics imposter
  27944. */
  27945. wakeUp(): PhysicsImpostor;
  27946. /**
  27947. * Clones the physics imposter
  27948. * @param newObject The physics imposter clones to this physics-enabled object
  27949. * @returns A nullable physics imposter
  27950. */
  27951. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27952. /**
  27953. * Disposes the physics imposter
  27954. */
  27955. dispose(): void;
  27956. /**
  27957. * Sets the delta position
  27958. * @param position The delta position amount
  27959. */
  27960. setDeltaPosition(position: Vector3): void;
  27961. /**
  27962. * Sets the delta rotation
  27963. * @param rotation The delta rotation amount
  27964. */
  27965. setDeltaRotation(rotation: Quaternion): void;
  27966. /**
  27967. * Gets the box size of the physics imposter and stores the result in the input parameter
  27968. * @param result Stores the box size
  27969. * @returns The physics imposter
  27970. */
  27971. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27972. /**
  27973. * Gets the radius of the physics imposter
  27974. * @returns Radius of the physics imposter
  27975. */
  27976. getRadius(): number;
  27977. /**
  27978. * Sync a bone with this impostor
  27979. * @param bone The bone to sync to the impostor.
  27980. * @param boneMesh The mesh that the bone is influencing.
  27981. * @param jointPivot The pivot of the joint / bone in local space.
  27982. * @param distToJoint Optional distance from the impostor to the joint.
  27983. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27984. */
  27985. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27986. /**
  27987. * Sync impostor to a bone
  27988. * @param bone The bone that the impostor will be synced to.
  27989. * @param boneMesh The mesh that the bone is influencing.
  27990. * @param jointPivot The pivot of the joint / bone in local space.
  27991. * @param distToJoint Optional distance from the impostor to the joint.
  27992. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27993. * @param boneAxis Optional vector3 axis the bone is aligned with
  27994. */
  27995. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27996. /**
  27997. * No-Imposter type
  27998. */
  27999. static NoImpostor: number;
  28000. /**
  28001. * Sphere-Imposter type
  28002. */
  28003. static SphereImpostor: number;
  28004. /**
  28005. * Box-Imposter type
  28006. */
  28007. static BoxImpostor: number;
  28008. /**
  28009. * Plane-Imposter type
  28010. */
  28011. static PlaneImpostor: number;
  28012. /**
  28013. * Mesh-imposter type
  28014. */
  28015. static MeshImpostor: number;
  28016. /**
  28017. * Capsule-Impostor type (Ammo.js plugin only)
  28018. */
  28019. static CapsuleImpostor: number;
  28020. /**
  28021. * Cylinder-Imposter type
  28022. */
  28023. static CylinderImpostor: number;
  28024. /**
  28025. * Particle-Imposter type
  28026. */
  28027. static ParticleImpostor: number;
  28028. /**
  28029. * Heightmap-Imposter type
  28030. */
  28031. static HeightmapImpostor: number;
  28032. /**
  28033. * ConvexHull-Impostor type (Ammo.js plugin only)
  28034. */
  28035. static ConvexHullImpostor: number;
  28036. /**
  28037. * Custom-Imposter type (Ammo.js plugin only)
  28038. */
  28039. static CustomImpostor: number;
  28040. /**
  28041. * Rope-Imposter type
  28042. */
  28043. static RopeImpostor: number;
  28044. /**
  28045. * Cloth-Imposter type
  28046. */
  28047. static ClothImpostor: number;
  28048. /**
  28049. * Softbody-Imposter type
  28050. */
  28051. static SoftbodyImpostor: number;
  28052. }
  28053. }
  28054. declare module BABYLON {
  28055. /**
  28056. * @hidden
  28057. **/
  28058. export class _CreationDataStorage {
  28059. closePath?: boolean;
  28060. closeArray?: boolean;
  28061. idx: number[];
  28062. dashSize: number;
  28063. gapSize: number;
  28064. path3D: Path3D;
  28065. pathArray: Vector3[][];
  28066. arc: number;
  28067. radius: number;
  28068. cap: number;
  28069. tessellation: number;
  28070. }
  28071. /**
  28072. * @hidden
  28073. **/
  28074. class _InstanceDataStorage {
  28075. visibleInstances: any;
  28076. batchCache: _InstancesBatch;
  28077. instancesBufferSize: number;
  28078. instancesBuffer: Nullable<Buffer>;
  28079. instancesData: Float32Array;
  28080. overridenInstanceCount: number;
  28081. isFrozen: boolean;
  28082. previousBatch: Nullable<_InstancesBatch>;
  28083. hardwareInstancedRendering: boolean;
  28084. sideOrientation: number;
  28085. manualUpdate: boolean;
  28086. }
  28087. /**
  28088. * @hidden
  28089. **/
  28090. export class _InstancesBatch {
  28091. mustReturn: boolean;
  28092. visibleInstances: Nullable<InstancedMesh[]>[];
  28093. renderSelf: boolean[];
  28094. hardwareInstancedRendering: boolean[];
  28095. }
  28096. /**
  28097. * @hidden
  28098. **/
  28099. class _ThinInstanceDataStorage {
  28100. instancesCount: number;
  28101. matrixBuffer: Nullable<Buffer>;
  28102. matrixBufferSize: number;
  28103. matrixData: Nullable<Float32Array>;
  28104. boundingVectors: Array<Vector3>;
  28105. worldMatrices: Nullable<Matrix[]>;
  28106. }
  28107. /**
  28108. * Class used to represent renderable models
  28109. */
  28110. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28111. /**
  28112. * Mesh side orientation : usually the external or front surface
  28113. */
  28114. static readonly FRONTSIDE: number;
  28115. /**
  28116. * Mesh side orientation : usually the internal or back surface
  28117. */
  28118. static readonly BACKSIDE: number;
  28119. /**
  28120. * Mesh side orientation : both internal and external or front and back surfaces
  28121. */
  28122. static readonly DOUBLESIDE: number;
  28123. /**
  28124. * Mesh side orientation : by default, `FRONTSIDE`
  28125. */
  28126. static readonly DEFAULTSIDE: number;
  28127. /**
  28128. * Mesh cap setting : no cap
  28129. */
  28130. static readonly NO_CAP: number;
  28131. /**
  28132. * Mesh cap setting : one cap at the beginning of the mesh
  28133. */
  28134. static readonly CAP_START: number;
  28135. /**
  28136. * Mesh cap setting : one cap at the end of the mesh
  28137. */
  28138. static readonly CAP_END: number;
  28139. /**
  28140. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28141. */
  28142. static readonly CAP_ALL: number;
  28143. /**
  28144. * Mesh pattern setting : no flip or rotate
  28145. */
  28146. static readonly NO_FLIP: number;
  28147. /**
  28148. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28149. */
  28150. static readonly FLIP_TILE: number;
  28151. /**
  28152. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28153. */
  28154. static readonly ROTATE_TILE: number;
  28155. /**
  28156. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28157. */
  28158. static readonly FLIP_ROW: number;
  28159. /**
  28160. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28161. */
  28162. static readonly ROTATE_ROW: number;
  28163. /**
  28164. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28165. */
  28166. static readonly FLIP_N_ROTATE_TILE: number;
  28167. /**
  28168. * Mesh pattern setting : rotate pattern and rotate
  28169. */
  28170. static readonly FLIP_N_ROTATE_ROW: number;
  28171. /**
  28172. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28173. */
  28174. static readonly CENTER: number;
  28175. /**
  28176. * Mesh tile positioning : part tiles on left
  28177. */
  28178. static readonly LEFT: number;
  28179. /**
  28180. * Mesh tile positioning : part tiles on right
  28181. */
  28182. static readonly RIGHT: number;
  28183. /**
  28184. * Mesh tile positioning : part tiles on top
  28185. */
  28186. static readonly TOP: number;
  28187. /**
  28188. * Mesh tile positioning : part tiles on bottom
  28189. */
  28190. static readonly BOTTOM: number;
  28191. /**
  28192. * Gets the default side orientation.
  28193. * @param orientation the orientation to value to attempt to get
  28194. * @returns the default orientation
  28195. * @hidden
  28196. */
  28197. static _GetDefaultSideOrientation(orientation?: number): number;
  28198. private _internalMeshDataInfo;
  28199. get computeBonesUsingShaders(): boolean;
  28200. set computeBonesUsingShaders(value: boolean);
  28201. /**
  28202. * An event triggered before rendering the mesh
  28203. */
  28204. get onBeforeRenderObservable(): Observable<Mesh>;
  28205. /**
  28206. * An event triggered before binding the mesh
  28207. */
  28208. get onBeforeBindObservable(): Observable<Mesh>;
  28209. /**
  28210. * An event triggered after rendering the mesh
  28211. */
  28212. get onAfterRenderObservable(): Observable<Mesh>;
  28213. /**
  28214. * An event triggered before drawing the mesh
  28215. */
  28216. get onBeforeDrawObservable(): Observable<Mesh>;
  28217. private _onBeforeDrawObserver;
  28218. /**
  28219. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28220. */
  28221. set onBeforeDraw(callback: () => void);
  28222. get hasInstances(): boolean;
  28223. get hasThinInstances(): boolean;
  28224. /**
  28225. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28226. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28227. */
  28228. delayLoadState: number;
  28229. /**
  28230. * Gets the list of instances created from this mesh
  28231. * it is not supposed to be modified manually.
  28232. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28233. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28234. */
  28235. instances: InstancedMesh[];
  28236. /**
  28237. * Gets the file containing delay loading data for this mesh
  28238. */
  28239. delayLoadingFile: string;
  28240. /** @hidden */
  28241. _binaryInfo: any;
  28242. /**
  28243. * User defined function used to change how LOD level selection is done
  28244. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28245. */
  28246. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28247. /**
  28248. * Gets or sets the morph target manager
  28249. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28250. */
  28251. get morphTargetManager(): Nullable<MorphTargetManager>;
  28252. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28253. /** @hidden */
  28254. _creationDataStorage: Nullable<_CreationDataStorage>;
  28255. /** @hidden */
  28256. _geometry: Nullable<Geometry>;
  28257. /** @hidden */
  28258. _delayInfo: Array<string>;
  28259. /** @hidden */
  28260. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28261. /** @hidden */
  28262. _instanceDataStorage: _InstanceDataStorage;
  28263. /** @hidden */
  28264. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28265. private _effectiveMaterial;
  28266. /** @hidden */
  28267. _shouldGenerateFlatShading: boolean;
  28268. /** @hidden */
  28269. _originalBuilderSideOrientation: number;
  28270. /**
  28271. * Use this property to change the original side orientation defined at construction time
  28272. */
  28273. overrideMaterialSideOrientation: Nullable<number>;
  28274. /**
  28275. * Gets the source mesh (the one used to clone this one from)
  28276. */
  28277. get source(): Nullable<Mesh>;
  28278. /**
  28279. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28280. */
  28281. get isUnIndexed(): boolean;
  28282. set isUnIndexed(value: boolean);
  28283. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28284. get worldMatrixInstancedBuffer(): Float32Array;
  28285. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28286. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28287. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28288. /**
  28289. * @constructor
  28290. * @param name The value used by scene.getMeshByName() to do a lookup.
  28291. * @param scene The scene to add this mesh to.
  28292. * @param parent The parent of this mesh, if it has one
  28293. * @param source An optional Mesh from which geometry is shared, cloned.
  28294. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28295. * When false, achieved by calling a clone(), also passing False.
  28296. * This will make creation of children, recursive.
  28297. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28298. */
  28299. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28300. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28301. doNotInstantiate: boolean;
  28302. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28303. /**
  28304. * Gets the class name
  28305. * @returns the string "Mesh".
  28306. */
  28307. getClassName(): string;
  28308. /** @hidden */
  28309. get _isMesh(): boolean;
  28310. /**
  28311. * Returns a description of this mesh
  28312. * @param fullDetails define if full details about this mesh must be used
  28313. * @returns a descriptive string representing this mesh
  28314. */
  28315. toString(fullDetails?: boolean): string;
  28316. /** @hidden */
  28317. _unBindEffect(): void;
  28318. /**
  28319. * Gets a boolean indicating if this mesh has LOD
  28320. */
  28321. get hasLODLevels(): boolean;
  28322. /**
  28323. * Gets the list of MeshLODLevel associated with the current mesh
  28324. * @returns an array of MeshLODLevel
  28325. */
  28326. getLODLevels(): MeshLODLevel[];
  28327. private _sortLODLevels;
  28328. /**
  28329. * Add a mesh as LOD level triggered at the given distance.
  28330. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28331. * @param distance The distance from the center of the object to show this level
  28332. * @param mesh The mesh to be added as LOD level (can be null)
  28333. * @return This mesh (for chaining)
  28334. */
  28335. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28336. /**
  28337. * Returns the LOD level mesh at the passed distance or null if not found.
  28338. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28339. * @param distance The distance from the center of the object to show this level
  28340. * @returns a Mesh or `null`
  28341. */
  28342. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28343. /**
  28344. * Remove a mesh from the LOD array
  28345. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28346. * @param mesh defines the mesh to be removed
  28347. * @return This mesh (for chaining)
  28348. */
  28349. removeLODLevel(mesh: Mesh): Mesh;
  28350. /**
  28351. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28352. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28353. * @param camera defines the camera to use to compute distance
  28354. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28355. * @return This mesh (for chaining)
  28356. */
  28357. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28358. /**
  28359. * Gets the mesh internal Geometry object
  28360. */
  28361. get geometry(): Nullable<Geometry>;
  28362. /**
  28363. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28364. * @returns the total number of vertices
  28365. */
  28366. getTotalVertices(): number;
  28367. /**
  28368. * Returns the content of an associated vertex buffer
  28369. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28370. * - VertexBuffer.PositionKind
  28371. * - VertexBuffer.UVKind
  28372. * - VertexBuffer.UV2Kind
  28373. * - VertexBuffer.UV3Kind
  28374. * - VertexBuffer.UV4Kind
  28375. * - VertexBuffer.UV5Kind
  28376. * - VertexBuffer.UV6Kind
  28377. * - VertexBuffer.ColorKind
  28378. * - VertexBuffer.MatricesIndicesKind
  28379. * - VertexBuffer.MatricesIndicesExtraKind
  28380. * - VertexBuffer.MatricesWeightsKind
  28381. * - VertexBuffer.MatricesWeightsExtraKind
  28382. * @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
  28383. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28384. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28385. */
  28386. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28387. /**
  28388. * Returns the mesh VertexBuffer object from the requested `kind`
  28389. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28390. * - VertexBuffer.PositionKind
  28391. * - VertexBuffer.NormalKind
  28392. * - VertexBuffer.UVKind
  28393. * - VertexBuffer.UV2Kind
  28394. * - VertexBuffer.UV3Kind
  28395. * - VertexBuffer.UV4Kind
  28396. * - VertexBuffer.UV5Kind
  28397. * - VertexBuffer.UV6Kind
  28398. * - VertexBuffer.ColorKind
  28399. * - VertexBuffer.MatricesIndicesKind
  28400. * - VertexBuffer.MatricesIndicesExtraKind
  28401. * - VertexBuffer.MatricesWeightsKind
  28402. * - VertexBuffer.MatricesWeightsExtraKind
  28403. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28404. */
  28405. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28406. /**
  28407. * Tests if a specific vertex buffer is associated with this mesh
  28408. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28409. * - VertexBuffer.PositionKind
  28410. * - VertexBuffer.NormalKind
  28411. * - VertexBuffer.UVKind
  28412. * - VertexBuffer.UV2Kind
  28413. * - VertexBuffer.UV3Kind
  28414. * - VertexBuffer.UV4Kind
  28415. * - VertexBuffer.UV5Kind
  28416. * - VertexBuffer.UV6Kind
  28417. * - VertexBuffer.ColorKind
  28418. * - VertexBuffer.MatricesIndicesKind
  28419. * - VertexBuffer.MatricesIndicesExtraKind
  28420. * - VertexBuffer.MatricesWeightsKind
  28421. * - VertexBuffer.MatricesWeightsExtraKind
  28422. * @returns a boolean
  28423. */
  28424. isVerticesDataPresent(kind: string): boolean;
  28425. /**
  28426. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28427. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28428. * - VertexBuffer.PositionKind
  28429. * - VertexBuffer.UVKind
  28430. * - VertexBuffer.UV2Kind
  28431. * - VertexBuffer.UV3Kind
  28432. * - VertexBuffer.UV4Kind
  28433. * - VertexBuffer.UV5Kind
  28434. * - VertexBuffer.UV6Kind
  28435. * - VertexBuffer.ColorKind
  28436. * - VertexBuffer.MatricesIndicesKind
  28437. * - VertexBuffer.MatricesIndicesExtraKind
  28438. * - VertexBuffer.MatricesWeightsKind
  28439. * - VertexBuffer.MatricesWeightsExtraKind
  28440. * @returns a boolean
  28441. */
  28442. isVertexBufferUpdatable(kind: string): boolean;
  28443. /**
  28444. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28445. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28446. * - VertexBuffer.PositionKind
  28447. * - VertexBuffer.NormalKind
  28448. * - VertexBuffer.UVKind
  28449. * - VertexBuffer.UV2Kind
  28450. * - VertexBuffer.UV3Kind
  28451. * - VertexBuffer.UV4Kind
  28452. * - VertexBuffer.UV5Kind
  28453. * - VertexBuffer.UV6Kind
  28454. * - VertexBuffer.ColorKind
  28455. * - VertexBuffer.MatricesIndicesKind
  28456. * - VertexBuffer.MatricesIndicesExtraKind
  28457. * - VertexBuffer.MatricesWeightsKind
  28458. * - VertexBuffer.MatricesWeightsExtraKind
  28459. * @returns an array of strings
  28460. */
  28461. getVerticesDataKinds(): string[];
  28462. /**
  28463. * Returns a positive integer : the total number of indices in this mesh geometry.
  28464. * @returns the numner of indices or zero if the mesh has no geometry.
  28465. */
  28466. getTotalIndices(): number;
  28467. /**
  28468. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28469. * @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.
  28470. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28471. * @returns the indices array or an empty array if the mesh has no geometry
  28472. */
  28473. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28474. get isBlocked(): boolean;
  28475. /**
  28476. * Determine if the current mesh is ready to be rendered
  28477. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28478. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28479. * @returns true if all associated assets are ready (material, textures, shaders)
  28480. */
  28481. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28482. /**
  28483. * 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.
  28484. */
  28485. get areNormalsFrozen(): boolean;
  28486. /**
  28487. * 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.
  28488. * @returns the current mesh
  28489. */
  28490. freezeNormals(): Mesh;
  28491. /**
  28492. * 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
  28493. * @returns the current mesh
  28494. */
  28495. unfreezeNormals(): Mesh;
  28496. /**
  28497. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28498. */
  28499. set overridenInstanceCount(count: number);
  28500. /** @hidden */
  28501. _preActivate(): Mesh;
  28502. /** @hidden */
  28503. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28504. /** @hidden */
  28505. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28506. protected _afterComputeWorldMatrix(): void;
  28507. /** @hidden */
  28508. _postActivate(): void;
  28509. /**
  28510. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28511. * This means the mesh underlying bounding box and sphere are recomputed.
  28512. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28513. * @returns the current mesh
  28514. */
  28515. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28516. /** @hidden */
  28517. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28518. /**
  28519. * This function will subdivide the mesh into multiple submeshes
  28520. * @param count defines the expected number of submeshes
  28521. */
  28522. subdivide(count: number): void;
  28523. /**
  28524. * Copy a FloatArray into a specific associated vertex buffer
  28525. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28526. * - VertexBuffer.PositionKind
  28527. * - VertexBuffer.UVKind
  28528. * - VertexBuffer.UV2Kind
  28529. * - VertexBuffer.UV3Kind
  28530. * - VertexBuffer.UV4Kind
  28531. * - VertexBuffer.UV5Kind
  28532. * - VertexBuffer.UV6Kind
  28533. * - VertexBuffer.ColorKind
  28534. * - VertexBuffer.MatricesIndicesKind
  28535. * - VertexBuffer.MatricesIndicesExtraKind
  28536. * - VertexBuffer.MatricesWeightsKind
  28537. * - VertexBuffer.MatricesWeightsExtraKind
  28538. * @param data defines the data source
  28539. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28540. * @param stride defines the data stride size (can be null)
  28541. * @returns the current mesh
  28542. */
  28543. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28544. /**
  28545. * Delete a vertex buffer associated with this mesh
  28546. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28547. * - VertexBuffer.PositionKind
  28548. * - VertexBuffer.UVKind
  28549. * - VertexBuffer.UV2Kind
  28550. * - VertexBuffer.UV3Kind
  28551. * - VertexBuffer.UV4Kind
  28552. * - VertexBuffer.UV5Kind
  28553. * - VertexBuffer.UV6Kind
  28554. * - VertexBuffer.ColorKind
  28555. * - VertexBuffer.MatricesIndicesKind
  28556. * - VertexBuffer.MatricesIndicesExtraKind
  28557. * - VertexBuffer.MatricesWeightsKind
  28558. * - VertexBuffer.MatricesWeightsExtraKind
  28559. */
  28560. removeVerticesData(kind: string): void;
  28561. /**
  28562. * Flags an associated vertex buffer as updatable
  28563. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28564. * - VertexBuffer.PositionKind
  28565. * - VertexBuffer.UVKind
  28566. * - VertexBuffer.UV2Kind
  28567. * - VertexBuffer.UV3Kind
  28568. * - VertexBuffer.UV4Kind
  28569. * - VertexBuffer.UV5Kind
  28570. * - VertexBuffer.UV6Kind
  28571. * - VertexBuffer.ColorKind
  28572. * - VertexBuffer.MatricesIndicesKind
  28573. * - VertexBuffer.MatricesIndicesExtraKind
  28574. * - VertexBuffer.MatricesWeightsKind
  28575. * - VertexBuffer.MatricesWeightsExtraKind
  28576. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28577. */
  28578. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28579. /**
  28580. * Sets the mesh global Vertex Buffer
  28581. * @param buffer defines the buffer to use
  28582. * @returns the current mesh
  28583. */
  28584. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28585. /**
  28586. * Update a specific associated vertex buffer
  28587. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28588. * - VertexBuffer.PositionKind
  28589. * - VertexBuffer.UVKind
  28590. * - VertexBuffer.UV2Kind
  28591. * - VertexBuffer.UV3Kind
  28592. * - VertexBuffer.UV4Kind
  28593. * - VertexBuffer.UV5Kind
  28594. * - VertexBuffer.UV6Kind
  28595. * - VertexBuffer.ColorKind
  28596. * - VertexBuffer.MatricesIndicesKind
  28597. * - VertexBuffer.MatricesIndicesExtraKind
  28598. * - VertexBuffer.MatricesWeightsKind
  28599. * - VertexBuffer.MatricesWeightsExtraKind
  28600. * @param data defines the data source
  28601. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28602. * @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)
  28603. * @returns the current mesh
  28604. */
  28605. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28606. /**
  28607. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28608. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28609. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28610. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28611. * @returns the current mesh
  28612. */
  28613. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28614. /**
  28615. * Creates a un-shared specific occurence of the geometry for the mesh.
  28616. * @returns the current mesh
  28617. */
  28618. makeGeometryUnique(): Mesh;
  28619. /**
  28620. * Set the index buffer of this mesh
  28621. * @param indices defines the source data
  28622. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28623. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28624. * @returns the current mesh
  28625. */
  28626. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28627. /**
  28628. * Update the current index buffer
  28629. * @param indices defines the source data
  28630. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28631. * @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)
  28632. * @returns the current mesh
  28633. */
  28634. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28635. /**
  28636. * Invert the geometry to move from a right handed system to a left handed one.
  28637. * @returns the current mesh
  28638. */
  28639. toLeftHanded(): Mesh;
  28640. /** @hidden */
  28641. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28642. /** @hidden */
  28643. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28644. /**
  28645. * Registers for this mesh a javascript function called just before the rendering process
  28646. * @param func defines the function to call before rendering this mesh
  28647. * @returns the current mesh
  28648. */
  28649. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28650. /**
  28651. * Disposes a previously registered javascript function called before the rendering
  28652. * @param func defines the function to remove
  28653. * @returns the current mesh
  28654. */
  28655. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28656. /**
  28657. * Registers for this mesh a javascript function called just after the rendering is complete
  28658. * @param func defines the function to call after rendering this mesh
  28659. * @returns the current mesh
  28660. */
  28661. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28662. /**
  28663. * Disposes a previously registered javascript function called after the rendering.
  28664. * @param func defines the function to remove
  28665. * @returns the current mesh
  28666. */
  28667. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28668. /** @hidden */
  28669. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28670. /** @hidden */
  28671. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28672. /** @hidden */
  28673. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28674. /** @hidden */
  28675. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28676. /** @hidden */
  28677. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28678. /** @hidden */
  28679. _rebuild(): void;
  28680. /** @hidden */
  28681. _freeze(): void;
  28682. /** @hidden */
  28683. _unFreeze(): void;
  28684. /**
  28685. * 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
  28686. * @param subMesh defines the subMesh to render
  28687. * @param enableAlphaMode defines if alpha mode can be changed
  28688. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28689. * @returns the current mesh
  28690. */
  28691. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28692. private _onBeforeDraw;
  28693. /**
  28694. * Renormalize the mesh and patch it up if there are no weights
  28695. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28696. * However in the case of zero weights then we set just a single influence to 1.
  28697. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28698. */
  28699. cleanMatrixWeights(): void;
  28700. private normalizeSkinFourWeights;
  28701. private normalizeSkinWeightsAndExtra;
  28702. /**
  28703. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28704. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28705. * the user know there was an issue with importing the mesh
  28706. * @returns a validation object with skinned, valid and report string
  28707. */
  28708. validateSkinning(): {
  28709. skinned: boolean;
  28710. valid: boolean;
  28711. report: string;
  28712. };
  28713. /** @hidden */
  28714. _checkDelayState(): Mesh;
  28715. private _queueLoad;
  28716. /**
  28717. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28718. * A mesh is in the frustum if its bounding box intersects the frustum
  28719. * @param frustumPlanes defines the frustum to test
  28720. * @returns true if the mesh is in the frustum planes
  28721. */
  28722. isInFrustum(frustumPlanes: Plane[]): boolean;
  28723. /**
  28724. * Sets the mesh material by the material or multiMaterial `id` property
  28725. * @param id is a string identifying the material or the multiMaterial
  28726. * @returns the current mesh
  28727. */
  28728. setMaterialByID(id: string): Mesh;
  28729. /**
  28730. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28731. * @returns an array of IAnimatable
  28732. */
  28733. getAnimatables(): IAnimatable[];
  28734. /**
  28735. * Modifies the mesh geometry according to the passed transformation matrix.
  28736. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28737. * The mesh normals are modified using the same transformation.
  28738. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28739. * @param transform defines the transform matrix to use
  28740. * @see https://doc.babylonjs.com/resources/baking_transformations
  28741. * @returns the current mesh
  28742. */
  28743. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28744. /**
  28745. * Modifies the mesh geometry according to its own current World Matrix.
  28746. * The mesh World Matrix is then reset.
  28747. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28748. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28749. * @see https://doc.babylonjs.com/resources/baking_transformations
  28750. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28751. * @returns the current mesh
  28752. */
  28753. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28754. /** @hidden */
  28755. get _positions(): Nullable<Vector3[]>;
  28756. /** @hidden */
  28757. _resetPointsArrayCache(): Mesh;
  28758. /** @hidden */
  28759. _generatePointsArray(): boolean;
  28760. /**
  28761. * Returns a new Mesh object generated from the current mesh properties.
  28762. * This method must not get confused with createInstance()
  28763. * @param name is a string, the name given to the new mesh
  28764. * @param newParent can be any Node object (default `null`)
  28765. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28766. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28767. * @returns a new mesh
  28768. */
  28769. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28770. /**
  28771. * Releases resources associated with this mesh.
  28772. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28773. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28774. */
  28775. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28776. /** @hidden */
  28777. _disposeInstanceSpecificData(): void;
  28778. /** @hidden */
  28779. _disposeThinInstanceSpecificData(): void;
  28780. /**
  28781. * Modifies the mesh geometry according to a displacement map.
  28782. * 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.
  28783. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28784. * @param url is a string, the URL from the image file is to be downloaded.
  28785. * @param minHeight is the lower limit of the displacement.
  28786. * @param maxHeight is the upper limit of the displacement.
  28787. * @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.
  28788. * @param uvOffset is an optional vector2 used to offset UV.
  28789. * @param uvScale is an optional vector2 used to scale UV.
  28790. * @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.
  28791. * @returns the Mesh.
  28792. */
  28793. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28794. /**
  28795. * Modifies the mesh geometry according to a displacementMap buffer.
  28796. * 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.
  28797. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28798. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28799. * @param heightMapWidth is the width of the buffer image.
  28800. * @param heightMapHeight is the height of the buffer image.
  28801. * @param minHeight is the lower limit of the displacement.
  28802. * @param maxHeight is the upper limit of the displacement.
  28803. * @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.
  28804. * @param uvOffset is an optional vector2 used to offset UV.
  28805. * @param uvScale is an optional vector2 used to scale UV.
  28806. * @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.
  28807. * @returns the Mesh.
  28808. */
  28809. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28810. /**
  28811. * Modify the mesh to get a flat shading rendering.
  28812. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28813. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28814. * @returns current mesh
  28815. */
  28816. convertToFlatShadedMesh(): Mesh;
  28817. /**
  28818. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28819. * In other words, more vertices, no more indices and a single bigger VBO.
  28820. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28821. * @returns current mesh
  28822. */
  28823. convertToUnIndexedMesh(): Mesh;
  28824. /**
  28825. * Inverses facet orientations.
  28826. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28827. * @param flipNormals will also inverts the normals
  28828. * @returns current mesh
  28829. */
  28830. flipFaces(flipNormals?: boolean): Mesh;
  28831. /**
  28832. * Increase the number of facets and hence vertices in a mesh
  28833. * Vertex normals are interpolated from existing vertex normals
  28834. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28835. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28836. */
  28837. increaseVertices(numberPerEdge: number): void;
  28838. /**
  28839. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28840. * This will undo any application of covertToFlatShadedMesh
  28841. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28842. */
  28843. forceSharedVertices(): void;
  28844. /** @hidden */
  28845. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28846. /** @hidden */
  28847. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28848. /**
  28849. * Creates a new InstancedMesh object from the mesh model.
  28850. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28851. * @param name defines the name of the new instance
  28852. * @returns a new InstancedMesh
  28853. */
  28854. createInstance(name: string): InstancedMesh;
  28855. /**
  28856. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28857. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28858. * @returns the current mesh
  28859. */
  28860. synchronizeInstances(): Mesh;
  28861. /**
  28862. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28863. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28864. * This should be used together with the simplification to avoid disappearing triangles.
  28865. * @param successCallback an optional success callback to be called after the optimization finished.
  28866. * @returns the current mesh
  28867. */
  28868. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28869. /**
  28870. * Serialize current mesh
  28871. * @param serializationObject defines the object which will receive the serialization data
  28872. */
  28873. serialize(serializationObject: any): void;
  28874. /** @hidden */
  28875. _syncGeometryWithMorphTargetManager(): void;
  28876. /** @hidden */
  28877. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28878. /**
  28879. * Returns a new Mesh object parsed from the source provided.
  28880. * @param parsedMesh is the source
  28881. * @param scene defines the hosting scene
  28882. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28883. * @returns a new Mesh
  28884. */
  28885. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28886. /**
  28887. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28889. * @param name defines the name of the mesh to create
  28890. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28891. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28892. * @param closePath creates a seam between the first and the last points of each path of the path array
  28893. * @param offset is taken in account only if the `pathArray` is containing a single path
  28894. * @param scene defines the hosting scene
  28895. * @param updatable defines if the mesh must be flagged as updatable
  28896. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28897. * @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)
  28898. * @returns a new Mesh
  28899. */
  28900. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28901. /**
  28902. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28903. * @param name defines the name of the mesh to create
  28904. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28905. * @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
  28906. * @param scene defines the hosting scene
  28907. * @param updatable defines if the mesh must be flagged as updatable
  28908. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28909. * @returns a new Mesh
  28910. */
  28911. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28912. /**
  28913. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28914. * @param name defines the name of the mesh to create
  28915. * @param size sets the size (float) of each box side (default 1)
  28916. * @param scene defines the hosting scene
  28917. * @param updatable defines if the mesh must be flagged as updatable
  28918. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28919. * @returns a new Mesh
  28920. */
  28921. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28922. /**
  28923. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28924. * @param name defines the name of the mesh to create
  28925. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28926. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28927. * @param scene defines the hosting scene
  28928. * @param updatable defines if the mesh must be flagged as updatable
  28929. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28930. * @returns a new Mesh
  28931. */
  28932. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28933. /**
  28934. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28935. * @param name defines the name of the mesh to create
  28936. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28937. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28938. * @param scene defines the hosting scene
  28939. * @returns a new Mesh
  28940. */
  28941. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28942. /**
  28943. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28944. * @param name defines the name of the mesh to create
  28945. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28946. * @param diameterTop set the top cap diameter (floats, default 1)
  28947. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28948. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28949. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28950. * @param scene defines the hosting scene
  28951. * @param updatable defines if the mesh must be flagged as updatable
  28952. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28953. * @returns a new Mesh
  28954. */
  28955. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28956. /**
  28957. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28958. * @param name defines the name of the mesh to create
  28959. * @param diameter sets the diameter size (float) of the torus (default 1)
  28960. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28961. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28962. * @param scene defines the hosting scene
  28963. * @param updatable defines if the mesh must be flagged as updatable
  28964. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28965. * @returns a new Mesh
  28966. */
  28967. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28968. /**
  28969. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28970. * @param name defines the name of the mesh to create
  28971. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28972. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28973. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28974. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28975. * @param p the number of windings on X axis (positive integers, default 2)
  28976. * @param q the number of windings on Y axis (positive integers, default 3)
  28977. * @param scene defines the hosting scene
  28978. * @param updatable defines if the mesh must be flagged as updatable
  28979. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28980. * @returns a new Mesh
  28981. */
  28982. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28983. /**
  28984. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28985. * @param name defines the name of the mesh to create
  28986. * @param points is an array successive Vector3
  28987. * @param scene defines the hosting scene
  28988. * @param updatable defines if the mesh must be flagged as updatable
  28989. * @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).
  28990. * @returns a new Mesh
  28991. */
  28992. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28993. /**
  28994. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28995. * @param name defines the name of the mesh to create
  28996. * @param points is an array successive Vector3
  28997. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28998. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28999. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29000. * @param scene defines the hosting scene
  29001. * @param updatable defines if the mesh must be flagged as updatable
  29002. * @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)
  29003. * @returns a new Mesh
  29004. */
  29005. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29006. /**
  29007. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29008. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29009. * 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.
  29010. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29011. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29012. * Remember you can only change the shape positions, not their number when updating a polygon.
  29013. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29014. * @param name defines the name of the mesh to create
  29015. * @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
  29016. * @param scene defines the hosting scene
  29017. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29018. * @param updatable defines if the mesh must be flagged as updatable
  29019. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29020. * @param earcutInjection can be used to inject your own earcut reference
  29021. * @returns a new Mesh
  29022. */
  29023. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29024. /**
  29025. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29027. * @param name defines the name of the mesh to create
  29028. * @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
  29029. * @param depth defines the height of extrusion
  29030. * @param scene defines the hosting scene
  29031. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29032. * @param updatable defines if the mesh must be flagged as updatable
  29033. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29034. * @param earcutInjection can be used to inject your own earcut reference
  29035. * @returns a new Mesh
  29036. */
  29037. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29038. /**
  29039. * Creates an extruded shape mesh.
  29040. * 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
  29041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29043. * @param name defines the name of the mesh to create
  29044. * @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
  29045. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29046. * @param scale is the value to scale the shape
  29047. * @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
  29048. * @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
  29049. * @param scene defines the hosting scene
  29050. * @param updatable defines if the mesh must be flagged as updatable
  29051. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29052. * @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)
  29053. * @returns a new Mesh
  29054. */
  29055. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29056. /**
  29057. * Creates an custom extruded shape mesh.
  29058. * The custom extrusion is a parametric shape.
  29059. * It has no predefined shape. Its final shape will depend on the input parameters.
  29060. * Please consider using the same method from the MeshBuilder class instead
  29061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29062. * @param name defines the name of the mesh to create
  29063. * @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
  29064. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29065. * @param scaleFunction is a custom Javascript function called on each path point
  29066. * @param rotationFunction is a custom Javascript function called on each path point
  29067. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29068. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29069. * @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
  29070. * @param scene defines the hosting scene
  29071. * @param updatable defines if the mesh must be flagged as updatable
  29072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29073. * @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)
  29074. * @returns a new Mesh
  29075. */
  29076. 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;
  29077. /**
  29078. * Creates lathe mesh.
  29079. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29080. * Please consider using the same method from the MeshBuilder class instead
  29081. * @param name defines the name of the mesh to create
  29082. * @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
  29083. * @param radius is the radius value of the lathe
  29084. * @param tessellation is the side number of the lathe.
  29085. * @param scene defines the hosting scene
  29086. * @param updatable defines if the mesh must be flagged as updatable
  29087. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29088. * @returns a new Mesh
  29089. */
  29090. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29091. /**
  29092. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29093. * @param name defines the name of the mesh to create
  29094. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29095. * @param scene defines the hosting scene
  29096. * @param updatable defines if the mesh must be flagged as updatable
  29097. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29098. * @returns a new Mesh
  29099. */
  29100. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29101. /**
  29102. * Creates a ground mesh.
  29103. * Please consider using the same method from the MeshBuilder class instead
  29104. * @param name defines the name of the mesh to create
  29105. * @param width set the width of the ground
  29106. * @param height set the height of the ground
  29107. * @param subdivisions sets the number of subdivisions per side
  29108. * @param scene defines the hosting scene
  29109. * @param updatable defines if the mesh must be flagged as updatable
  29110. * @returns a new Mesh
  29111. */
  29112. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29113. /**
  29114. * Creates a tiled ground mesh.
  29115. * Please consider using the same method from the MeshBuilder class instead
  29116. * @param name defines the name of the mesh to create
  29117. * @param xmin set the ground minimum X coordinate
  29118. * @param zmin set the ground minimum Y coordinate
  29119. * @param xmax set the ground maximum X coordinate
  29120. * @param zmax set the ground maximum Z coordinate
  29121. * @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
  29122. * @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
  29123. * @param scene defines the hosting scene
  29124. * @param updatable defines if the mesh must be flagged as updatable
  29125. * @returns a new Mesh
  29126. */
  29127. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29128. w: number;
  29129. h: number;
  29130. }, precision: {
  29131. w: number;
  29132. h: number;
  29133. }, scene: Scene, updatable?: boolean): Mesh;
  29134. /**
  29135. * Creates a ground mesh from a height map.
  29136. * Please consider using the same method from the MeshBuilder class instead
  29137. * @see https://doc.babylonjs.com/babylon101/height_map
  29138. * @param name defines the name of the mesh to create
  29139. * @param url sets the URL of the height map image resource
  29140. * @param width set the ground width size
  29141. * @param height set the ground height size
  29142. * @param subdivisions sets the number of subdivision per side
  29143. * @param minHeight is the minimum altitude on the ground
  29144. * @param maxHeight is the maximum altitude on the ground
  29145. * @param scene defines the hosting scene
  29146. * @param updatable defines if the mesh must be flagged as updatable
  29147. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29148. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29149. * @returns a new Mesh
  29150. */
  29151. 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;
  29152. /**
  29153. * Creates a tube mesh.
  29154. * The tube is a parametric shape.
  29155. * It has no predefined shape. Its final shape will depend on the input parameters.
  29156. * Please consider using the same method from the MeshBuilder class instead
  29157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29158. * @param name defines the name of the mesh to create
  29159. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29160. * @param radius sets the tube radius size
  29161. * @param tessellation is the number of sides on the tubular surface
  29162. * @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
  29163. * @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
  29164. * @param scene defines the hosting scene
  29165. * @param updatable defines if the mesh must be flagged as updatable
  29166. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29167. * @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)
  29168. * @returns a new Mesh
  29169. */
  29170. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29171. (i: number, distance: number): number;
  29172. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29173. /**
  29174. * Creates a polyhedron mesh.
  29175. * Please consider using the same method from the MeshBuilder class instead.
  29176. * * 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
  29177. * * The parameter `size` (positive float, default 1) sets the polygon size
  29178. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29179. * * 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`
  29180. * * 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
  29181. * * 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)`)
  29182. * * 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
  29183. * * 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
  29184. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29185. * * 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
  29186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29187. * @param name defines the name of the mesh to create
  29188. * @param options defines the options used to create the mesh
  29189. * @param scene defines the hosting scene
  29190. * @returns a new Mesh
  29191. */
  29192. static CreatePolyhedron(name: string, options: {
  29193. type?: number;
  29194. size?: number;
  29195. sizeX?: number;
  29196. sizeY?: number;
  29197. sizeZ?: number;
  29198. custom?: any;
  29199. faceUV?: Vector4[];
  29200. faceColors?: Color4[];
  29201. updatable?: boolean;
  29202. sideOrientation?: number;
  29203. }, scene: Scene): Mesh;
  29204. /**
  29205. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29206. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29207. * * 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`)
  29208. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29209. * * 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
  29210. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29211. * * 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
  29212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29213. * @param name defines the name of the mesh
  29214. * @param options defines the options used to create the mesh
  29215. * @param scene defines the hosting scene
  29216. * @returns a new Mesh
  29217. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29218. */
  29219. static CreateIcoSphere(name: string, options: {
  29220. radius?: number;
  29221. flat?: boolean;
  29222. subdivisions?: number;
  29223. sideOrientation?: number;
  29224. updatable?: boolean;
  29225. }, scene: Scene): Mesh;
  29226. /**
  29227. * Creates a decal mesh.
  29228. * Please consider using the same method from the MeshBuilder class instead.
  29229. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29230. * @param name defines the name of the mesh
  29231. * @param sourceMesh defines the mesh receiving the decal
  29232. * @param position sets the position of the decal in world coordinates
  29233. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29234. * @param size sets the decal scaling
  29235. * @param angle sets the angle to rotate the decal
  29236. * @returns a new Mesh
  29237. */
  29238. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29239. /**
  29240. * Prepare internal position array for software CPU skinning
  29241. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29242. */
  29243. setPositionsForCPUSkinning(): Float32Array;
  29244. /**
  29245. * Prepare internal normal array for software CPU skinning
  29246. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29247. */
  29248. setNormalsForCPUSkinning(): Float32Array;
  29249. /**
  29250. * Updates the vertex buffer by applying transformation from the bones
  29251. * @param skeleton defines the skeleton to apply to current mesh
  29252. * @returns the current mesh
  29253. */
  29254. applySkeleton(skeleton: Skeleton): Mesh;
  29255. /**
  29256. * 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
  29257. * @param meshes defines the list of meshes to scan
  29258. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29259. */
  29260. static MinMax(meshes: AbstractMesh[]): {
  29261. min: Vector3;
  29262. max: Vector3;
  29263. };
  29264. /**
  29265. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29266. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29267. * @returns a vector3
  29268. */
  29269. static Center(meshesOrMinMaxVector: {
  29270. min: Vector3;
  29271. max: Vector3;
  29272. } | AbstractMesh[]): Vector3;
  29273. /**
  29274. * Merge the array of meshes into a single mesh for performance reasons.
  29275. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29276. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29277. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29278. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29279. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29280. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29281. * @returns a new mesh
  29282. */
  29283. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29284. /** @hidden */
  29285. addInstance(instance: InstancedMesh): void;
  29286. /** @hidden */
  29287. removeInstance(instance: InstancedMesh): void;
  29288. }
  29289. }
  29290. declare module BABYLON {
  29291. /**
  29292. * This is the base class of all the camera used in the application.
  29293. * @see https://doc.babylonjs.com/features/cameras
  29294. */
  29295. export class Camera extends Node {
  29296. /** @hidden */
  29297. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29298. /**
  29299. * This is the default projection mode used by the cameras.
  29300. * It helps recreating a feeling of perspective and better appreciate depth.
  29301. * This is the best way to simulate real life cameras.
  29302. */
  29303. static readonly PERSPECTIVE_CAMERA: number;
  29304. /**
  29305. * This helps creating camera with an orthographic mode.
  29306. * 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.
  29307. */
  29308. static readonly ORTHOGRAPHIC_CAMERA: number;
  29309. /**
  29310. * This is the default FOV mode for perspective cameras.
  29311. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29312. */
  29313. static readonly FOVMODE_VERTICAL_FIXED: number;
  29314. /**
  29315. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29316. */
  29317. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29318. /**
  29319. * This specifies ther is no need for a camera rig.
  29320. * Basically only one eye is rendered corresponding to the camera.
  29321. */
  29322. static readonly RIG_MODE_NONE: number;
  29323. /**
  29324. * Simulates a camera Rig with one blue eye and one red eye.
  29325. * This can be use with 3d blue and red glasses.
  29326. */
  29327. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29328. /**
  29329. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29330. */
  29331. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29332. /**
  29333. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29334. */
  29335. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29336. /**
  29337. * Defines that both eyes of the camera will be rendered over under each other.
  29338. */
  29339. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29340. /**
  29341. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29342. */
  29343. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29344. /**
  29345. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29346. */
  29347. static readonly RIG_MODE_VR: number;
  29348. /**
  29349. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29350. */
  29351. static readonly RIG_MODE_WEBVR: number;
  29352. /**
  29353. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29354. */
  29355. static readonly RIG_MODE_CUSTOM: number;
  29356. /**
  29357. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29358. */
  29359. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29360. /**
  29361. * Define the input manager associated with the camera.
  29362. */
  29363. inputs: CameraInputsManager<Camera>;
  29364. /** @hidden */
  29365. _position: Vector3;
  29366. /**
  29367. * Define the current local position of the camera in the scene
  29368. */
  29369. get position(): Vector3;
  29370. set position(newPosition: Vector3);
  29371. protected _upVector: Vector3;
  29372. /**
  29373. * The vector the camera should consider as up.
  29374. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29375. */
  29376. set upVector(vec: Vector3);
  29377. get upVector(): Vector3;
  29378. /**
  29379. * Define the current limit on the left side for an orthographic camera
  29380. * In scene unit
  29381. */
  29382. orthoLeft: Nullable<number>;
  29383. /**
  29384. * Define the current limit on the right side for an orthographic camera
  29385. * In scene unit
  29386. */
  29387. orthoRight: Nullable<number>;
  29388. /**
  29389. * Define the current limit on the bottom side for an orthographic camera
  29390. * In scene unit
  29391. */
  29392. orthoBottom: Nullable<number>;
  29393. /**
  29394. * Define the current limit on the top side for an orthographic camera
  29395. * In scene unit
  29396. */
  29397. orthoTop: Nullable<number>;
  29398. /**
  29399. * Field Of View is set in Radians. (default is 0.8)
  29400. */
  29401. fov: number;
  29402. /**
  29403. * Define the minimum distance the camera can see from.
  29404. * This is important to note that the depth buffer are not infinite and the closer it starts
  29405. * the more your scene might encounter depth fighting issue.
  29406. */
  29407. minZ: number;
  29408. /**
  29409. * Define the maximum distance the camera can see to.
  29410. * This is important to note that the depth buffer are not infinite and the further it end
  29411. * the more your scene might encounter depth fighting issue.
  29412. */
  29413. maxZ: number;
  29414. /**
  29415. * Define the default inertia of the camera.
  29416. * This helps giving a smooth feeling to the camera movement.
  29417. */
  29418. inertia: number;
  29419. /**
  29420. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29421. */
  29422. mode: number;
  29423. /**
  29424. * Define whether the camera is intermediate.
  29425. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29426. */
  29427. isIntermediate: boolean;
  29428. /**
  29429. * Define the viewport of the camera.
  29430. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29431. */
  29432. viewport: Viewport;
  29433. /**
  29434. * Restricts the camera to viewing objects with the same layerMask.
  29435. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29436. */
  29437. layerMask: number;
  29438. /**
  29439. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29440. */
  29441. fovMode: number;
  29442. /**
  29443. * Rig mode of the camera.
  29444. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29445. * This is normally controlled byt the camera themselves as internal use.
  29446. */
  29447. cameraRigMode: number;
  29448. /**
  29449. * Defines the distance between both "eyes" in case of a RIG
  29450. */
  29451. interaxialDistance: number;
  29452. /**
  29453. * Defines if stereoscopic rendering is done side by side or over under.
  29454. */
  29455. isStereoscopicSideBySide: boolean;
  29456. /**
  29457. * 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
  29458. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29459. * else in the scene. (Eg. security camera)
  29460. *
  29461. * 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)
  29462. */
  29463. customRenderTargets: RenderTargetTexture[];
  29464. /**
  29465. * When set, the camera will render to this render target instead of the default canvas
  29466. *
  29467. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29468. */
  29469. outputRenderTarget: Nullable<RenderTargetTexture>;
  29470. /**
  29471. * Observable triggered when the camera view matrix has changed.
  29472. */
  29473. onViewMatrixChangedObservable: Observable<Camera>;
  29474. /**
  29475. * Observable triggered when the camera Projection matrix has changed.
  29476. */
  29477. onProjectionMatrixChangedObservable: Observable<Camera>;
  29478. /**
  29479. * Observable triggered when the inputs have been processed.
  29480. */
  29481. onAfterCheckInputsObservable: Observable<Camera>;
  29482. /**
  29483. * Observable triggered when reset has been called and applied to the camera.
  29484. */
  29485. onRestoreStateObservable: Observable<Camera>;
  29486. /**
  29487. * Is this camera a part of a rig system?
  29488. */
  29489. isRigCamera: boolean;
  29490. /**
  29491. * If isRigCamera set to true this will be set with the parent camera.
  29492. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29493. */
  29494. rigParent?: Camera;
  29495. /** @hidden */
  29496. _cameraRigParams: any;
  29497. /** @hidden */
  29498. _rigCameras: Camera[];
  29499. /** @hidden */
  29500. _rigPostProcess: Nullable<PostProcess>;
  29501. protected _webvrViewMatrix: Matrix;
  29502. /** @hidden */
  29503. _skipRendering: boolean;
  29504. /** @hidden */
  29505. _projectionMatrix: Matrix;
  29506. /** @hidden */
  29507. _postProcesses: Nullable<PostProcess>[];
  29508. /** @hidden */
  29509. _activeMeshes: SmartArray<AbstractMesh>;
  29510. protected _globalPosition: Vector3;
  29511. /** @hidden */
  29512. _computedViewMatrix: Matrix;
  29513. private _doNotComputeProjectionMatrix;
  29514. private _transformMatrix;
  29515. private _frustumPlanes;
  29516. private _refreshFrustumPlanes;
  29517. private _storedFov;
  29518. private _stateStored;
  29519. /**
  29520. * Instantiates a new camera object.
  29521. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29522. * @see https://doc.babylonjs.com/features/cameras
  29523. * @param name Defines the name of the camera in the scene
  29524. * @param position Defines the position of the camera
  29525. * @param scene Defines the scene the camera belongs too
  29526. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29527. */
  29528. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29529. /**
  29530. * Store current camera state (fov, position, etc..)
  29531. * @returns the camera
  29532. */
  29533. storeState(): Camera;
  29534. /**
  29535. * Restores the camera state values if it has been stored. You must call storeState() first
  29536. */
  29537. protected _restoreStateValues(): boolean;
  29538. /**
  29539. * Restored camera state. You must call storeState() first.
  29540. * @returns true if restored and false otherwise
  29541. */
  29542. restoreState(): boolean;
  29543. /**
  29544. * Gets the class name of the camera.
  29545. * @returns the class name
  29546. */
  29547. getClassName(): string;
  29548. /** @hidden */
  29549. readonly _isCamera: boolean;
  29550. /**
  29551. * Gets a string representation of the camera useful for debug purpose.
  29552. * @param fullDetails Defines that a more verboe level of logging is required
  29553. * @returns the string representation
  29554. */
  29555. toString(fullDetails?: boolean): string;
  29556. /**
  29557. * Gets the current world space position of the camera.
  29558. */
  29559. get globalPosition(): Vector3;
  29560. /**
  29561. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29562. * @returns the active meshe list
  29563. */
  29564. getActiveMeshes(): SmartArray<AbstractMesh>;
  29565. /**
  29566. * Check whether a mesh is part of the current active mesh list of the camera
  29567. * @param mesh Defines the mesh to check
  29568. * @returns true if active, false otherwise
  29569. */
  29570. isActiveMesh(mesh: Mesh): boolean;
  29571. /**
  29572. * Is this camera ready to be used/rendered
  29573. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29574. * @return true if the camera is ready
  29575. */
  29576. isReady(completeCheck?: boolean): boolean;
  29577. /** @hidden */
  29578. _initCache(): void;
  29579. /** @hidden */
  29580. _updateCache(ignoreParentClass?: boolean): void;
  29581. /** @hidden */
  29582. _isSynchronized(): boolean;
  29583. /** @hidden */
  29584. _isSynchronizedViewMatrix(): boolean;
  29585. /** @hidden */
  29586. _isSynchronizedProjectionMatrix(): boolean;
  29587. /**
  29588. * Attach the input controls to a specific dom element to get the input from.
  29589. * @param element Defines the element the controls should be listened from
  29590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29591. */
  29592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29593. /**
  29594. * Detach the current controls from the specified dom element.
  29595. * @param element Defines the element to stop listening the inputs from
  29596. */
  29597. detachControl(element: HTMLElement): void;
  29598. /**
  29599. * Update the camera state according to the different inputs gathered during the frame.
  29600. */
  29601. update(): void;
  29602. /** @hidden */
  29603. _checkInputs(): void;
  29604. /** @hidden */
  29605. get rigCameras(): Camera[];
  29606. /**
  29607. * Gets the post process used by the rig cameras
  29608. */
  29609. get rigPostProcess(): Nullable<PostProcess>;
  29610. /**
  29611. * Internal, gets the first post proces.
  29612. * @returns the first post process to be run on this camera.
  29613. */
  29614. _getFirstPostProcess(): Nullable<PostProcess>;
  29615. private _cascadePostProcessesToRigCams;
  29616. /**
  29617. * Attach a post process to the camera.
  29618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29619. * @param postProcess The post process to attach to the camera
  29620. * @param insertAt The position of the post process in case several of them are in use in the scene
  29621. * @returns the position the post process has been inserted at
  29622. */
  29623. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29624. /**
  29625. * Detach a post process to the camera.
  29626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29627. * @param postProcess The post process to detach from the camera
  29628. */
  29629. detachPostProcess(postProcess: PostProcess): void;
  29630. /**
  29631. * Gets the current world matrix of the camera
  29632. */
  29633. getWorldMatrix(): Matrix;
  29634. /** @hidden */
  29635. _getViewMatrix(): Matrix;
  29636. /**
  29637. * Gets the current view matrix of the camera.
  29638. * @param force forces the camera to recompute the matrix without looking at the cached state
  29639. * @returns the view matrix
  29640. */
  29641. getViewMatrix(force?: boolean): Matrix;
  29642. /**
  29643. * Freeze the projection matrix.
  29644. * It will prevent the cache check of the camera projection compute and can speed up perf
  29645. * if no parameter of the camera are meant to change
  29646. * @param projection Defines manually a projection if necessary
  29647. */
  29648. freezeProjectionMatrix(projection?: Matrix): void;
  29649. /**
  29650. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29651. */
  29652. unfreezeProjectionMatrix(): void;
  29653. /**
  29654. * Gets the current projection matrix of the camera.
  29655. * @param force forces the camera to recompute the matrix without looking at the cached state
  29656. * @returns the projection matrix
  29657. */
  29658. getProjectionMatrix(force?: boolean): Matrix;
  29659. /**
  29660. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29661. * @returns a Matrix
  29662. */
  29663. getTransformationMatrix(): Matrix;
  29664. private _updateFrustumPlanes;
  29665. /**
  29666. * Checks if a cullable object (mesh...) is in the camera frustum
  29667. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29668. * @param target The object to check
  29669. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29670. * @returns true if the object is in frustum otherwise false
  29671. */
  29672. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29673. /**
  29674. * Checks if a cullable object (mesh...) is in the camera frustum
  29675. * Unlike isInFrustum this cheks the full bounding box
  29676. * @param target The object to check
  29677. * @returns true if the object is in frustum otherwise false
  29678. */
  29679. isCompletelyInFrustum(target: ICullable): boolean;
  29680. /**
  29681. * Gets a ray in the forward direction from the camera.
  29682. * @param length Defines the length of the ray to create
  29683. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29684. * @param origin Defines the start point of the ray which defaults to the camera position
  29685. * @returns the forward ray
  29686. */
  29687. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29688. /**
  29689. * Gets a ray in the forward direction from the camera.
  29690. * @param refRay the ray to (re)use when setting the values
  29691. * @param length Defines the length of the ray to create
  29692. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29693. * @param origin Defines the start point of the ray which defaults to the camera position
  29694. * @returns the forward ray
  29695. */
  29696. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29697. /**
  29698. * Releases resources associated with this node.
  29699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29701. */
  29702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29703. /** @hidden */
  29704. _isLeftCamera: boolean;
  29705. /**
  29706. * Gets the left camera of a rig setup in case of Rigged Camera
  29707. */
  29708. get isLeftCamera(): boolean;
  29709. /** @hidden */
  29710. _isRightCamera: boolean;
  29711. /**
  29712. * Gets the right camera of a rig setup in case of Rigged Camera
  29713. */
  29714. get isRightCamera(): boolean;
  29715. /**
  29716. * Gets the left camera of a rig setup in case of Rigged Camera
  29717. */
  29718. get leftCamera(): Nullable<FreeCamera>;
  29719. /**
  29720. * Gets the right camera of a rig setup in case of Rigged Camera
  29721. */
  29722. get rightCamera(): Nullable<FreeCamera>;
  29723. /**
  29724. * Gets the left camera target of a rig setup in case of Rigged Camera
  29725. * @returns the target position
  29726. */
  29727. getLeftTarget(): Nullable<Vector3>;
  29728. /**
  29729. * Gets the right camera target of a rig setup in case of Rigged Camera
  29730. * @returns the target position
  29731. */
  29732. getRightTarget(): Nullable<Vector3>;
  29733. /**
  29734. * @hidden
  29735. */
  29736. setCameraRigMode(mode: number, rigParams: any): void;
  29737. /** @hidden */
  29738. static _setStereoscopicRigMode(camera: Camera): void;
  29739. /** @hidden */
  29740. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29741. /** @hidden */
  29742. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29743. /** @hidden */
  29744. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29745. /** @hidden */
  29746. _getVRProjectionMatrix(): Matrix;
  29747. protected _updateCameraRotationMatrix(): void;
  29748. protected _updateWebVRCameraRotationMatrix(): void;
  29749. /**
  29750. * This function MUST be overwritten by the different WebVR cameras available.
  29751. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29752. * @hidden
  29753. */
  29754. _getWebVRProjectionMatrix(): Matrix;
  29755. /**
  29756. * This function MUST be overwritten by the different WebVR cameras available.
  29757. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29758. * @hidden
  29759. */
  29760. _getWebVRViewMatrix(): Matrix;
  29761. /** @hidden */
  29762. setCameraRigParameter(name: string, value: any): void;
  29763. /**
  29764. * needs to be overridden by children so sub has required properties to be copied
  29765. * @hidden
  29766. */
  29767. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29768. /**
  29769. * May need to be overridden by children
  29770. * @hidden
  29771. */
  29772. _updateRigCameras(): void;
  29773. /** @hidden */
  29774. _setupInputs(): void;
  29775. /**
  29776. * Serialiaze the camera setup to a json represention
  29777. * @returns the JSON representation
  29778. */
  29779. serialize(): any;
  29780. /**
  29781. * Clones the current camera.
  29782. * @param name The cloned camera name
  29783. * @returns the cloned camera
  29784. */
  29785. clone(name: string): Camera;
  29786. /**
  29787. * Gets the direction of the camera relative to a given local axis.
  29788. * @param localAxis Defines the reference axis to provide a relative direction.
  29789. * @return the direction
  29790. */
  29791. getDirection(localAxis: Vector3): Vector3;
  29792. /**
  29793. * Returns the current camera absolute rotation
  29794. */
  29795. get absoluteRotation(): Quaternion;
  29796. /**
  29797. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29798. * @param localAxis Defines the reference axis to provide a relative direction.
  29799. * @param result Defines the vector to store the result in
  29800. */
  29801. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29802. /**
  29803. * Gets a camera constructor for a given camera type
  29804. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29805. * @param name The name of the camera the result will be able to instantiate
  29806. * @param scene The scene the result will construct the camera in
  29807. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29808. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29809. * @returns a factory method to construc the camera
  29810. */
  29811. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29812. /**
  29813. * Compute the world matrix of the camera.
  29814. * @returns the camera world matrix
  29815. */
  29816. computeWorldMatrix(): Matrix;
  29817. /**
  29818. * Parse a JSON and creates the camera from the parsed information
  29819. * @param parsedCamera The JSON to parse
  29820. * @param scene The scene to instantiate the camera in
  29821. * @returns the newly constructed camera
  29822. */
  29823. static Parse(parsedCamera: any, scene: Scene): Camera;
  29824. }
  29825. }
  29826. declare module BABYLON {
  29827. /**
  29828. * Class containing static functions to help procedurally build meshes
  29829. */
  29830. export class DiscBuilder {
  29831. /**
  29832. * Creates a plane polygonal mesh. By default, this is a disc
  29833. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29834. * * 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
  29835. * * 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
  29836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29837. * * 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
  29838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29839. * @param name defines the name of the mesh
  29840. * @param options defines the options used to create the mesh
  29841. * @param scene defines the hosting scene
  29842. * @returns the plane polygonal mesh
  29843. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29844. */
  29845. static CreateDisc(name: string, options: {
  29846. radius?: number;
  29847. tessellation?: number;
  29848. arc?: number;
  29849. updatable?: boolean;
  29850. sideOrientation?: number;
  29851. frontUVs?: Vector4;
  29852. backUVs?: Vector4;
  29853. }, scene?: Nullable<Scene>): Mesh;
  29854. }
  29855. }
  29856. declare module BABYLON {
  29857. /**
  29858. * Options to be used when creating a FresnelParameters.
  29859. */
  29860. export type IFresnelParametersCreationOptions = {
  29861. /**
  29862. * Define the color used on edges (grazing angle)
  29863. */
  29864. leftColor?: Color3;
  29865. /**
  29866. * Define the color used on center
  29867. */
  29868. rightColor?: Color3;
  29869. /**
  29870. * Define bias applied to computed fresnel term
  29871. */
  29872. bias?: number;
  29873. /**
  29874. * Defined the power exponent applied to fresnel term
  29875. */
  29876. power?: number;
  29877. /**
  29878. * Define if the fresnel effect is enable or not.
  29879. */
  29880. isEnabled?: boolean;
  29881. };
  29882. /**
  29883. * Serialized format for FresnelParameters.
  29884. */
  29885. export type IFresnelParametersSerialized = {
  29886. /**
  29887. * Define the color used on edges (grazing angle) [as an array]
  29888. */
  29889. leftColor: number[];
  29890. /**
  29891. * Define the color used on center [as an array]
  29892. */
  29893. rightColor: number[];
  29894. /**
  29895. * Define bias applied to computed fresnel term
  29896. */
  29897. bias: number;
  29898. /**
  29899. * Defined the power exponent applied to fresnel term
  29900. */
  29901. power?: number;
  29902. /**
  29903. * Define if the fresnel effect is enable or not.
  29904. */
  29905. isEnabled: boolean;
  29906. };
  29907. /**
  29908. * This represents all the required information to add a fresnel effect on a material:
  29909. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29910. */
  29911. export class FresnelParameters {
  29912. private _isEnabled;
  29913. /**
  29914. * Define if the fresnel effect is enable or not.
  29915. */
  29916. get isEnabled(): boolean;
  29917. set isEnabled(value: boolean);
  29918. /**
  29919. * Define the color used on edges (grazing angle)
  29920. */
  29921. leftColor: Color3;
  29922. /**
  29923. * Define the color used on center
  29924. */
  29925. rightColor: Color3;
  29926. /**
  29927. * Define bias applied to computed fresnel term
  29928. */
  29929. bias: number;
  29930. /**
  29931. * Defined the power exponent applied to fresnel term
  29932. */
  29933. power: number;
  29934. /**
  29935. * Creates a new FresnelParameters object.
  29936. *
  29937. * @param options provide your own settings to optionally to override defaults
  29938. */
  29939. constructor(options?: IFresnelParametersCreationOptions);
  29940. /**
  29941. * Clones the current fresnel and its valuues
  29942. * @returns a clone fresnel configuration
  29943. */
  29944. clone(): FresnelParameters;
  29945. /**
  29946. * Determines equality between FresnelParameters objects
  29947. * @param otherFresnelParameters defines the second operand
  29948. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29949. */
  29950. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29951. /**
  29952. * Serializes the current fresnel parameters to a JSON representation.
  29953. * @return the JSON serialization
  29954. */
  29955. serialize(): IFresnelParametersSerialized;
  29956. /**
  29957. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29958. * @param parsedFresnelParameters Define the JSON representation
  29959. * @returns the parsed parameters
  29960. */
  29961. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29962. }
  29963. }
  29964. declare module BABYLON {
  29965. /**
  29966. * This groups all the flags used to control the materials channel.
  29967. */
  29968. export class MaterialFlags {
  29969. private static _DiffuseTextureEnabled;
  29970. /**
  29971. * Are diffuse textures enabled in the application.
  29972. */
  29973. static get DiffuseTextureEnabled(): boolean;
  29974. static set DiffuseTextureEnabled(value: boolean);
  29975. private static _DetailTextureEnabled;
  29976. /**
  29977. * Are detail textures enabled in the application.
  29978. */
  29979. static get DetailTextureEnabled(): boolean;
  29980. static set DetailTextureEnabled(value: boolean);
  29981. private static _AmbientTextureEnabled;
  29982. /**
  29983. * Are ambient textures enabled in the application.
  29984. */
  29985. static get AmbientTextureEnabled(): boolean;
  29986. static set AmbientTextureEnabled(value: boolean);
  29987. private static _OpacityTextureEnabled;
  29988. /**
  29989. * Are opacity textures enabled in the application.
  29990. */
  29991. static get OpacityTextureEnabled(): boolean;
  29992. static set OpacityTextureEnabled(value: boolean);
  29993. private static _ReflectionTextureEnabled;
  29994. /**
  29995. * Are reflection textures enabled in the application.
  29996. */
  29997. static get ReflectionTextureEnabled(): boolean;
  29998. static set ReflectionTextureEnabled(value: boolean);
  29999. private static _EmissiveTextureEnabled;
  30000. /**
  30001. * Are emissive textures enabled in the application.
  30002. */
  30003. static get EmissiveTextureEnabled(): boolean;
  30004. static set EmissiveTextureEnabled(value: boolean);
  30005. private static _SpecularTextureEnabled;
  30006. /**
  30007. * Are specular textures enabled in the application.
  30008. */
  30009. static get SpecularTextureEnabled(): boolean;
  30010. static set SpecularTextureEnabled(value: boolean);
  30011. private static _BumpTextureEnabled;
  30012. /**
  30013. * Are bump textures enabled in the application.
  30014. */
  30015. static get BumpTextureEnabled(): boolean;
  30016. static set BumpTextureEnabled(value: boolean);
  30017. private static _LightmapTextureEnabled;
  30018. /**
  30019. * Are lightmap textures enabled in the application.
  30020. */
  30021. static get LightmapTextureEnabled(): boolean;
  30022. static set LightmapTextureEnabled(value: boolean);
  30023. private static _RefractionTextureEnabled;
  30024. /**
  30025. * Are refraction textures enabled in the application.
  30026. */
  30027. static get RefractionTextureEnabled(): boolean;
  30028. static set RefractionTextureEnabled(value: boolean);
  30029. private static _ColorGradingTextureEnabled;
  30030. /**
  30031. * Are color grading textures enabled in the application.
  30032. */
  30033. static get ColorGradingTextureEnabled(): boolean;
  30034. static set ColorGradingTextureEnabled(value: boolean);
  30035. private static _FresnelEnabled;
  30036. /**
  30037. * Are fresnels enabled in the application.
  30038. */
  30039. static get FresnelEnabled(): boolean;
  30040. static set FresnelEnabled(value: boolean);
  30041. private static _ClearCoatTextureEnabled;
  30042. /**
  30043. * Are clear coat textures enabled in the application.
  30044. */
  30045. static get ClearCoatTextureEnabled(): boolean;
  30046. static set ClearCoatTextureEnabled(value: boolean);
  30047. private static _ClearCoatBumpTextureEnabled;
  30048. /**
  30049. * Are clear coat bump textures enabled in the application.
  30050. */
  30051. static get ClearCoatBumpTextureEnabled(): boolean;
  30052. static set ClearCoatBumpTextureEnabled(value: boolean);
  30053. private static _ClearCoatTintTextureEnabled;
  30054. /**
  30055. * Are clear coat tint textures enabled in the application.
  30056. */
  30057. static get ClearCoatTintTextureEnabled(): boolean;
  30058. static set ClearCoatTintTextureEnabled(value: boolean);
  30059. private static _SheenTextureEnabled;
  30060. /**
  30061. * Are sheen textures enabled in the application.
  30062. */
  30063. static get SheenTextureEnabled(): boolean;
  30064. static set SheenTextureEnabled(value: boolean);
  30065. private static _AnisotropicTextureEnabled;
  30066. /**
  30067. * Are anisotropic textures enabled in the application.
  30068. */
  30069. static get AnisotropicTextureEnabled(): boolean;
  30070. static set AnisotropicTextureEnabled(value: boolean);
  30071. private static _ThicknessTextureEnabled;
  30072. /**
  30073. * Are thickness textures enabled in the application.
  30074. */
  30075. static get ThicknessTextureEnabled(): boolean;
  30076. static set ThicknessTextureEnabled(value: boolean);
  30077. }
  30078. }
  30079. declare module BABYLON {
  30080. /** @hidden */
  30081. export var defaultFragmentDeclaration: {
  30082. name: string;
  30083. shader: string;
  30084. };
  30085. }
  30086. declare module BABYLON {
  30087. /** @hidden */
  30088. export var defaultUboDeclaration: {
  30089. name: string;
  30090. shader: string;
  30091. };
  30092. }
  30093. declare module BABYLON {
  30094. /** @hidden */
  30095. export var prePassDeclaration: {
  30096. name: string;
  30097. shader: string;
  30098. };
  30099. }
  30100. declare module BABYLON {
  30101. /** @hidden */
  30102. export var lightFragmentDeclaration: {
  30103. name: string;
  30104. shader: string;
  30105. };
  30106. }
  30107. declare module BABYLON {
  30108. /** @hidden */
  30109. export var lightUboDeclaration: {
  30110. name: string;
  30111. shader: string;
  30112. };
  30113. }
  30114. declare module BABYLON {
  30115. /** @hidden */
  30116. export var lightsFragmentFunctions: {
  30117. name: string;
  30118. shader: string;
  30119. };
  30120. }
  30121. declare module BABYLON {
  30122. /** @hidden */
  30123. export var shadowsFragmentFunctions: {
  30124. name: string;
  30125. shader: string;
  30126. };
  30127. }
  30128. declare module BABYLON {
  30129. /** @hidden */
  30130. export var fresnelFunction: {
  30131. name: string;
  30132. shader: string;
  30133. };
  30134. }
  30135. declare module BABYLON {
  30136. /** @hidden */
  30137. export var bumpFragmentMainFunctions: {
  30138. name: string;
  30139. shader: string;
  30140. };
  30141. }
  30142. declare module BABYLON {
  30143. /** @hidden */
  30144. export var bumpFragmentFunctions: {
  30145. name: string;
  30146. shader: string;
  30147. };
  30148. }
  30149. declare module BABYLON {
  30150. /** @hidden */
  30151. export var logDepthDeclaration: {
  30152. name: string;
  30153. shader: string;
  30154. };
  30155. }
  30156. declare module BABYLON {
  30157. /** @hidden */
  30158. export var bumpFragment: {
  30159. name: string;
  30160. shader: string;
  30161. };
  30162. }
  30163. declare module BABYLON {
  30164. /** @hidden */
  30165. export var depthPrePass: {
  30166. name: string;
  30167. shader: string;
  30168. };
  30169. }
  30170. declare module BABYLON {
  30171. /** @hidden */
  30172. export var lightFragment: {
  30173. name: string;
  30174. shader: string;
  30175. };
  30176. }
  30177. declare module BABYLON {
  30178. /** @hidden */
  30179. export var logDepthFragment: {
  30180. name: string;
  30181. shader: string;
  30182. };
  30183. }
  30184. declare module BABYLON {
  30185. /** @hidden */
  30186. export var defaultPixelShader: {
  30187. name: string;
  30188. shader: string;
  30189. };
  30190. }
  30191. declare module BABYLON {
  30192. /** @hidden */
  30193. export var defaultVertexDeclaration: {
  30194. name: string;
  30195. shader: string;
  30196. };
  30197. }
  30198. declare module BABYLON {
  30199. /** @hidden */
  30200. export var bumpVertexDeclaration: {
  30201. name: string;
  30202. shader: string;
  30203. };
  30204. }
  30205. declare module BABYLON {
  30206. /** @hidden */
  30207. export var bumpVertex: {
  30208. name: string;
  30209. shader: string;
  30210. };
  30211. }
  30212. declare module BABYLON {
  30213. /** @hidden */
  30214. export var fogVertex: {
  30215. name: string;
  30216. shader: string;
  30217. };
  30218. }
  30219. declare module BABYLON {
  30220. /** @hidden */
  30221. export var shadowsVertex: {
  30222. name: string;
  30223. shader: string;
  30224. };
  30225. }
  30226. declare module BABYLON {
  30227. /** @hidden */
  30228. export var pointCloudVertex: {
  30229. name: string;
  30230. shader: string;
  30231. };
  30232. }
  30233. declare module BABYLON {
  30234. /** @hidden */
  30235. export var logDepthVertex: {
  30236. name: string;
  30237. shader: string;
  30238. };
  30239. }
  30240. declare module BABYLON {
  30241. /** @hidden */
  30242. export var defaultVertexShader: {
  30243. name: string;
  30244. shader: string;
  30245. };
  30246. }
  30247. declare module BABYLON {
  30248. /**
  30249. * @hidden
  30250. */
  30251. export interface IMaterialDetailMapDefines {
  30252. DETAIL: boolean;
  30253. DETAILDIRECTUV: number;
  30254. DETAIL_NORMALBLENDMETHOD: number;
  30255. /** @hidden */
  30256. _areTexturesDirty: boolean;
  30257. }
  30258. /**
  30259. * Define the code related to the detail map parameters of a material
  30260. *
  30261. * Inspired from:
  30262. * 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
  30263. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30264. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30265. */
  30266. export class DetailMapConfiguration {
  30267. private _texture;
  30268. /**
  30269. * The detail texture of the material.
  30270. */
  30271. texture: Nullable<BaseTexture>;
  30272. /**
  30273. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30274. * Bigger values mean stronger blending
  30275. */
  30276. diffuseBlendLevel: number;
  30277. /**
  30278. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30279. * Bigger values mean stronger blending. Only used with PBR materials
  30280. */
  30281. roughnessBlendLevel: number;
  30282. /**
  30283. * Defines how strong the bump effect from the detail map is
  30284. * Bigger values mean stronger effect
  30285. */
  30286. bumpLevel: number;
  30287. private _normalBlendMethod;
  30288. /**
  30289. * The method used to blend the bump and detail normals together
  30290. */
  30291. normalBlendMethod: number;
  30292. private _isEnabled;
  30293. /**
  30294. * Enable or disable the detail map on this material
  30295. */
  30296. isEnabled: boolean;
  30297. /** @hidden */
  30298. private _internalMarkAllSubMeshesAsTexturesDirty;
  30299. /** @hidden */
  30300. _markAllSubMeshesAsTexturesDirty(): void;
  30301. /**
  30302. * Instantiate a new detail map
  30303. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30304. */
  30305. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30306. /**
  30307. * Gets whether the submesh is ready to be used or not.
  30308. * @param defines the list of "defines" to update.
  30309. * @param scene defines the scene the material belongs to.
  30310. * @returns - boolean indicating that the submesh is ready or not.
  30311. */
  30312. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30313. /**
  30314. * Update the defines for detail map usage
  30315. * @param defines the list of "defines" to update.
  30316. * @param scene defines the scene the material belongs to.
  30317. */
  30318. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30319. /**
  30320. * Binds the material data.
  30321. * @param uniformBuffer defines the Uniform buffer to fill in.
  30322. * @param scene defines the scene the material belongs to.
  30323. * @param isFrozen defines whether the material is frozen or not.
  30324. */
  30325. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30326. /**
  30327. * Checks to see if a texture is used in the material.
  30328. * @param texture - Base texture to use.
  30329. * @returns - Boolean specifying if a texture is used in the material.
  30330. */
  30331. hasTexture(texture: BaseTexture): boolean;
  30332. /**
  30333. * Returns an array of the actively used textures.
  30334. * @param activeTextures Array of BaseTextures
  30335. */
  30336. getActiveTextures(activeTextures: BaseTexture[]): void;
  30337. /**
  30338. * Returns the animatable textures.
  30339. * @param animatables Array of animatable textures.
  30340. */
  30341. getAnimatables(animatables: IAnimatable[]): void;
  30342. /**
  30343. * Disposes the resources of the material.
  30344. * @param forceDisposeTextures - Forces the disposal of all textures.
  30345. */
  30346. dispose(forceDisposeTextures?: boolean): void;
  30347. /**
  30348. * Get the current class name useful for serialization or dynamic coding.
  30349. * @returns "DetailMap"
  30350. */
  30351. getClassName(): string;
  30352. /**
  30353. * Add the required uniforms to the current list.
  30354. * @param uniforms defines the current uniform list.
  30355. */
  30356. static AddUniforms(uniforms: string[]): void;
  30357. /**
  30358. * Add the required samplers to the current list.
  30359. * @param samplers defines the current sampler list.
  30360. */
  30361. static AddSamplers(samplers: string[]): void;
  30362. /**
  30363. * Add the required uniforms to the current buffer.
  30364. * @param uniformBuffer defines the current uniform buffer.
  30365. */
  30366. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30367. /**
  30368. * Makes a duplicate of the current instance into another one.
  30369. * @param detailMap define the instance where to copy the info
  30370. */
  30371. copyTo(detailMap: DetailMapConfiguration): void;
  30372. /**
  30373. * Serializes this detail map instance
  30374. * @returns - An object with the serialized instance.
  30375. */
  30376. serialize(): any;
  30377. /**
  30378. * Parses a detail map setting from a serialized object.
  30379. * @param source - Serialized object.
  30380. * @param scene Defines the scene we are parsing for
  30381. * @param rootUrl Defines the rootUrl to load from
  30382. */
  30383. parse(source: any, scene: Scene, rootUrl: string): void;
  30384. }
  30385. }
  30386. declare module BABYLON {
  30387. /** @hidden */
  30388. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30389. MAINUV1: boolean;
  30390. MAINUV2: boolean;
  30391. DIFFUSE: boolean;
  30392. DIFFUSEDIRECTUV: number;
  30393. DETAIL: boolean;
  30394. DETAILDIRECTUV: number;
  30395. DETAIL_NORMALBLENDMETHOD: number;
  30396. AMBIENT: boolean;
  30397. AMBIENTDIRECTUV: number;
  30398. OPACITY: boolean;
  30399. OPACITYDIRECTUV: number;
  30400. OPACITYRGB: boolean;
  30401. REFLECTION: boolean;
  30402. EMISSIVE: boolean;
  30403. EMISSIVEDIRECTUV: number;
  30404. SPECULAR: boolean;
  30405. SPECULARDIRECTUV: number;
  30406. BUMP: boolean;
  30407. BUMPDIRECTUV: number;
  30408. PARALLAX: boolean;
  30409. PARALLAXOCCLUSION: boolean;
  30410. SPECULAROVERALPHA: boolean;
  30411. CLIPPLANE: boolean;
  30412. CLIPPLANE2: boolean;
  30413. CLIPPLANE3: boolean;
  30414. CLIPPLANE4: boolean;
  30415. CLIPPLANE5: boolean;
  30416. CLIPPLANE6: boolean;
  30417. ALPHATEST: boolean;
  30418. DEPTHPREPASS: boolean;
  30419. ALPHAFROMDIFFUSE: boolean;
  30420. POINTSIZE: boolean;
  30421. FOG: boolean;
  30422. SPECULARTERM: boolean;
  30423. DIFFUSEFRESNEL: boolean;
  30424. OPACITYFRESNEL: boolean;
  30425. REFLECTIONFRESNEL: boolean;
  30426. REFRACTIONFRESNEL: boolean;
  30427. EMISSIVEFRESNEL: boolean;
  30428. FRESNEL: boolean;
  30429. NORMAL: boolean;
  30430. UV1: boolean;
  30431. UV2: boolean;
  30432. VERTEXCOLOR: boolean;
  30433. VERTEXALPHA: boolean;
  30434. NUM_BONE_INFLUENCERS: number;
  30435. BonesPerMesh: number;
  30436. BONETEXTURE: boolean;
  30437. INSTANCES: boolean;
  30438. THIN_INSTANCES: boolean;
  30439. GLOSSINESS: boolean;
  30440. ROUGHNESS: boolean;
  30441. EMISSIVEASILLUMINATION: boolean;
  30442. LINKEMISSIVEWITHDIFFUSE: boolean;
  30443. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30444. LIGHTMAP: boolean;
  30445. LIGHTMAPDIRECTUV: number;
  30446. OBJECTSPACE_NORMALMAP: boolean;
  30447. USELIGHTMAPASSHADOWMAP: boolean;
  30448. REFLECTIONMAP_3D: boolean;
  30449. REFLECTIONMAP_SPHERICAL: boolean;
  30450. REFLECTIONMAP_PLANAR: boolean;
  30451. REFLECTIONMAP_CUBIC: boolean;
  30452. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30453. REFLECTIONMAP_PROJECTION: boolean;
  30454. REFLECTIONMAP_SKYBOX: boolean;
  30455. REFLECTIONMAP_EXPLICIT: boolean;
  30456. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30457. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30458. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30459. INVERTCUBICMAP: boolean;
  30460. LOGARITHMICDEPTH: boolean;
  30461. REFRACTION: boolean;
  30462. REFRACTIONMAP_3D: boolean;
  30463. REFLECTIONOVERALPHA: boolean;
  30464. TWOSIDEDLIGHTING: boolean;
  30465. SHADOWFLOAT: boolean;
  30466. MORPHTARGETS: boolean;
  30467. MORPHTARGETS_NORMAL: boolean;
  30468. MORPHTARGETS_TANGENT: boolean;
  30469. MORPHTARGETS_UV: boolean;
  30470. NUM_MORPH_INFLUENCERS: number;
  30471. NONUNIFORMSCALING: boolean;
  30472. PREMULTIPLYALPHA: boolean;
  30473. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30474. ALPHABLEND: boolean;
  30475. PREPASS: boolean;
  30476. SCENE_MRT_COUNT: number;
  30477. RGBDLIGHTMAP: boolean;
  30478. RGBDREFLECTION: boolean;
  30479. RGBDREFRACTION: boolean;
  30480. IMAGEPROCESSING: boolean;
  30481. VIGNETTE: boolean;
  30482. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30483. VIGNETTEBLENDMODEOPAQUE: boolean;
  30484. TONEMAPPING: boolean;
  30485. TONEMAPPING_ACES: boolean;
  30486. CONTRAST: boolean;
  30487. COLORCURVES: boolean;
  30488. COLORGRADING: boolean;
  30489. COLORGRADING3D: boolean;
  30490. SAMPLER3DGREENDEPTH: boolean;
  30491. SAMPLER3DBGRMAP: boolean;
  30492. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30493. MULTIVIEW: boolean;
  30494. /**
  30495. * If the reflection texture on this material is in linear color space
  30496. * @hidden
  30497. */
  30498. IS_REFLECTION_LINEAR: boolean;
  30499. /**
  30500. * If the refraction texture on this material is in linear color space
  30501. * @hidden
  30502. */
  30503. IS_REFRACTION_LINEAR: boolean;
  30504. EXPOSURE: boolean;
  30505. constructor();
  30506. setReflectionMode(modeToEnable: string): void;
  30507. }
  30508. /**
  30509. * This is the default material used in Babylon. It is the best trade off between quality
  30510. * and performances.
  30511. * @see https://doc.babylonjs.com/babylon101/materials
  30512. */
  30513. export class StandardMaterial extends PushMaterial {
  30514. private _diffuseTexture;
  30515. /**
  30516. * The basic texture of the material as viewed under a light.
  30517. */
  30518. diffuseTexture: Nullable<BaseTexture>;
  30519. private _ambientTexture;
  30520. /**
  30521. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30522. */
  30523. ambientTexture: Nullable<BaseTexture>;
  30524. private _opacityTexture;
  30525. /**
  30526. * Define the transparency of the material from a texture.
  30527. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30528. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30529. */
  30530. opacityTexture: Nullable<BaseTexture>;
  30531. private _reflectionTexture;
  30532. /**
  30533. * Define the texture used to display the reflection.
  30534. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30535. */
  30536. reflectionTexture: Nullable<BaseTexture>;
  30537. private _emissiveTexture;
  30538. /**
  30539. * Define texture of the material as if self lit.
  30540. * This will be mixed in the final result even in the absence of light.
  30541. */
  30542. emissiveTexture: Nullable<BaseTexture>;
  30543. private _specularTexture;
  30544. /**
  30545. * Define how the color and intensity of the highlight given by the light in the material.
  30546. */
  30547. specularTexture: Nullable<BaseTexture>;
  30548. private _bumpTexture;
  30549. /**
  30550. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30551. * 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.
  30552. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30553. */
  30554. bumpTexture: Nullable<BaseTexture>;
  30555. private _lightmapTexture;
  30556. /**
  30557. * Complex lighting can be computationally expensive to compute at runtime.
  30558. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30559. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30560. */
  30561. lightmapTexture: Nullable<BaseTexture>;
  30562. private _refractionTexture;
  30563. /**
  30564. * Define the texture used to display the refraction.
  30565. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30566. */
  30567. refractionTexture: Nullable<BaseTexture>;
  30568. /**
  30569. * The color of the material lit by the environmental background lighting.
  30570. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30571. */
  30572. ambientColor: Color3;
  30573. /**
  30574. * The basic color of the material as viewed under a light.
  30575. */
  30576. diffuseColor: Color3;
  30577. /**
  30578. * Define how the color and intensity of the highlight given by the light in the material.
  30579. */
  30580. specularColor: Color3;
  30581. /**
  30582. * Define the color of the material as if self lit.
  30583. * This will be mixed in the final result even in the absence of light.
  30584. */
  30585. emissiveColor: Color3;
  30586. /**
  30587. * Defines how sharp are the highlights in the material.
  30588. * The bigger the value the sharper giving a more glossy feeling to the result.
  30589. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30590. */
  30591. specularPower: number;
  30592. private _useAlphaFromDiffuseTexture;
  30593. /**
  30594. * Does the transparency come from the diffuse texture alpha channel.
  30595. */
  30596. useAlphaFromDiffuseTexture: boolean;
  30597. private _useEmissiveAsIllumination;
  30598. /**
  30599. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30600. */
  30601. useEmissiveAsIllumination: boolean;
  30602. private _linkEmissiveWithDiffuse;
  30603. /**
  30604. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30605. * the emissive level when the final color is close to one.
  30606. */
  30607. linkEmissiveWithDiffuse: boolean;
  30608. private _useSpecularOverAlpha;
  30609. /**
  30610. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30611. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30612. */
  30613. useSpecularOverAlpha: boolean;
  30614. private _useReflectionOverAlpha;
  30615. /**
  30616. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30617. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30618. */
  30619. useReflectionOverAlpha: boolean;
  30620. private _disableLighting;
  30621. /**
  30622. * Does lights from the scene impacts this material.
  30623. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30624. */
  30625. disableLighting: boolean;
  30626. private _useObjectSpaceNormalMap;
  30627. /**
  30628. * Allows using an object space normal map (instead of tangent space).
  30629. */
  30630. useObjectSpaceNormalMap: boolean;
  30631. private _useParallax;
  30632. /**
  30633. * Is parallax enabled or not.
  30634. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30635. */
  30636. useParallax: boolean;
  30637. private _useParallaxOcclusion;
  30638. /**
  30639. * Is parallax occlusion enabled or not.
  30640. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30641. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30642. */
  30643. useParallaxOcclusion: boolean;
  30644. /**
  30645. * 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.
  30646. */
  30647. parallaxScaleBias: number;
  30648. private _roughness;
  30649. /**
  30650. * Helps to define how blurry the reflections should appears in the material.
  30651. */
  30652. roughness: number;
  30653. /**
  30654. * In case of refraction, define the value of the index of refraction.
  30655. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30656. */
  30657. indexOfRefraction: number;
  30658. /**
  30659. * Invert the refraction texture alongside the y axis.
  30660. * It can be useful with procedural textures or probe for instance.
  30661. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30662. */
  30663. invertRefractionY: boolean;
  30664. /**
  30665. * Defines the alpha limits in alpha test mode.
  30666. */
  30667. alphaCutOff: number;
  30668. private _useLightmapAsShadowmap;
  30669. /**
  30670. * In case of light mapping, define whether the map contains light or shadow informations.
  30671. */
  30672. useLightmapAsShadowmap: boolean;
  30673. private _diffuseFresnelParameters;
  30674. /**
  30675. * Define the diffuse fresnel parameters of the material.
  30676. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30677. */
  30678. diffuseFresnelParameters: FresnelParameters;
  30679. private _opacityFresnelParameters;
  30680. /**
  30681. * Define the opacity fresnel parameters of the material.
  30682. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30683. */
  30684. opacityFresnelParameters: FresnelParameters;
  30685. private _reflectionFresnelParameters;
  30686. /**
  30687. * Define the reflection fresnel parameters of the material.
  30688. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30689. */
  30690. reflectionFresnelParameters: FresnelParameters;
  30691. private _refractionFresnelParameters;
  30692. /**
  30693. * Define the refraction fresnel parameters of the material.
  30694. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30695. */
  30696. refractionFresnelParameters: FresnelParameters;
  30697. private _emissiveFresnelParameters;
  30698. /**
  30699. * Define the emissive fresnel parameters of the material.
  30700. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30701. */
  30702. emissiveFresnelParameters: FresnelParameters;
  30703. private _useReflectionFresnelFromSpecular;
  30704. /**
  30705. * If true automatically deducts the fresnels values from the material specularity.
  30706. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30707. */
  30708. useReflectionFresnelFromSpecular: boolean;
  30709. private _useGlossinessFromSpecularMapAlpha;
  30710. /**
  30711. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30712. */
  30713. useGlossinessFromSpecularMapAlpha: boolean;
  30714. private _maxSimultaneousLights;
  30715. /**
  30716. * Defines the maximum number of lights that can be used in the material
  30717. */
  30718. maxSimultaneousLights: number;
  30719. private _invertNormalMapX;
  30720. /**
  30721. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30722. */
  30723. invertNormalMapX: boolean;
  30724. private _invertNormalMapY;
  30725. /**
  30726. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30727. */
  30728. invertNormalMapY: boolean;
  30729. private _twoSidedLighting;
  30730. /**
  30731. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30732. */
  30733. twoSidedLighting: boolean;
  30734. /**
  30735. * Default configuration related to image processing available in the standard Material.
  30736. */
  30737. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30738. /**
  30739. * Gets the image processing configuration used either in this material.
  30740. */
  30741. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30742. /**
  30743. * Sets the Default image processing configuration used either in the this material.
  30744. *
  30745. * If sets to null, the scene one is in use.
  30746. */
  30747. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30748. /**
  30749. * Keep track of the image processing observer to allow dispose and replace.
  30750. */
  30751. private _imageProcessingObserver;
  30752. /**
  30753. * Attaches a new image processing configuration to the Standard Material.
  30754. * @param configuration
  30755. */
  30756. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30757. /**
  30758. * Gets wether the color curves effect is enabled.
  30759. */
  30760. get cameraColorCurvesEnabled(): boolean;
  30761. /**
  30762. * Sets wether the color curves effect is enabled.
  30763. */
  30764. set cameraColorCurvesEnabled(value: boolean);
  30765. /**
  30766. * Gets wether the color grading effect is enabled.
  30767. */
  30768. get cameraColorGradingEnabled(): boolean;
  30769. /**
  30770. * Gets wether the color grading effect is enabled.
  30771. */
  30772. set cameraColorGradingEnabled(value: boolean);
  30773. /**
  30774. * Gets wether tonemapping is enabled or not.
  30775. */
  30776. get cameraToneMappingEnabled(): boolean;
  30777. /**
  30778. * Sets wether tonemapping is enabled or not
  30779. */
  30780. set cameraToneMappingEnabled(value: boolean);
  30781. /**
  30782. * The camera exposure used on this material.
  30783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30784. * This corresponds to a photographic exposure.
  30785. */
  30786. get cameraExposure(): number;
  30787. /**
  30788. * The camera exposure used on this material.
  30789. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30790. * This corresponds to a photographic exposure.
  30791. */
  30792. set cameraExposure(value: number);
  30793. /**
  30794. * Gets The camera contrast used on this material.
  30795. */
  30796. get cameraContrast(): number;
  30797. /**
  30798. * Sets The camera contrast used on this material.
  30799. */
  30800. set cameraContrast(value: number);
  30801. /**
  30802. * Gets the Color Grading 2D Lookup Texture.
  30803. */
  30804. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30805. /**
  30806. * Sets the Color Grading 2D Lookup Texture.
  30807. */
  30808. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30809. /**
  30810. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30811. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30812. * 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;
  30813. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30814. */
  30815. get cameraColorCurves(): Nullable<ColorCurves>;
  30816. /**
  30817. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30818. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30819. * 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;
  30820. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30821. */
  30822. set cameraColorCurves(value: Nullable<ColorCurves>);
  30823. /**
  30824. * Can this material render to several textures at once
  30825. */
  30826. get canRenderToMRT(): boolean;
  30827. /**
  30828. * Defines the detail map parameters for the material.
  30829. */
  30830. readonly detailMap: DetailMapConfiguration;
  30831. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30832. protected _worldViewProjectionMatrix: Matrix;
  30833. protected _globalAmbientColor: Color3;
  30834. protected _useLogarithmicDepth: boolean;
  30835. protected _rebuildInParallel: boolean;
  30836. /**
  30837. * Instantiates a new standard material.
  30838. * This is the default material used in Babylon. It is the best trade off between quality
  30839. * and performances.
  30840. * @see https://doc.babylonjs.com/babylon101/materials
  30841. * @param name Define the name of the material in the scene
  30842. * @param scene Define the scene the material belong to
  30843. */
  30844. constructor(name: string, scene: Scene);
  30845. /**
  30846. * Gets a boolean indicating that current material needs to register RTT
  30847. */
  30848. get hasRenderTargetTextures(): boolean;
  30849. /**
  30850. * Gets the current class name of the material e.g. "StandardMaterial"
  30851. * Mainly use in serialization.
  30852. * @returns the class name
  30853. */
  30854. getClassName(): string;
  30855. /**
  30856. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30857. * You can try switching to logarithmic depth.
  30858. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30859. */
  30860. get useLogarithmicDepth(): boolean;
  30861. set useLogarithmicDepth(value: boolean);
  30862. /**
  30863. * Specifies if the material will require alpha blending
  30864. * @returns a boolean specifying if alpha blending is needed
  30865. */
  30866. needAlphaBlending(): boolean;
  30867. /**
  30868. * Specifies if this material should be rendered in alpha test mode
  30869. * @returns a boolean specifying if an alpha test is needed.
  30870. */
  30871. needAlphaTesting(): boolean;
  30872. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30873. /**
  30874. * Get the texture used for alpha test purpose.
  30875. * @returns the diffuse texture in case of the standard material.
  30876. */
  30877. getAlphaTestTexture(): Nullable<BaseTexture>;
  30878. /**
  30879. * Get if the submesh is ready to be used and all its information available.
  30880. * Child classes can use it to update shaders
  30881. * @param mesh defines the mesh to check
  30882. * @param subMesh defines which submesh to check
  30883. * @param useInstances specifies that instances should be used
  30884. * @returns a boolean indicating that the submesh is ready or not
  30885. */
  30886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30887. /**
  30888. * Builds the material UBO layouts.
  30889. * Used internally during the effect preparation.
  30890. */
  30891. buildUniformLayout(): void;
  30892. /**
  30893. * Unbinds the material from the mesh
  30894. */
  30895. unbind(): void;
  30896. /**
  30897. * Binds the submesh to this material by preparing the effect and shader to draw
  30898. * @param world defines the world transformation matrix
  30899. * @param mesh defines the mesh containing the submesh
  30900. * @param subMesh defines the submesh to bind the material to
  30901. */
  30902. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30903. /**
  30904. * Get the list of animatables in the material.
  30905. * @returns the list of animatables object used in the material
  30906. */
  30907. getAnimatables(): IAnimatable[];
  30908. /**
  30909. * Gets the active textures from the material
  30910. * @returns an array of textures
  30911. */
  30912. getActiveTextures(): BaseTexture[];
  30913. /**
  30914. * Specifies if the material uses a texture
  30915. * @param texture defines the texture to check against the material
  30916. * @returns a boolean specifying if the material uses the texture
  30917. */
  30918. hasTexture(texture: BaseTexture): boolean;
  30919. /**
  30920. * Disposes the material
  30921. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30922. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30923. */
  30924. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30925. /**
  30926. * Makes a duplicate of the material, and gives it a new name
  30927. * @param name defines the new name for the duplicated material
  30928. * @returns the cloned material
  30929. */
  30930. clone(name: string): StandardMaterial;
  30931. /**
  30932. * Serializes this material in a JSON representation
  30933. * @returns the serialized material object
  30934. */
  30935. serialize(): any;
  30936. /**
  30937. * Creates a standard material from parsed material data
  30938. * @param source defines the JSON representation of the material
  30939. * @param scene defines the hosting scene
  30940. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30941. * @returns a new standard material
  30942. */
  30943. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30944. /**
  30945. * Are diffuse textures enabled in the application.
  30946. */
  30947. static get DiffuseTextureEnabled(): boolean;
  30948. static set DiffuseTextureEnabled(value: boolean);
  30949. /**
  30950. * Are detail textures enabled in the application.
  30951. */
  30952. static get DetailTextureEnabled(): boolean;
  30953. static set DetailTextureEnabled(value: boolean);
  30954. /**
  30955. * Are ambient textures enabled in the application.
  30956. */
  30957. static get AmbientTextureEnabled(): boolean;
  30958. static set AmbientTextureEnabled(value: boolean);
  30959. /**
  30960. * Are opacity textures enabled in the application.
  30961. */
  30962. static get OpacityTextureEnabled(): boolean;
  30963. static set OpacityTextureEnabled(value: boolean);
  30964. /**
  30965. * Are reflection textures enabled in the application.
  30966. */
  30967. static get ReflectionTextureEnabled(): boolean;
  30968. static set ReflectionTextureEnabled(value: boolean);
  30969. /**
  30970. * Are emissive textures enabled in the application.
  30971. */
  30972. static get EmissiveTextureEnabled(): boolean;
  30973. static set EmissiveTextureEnabled(value: boolean);
  30974. /**
  30975. * Are specular textures enabled in the application.
  30976. */
  30977. static get SpecularTextureEnabled(): boolean;
  30978. static set SpecularTextureEnabled(value: boolean);
  30979. /**
  30980. * Are bump textures enabled in the application.
  30981. */
  30982. static get BumpTextureEnabled(): boolean;
  30983. static set BumpTextureEnabled(value: boolean);
  30984. /**
  30985. * Are lightmap textures enabled in the application.
  30986. */
  30987. static get LightmapTextureEnabled(): boolean;
  30988. static set LightmapTextureEnabled(value: boolean);
  30989. /**
  30990. * Are refraction textures enabled in the application.
  30991. */
  30992. static get RefractionTextureEnabled(): boolean;
  30993. static set RefractionTextureEnabled(value: boolean);
  30994. /**
  30995. * Are color grading textures enabled in the application.
  30996. */
  30997. static get ColorGradingTextureEnabled(): boolean;
  30998. static set ColorGradingTextureEnabled(value: boolean);
  30999. /**
  31000. * Are fresnels enabled in the application.
  31001. */
  31002. static get FresnelEnabled(): boolean;
  31003. static set FresnelEnabled(value: boolean);
  31004. }
  31005. }
  31006. declare module BABYLON {
  31007. /**
  31008. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31009. *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.
  31010. * The SPS is also a particle system. It provides some methods to manage the particles.
  31011. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31012. *
  31013. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31014. */
  31015. export class SolidParticleSystem implements IDisposable {
  31016. /**
  31017. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31018. * Example : var p = SPS.particles[i];
  31019. */
  31020. particles: SolidParticle[];
  31021. /**
  31022. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31023. */
  31024. nbParticles: number;
  31025. /**
  31026. * If the particles must ever face the camera (default false). Useful for planar particles.
  31027. */
  31028. billboard: boolean;
  31029. /**
  31030. * Recompute normals when adding a shape
  31031. */
  31032. recomputeNormals: boolean;
  31033. /**
  31034. * This a counter ofr your own usage. It's not set by any SPS functions.
  31035. */
  31036. counter: number;
  31037. /**
  31038. * The SPS name. This name is also given to the underlying mesh.
  31039. */
  31040. name: string;
  31041. /**
  31042. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31043. */
  31044. mesh: Mesh;
  31045. /**
  31046. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31047. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31048. */
  31049. vars: any;
  31050. /**
  31051. * This array is populated when the SPS is set as 'pickable'.
  31052. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31053. * Each element of this array is an object `{idx: int, faceId: int}`.
  31054. * `idx` is the picked particle index in the `SPS.particles` array
  31055. * `faceId` is the picked face index counted within this particle.
  31056. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31057. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31058. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31059. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31060. */
  31061. pickedParticles: {
  31062. idx: number;
  31063. faceId: number;
  31064. }[];
  31065. /**
  31066. * This array is populated when the SPS is set as 'pickable'
  31067. * Each key of this array is a submesh index.
  31068. * Each element of this array is a second array defined like this :
  31069. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31070. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31071. * `idx` is the picked particle index in the `SPS.particles` array
  31072. * `faceId` is the picked face index counted within this particle.
  31073. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31074. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31075. */
  31076. pickedBySubMesh: {
  31077. idx: number;
  31078. faceId: number;
  31079. }[][];
  31080. /**
  31081. * This array is populated when `enableDepthSort` is set to true.
  31082. * Each element of this array is an instance of the class DepthSortedParticle.
  31083. */
  31084. depthSortedParticles: DepthSortedParticle[];
  31085. /**
  31086. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31087. * @hidden
  31088. */
  31089. _bSphereOnly: boolean;
  31090. /**
  31091. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31092. * @hidden
  31093. */
  31094. _bSphereRadiusFactor: number;
  31095. private _scene;
  31096. private _positions;
  31097. private _indices;
  31098. private _normals;
  31099. private _colors;
  31100. private _uvs;
  31101. private _indices32;
  31102. private _positions32;
  31103. private _normals32;
  31104. private _fixedNormal32;
  31105. private _colors32;
  31106. private _uvs32;
  31107. private _index;
  31108. private _updatable;
  31109. private _pickable;
  31110. private _isVisibilityBoxLocked;
  31111. private _alwaysVisible;
  31112. private _depthSort;
  31113. private _expandable;
  31114. private _shapeCounter;
  31115. private _copy;
  31116. private _color;
  31117. private _computeParticleColor;
  31118. private _computeParticleTexture;
  31119. private _computeParticleRotation;
  31120. private _computeParticleVertex;
  31121. private _computeBoundingBox;
  31122. private _depthSortParticles;
  31123. private _camera;
  31124. private _mustUnrotateFixedNormals;
  31125. private _particlesIntersect;
  31126. private _needs32Bits;
  31127. private _isNotBuilt;
  31128. private _lastParticleId;
  31129. private _idxOfId;
  31130. private _multimaterialEnabled;
  31131. private _useModelMaterial;
  31132. private _indicesByMaterial;
  31133. private _materialIndexes;
  31134. private _depthSortFunction;
  31135. private _materialSortFunction;
  31136. private _materials;
  31137. private _multimaterial;
  31138. private _materialIndexesById;
  31139. private _defaultMaterial;
  31140. private _autoUpdateSubMeshes;
  31141. private _tmpVertex;
  31142. /**
  31143. * Creates a SPS (Solid Particle System) object.
  31144. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31145. * @param scene (Scene) is the scene in which the SPS is added.
  31146. * @param options defines the options of the sps e.g.
  31147. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31148. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31149. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31150. * * 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.
  31151. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31152. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31153. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31154. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31155. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31156. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31157. */
  31158. constructor(name: string, scene: Scene, options?: {
  31159. updatable?: boolean;
  31160. isPickable?: boolean;
  31161. enableDepthSort?: boolean;
  31162. particleIntersection?: boolean;
  31163. boundingSphereOnly?: boolean;
  31164. bSphereRadiusFactor?: number;
  31165. expandable?: boolean;
  31166. useModelMaterial?: boolean;
  31167. enableMultiMaterial?: boolean;
  31168. });
  31169. /**
  31170. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31171. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31172. * @returns the created mesh
  31173. */
  31174. buildMesh(): Mesh;
  31175. /**
  31176. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31177. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31178. * Thus the particles generated from `digest()` have their property `position` set yet.
  31179. * @param mesh ( Mesh ) is the mesh to be digested
  31180. * @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
  31181. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31182. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31183. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31184. * @returns the current SPS
  31185. */
  31186. digest(mesh: Mesh, options?: {
  31187. facetNb?: number;
  31188. number?: number;
  31189. delta?: number;
  31190. storage?: [];
  31191. }): SolidParticleSystem;
  31192. /**
  31193. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31194. * @hidden
  31195. */
  31196. private _unrotateFixedNormals;
  31197. /**
  31198. * Resets the temporary working copy particle
  31199. * @hidden
  31200. */
  31201. private _resetCopy;
  31202. /**
  31203. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31204. * @param p the current index in the positions array to be updated
  31205. * @param ind the current index in the indices array
  31206. * @param shape a Vector3 array, the shape geometry
  31207. * @param positions the positions array to be updated
  31208. * @param meshInd the shape indices array
  31209. * @param indices the indices array to be updated
  31210. * @param meshUV the shape uv array
  31211. * @param uvs the uv array to be updated
  31212. * @param meshCol the shape color array
  31213. * @param colors the color array to be updated
  31214. * @param meshNor the shape normals array
  31215. * @param normals the normals array to be updated
  31216. * @param idx the particle index
  31217. * @param idxInShape the particle index in its shape
  31218. * @param options the addShape() method passed options
  31219. * @model the particle model
  31220. * @hidden
  31221. */
  31222. private _meshBuilder;
  31223. /**
  31224. * Returns a shape Vector3 array from positions float array
  31225. * @param positions float array
  31226. * @returns a vector3 array
  31227. * @hidden
  31228. */
  31229. private _posToShape;
  31230. /**
  31231. * Returns a shapeUV array from a float uvs (array deep copy)
  31232. * @param uvs as a float array
  31233. * @returns a shapeUV array
  31234. * @hidden
  31235. */
  31236. private _uvsToShapeUV;
  31237. /**
  31238. * Adds a new particle object in the particles array
  31239. * @param idx particle index in particles array
  31240. * @param id particle id
  31241. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31242. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31243. * @param model particle ModelShape object
  31244. * @param shapeId model shape identifier
  31245. * @param idxInShape index of the particle in the current model
  31246. * @param bInfo model bounding info object
  31247. * @param storage target storage array, if any
  31248. * @hidden
  31249. */
  31250. private _addParticle;
  31251. /**
  31252. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31253. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31254. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31255. * @param nb (positive integer) the number of particles to be created from this model
  31256. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31257. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31258. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31259. * @returns the number of shapes in the system
  31260. */
  31261. addShape(mesh: Mesh, nb: number, options?: {
  31262. positionFunction?: any;
  31263. vertexFunction?: any;
  31264. storage?: [];
  31265. }): number;
  31266. /**
  31267. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31268. * @hidden
  31269. */
  31270. private _rebuildParticle;
  31271. /**
  31272. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31273. * @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.
  31274. * @returns the SPS.
  31275. */
  31276. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31277. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31278. * Returns an array with the removed particles.
  31279. * 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.
  31280. * The SPS can't be empty so at least one particle needs to remain in place.
  31281. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31282. * @param start index of the first particle to remove
  31283. * @param end index of the last particle to remove (included)
  31284. * @returns an array populated with the removed particles
  31285. */
  31286. removeParticles(start: number, end: number): SolidParticle[];
  31287. /**
  31288. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31289. * @param solidParticleArray an array populated with Solid Particles objects
  31290. * @returns the SPS
  31291. */
  31292. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31293. /**
  31294. * Creates a new particle and modifies the SPS mesh geometry :
  31295. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31296. * - calls _addParticle() to populate the particle array
  31297. * factorized code from addShape() and insertParticlesFromArray()
  31298. * @param idx particle index in the particles array
  31299. * @param i particle index in its shape
  31300. * @param modelShape particle ModelShape object
  31301. * @param shape shape vertex array
  31302. * @param meshInd shape indices array
  31303. * @param meshUV shape uv array
  31304. * @param meshCol shape color array
  31305. * @param meshNor shape normals array
  31306. * @param bbInfo shape bounding info
  31307. * @param storage target particle storage
  31308. * @options addShape() passed options
  31309. * @hidden
  31310. */
  31311. private _insertNewParticle;
  31312. /**
  31313. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31314. * This method calls `updateParticle()` for each particle of the SPS.
  31315. * For an animated SPS, it is usually called within the render loop.
  31316. * 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.
  31317. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31318. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31319. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31320. * @returns the SPS.
  31321. */
  31322. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31323. /**
  31324. * Disposes the SPS.
  31325. */
  31326. dispose(): void;
  31327. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31328. * idx is the particle index in the SPS
  31329. * faceId is the picked face index counted within this particle.
  31330. * Returns null if the pickInfo can't identify a picked particle.
  31331. * @param pickingInfo (PickingInfo object)
  31332. * @returns {idx: number, faceId: number} or null
  31333. */
  31334. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31335. idx: number;
  31336. faceId: number;
  31337. }>;
  31338. /**
  31339. * Returns a SolidParticle object from its identifier : particle.id
  31340. * @param id (integer) the particle Id
  31341. * @returns the searched particle or null if not found in the SPS.
  31342. */
  31343. getParticleById(id: number): Nullable<SolidParticle>;
  31344. /**
  31345. * Returns a new array populated with the particles having the passed shapeId.
  31346. * @param shapeId (integer) the shape identifier
  31347. * @returns a new solid particle array
  31348. */
  31349. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31350. /**
  31351. * Populates the passed array "ref" with the particles having the passed shapeId.
  31352. * @param shapeId the shape identifier
  31353. * @returns the SPS
  31354. * @param ref
  31355. */
  31356. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31357. /**
  31358. * Computes the required SubMeshes according the materials assigned to the particles.
  31359. * @returns the solid particle system.
  31360. * Does nothing if called before the SPS mesh is built.
  31361. */
  31362. computeSubMeshes(): SolidParticleSystem;
  31363. /**
  31364. * Sorts the solid particles by material when MultiMaterial is enabled.
  31365. * Updates the indices32 array.
  31366. * Updates the indicesByMaterial array.
  31367. * Updates the mesh indices array.
  31368. * @returns the SPS
  31369. * @hidden
  31370. */
  31371. private _sortParticlesByMaterial;
  31372. /**
  31373. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31374. * @hidden
  31375. */
  31376. private _setMaterialIndexesById;
  31377. /**
  31378. * Returns an array with unique values of Materials from the passed array
  31379. * @param array the material array to be checked and filtered
  31380. * @hidden
  31381. */
  31382. private _filterUniqueMaterialId;
  31383. /**
  31384. * Sets a new Standard Material as _defaultMaterial if not already set.
  31385. * @hidden
  31386. */
  31387. private _setDefaultMaterial;
  31388. /**
  31389. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31390. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31391. * @returns the SPS.
  31392. */
  31393. refreshVisibleSize(): SolidParticleSystem;
  31394. /**
  31395. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31396. * @param size the size (float) of the visibility box
  31397. * note : this doesn't lock the SPS mesh bounding box.
  31398. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31399. */
  31400. setVisibilityBox(size: number): void;
  31401. /**
  31402. * Gets whether the SPS as always visible or not
  31403. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31404. */
  31405. get isAlwaysVisible(): boolean;
  31406. /**
  31407. * Sets the SPS as always visible or not
  31408. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31409. */
  31410. set isAlwaysVisible(val: boolean);
  31411. /**
  31412. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31413. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31414. */
  31415. set isVisibilityBoxLocked(val: boolean);
  31416. /**
  31417. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31418. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31419. */
  31420. get isVisibilityBoxLocked(): boolean;
  31421. /**
  31422. * Tells to `setParticles()` to compute the particle rotations or not.
  31423. * Default value : true. The SPS is faster when it's set to false.
  31424. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31425. */
  31426. set computeParticleRotation(val: boolean);
  31427. /**
  31428. * Tells to `setParticles()` to compute the particle colors or not.
  31429. * Default value : true. The SPS is faster when it's set to false.
  31430. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31431. */
  31432. set computeParticleColor(val: boolean);
  31433. set computeParticleTexture(val: boolean);
  31434. /**
  31435. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31436. * Default value : false. The SPS is faster when it's set to false.
  31437. * Note : the particle custom vertex positions aren't stored values.
  31438. */
  31439. set computeParticleVertex(val: boolean);
  31440. /**
  31441. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31442. */
  31443. set computeBoundingBox(val: boolean);
  31444. /**
  31445. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31446. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31447. * Default : `true`
  31448. */
  31449. set depthSortParticles(val: boolean);
  31450. /**
  31451. * Gets if `setParticles()` computes the particle rotations or not.
  31452. * Default value : true. The SPS is faster when it's set to false.
  31453. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31454. */
  31455. get computeParticleRotation(): boolean;
  31456. /**
  31457. * Gets if `setParticles()` computes the particle colors or not.
  31458. * Default value : true. The SPS is faster when it's set to false.
  31459. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31460. */
  31461. get computeParticleColor(): boolean;
  31462. /**
  31463. * Gets if `setParticles()` computes the particle textures or not.
  31464. * Default value : true. The SPS is faster when it's set to false.
  31465. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31466. */
  31467. get computeParticleTexture(): boolean;
  31468. /**
  31469. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31470. * Default value : false. The SPS is faster when it's set to false.
  31471. * Note : the particle custom vertex positions aren't stored values.
  31472. */
  31473. get computeParticleVertex(): boolean;
  31474. /**
  31475. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31476. */
  31477. get computeBoundingBox(): boolean;
  31478. /**
  31479. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31480. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31481. * Default : `true`
  31482. */
  31483. get depthSortParticles(): boolean;
  31484. /**
  31485. * Gets if the SPS is created as expandable at construction time.
  31486. * Default : `false`
  31487. */
  31488. get expandable(): boolean;
  31489. /**
  31490. * Gets if the SPS supports the Multi Materials
  31491. */
  31492. get multimaterialEnabled(): boolean;
  31493. /**
  31494. * Gets if the SPS uses the model materials for its own multimaterial.
  31495. */
  31496. get useModelMaterial(): boolean;
  31497. /**
  31498. * The SPS used material array.
  31499. */
  31500. get materials(): Material[];
  31501. /**
  31502. * Sets the SPS MultiMaterial from the passed materials.
  31503. * Note : the passed array is internally copied and not used then by reference.
  31504. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31505. */
  31506. setMultiMaterial(materials: Material[]): void;
  31507. /**
  31508. * The SPS computed multimaterial object
  31509. */
  31510. get multimaterial(): MultiMaterial;
  31511. set multimaterial(mm: MultiMaterial);
  31512. /**
  31513. * If the subMeshes must be updated on the next call to setParticles()
  31514. */
  31515. get autoUpdateSubMeshes(): boolean;
  31516. set autoUpdateSubMeshes(val: boolean);
  31517. /**
  31518. * This function does nothing. It may be overwritten to set all the particle first values.
  31519. * The SPS doesn't call this function, you may have to call it by your own.
  31520. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31521. */
  31522. initParticles(): void;
  31523. /**
  31524. * This function does nothing. It may be overwritten to recycle a particle.
  31525. * The SPS doesn't call this function, you may have to call it by your own.
  31526. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31527. * @param particle The particle to recycle
  31528. * @returns the recycled particle
  31529. */
  31530. recycleParticle(particle: SolidParticle): SolidParticle;
  31531. /**
  31532. * Updates a particle : this function should be overwritten by the user.
  31533. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31534. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31535. * @example : just set a particle position or velocity and recycle conditions
  31536. * @param particle The particle to update
  31537. * @returns the updated particle
  31538. */
  31539. updateParticle(particle: SolidParticle): SolidParticle;
  31540. /**
  31541. * Updates a vertex of a particle : it can be overwritten by the user.
  31542. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31543. * @param particle the current particle
  31544. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31545. * @param pt the index of the current vertex in the particle shape
  31546. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31547. * @example : just set a vertex particle position or color
  31548. * @returns the sps
  31549. */
  31550. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31551. /**
  31552. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31553. * This does nothing and may be overwritten by the user.
  31554. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31555. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31556. * @param update the boolean update value actually passed to setParticles()
  31557. */
  31558. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31559. /**
  31560. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31561. * This will be passed three parameters.
  31562. * This does nothing and may be overwritten by the user.
  31563. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31564. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31565. * @param update the boolean update value actually passed to setParticles()
  31566. */
  31567. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31568. }
  31569. }
  31570. declare module BABYLON {
  31571. /**
  31572. * Represents one particle of a solid particle system.
  31573. */
  31574. export class SolidParticle {
  31575. /**
  31576. * particle global index
  31577. */
  31578. idx: number;
  31579. /**
  31580. * particle identifier
  31581. */
  31582. id: number;
  31583. /**
  31584. * The color of the particle
  31585. */
  31586. color: Nullable<Color4>;
  31587. /**
  31588. * The world space position of the particle.
  31589. */
  31590. position: Vector3;
  31591. /**
  31592. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31593. */
  31594. rotation: Vector3;
  31595. /**
  31596. * The world space rotation quaternion of the particle.
  31597. */
  31598. rotationQuaternion: Nullable<Quaternion>;
  31599. /**
  31600. * The scaling of the particle.
  31601. */
  31602. scaling: Vector3;
  31603. /**
  31604. * The uvs of the particle.
  31605. */
  31606. uvs: Vector4;
  31607. /**
  31608. * The current speed of the particle.
  31609. */
  31610. velocity: Vector3;
  31611. /**
  31612. * The pivot point in the particle local space.
  31613. */
  31614. pivot: Vector3;
  31615. /**
  31616. * Must the particle be translated from its pivot point in its local space ?
  31617. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31618. * Default : false
  31619. */
  31620. translateFromPivot: boolean;
  31621. /**
  31622. * Is the particle active or not ?
  31623. */
  31624. alive: boolean;
  31625. /**
  31626. * Is the particle visible or not ?
  31627. */
  31628. isVisible: boolean;
  31629. /**
  31630. * Index of this particle in the global "positions" array (Internal use)
  31631. * @hidden
  31632. */
  31633. _pos: number;
  31634. /**
  31635. * @hidden Index of this particle in the global "indices" array (Internal use)
  31636. */
  31637. _ind: number;
  31638. /**
  31639. * @hidden ModelShape of this particle (Internal use)
  31640. */
  31641. _model: ModelShape;
  31642. /**
  31643. * ModelShape id of this particle
  31644. */
  31645. shapeId: number;
  31646. /**
  31647. * Index of the particle in its shape id
  31648. */
  31649. idxInShape: number;
  31650. /**
  31651. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31652. */
  31653. _modelBoundingInfo: BoundingInfo;
  31654. /**
  31655. * @hidden Particle BoundingInfo object (Internal use)
  31656. */
  31657. _boundingInfo: BoundingInfo;
  31658. /**
  31659. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31660. */
  31661. _sps: SolidParticleSystem;
  31662. /**
  31663. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31664. */
  31665. _stillInvisible: boolean;
  31666. /**
  31667. * @hidden Last computed particle rotation matrix
  31668. */
  31669. _rotationMatrix: number[];
  31670. /**
  31671. * Parent particle Id, if any.
  31672. * Default null.
  31673. */
  31674. parentId: Nullable<number>;
  31675. /**
  31676. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31677. */
  31678. materialIndex: Nullable<number>;
  31679. /**
  31680. * Custom object or properties.
  31681. */
  31682. props: Nullable<any>;
  31683. /**
  31684. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31685. * The possible values are :
  31686. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31687. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31688. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31689. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31690. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31691. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31692. * */
  31693. cullingStrategy: number;
  31694. /**
  31695. * @hidden Internal global position in the SPS.
  31696. */
  31697. _globalPosition: Vector3;
  31698. /**
  31699. * Creates a Solid Particle object.
  31700. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31701. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31702. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31703. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31704. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31705. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31706. * @param shapeId (integer) is the model shape identifier in the SPS.
  31707. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31708. * @param sps defines the sps it is associated to
  31709. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31710. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31711. */
  31712. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31713. /**
  31714. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31715. * @param target the particle target
  31716. * @returns the current particle
  31717. */
  31718. copyToRef(target: SolidParticle): SolidParticle;
  31719. /**
  31720. * Legacy support, changed scale to scaling
  31721. */
  31722. get scale(): Vector3;
  31723. /**
  31724. * Legacy support, changed scale to scaling
  31725. */
  31726. set scale(scale: Vector3);
  31727. /**
  31728. * Legacy support, changed quaternion to rotationQuaternion
  31729. */
  31730. get quaternion(): Nullable<Quaternion>;
  31731. /**
  31732. * Legacy support, changed quaternion to rotationQuaternion
  31733. */
  31734. set quaternion(q: Nullable<Quaternion>);
  31735. /**
  31736. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31737. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31738. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31739. * @returns true if it intersects
  31740. */
  31741. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31742. /**
  31743. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31744. * A particle is in the frustum if its bounding box intersects the frustum
  31745. * @param frustumPlanes defines the frustum to test
  31746. * @returns true if the particle is in the frustum planes
  31747. */
  31748. isInFrustum(frustumPlanes: Plane[]): boolean;
  31749. /**
  31750. * get the rotation matrix of the particle
  31751. * @hidden
  31752. */
  31753. getRotationMatrix(m: Matrix): void;
  31754. }
  31755. /**
  31756. * Represents the shape of the model used by one particle of a solid particle system.
  31757. * SPS internal tool, don't use it manually.
  31758. */
  31759. export class ModelShape {
  31760. /**
  31761. * The shape id
  31762. * @hidden
  31763. */
  31764. shapeID: number;
  31765. /**
  31766. * flat array of model positions (internal use)
  31767. * @hidden
  31768. */
  31769. _shape: Vector3[];
  31770. /**
  31771. * flat array of model UVs (internal use)
  31772. * @hidden
  31773. */
  31774. _shapeUV: number[];
  31775. /**
  31776. * color array of the model
  31777. * @hidden
  31778. */
  31779. _shapeColors: number[];
  31780. /**
  31781. * indices array of the model
  31782. * @hidden
  31783. */
  31784. _indices: number[];
  31785. /**
  31786. * normals array of the model
  31787. * @hidden
  31788. */
  31789. _normals: number[];
  31790. /**
  31791. * length of the shape in the model indices array (internal use)
  31792. * @hidden
  31793. */
  31794. _indicesLength: number;
  31795. /**
  31796. * Custom position function (internal use)
  31797. * @hidden
  31798. */
  31799. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31800. /**
  31801. * Custom vertex function (internal use)
  31802. * @hidden
  31803. */
  31804. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31805. /**
  31806. * Model material (internal use)
  31807. * @hidden
  31808. */
  31809. _material: Nullable<Material>;
  31810. /**
  31811. * 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.
  31812. * SPS internal tool, don't use it manually.
  31813. * @hidden
  31814. */
  31815. 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>);
  31816. }
  31817. /**
  31818. * Represents a Depth Sorted Particle in the solid particle system.
  31819. * @hidden
  31820. */
  31821. export class DepthSortedParticle {
  31822. /**
  31823. * Particle index
  31824. */
  31825. idx: number;
  31826. /**
  31827. * Index of the particle in the "indices" array
  31828. */
  31829. ind: number;
  31830. /**
  31831. * Length of the particle shape in the "indices" array
  31832. */
  31833. indicesLength: number;
  31834. /**
  31835. * Squared distance from the particle to the camera
  31836. */
  31837. sqDistance: number;
  31838. /**
  31839. * Material index when used with MultiMaterials
  31840. */
  31841. materialIndex: number;
  31842. /**
  31843. * Creates a new sorted particle
  31844. * @param materialIndex
  31845. */
  31846. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31847. }
  31848. /**
  31849. * Represents a solid particle vertex
  31850. */
  31851. export class SolidParticleVertex {
  31852. /**
  31853. * Vertex position
  31854. */
  31855. position: Vector3;
  31856. /**
  31857. * Vertex color
  31858. */
  31859. color: Color4;
  31860. /**
  31861. * Vertex UV
  31862. */
  31863. uv: Vector2;
  31864. /**
  31865. * Creates a new solid particle vertex
  31866. */
  31867. constructor();
  31868. /** Vertex x coordinate */
  31869. get x(): number;
  31870. set x(val: number);
  31871. /** Vertex y coordinate */
  31872. get y(): number;
  31873. set y(val: number);
  31874. /** Vertex z coordinate */
  31875. get z(): number;
  31876. set z(val: number);
  31877. }
  31878. }
  31879. declare module BABYLON {
  31880. /**
  31881. * @hidden
  31882. */
  31883. export class _MeshCollisionData {
  31884. _checkCollisions: boolean;
  31885. _collisionMask: number;
  31886. _collisionGroup: number;
  31887. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31888. _collider: Nullable<Collider>;
  31889. _oldPositionForCollisions: Vector3;
  31890. _diffPositionForCollisions: Vector3;
  31891. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31892. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31893. }
  31894. }
  31895. declare module BABYLON {
  31896. /** @hidden */
  31897. class _FacetDataStorage {
  31898. facetPositions: Vector3[];
  31899. facetNormals: Vector3[];
  31900. facetPartitioning: number[][];
  31901. facetNb: number;
  31902. partitioningSubdivisions: number;
  31903. partitioningBBoxRatio: number;
  31904. facetDataEnabled: boolean;
  31905. facetParameters: any;
  31906. bbSize: Vector3;
  31907. subDiv: {
  31908. max: number;
  31909. X: number;
  31910. Y: number;
  31911. Z: number;
  31912. };
  31913. facetDepthSort: boolean;
  31914. facetDepthSortEnabled: boolean;
  31915. depthSortedIndices: IndicesArray;
  31916. depthSortedFacets: {
  31917. ind: number;
  31918. sqDistance: number;
  31919. }[];
  31920. facetDepthSortFunction: (f1: {
  31921. ind: number;
  31922. sqDistance: number;
  31923. }, f2: {
  31924. ind: number;
  31925. sqDistance: number;
  31926. }) => number;
  31927. facetDepthSortFrom: Vector3;
  31928. facetDepthSortOrigin: Vector3;
  31929. invertedMatrix: Matrix;
  31930. }
  31931. /**
  31932. * @hidden
  31933. **/
  31934. class _InternalAbstractMeshDataInfo {
  31935. _hasVertexAlpha: boolean;
  31936. _useVertexColors: boolean;
  31937. _numBoneInfluencers: number;
  31938. _applyFog: boolean;
  31939. _receiveShadows: boolean;
  31940. _facetData: _FacetDataStorage;
  31941. _visibility: number;
  31942. _skeleton: Nullable<Skeleton>;
  31943. _layerMask: number;
  31944. _computeBonesUsingShaders: boolean;
  31945. _isActive: boolean;
  31946. _onlyForInstances: boolean;
  31947. _isActiveIntermediate: boolean;
  31948. _onlyForInstancesIntermediate: boolean;
  31949. _actAsRegularMesh: boolean;
  31950. }
  31951. /**
  31952. * Class used to store all common mesh properties
  31953. */
  31954. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31955. /** No occlusion */
  31956. static OCCLUSION_TYPE_NONE: number;
  31957. /** Occlusion set to optimisitic */
  31958. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31959. /** Occlusion set to strict */
  31960. static OCCLUSION_TYPE_STRICT: number;
  31961. /** Use an accurante occlusion algorithm */
  31962. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31963. /** Use a conservative occlusion algorithm */
  31964. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31965. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31966. * Test order :
  31967. * Is the bounding sphere outside the frustum ?
  31968. * If not, are the bounding box vertices outside the frustum ?
  31969. * It not, then the cullable object is in the frustum.
  31970. */
  31971. static readonly CULLINGSTRATEGY_STANDARD: number;
  31972. /** Culling strategy : Bounding Sphere Only.
  31973. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31974. * It's also less accurate than the standard because some not visible objects can still be selected.
  31975. * Test : is the bounding sphere outside the frustum ?
  31976. * If not, then the cullable object is in the frustum.
  31977. */
  31978. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31979. /** Culling strategy : Optimistic Inclusion.
  31980. * This in an inclusion test first, then the standard exclusion test.
  31981. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31982. * 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.
  31983. * Anyway, it's as accurate as the standard strategy.
  31984. * Test :
  31985. * Is the cullable object bounding sphere center in the frustum ?
  31986. * If not, apply the default culling strategy.
  31987. */
  31988. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31989. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31990. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31991. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31992. * 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.
  31993. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31994. * Test :
  31995. * Is the cullable object bounding sphere center in the frustum ?
  31996. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31997. */
  31998. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31999. /**
  32000. * No billboard
  32001. */
  32002. static get BILLBOARDMODE_NONE(): number;
  32003. /** Billboard on X axis */
  32004. static get BILLBOARDMODE_X(): number;
  32005. /** Billboard on Y axis */
  32006. static get BILLBOARDMODE_Y(): number;
  32007. /** Billboard on Z axis */
  32008. static get BILLBOARDMODE_Z(): number;
  32009. /** Billboard on all axes */
  32010. static get BILLBOARDMODE_ALL(): number;
  32011. /** Billboard on using position instead of orientation */
  32012. static get BILLBOARDMODE_USE_POSITION(): number;
  32013. /** @hidden */
  32014. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32015. /**
  32016. * The culling strategy to use to check whether the mesh must be rendered or not.
  32017. * This value can be changed at any time and will be used on the next render mesh selection.
  32018. * The possible values are :
  32019. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32020. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32021. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32022. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32023. * Please read each static variable documentation to get details about the culling process.
  32024. * */
  32025. cullingStrategy: number;
  32026. /**
  32027. * Gets the number of facets in the mesh
  32028. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32029. */
  32030. get facetNb(): number;
  32031. /**
  32032. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32033. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32034. */
  32035. get partitioningSubdivisions(): number;
  32036. set partitioningSubdivisions(nb: number);
  32037. /**
  32038. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32039. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32040. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32041. */
  32042. get partitioningBBoxRatio(): number;
  32043. set partitioningBBoxRatio(ratio: number);
  32044. /**
  32045. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32046. * Works only for updatable meshes.
  32047. * Doesn't work with multi-materials
  32048. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32049. */
  32050. get mustDepthSortFacets(): boolean;
  32051. set mustDepthSortFacets(sort: boolean);
  32052. /**
  32053. * The location (Vector3) where the facet depth sort must be computed from.
  32054. * By default, the active camera position.
  32055. * Used only when facet depth sort is enabled
  32056. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32057. */
  32058. get facetDepthSortFrom(): Vector3;
  32059. set facetDepthSortFrom(location: Vector3);
  32060. /**
  32061. * gets a boolean indicating if facetData is enabled
  32062. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32063. */
  32064. get isFacetDataEnabled(): boolean;
  32065. /** @hidden */
  32066. _updateNonUniformScalingState(value: boolean): boolean;
  32067. /**
  32068. * An event triggered when this mesh collides with another one
  32069. */
  32070. onCollideObservable: Observable<AbstractMesh>;
  32071. /** Set a function to call when this mesh collides with another one */
  32072. set onCollide(callback: () => void);
  32073. /**
  32074. * An event triggered when the collision's position changes
  32075. */
  32076. onCollisionPositionChangeObservable: Observable<Vector3>;
  32077. /** Set a function to call when the collision's position changes */
  32078. set onCollisionPositionChange(callback: () => void);
  32079. /**
  32080. * An event triggered when material is changed
  32081. */
  32082. onMaterialChangedObservable: Observable<AbstractMesh>;
  32083. /**
  32084. * Gets or sets the orientation for POV movement & rotation
  32085. */
  32086. definedFacingForward: boolean;
  32087. /** @hidden */
  32088. _occlusionQuery: Nullable<WebGLQuery>;
  32089. /** @hidden */
  32090. _renderingGroup: Nullable<RenderingGroup>;
  32091. /**
  32092. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32093. */
  32094. get visibility(): number;
  32095. /**
  32096. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32097. */
  32098. set visibility(value: number);
  32099. /** Gets or sets the alpha index used to sort transparent meshes
  32100. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32101. */
  32102. alphaIndex: number;
  32103. /**
  32104. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32105. */
  32106. isVisible: boolean;
  32107. /**
  32108. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32109. */
  32110. isPickable: boolean;
  32111. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32112. showSubMeshesBoundingBox: boolean;
  32113. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32114. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32115. */
  32116. isBlocker: boolean;
  32117. /**
  32118. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32119. */
  32120. enablePointerMoveEvents: boolean;
  32121. private _renderingGroupId;
  32122. /**
  32123. * Specifies the rendering group id for this mesh (0 by default)
  32124. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32125. */
  32126. get renderingGroupId(): number;
  32127. set renderingGroupId(value: number);
  32128. private _material;
  32129. /** Gets or sets current material */
  32130. get material(): Nullable<Material>;
  32131. set material(value: Nullable<Material>);
  32132. /**
  32133. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32134. * @see https://doc.babylonjs.com/babylon101/shadows
  32135. */
  32136. get receiveShadows(): boolean;
  32137. set receiveShadows(value: boolean);
  32138. /** Defines color to use when rendering outline */
  32139. outlineColor: Color3;
  32140. /** Define width to use when rendering outline */
  32141. outlineWidth: number;
  32142. /** Defines color to use when rendering overlay */
  32143. overlayColor: Color3;
  32144. /** Defines alpha to use when rendering overlay */
  32145. overlayAlpha: number;
  32146. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32147. get hasVertexAlpha(): boolean;
  32148. set hasVertexAlpha(value: boolean);
  32149. /** 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) */
  32150. get useVertexColors(): boolean;
  32151. set useVertexColors(value: boolean);
  32152. /**
  32153. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32154. */
  32155. get computeBonesUsingShaders(): boolean;
  32156. set computeBonesUsingShaders(value: boolean);
  32157. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32158. get numBoneInfluencers(): number;
  32159. set numBoneInfluencers(value: number);
  32160. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32161. get applyFog(): boolean;
  32162. set applyFog(value: boolean);
  32163. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32164. useOctreeForRenderingSelection: boolean;
  32165. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32166. useOctreeForPicking: boolean;
  32167. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32168. useOctreeForCollisions: boolean;
  32169. /**
  32170. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32171. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32172. */
  32173. get layerMask(): number;
  32174. set layerMask(value: number);
  32175. /**
  32176. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32177. */
  32178. alwaysSelectAsActiveMesh: boolean;
  32179. /**
  32180. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32181. */
  32182. doNotSyncBoundingInfo: boolean;
  32183. /**
  32184. * Gets or sets the current action manager
  32185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32186. */
  32187. actionManager: Nullable<AbstractActionManager>;
  32188. private _meshCollisionData;
  32189. /**
  32190. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32191. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32192. */
  32193. ellipsoid: Vector3;
  32194. /**
  32195. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32196. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32197. */
  32198. ellipsoidOffset: Vector3;
  32199. /**
  32200. * Gets or sets a collision mask used to mask collisions (default is -1).
  32201. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32202. */
  32203. get collisionMask(): number;
  32204. set collisionMask(mask: number);
  32205. /**
  32206. * Gets or sets the current collision group mask (-1 by default).
  32207. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32208. */
  32209. get collisionGroup(): number;
  32210. set collisionGroup(mask: number);
  32211. /**
  32212. * Gets or sets current surrounding meshes (null by default).
  32213. *
  32214. * By default collision detection is tested against every mesh in the scene.
  32215. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32216. * meshes will be tested for the collision.
  32217. *
  32218. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32219. */
  32220. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32221. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32222. /**
  32223. * Defines edge width used when edgesRenderer is enabled
  32224. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32225. */
  32226. edgesWidth: number;
  32227. /**
  32228. * Defines edge color used when edgesRenderer is enabled
  32229. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32230. */
  32231. edgesColor: Color4;
  32232. /** @hidden */
  32233. _edgesRenderer: Nullable<IEdgesRenderer>;
  32234. /** @hidden */
  32235. _masterMesh: Nullable<AbstractMesh>;
  32236. /** @hidden */
  32237. _boundingInfo: Nullable<BoundingInfo>;
  32238. /** @hidden */
  32239. _renderId: number;
  32240. /**
  32241. * Gets or sets the list of subMeshes
  32242. * @see https://doc.babylonjs.com/how_to/multi_materials
  32243. */
  32244. subMeshes: SubMesh[];
  32245. /** @hidden */
  32246. _intersectionsInProgress: AbstractMesh[];
  32247. /** @hidden */
  32248. _unIndexed: boolean;
  32249. /** @hidden */
  32250. _lightSources: Light[];
  32251. /** Gets the list of lights affecting that mesh */
  32252. get lightSources(): Light[];
  32253. /** @hidden */
  32254. get _positions(): Nullable<Vector3[]>;
  32255. /** @hidden */
  32256. _waitingData: {
  32257. lods: Nullable<any>;
  32258. actions: Nullable<any>;
  32259. freezeWorldMatrix: Nullable<boolean>;
  32260. };
  32261. /** @hidden */
  32262. _bonesTransformMatrices: Nullable<Float32Array>;
  32263. /** @hidden */
  32264. _transformMatrixTexture: Nullable<RawTexture>;
  32265. /**
  32266. * Gets or sets a skeleton to apply skining transformations
  32267. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32268. */
  32269. set skeleton(value: Nullable<Skeleton>);
  32270. get skeleton(): Nullable<Skeleton>;
  32271. /**
  32272. * An event triggered when the mesh is rebuilt.
  32273. */
  32274. onRebuildObservable: Observable<AbstractMesh>;
  32275. /**
  32276. * Creates a new AbstractMesh
  32277. * @param name defines the name of the mesh
  32278. * @param scene defines the hosting scene
  32279. */
  32280. constructor(name: string, scene?: Nullable<Scene>);
  32281. /**
  32282. * Returns the string "AbstractMesh"
  32283. * @returns "AbstractMesh"
  32284. */
  32285. getClassName(): string;
  32286. /**
  32287. * Gets a string representation of the current mesh
  32288. * @param fullDetails defines a boolean indicating if full details must be included
  32289. * @returns a string representation of the current mesh
  32290. */
  32291. toString(fullDetails?: boolean): string;
  32292. /**
  32293. * @hidden
  32294. */
  32295. protected _getEffectiveParent(): Nullable<Node>;
  32296. /** @hidden */
  32297. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32298. /** @hidden */
  32299. _rebuild(): void;
  32300. /** @hidden */
  32301. _resyncLightSources(): void;
  32302. /** @hidden */
  32303. _resyncLightSource(light: Light): void;
  32304. /** @hidden */
  32305. _unBindEffect(): void;
  32306. /** @hidden */
  32307. _removeLightSource(light: Light, dispose: boolean): void;
  32308. private _markSubMeshesAsDirty;
  32309. /** @hidden */
  32310. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32311. /** @hidden */
  32312. _markSubMeshesAsAttributesDirty(): void;
  32313. /** @hidden */
  32314. _markSubMeshesAsMiscDirty(): void;
  32315. /**
  32316. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32317. */
  32318. get scaling(): Vector3;
  32319. set scaling(newScaling: Vector3);
  32320. /**
  32321. * Returns true if the mesh is blocked. Implemented by child classes
  32322. */
  32323. get isBlocked(): boolean;
  32324. /**
  32325. * Returns the mesh itself by default. Implemented by child classes
  32326. * @param camera defines the camera to use to pick the right LOD level
  32327. * @returns the currentAbstractMesh
  32328. */
  32329. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32330. /**
  32331. * Returns 0 by default. Implemented by child classes
  32332. * @returns an integer
  32333. */
  32334. getTotalVertices(): number;
  32335. /**
  32336. * Returns a positive integer : the total number of indices in this mesh geometry.
  32337. * @returns the numner of indices or zero if the mesh has no geometry.
  32338. */
  32339. getTotalIndices(): number;
  32340. /**
  32341. * Returns null by default. Implemented by child classes
  32342. * @returns null
  32343. */
  32344. getIndices(): Nullable<IndicesArray>;
  32345. /**
  32346. * Returns the array of the requested vertex data kind. Implemented by child classes
  32347. * @param kind defines the vertex data kind to use
  32348. * @returns null
  32349. */
  32350. getVerticesData(kind: string): Nullable<FloatArray>;
  32351. /**
  32352. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32353. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32354. * Note that a new underlying VertexBuffer object is created each call.
  32355. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32356. * @param kind defines vertex data kind:
  32357. * * VertexBuffer.PositionKind
  32358. * * VertexBuffer.UVKind
  32359. * * VertexBuffer.UV2Kind
  32360. * * VertexBuffer.UV3Kind
  32361. * * VertexBuffer.UV4Kind
  32362. * * VertexBuffer.UV5Kind
  32363. * * VertexBuffer.UV6Kind
  32364. * * VertexBuffer.ColorKind
  32365. * * VertexBuffer.MatricesIndicesKind
  32366. * * VertexBuffer.MatricesIndicesExtraKind
  32367. * * VertexBuffer.MatricesWeightsKind
  32368. * * VertexBuffer.MatricesWeightsExtraKind
  32369. * @param data defines the data source
  32370. * @param updatable defines if the data must be flagged as updatable (or static)
  32371. * @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
  32372. * @returns the current mesh
  32373. */
  32374. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32375. /**
  32376. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32377. * If the mesh has no geometry, it is simply returned as it is.
  32378. * @param kind defines vertex data kind:
  32379. * * VertexBuffer.PositionKind
  32380. * * VertexBuffer.UVKind
  32381. * * VertexBuffer.UV2Kind
  32382. * * VertexBuffer.UV3Kind
  32383. * * VertexBuffer.UV4Kind
  32384. * * VertexBuffer.UV5Kind
  32385. * * VertexBuffer.UV6Kind
  32386. * * VertexBuffer.ColorKind
  32387. * * VertexBuffer.MatricesIndicesKind
  32388. * * VertexBuffer.MatricesIndicesExtraKind
  32389. * * VertexBuffer.MatricesWeightsKind
  32390. * * VertexBuffer.MatricesWeightsExtraKind
  32391. * @param data defines the data source
  32392. * @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
  32393. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32394. * @returns the current mesh
  32395. */
  32396. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32397. /**
  32398. * Sets the mesh indices,
  32399. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32400. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32401. * @param totalVertices Defines the total number of vertices
  32402. * @returns the current mesh
  32403. */
  32404. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32405. /**
  32406. * Gets a boolean indicating if specific vertex data is present
  32407. * @param kind defines the vertex data kind to use
  32408. * @returns true is data kind is present
  32409. */
  32410. isVerticesDataPresent(kind: string): boolean;
  32411. /**
  32412. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32413. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32414. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32415. * @returns a BoundingInfo
  32416. */
  32417. getBoundingInfo(): BoundingInfo;
  32418. /**
  32419. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32420. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32421. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32422. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32423. * @returns the current mesh
  32424. */
  32425. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32426. /**
  32427. * Overwrite the current bounding info
  32428. * @param boundingInfo defines the new bounding info
  32429. * @returns the current mesh
  32430. */
  32431. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32432. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32433. get useBones(): boolean;
  32434. /** @hidden */
  32435. _preActivate(): void;
  32436. /** @hidden */
  32437. _preActivateForIntermediateRendering(renderId: number): void;
  32438. /** @hidden */
  32439. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32440. /** @hidden */
  32441. _postActivate(): void;
  32442. /** @hidden */
  32443. _freeze(): void;
  32444. /** @hidden */
  32445. _unFreeze(): void;
  32446. /**
  32447. * Gets the current world matrix
  32448. * @returns a Matrix
  32449. */
  32450. getWorldMatrix(): Matrix;
  32451. /** @hidden */
  32452. _getWorldMatrixDeterminant(): number;
  32453. /**
  32454. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32455. */
  32456. get isAnInstance(): boolean;
  32457. /**
  32458. * Gets a boolean indicating if this mesh has instances
  32459. */
  32460. get hasInstances(): boolean;
  32461. /**
  32462. * Gets a boolean indicating if this mesh has thin instances
  32463. */
  32464. get hasThinInstances(): boolean;
  32465. /**
  32466. * Perform relative position change from the point of view of behind the front of the mesh.
  32467. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32468. * Supports definition of mesh facing forward or backward
  32469. * @param amountRight defines the distance on the right axis
  32470. * @param amountUp defines the distance on the up axis
  32471. * @param amountForward defines the distance on the forward axis
  32472. * @returns the current mesh
  32473. */
  32474. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32475. /**
  32476. * Calculate relative position change from the point of view of behind the front of the mesh.
  32477. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32478. * Supports definition of mesh facing forward or backward
  32479. * @param amountRight defines the distance on the right axis
  32480. * @param amountUp defines the distance on the up axis
  32481. * @param amountForward defines the distance on the forward axis
  32482. * @returns the new displacement vector
  32483. */
  32484. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32485. /**
  32486. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32487. * Supports definition of mesh facing forward or backward
  32488. * @param flipBack defines the flip
  32489. * @param twirlClockwise defines the twirl
  32490. * @param tiltRight defines the tilt
  32491. * @returns the current mesh
  32492. */
  32493. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32494. /**
  32495. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32496. * Supports definition of mesh facing forward or backward.
  32497. * @param flipBack defines the flip
  32498. * @param twirlClockwise defines the twirl
  32499. * @param tiltRight defines the tilt
  32500. * @returns the new rotation vector
  32501. */
  32502. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32503. /**
  32504. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32505. * This means the mesh underlying bounding box and sphere are recomputed.
  32506. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32507. * @returns the current mesh
  32508. */
  32509. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32510. /** @hidden */
  32511. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32512. /** @hidden */
  32513. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32514. /** @hidden */
  32515. _updateBoundingInfo(): AbstractMesh;
  32516. /** @hidden */
  32517. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32518. /** @hidden */
  32519. protected _afterComputeWorldMatrix(): void;
  32520. /** @hidden */
  32521. get _effectiveMesh(): AbstractMesh;
  32522. /**
  32523. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32524. * A mesh is in the frustum if its bounding box intersects the frustum
  32525. * @param frustumPlanes defines the frustum to test
  32526. * @returns true if the mesh is in the frustum planes
  32527. */
  32528. isInFrustum(frustumPlanes: Plane[]): boolean;
  32529. /**
  32530. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32531. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32532. * @param frustumPlanes defines the frustum to test
  32533. * @returns true if the mesh is completely in the frustum planes
  32534. */
  32535. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32536. /**
  32537. * True if the mesh intersects another mesh or a SolidParticle object
  32538. * @param mesh defines a target mesh or SolidParticle to test
  32539. * @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)
  32540. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32541. * @returns true if there is an intersection
  32542. */
  32543. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32544. /**
  32545. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32546. * @param point defines the point to test
  32547. * @returns true if there is an intersection
  32548. */
  32549. intersectsPoint(point: Vector3): boolean;
  32550. /**
  32551. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32552. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32553. */
  32554. get checkCollisions(): boolean;
  32555. set checkCollisions(collisionEnabled: boolean);
  32556. /**
  32557. * Gets Collider object used to compute collisions (not physics)
  32558. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32559. */
  32560. get collider(): Nullable<Collider>;
  32561. /**
  32562. * Move the mesh using collision engine
  32563. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32564. * @param displacement defines the requested displacement vector
  32565. * @returns the current mesh
  32566. */
  32567. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32568. private _onCollisionPositionChange;
  32569. /** @hidden */
  32570. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32571. /** @hidden */
  32572. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32573. /** @hidden */
  32574. _checkCollision(collider: Collider): AbstractMesh;
  32575. /** @hidden */
  32576. _generatePointsArray(): boolean;
  32577. /**
  32578. * Checks if the passed Ray intersects with the mesh
  32579. * @param ray defines the ray to use
  32580. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32581. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32582. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32583. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32584. * @returns the picking info
  32585. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32586. */
  32587. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32588. /**
  32589. * Clones the current mesh
  32590. * @param name defines the mesh name
  32591. * @param newParent defines the new mesh parent
  32592. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32593. * @returns the new mesh
  32594. */
  32595. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32596. /**
  32597. * Disposes all the submeshes of the current meshnp
  32598. * @returns the current mesh
  32599. */
  32600. releaseSubMeshes(): AbstractMesh;
  32601. /**
  32602. * Releases resources associated with this abstract mesh.
  32603. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32604. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32605. */
  32606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32607. /**
  32608. * Adds the passed mesh as a child to the current mesh
  32609. * @param mesh defines the child mesh
  32610. * @returns the current mesh
  32611. */
  32612. addChild(mesh: AbstractMesh): AbstractMesh;
  32613. /**
  32614. * Removes the passed mesh from the current mesh children list
  32615. * @param mesh defines the child mesh
  32616. * @returns the current mesh
  32617. */
  32618. removeChild(mesh: AbstractMesh): AbstractMesh;
  32619. /** @hidden */
  32620. private _initFacetData;
  32621. /**
  32622. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32623. * This method can be called within the render loop.
  32624. * 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
  32625. * @returns the current mesh
  32626. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32627. */
  32628. updateFacetData(): AbstractMesh;
  32629. /**
  32630. * Returns the facetLocalNormals array.
  32631. * The normals are expressed in the mesh local spac
  32632. * @returns an array of Vector3
  32633. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32634. */
  32635. getFacetLocalNormals(): Vector3[];
  32636. /**
  32637. * Returns the facetLocalPositions array.
  32638. * The facet positions are expressed in the mesh local space
  32639. * @returns an array of Vector3
  32640. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32641. */
  32642. getFacetLocalPositions(): Vector3[];
  32643. /**
  32644. * Returns the facetLocalPartioning array
  32645. * @returns an array of array of numbers
  32646. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32647. */
  32648. getFacetLocalPartitioning(): number[][];
  32649. /**
  32650. * Returns the i-th facet position in the world system.
  32651. * This method allocates a new Vector3 per call
  32652. * @param i defines the facet index
  32653. * @returns a new Vector3
  32654. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32655. */
  32656. getFacetPosition(i: number): Vector3;
  32657. /**
  32658. * Sets the reference Vector3 with the i-th facet position in the world system
  32659. * @param i defines the facet index
  32660. * @param ref defines the target vector
  32661. * @returns the current mesh
  32662. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32663. */
  32664. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32665. /**
  32666. * Returns the i-th facet normal in the world system.
  32667. * This method allocates a new Vector3 per call
  32668. * @param i defines the facet index
  32669. * @returns a new Vector3
  32670. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32671. */
  32672. getFacetNormal(i: number): Vector3;
  32673. /**
  32674. * Sets the reference Vector3 with the i-th facet normal in the world system
  32675. * @param i defines the facet index
  32676. * @param ref defines the target vector
  32677. * @returns the current mesh
  32678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32679. */
  32680. getFacetNormalToRef(i: number, ref: Vector3): this;
  32681. /**
  32682. * 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)
  32683. * @param x defines x coordinate
  32684. * @param y defines y coordinate
  32685. * @param z defines z coordinate
  32686. * @returns the array of facet indexes
  32687. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32688. */
  32689. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32690. /**
  32691. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32692. * @param projected sets as the (x,y,z) world projection on the facet
  32693. * @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
  32694. * @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
  32695. * @param x defines x coordinate
  32696. * @param y defines y coordinate
  32697. * @param z defines z coordinate
  32698. * @returns the face index if found (or null instead)
  32699. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32700. */
  32701. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32702. /**
  32703. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32704. * @param projected sets as the (x,y,z) local projection on the facet
  32705. * @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
  32706. * @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
  32707. * @param x defines x coordinate
  32708. * @param y defines y coordinate
  32709. * @param z defines z coordinate
  32710. * @returns the face index if found (or null instead)
  32711. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32712. */
  32713. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32714. /**
  32715. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32716. * @returns the parameters
  32717. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32718. */
  32719. getFacetDataParameters(): any;
  32720. /**
  32721. * Disables the feature FacetData and frees the related memory
  32722. * @returns the current mesh
  32723. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32724. */
  32725. disableFacetData(): AbstractMesh;
  32726. /**
  32727. * Updates the AbstractMesh indices array
  32728. * @param indices defines the data source
  32729. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32730. * @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)
  32731. * @returns the current mesh
  32732. */
  32733. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32734. /**
  32735. * Creates new normals data for the mesh
  32736. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32737. * @returns the current mesh
  32738. */
  32739. createNormals(updatable: boolean): AbstractMesh;
  32740. /**
  32741. * Align the mesh with a normal
  32742. * @param normal defines the normal to use
  32743. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32744. * @returns the current mesh
  32745. */
  32746. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32747. /** @hidden */
  32748. _checkOcclusionQuery(): boolean;
  32749. /**
  32750. * Disables the mesh edge rendering mode
  32751. * @returns the currentAbstractMesh
  32752. */
  32753. disableEdgesRendering(): AbstractMesh;
  32754. /**
  32755. * Enables the edge rendering mode on the mesh.
  32756. * This mode makes the mesh edges visible
  32757. * @param epsilon defines the maximal distance between two angles to detect a face
  32758. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32759. * @returns the currentAbstractMesh
  32760. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32761. */
  32762. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32763. /**
  32764. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32765. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32766. */
  32767. getConnectedParticleSystems(): IParticleSystem[];
  32768. }
  32769. }
  32770. declare module BABYLON {
  32771. /**
  32772. * Interface used to define ActionEvent
  32773. */
  32774. export interface IActionEvent {
  32775. /** The mesh or sprite that triggered the action */
  32776. source: any;
  32777. /** The X mouse cursor position at the time of the event */
  32778. pointerX: number;
  32779. /** The Y mouse cursor position at the time of the event */
  32780. pointerY: number;
  32781. /** The mesh that is currently pointed at (can be null) */
  32782. meshUnderPointer: Nullable<AbstractMesh>;
  32783. /** the original (browser) event that triggered the ActionEvent */
  32784. sourceEvent?: any;
  32785. /** additional data for the event */
  32786. additionalData?: any;
  32787. }
  32788. /**
  32789. * ActionEvent is the event being sent when an action is triggered.
  32790. */
  32791. export class ActionEvent implements IActionEvent {
  32792. /** The mesh or sprite that triggered the action */
  32793. source: any;
  32794. /** The X mouse cursor position at the time of the event */
  32795. pointerX: number;
  32796. /** The Y mouse cursor position at the time of the event */
  32797. pointerY: number;
  32798. /** The mesh that is currently pointed at (can be null) */
  32799. meshUnderPointer: Nullable<AbstractMesh>;
  32800. /** the original (browser) event that triggered the ActionEvent */
  32801. sourceEvent?: any;
  32802. /** additional data for the event */
  32803. additionalData?: any;
  32804. /**
  32805. * Creates a new ActionEvent
  32806. * @param source The mesh or sprite that triggered the action
  32807. * @param pointerX The X mouse cursor position at the time of the event
  32808. * @param pointerY The Y mouse cursor position at the time of the event
  32809. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32810. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32811. * @param additionalData additional data for the event
  32812. */
  32813. constructor(
  32814. /** The mesh or sprite that triggered the action */
  32815. source: any,
  32816. /** The X mouse cursor position at the time of the event */
  32817. pointerX: number,
  32818. /** The Y mouse cursor position at the time of the event */
  32819. pointerY: number,
  32820. /** The mesh that is currently pointed at (can be null) */
  32821. meshUnderPointer: Nullable<AbstractMesh>,
  32822. /** the original (browser) event that triggered the ActionEvent */
  32823. sourceEvent?: any,
  32824. /** additional data for the event */
  32825. additionalData?: any);
  32826. /**
  32827. * Helper function to auto-create an ActionEvent from a source mesh.
  32828. * @param source The source mesh that triggered the event
  32829. * @param evt The original (browser) event
  32830. * @param additionalData additional data for the event
  32831. * @returns the new ActionEvent
  32832. */
  32833. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32834. /**
  32835. * Helper function to auto-create an ActionEvent from a source sprite
  32836. * @param source The source sprite that triggered the event
  32837. * @param scene Scene associated with the sprite
  32838. * @param evt The original (browser) event
  32839. * @param additionalData additional data for the event
  32840. * @returns the new ActionEvent
  32841. */
  32842. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32843. /**
  32844. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32845. * @param scene the scene where the event occurred
  32846. * @param evt The original (browser) event
  32847. * @returns the new ActionEvent
  32848. */
  32849. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32850. /**
  32851. * Helper function to auto-create an ActionEvent from a primitive
  32852. * @param prim defines the target primitive
  32853. * @param pointerPos defines the pointer position
  32854. * @param evt The original (browser) event
  32855. * @param additionalData additional data for the event
  32856. * @returns the new ActionEvent
  32857. */
  32858. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32859. }
  32860. }
  32861. declare module BABYLON {
  32862. /**
  32863. * Abstract class used to decouple action Manager from scene and meshes.
  32864. * Do not instantiate.
  32865. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32866. */
  32867. export abstract class AbstractActionManager implements IDisposable {
  32868. /** Gets the list of active triggers */
  32869. static Triggers: {
  32870. [key: string]: number;
  32871. };
  32872. /** Gets the cursor to use when hovering items */
  32873. hoverCursor: string;
  32874. /** Gets the list of actions */
  32875. actions: IAction[];
  32876. /**
  32877. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32878. */
  32879. isRecursive: boolean;
  32880. /**
  32881. * Releases all associated resources
  32882. */
  32883. abstract dispose(): void;
  32884. /**
  32885. * Does this action manager has pointer triggers
  32886. */
  32887. abstract get hasPointerTriggers(): boolean;
  32888. /**
  32889. * Does this action manager has pick triggers
  32890. */
  32891. abstract get hasPickTriggers(): boolean;
  32892. /**
  32893. * Process a specific trigger
  32894. * @param trigger defines the trigger to process
  32895. * @param evt defines the event details to be processed
  32896. */
  32897. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32898. /**
  32899. * Does this action manager handles actions of any of the given triggers
  32900. * @param triggers defines the triggers to be tested
  32901. * @return a boolean indicating whether one (or more) of the triggers is handled
  32902. */
  32903. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32904. /**
  32905. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32906. * speed.
  32907. * @param triggerA defines the trigger to be tested
  32908. * @param triggerB defines the trigger to be tested
  32909. * @return a boolean indicating whether one (or more) of the triggers is handled
  32910. */
  32911. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32912. /**
  32913. * Does this action manager handles actions of a given trigger
  32914. * @param trigger defines the trigger to be tested
  32915. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32916. * @return whether the trigger is handled
  32917. */
  32918. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32919. /**
  32920. * Serialize this manager to a JSON object
  32921. * @param name defines the property name to store this manager
  32922. * @returns a JSON representation of this manager
  32923. */
  32924. abstract serialize(name: string): any;
  32925. /**
  32926. * Registers an action to this action manager
  32927. * @param action defines the action to be registered
  32928. * @return the action amended (prepared) after registration
  32929. */
  32930. abstract registerAction(action: IAction): Nullable<IAction>;
  32931. /**
  32932. * Unregisters an action to this action manager
  32933. * @param action defines the action to be unregistered
  32934. * @return a boolean indicating whether the action has been unregistered
  32935. */
  32936. abstract unregisterAction(action: IAction): Boolean;
  32937. /**
  32938. * Does exist one action manager with at least one trigger
  32939. **/
  32940. static get HasTriggers(): boolean;
  32941. /**
  32942. * Does exist one action manager with at least one pick trigger
  32943. **/
  32944. static get HasPickTriggers(): boolean;
  32945. /**
  32946. * Does exist one action manager that handles actions of a given trigger
  32947. * @param trigger defines the trigger to be tested
  32948. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32949. **/
  32950. static HasSpecificTrigger(trigger: number): boolean;
  32951. }
  32952. }
  32953. declare module BABYLON {
  32954. /**
  32955. * Defines how a node can be built from a string name.
  32956. */
  32957. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32958. /**
  32959. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32960. */
  32961. export class Node implements IBehaviorAware<Node> {
  32962. /** @hidden */
  32963. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32964. private static _NodeConstructors;
  32965. /**
  32966. * Add a new node constructor
  32967. * @param type defines the type name of the node to construct
  32968. * @param constructorFunc defines the constructor function
  32969. */
  32970. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32971. /**
  32972. * Returns a node constructor based on type name
  32973. * @param type defines the type name
  32974. * @param name defines the new node name
  32975. * @param scene defines the hosting scene
  32976. * @param options defines optional options to transmit to constructors
  32977. * @returns the new constructor or null
  32978. */
  32979. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32980. /**
  32981. * Gets or sets the name of the node
  32982. */
  32983. name: string;
  32984. /**
  32985. * Gets or sets the id of the node
  32986. */
  32987. id: string;
  32988. /**
  32989. * Gets or sets the unique id of the node
  32990. */
  32991. uniqueId: number;
  32992. /**
  32993. * Gets or sets a string used to store user defined state for the node
  32994. */
  32995. state: string;
  32996. /**
  32997. * Gets or sets an object used to store user defined information for the node
  32998. */
  32999. metadata: any;
  33000. /**
  33001. * For internal use only. Please do not use.
  33002. */
  33003. reservedDataStore: any;
  33004. /**
  33005. * List of inspectable custom properties (used by the Inspector)
  33006. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33007. */
  33008. inspectableCustomProperties: IInspectable[];
  33009. private _doNotSerialize;
  33010. /**
  33011. * Gets or sets a boolean used to define if the node must be serialized
  33012. */
  33013. get doNotSerialize(): boolean;
  33014. set doNotSerialize(value: boolean);
  33015. /** @hidden */
  33016. _isDisposed: boolean;
  33017. /**
  33018. * Gets a list of Animations associated with the node
  33019. */
  33020. animations: Animation[];
  33021. protected _ranges: {
  33022. [name: string]: Nullable<AnimationRange>;
  33023. };
  33024. /**
  33025. * Callback raised when the node is ready to be used
  33026. */
  33027. onReady: Nullable<(node: Node) => void>;
  33028. private _isEnabled;
  33029. private _isParentEnabled;
  33030. private _isReady;
  33031. /** @hidden */
  33032. _currentRenderId: number;
  33033. private _parentUpdateId;
  33034. /** @hidden */
  33035. _childUpdateId: number;
  33036. /** @hidden */
  33037. _waitingParentId: Nullable<string>;
  33038. /** @hidden */
  33039. _scene: Scene;
  33040. /** @hidden */
  33041. _cache: any;
  33042. private _parentNode;
  33043. private _children;
  33044. /** @hidden */
  33045. _worldMatrix: Matrix;
  33046. /** @hidden */
  33047. _worldMatrixDeterminant: number;
  33048. /** @hidden */
  33049. _worldMatrixDeterminantIsDirty: boolean;
  33050. /** @hidden */
  33051. private _sceneRootNodesIndex;
  33052. /**
  33053. * Gets a boolean indicating if the node has been disposed
  33054. * @returns true if the node was disposed
  33055. */
  33056. isDisposed(): boolean;
  33057. /**
  33058. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33059. * @see https://doc.babylonjs.com/how_to/parenting
  33060. */
  33061. set parent(parent: Nullable<Node>);
  33062. get parent(): Nullable<Node>;
  33063. /** @hidden */
  33064. _addToSceneRootNodes(): void;
  33065. /** @hidden */
  33066. _removeFromSceneRootNodes(): void;
  33067. private _animationPropertiesOverride;
  33068. /**
  33069. * Gets or sets the animation properties override
  33070. */
  33071. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33072. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33073. /**
  33074. * Gets a string identifying the name of the class
  33075. * @returns "Node" string
  33076. */
  33077. getClassName(): string;
  33078. /** @hidden */
  33079. readonly _isNode: boolean;
  33080. /**
  33081. * An event triggered when the mesh is disposed
  33082. */
  33083. onDisposeObservable: Observable<Node>;
  33084. private _onDisposeObserver;
  33085. /**
  33086. * Sets a callback that will be raised when the node will be disposed
  33087. */
  33088. set onDispose(callback: () => void);
  33089. /**
  33090. * Creates a new Node
  33091. * @param name the name and id to be given to this node
  33092. * @param scene the scene this node will be added to
  33093. */
  33094. constructor(name: string, scene?: Nullable<Scene>);
  33095. /**
  33096. * Gets the scene of the node
  33097. * @returns a scene
  33098. */
  33099. getScene(): Scene;
  33100. /**
  33101. * Gets the engine of the node
  33102. * @returns a Engine
  33103. */
  33104. getEngine(): Engine;
  33105. private _behaviors;
  33106. /**
  33107. * Attach a behavior to the node
  33108. * @see https://doc.babylonjs.com/features/behaviour
  33109. * @param behavior defines the behavior to attach
  33110. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33111. * @returns the current Node
  33112. */
  33113. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33114. /**
  33115. * Remove an attached behavior
  33116. * @see https://doc.babylonjs.com/features/behaviour
  33117. * @param behavior defines the behavior to attach
  33118. * @returns the current Node
  33119. */
  33120. removeBehavior(behavior: Behavior<Node>): Node;
  33121. /**
  33122. * Gets the list of attached behaviors
  33123. * @see https://doc.babylonjs.com/features/behaviour
  33124. */
  33125. get behaviors(): Behavior<Node>[];
  33126. /**
  33127. * Gets an attached behavior by name
  33128. * @param name defines the name of the behavior to look for
  33129. * @see https://doc.babylonjs.com/features/behaviour
  33130. * @returns null if behavior was not found else the requested behavior
  33131. */
  33132. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33133. /**
  33134. * Returns the latest update of the World matrix
  33135. * @returns a Matrix
  33136. */
  33137. getWorldMatrix(): Matrix;
  33138. /** @hidden */
  33139. _getWorldMatrixDeterminant(): number;
  33140. /**
  33141. * Returns directly the latest state of the mesh World matrix.
  33142. * A Matrix is returned.
  33143. */
  33144. get worldMatrixFromCache(): Matrix;
  33145. /** @hidden */
  33146. _initCache(): void;
  33147. /** @hidden */
  33148. updateCache(force?: boolean): void;
  33149. /** @hidden */
  33150. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33151. /** @hidden */
  33152. _updateCache(ignoreParentClass?: boolean): void;
  33153. /** @hidden */
  33154. _isSynchronized(): boolean;
  33155. /** @hidden */
  33156. _markSyncedWithParent(): void;
  33157. /** @hidden */
  33158. isSynchronizedWithParent(): boolean;
  33159. /** @hidden */
  33160. isSynchronized(): boolean;
  33161. /**
  33162. * Is this node ready to be used/rendered
  33163. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33164. * @return true if the node is ready
  33165. */
  33166. isReady(completeCheck?: boolean): boolean;
  33167. /**
  33168. * Is this node enabled?
  33169. * 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
  33170. * @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
  33171. * @return whether this node (and its parent) is enabled
  33172. */
  33173. isEnabled(checkAncestors?: boolean): boolean;
  33174. /** @hidden */
  33175. protected _syncParentEnabledState(): void;
  33176. /**
  33177. * Set the enabled state of this node
  33178. * @param value defines the new enabled state
  33179. */
  33180. setEnabled(value: boolean): void;
  33181. /**
  33182. * Is this node a descendant of the given node?
  33183. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33184. * @param ancestor defines the parent node to inspect
  33185. * @returns a boolean indicating if this node is a descendant of the given node
  33186. */
  33187. isDescendantOf(ancestor: Node): boolean;
  33188. /** @hidden */
  33189. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33190. /**
  33191. * Will return all nodes that have this node as ascendant
  33192. * @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
  33193. * @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
  33194. * @return all children nodes of all types
  33195. */
  33196. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33197. /**
  33198. * Get all child-meshes of this node
  33199. * @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)
  33200. * @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
  33201. * @returns an array of AbstractMesh
  33202. */
  33203. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33204. /**
  33205. * Get all direct children of this node
  33206. * @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
  33207. * @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)
  33208. * @returns an array of Node
  33209. */
  33210. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33211. /** @hidden */
  33212. _setReady(state: boolean): void;
  33213. /**
  33214. * Get an animation by name
  33215. * @param name defines the name of the animation to look for
  33216. * @returns null if not found else the requested animation
  33217. */
  33218. getAnimationByName(name: string): Nullable<Animation>;
  33219. /**
  33220. * Creates an animation range for this node
  33221. * @param name defines the name of the range
  33222. * @param from defines the starting key
  33223. * @param to defines the end key
  33224. */
  33225. createAnimationRange(name: string, from: number, to: number): void;
  33226. /**
  33227. * Delete a specific animation range
  33228. * @param name defines the name of the range to delete
  33229. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33230. */
  33231. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33232. /**
  33233. * Get an animation range by name
  33234. * @param name defines the name of the animation range to look for
  33235. * @returns null if not found else the requested animation range
  33236. */
  33237. getAnimationRange(name: string): Nullable<AnimationRange>;
  33238. /**
  33239. * Gets the list of all animation ranges defined on this node
  33240. * @returns an array
  33241. */
  33242. getAnimationRanges(): Nullable<AnimationRange>[];
  33243. /**
  33244. * Will start the animation sequence
  33245. * @param name defines the range frames for animation sequence
  33246. * @param loop defines if the animation should loop (false by default)
  33247. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33248. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33249. * @returns the object created for this animation. If range does not exist, it will return null
  33250. */
  33251. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33252. /**
  33253. * Serialize animation ranges into a JSON compatible object
  33254. * @returns serialization object
  33255. */
  33256. serializeAnimationRanges(): any;
  33257. /**
  33258. * Computes the world matrix of the node
  33259. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33260. * @returns the world matrix
  33261. */
  33262. computeWorldMatrix(force?: boolean): Matrix;
  33263. /**
  33264. * Releases resources associated with this node.
  33265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33267. */
  33268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33269. /**
  33270. * Parse animation range data from a serialization object and store them into a given node
  33271. * @param node defines where to store the animation ranges
  33272. * @param parsedNode defines the serialization object to read data from
  33273. * @param scene defines the hosting scene
  33274. */
  33275. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33276. /**
  33277. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33278. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33279. * @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
  33280. * @returns the new bounding vectors
  33281. */
  33282. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33283. min: Vector3;
  33284. max: Vector3;
  33285. };
  33286. }
  33287. }
  33288. declare module BABYLON {
  33289. /**
  33290. * @hidden
  33291. */
  33292. export class _IAnimationState {
  33293. key: number;
  33294. repeatCount: number;
  33295. workValue?: any;
  33296. loopMode?: number;
  33297. offsetValue?: any;
  33298. highLimitValue?: any;
  33299. }
  33300. /**
  33301. * Class used to store any kind of animation
  33302. */
  33303. export class Animation {
  33304. /**Name of the animation */
  33305. name: string;
  33306. /**Property to animate */
  33307. targetProperty: string;
  33308. /**The frames per second of the animation */
  33309. framePerSecond: number;
  33310. /**The data type of the animation */
  33311. dataType: number;
  33312. /**The loop mode of the animation */
  33313. loopMode?: number | undefined;
  33314. /**Specifies if blending should be enabled */
  33315. enableBlending?: boolean | undefined;
  33316. /**
  33317. * Use matrix interpolation instead of using direct key value when animating matrices
  33318. */
  33319. static AllowMatricesInterpolation: boolean;
  33320. /**
  33321. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33322. */
  33323. static AllowMatrixDecomposeForInterpolation: boolean;
  33324. /** Define the Url to load snippets */
  33325. static SnippetUrl: string;
  33326. /** Snippet ID if the animation was created from the snippet server */
  33327. snippetId: string;
  33328. /**
  33329. * Stores the key frames of the animation
  33330. */
  33331. private _keys;
  33332. /**
  33333. * Stores the easing function of the animation
  33334. */
  33335. private _easingFunction;
  33336. /**
  33337. * @hidden Internal use only
  33338. */
  33339. _runtimeAnimations: RuntimeAnimation[];
  33340. /**
  33341. * The set of event that will be linked to this animation
  33342. */
  33343. private _events;
  33344. /**
  33345. * Stores an array of target property paths
  33346. */
  33347. targetPropertyPath: string[];
  33348. /**
  33349. * Stores the blending speed of the animation
  33350. */
  33351. blendingSpeed: number;
  33352. /**
  33353. * Stores the animation ranges for the animation
  33354. */
  33355. private _ranges;
  33356. /**
  33357. * @hidden Internal use
  33358. */
  33359. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33360. /**
  33361. * Sets up an animation
  33362. * @param property The property to animate
  33363. * @param animationType The animation type to apply
  33364. * @param framePerSecond The frames per second of the animation
  33365. * @param easingFunction The easing function used in the animation
  33366. * @returns The created animation
  33367. */
  33368. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33369. /**
  33370. * Create and start an animation on a node
  33371. * @param name defines the name of the global animation that will be run on all nodes
  33372. * @param node defines the root node where the animation will take place
  33373. * @param targetProperty defines property to animate
  33374. * @param framePerSecond defines the number of frame per second yo use
  33375. * @param totalFrame defines the number of frames in total
  33376. * @param from defines the initial value
  33377. * @param to defines the final value
  33378. * @param loopMode defines which loop mode you want to use (off by default)
  33379. * @param easingFunction defines the easing function to use (linear by default)
  33380. * @param onAnimationEnd defines the callback to call when animation end
  33381. * @returns the animatable created for this animation
  33382. */
  33383. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33384. /**
  33385. * Create and start an animation on a node and its descendants
  33386. * @param name defines the name of the global animation that will be run on all nodes
  33387. * @param node defines the root node where the animation will take place
  33388. * @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
  33389. * @param targetProperty defines property to animate
  33390. * @param framePerSecond defines the number of frame per second to use
  33391. * @param totalFrame defines the number of frames in total
  33392. * @param from defines the initial value
  33393. * @param to defines the final value
  33394. * @param loopMode defines which loop mode you want to use (off by default)
  33395. * @param easingFunction defines the easing function to use (linear by default)
  33396. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33397. * @returns the list of animatables created for all nodes
  33398. * @example https://www.babylonjs-playground.com/#MH0VLI
  33399. */
  33400. 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[]>;
  33401. /**
  33402. * Creates a new animation, merges it with the existing animations and starts it
  33403. * @param name Name of the animation
  33404. * @param node Node which contains the scene that begins the animations
  33405. * @param targetProperty Specifies which property to animate
  33406. * @param framePerSecond The frames per second of the animation
  33407. * @param totalFrame The total number of frames
  33408. * @param from The frame at the beginning of the animation
  33409. * @param to The frame at the end of the animation
  33410. * @param loopMode Specifies the loop mode of the animation
  33411. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33412. * @param onAnimationEnd Callback to run once the animation is complete
  33413. * @returns Nullable animation
  33414. */
  33415. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33416. /**
  33417. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33418. * @param sourceAnimation defines the Animation containing keyframes to convert
  33419. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33420. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33421. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33422. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33423. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33424. */
  33425. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33426. /**
  33427. * Transition property of an host to the target Value
  33428. * @param property The property to transition
  33429. * @param targetValue The target Value of the property
  33430. * @param host The object where the property to animate belongs
  33431. * @param scene Scene used to run the animation
  33432. * @param frameRate Framerate (in frame/s) to use
  33433. * @param transition The transition type we want to use
  33434. * @param duration The duration of the animation, in milliseconds
  33435. * @param onAnimationEnd Callback trigger at the end of the animation
  33436. * @returns Nullable animation
  33437. */
  33438. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33439. /**
  33440. * Return the array of runtime animations currently using this animation
  33441. */
  33442. get runtimeAnimations(): RuntimeAnimation[];
  33443. /**
  33444. * Specifies if any of the runtime animations are currently running
  33445. */
  33446. get hasRunningRuntimeAnimations(): boolean;
  33447. /**
  33448. * Initializes the animation
  33449. * @param name Name of the animation
  33450. * @param targetProperty Property to animate
  33451. * @param framePerSecond The frames per second of the animation
  33452. * @param dataType The data type of the animation
  33453. * @param loopMode The loop mode of the animation
  33454. * @param enableBlending Specifies if blending should be enabled
  33455. */
  33456. constructor(
  33457. /**Name of the animation */
  33458. name: string,
  33459. /**Property to animate */
  33460. targetProperty: string,
  33461. /**The frames per second of the animation */
  33462. framePerSecond: number,
  33463. /**The data type of the animation */
  33464. dataType: number,
  33465. /**The loop mode of the animation */
  33466. loopMode?: number | undefined,
  33467. /**Specifies if blending should be enabled */
  33468. enableBlending?: boolean | undefined);
  33469. /**
  33470. * Converts the animation to a string
  33471. * @param fullDetails support for multiple levels of logging within scene loading
  33472. * @returns String form of the animation
  33473. */
  33474. toString(fullDetails?: boolean): string;
  33475. /**
  33476. * Add an event to this animation
  33477. * @param event Event to add
  33478. */
  33479. addEvent(event: AnimationEvent): void;
  33480. /**
  33481. * Remove all events found at the given frame
  33482. * @param frame The frame to remove events from
  33483. */
  33484. removeEvents(frame: number): void;
  33485. /**
  33486. * Retrieves all the events from the animation
  33487. * @returns Events from the animation
  33488. */
  33489. getEvents(): AnimationEvent[];
  33490. /**
  33491. * Creates an animation range
  33492. * @param name Name of the animation range
  33493. * @param from Starting frame of the animation range
  33494. * @param to Ending frame of the animation
  33495. */
  33496. createRange(name: string, from: number, to: number): void;
  33497. /**
  33498. * Deletes an animation range by name
  33499. * @param name Name of the animation range to delete
  33500. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33501. */
  33502. deleteRange(name: string, deleteFrames?: boolean): void;
  33503. /**
  33504. * Gets the animation range by name, or null if not defined
  33505. * @param name Name of the animation range
  33506. * @returns Nullable animation range
  33507. */
  33508. getRange(name: string): Nullable<AnimationRange>;
  33509. /**
  33510. * Gets the key frames from the animation
  33511. * @returns The key frames of the animation
  33512. */
  33513. getKeys(): Array<IAnimationKey>;
  33514. /**
  33515. * Gets the highest frame rate of the animation
  33516. * @returns Highest frame rate of the animation
  33517. */
  33518. getHighestFrame(): number;
  33519. /**
  33520. * Gets the easing function of the animation
  33521. * @returns Easing function of the animation
  33522. */
  33523. getEasingFunction(): IEasingFunction;
  33524. /**
  33525. * Sets the easing function of the animation
  33526. * @param easingFunction A custom mathematical formula for animation
  33527. */
  33528. setEasingFunction(easingFunction: EasingFunction): void;
  33529. /**
  33530. * Interpolates a scalar linearly
  33531. * @param startValue Start value of the animation curve
  33532. * @param endValue End value of the animation curve
  33533. * @param gradient Scalar amount to interpolate
  33534. * @returns Interpolated scalar value
  33535. */
  33536. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33537. /**
  33538. * Interpolates a scalar cubically
  33539. * @param startValue Start value of the animation curve
  33540. * @param outTangent End tangent of the animation
  33541. * @param endValue End value of the animation curve
  33542. * @param inTangent Start tangent of the animation curve
  33543. * @param gradient Scalar amount to interpolate
  33544. * @returns Interpolated scalar value
  33545. */
  33546. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33547. /**
  33548. * Interpolates a quaternion using a spherical linear interpolation
  33549. * @param startValue Start value of the animation curve
  33550. * @param endValue End value of the animation curve
  33551. * @param gradient Scalar amount to interpolate
  33552. * @returns Interpolated quaternion value
  33553. */
  33554. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33555. /**
  33556. * Interpolates a quaternion cubically
  33557. * @param startValue Start value of the animation curve
  33558. * @param outTangent End tangent of the animation curve
  33559. * @param endValue End value of the animation curve
  33560. * @param inTangent Start tangent of the animation curve
  33561. * @param gradient Scalar amount to interpolate
  33562. * @returns Interpolated quaternion value
  33563. */
  33564. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33565. /**
  33566. * Interpolates a Vector3 linearl
  33567. * @param startValue Start value of the animation curve
  33568. * @param endValue End value of the animation curve
  33569. * @param gradient Scalar amount to interpolate
  33570. * @returns Interpolated scalar value
  33571. */
  33572. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33573. /**
  33574. * Interpolates a Vector3 cubically
  33575. * @param startValue Start value of the animation curve
  33576. * @param outTangent End tangent of the animation
  33577. * @param endValue End value of the animation curve
  33578. * @param inTangent Start tangent of the animation curve
  33579. * @param gradient Scalar amount to interpolate
  33580. * @returns InterpolatedVector3 value
  33581. */
  33582. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33583. /**
  33584. * Interpolates a Vector2 linearly
  33585. * @param startValue Start value of the animation curve
  33586. * @param endValue End value of the animation curve
  33587. * @param gradient Scalar amount to interpolate
  33588. * @returns Interpolated Vector2 value
  33589. */
  33590. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33591. /**
  33592. * Interpolates a Vector2 cubically
  33593. * @param startValue Start value of the animation curve
  33594. * @param outTangent End tangent of the animation
  33595. * @param endValue End value of the animation curve
  33596. * @param inTangent Start tangent of the animation curve
  33597. * @param gradient Scalar amount to interpolate
  33598. * @returns Interpolated Vector2 value
  33599. */
  33600. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33601. /**
  33602. * Interpolates a size linearly
  33603. * @param startValue Start value of the animation curve
  33604. * @param endValue End value of the animation curve
  33605. * @param gradient Scalar amount to interpolate
  33606. * @returns Interpolated Size value
  33607. */
  33608. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33609. /**
  33610. * Interpolates a Color3 linearly
  33611. * @param startValue Start value of the animation curve
  33612. * @param endValue End value of the animation curve
  33613. * @param gradient Scalar amount to interpolate
  33614. * @returns Interpolated Color3 value
  33615. */
  33616. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33617. /**
  33618. * Interpolates a Color4 linearly
  33619. * @param startValue Start value of the animation curve
  33620. * @param endValue End value of the animation curve
  33621. * @param gradient Scalar amount to interpolate
  33622. * @returns Interpolated Color3 value
  33623. */
  33624. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33625. /**
  33626. * @hidden Internal use only
  33627. */
  33628. _getKeyValue(value: any): any;
  33629. /**
  33630. * @hidden Internal use only
  33631. */
  33632. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33633. /**
  33634. * Defines the function to use to interpolate matrices
  33635. * @param startValue defines the start matrix
  33636. * @param endValue defines the end matrix
  33637. * @param gradient defines the gradient between both matrices
  33638. * @param result defines an optional target matrix where to store the interpolation
  33639. * @returns the interpolated matrix
  33640. */
  33641. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33642. /**
  33643. * Makes a copy of the animation
  33644. * @returns Cloned animation
  33645. */
  33646. clone(): Animation;
  33647. /**
  33648. * Sets the key frames of the animation
  33649. * @param values The animation key frames to set
  33650. */
  33651. setKeys(values: Array<IAnimationKey>): void;
  33652. /**
  33653. * Serializes the animation to an object
  33654. * @returns Serialized object
  33655. */
  33656. serialize(): any;
  33657. /**
  33658. * Float animation type
  33659. */
  33660. static readonly ANIMATIONTYPE_FLOAT: number;
  33661. /**
  33662. * Vector3 animation type
  33663. */
  33664. static readonly ANIMATIONTYPE_VECTOR3: number;
  33665. /**
  33666. * Quaternion animation type
  33667. */
  33668. static readonly ANIMATIONTYPE_QUATERNION: number;
  33669. /**
  33670. * Matrix animation type
  33671. */
  33672. static readonly ANIMATIONTYPE_MATRIX: number;
  33673. /**
  33674. * Color3 animation type
  33675. */
  33676. static readonly ANIMATIONTYPE_COLOR3: number;
  33677. /**
  33678. * Color3 animation type
  33679. */
  33680. static readonly ANIMATIONTYPE_COLOR4: number;
  33681. /**
  33682. * Vector2 animation type
  33683. */
  33684. static readonly ANIMATIONTYPE_VECTOR2: number;
  33685. /**
  33686. * Size animation type
  33687. */
  33688. static readonly ANIMATIONTYPE_SIZE: number;
  33689. /**
  33690. * Relative Loop Mode
  33691. */
  33692. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33693. /**
  33694. * Cycle Loop Mode
  33695. */
  33696. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33697. /**
  33698. * Constant Loop Mode
  33699. */
  33700. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33701. /** @hidden */
  33702. static _UniversalLerp(left: any, right: any, amount: number): any;
  33703. /**
  33704. * Parses an animation object and creates an animation
  33705. * @param parsedAnimation Parsed animation object
  33706. * @returns Animation object
  33707. */
  33708. static Parse(parsedAnimation: any): Animation;
  33709. /**
  33710. * Appends the serialized animations from the source animations
  33711. * @param source Source containing the animations
  33712. * @param destination Target to store the animations
  33713. */
  33714. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33715. /**
  33716. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33717. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33718. * @param url defines the url to load from
  33719. * @returns a promise that will resolve to the new animation or an array of animations
  33720. */
  33721. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33722. /**
  33723. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33724. * @param snippetId defines the snippet to load
  33725. * @returns a promise that will resolve to the new animation or a new array of animations
  33726. */
  33727. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33728. }
  33729. }
  33730. declare module BABYLON {
  33731. /**
  33732. * Interface containing an array of animations
  33733. */
  33734. export interface IAnimatable {
  33735. /**
  33736. * Array of animations
  33737. */
  33738. animations: Nullable<Array<Animation>>;
  33739. }
  33740. }
  33741. declare module BABYLON {
  33742. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33743. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33744. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33745. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33746. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33747. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33748. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33749. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33750. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33751. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33752. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33753. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33754. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33755. /**
  33756. * Decorator used to define property that can be serialized as reference to a camera
  33757. * @param sourceName defines the name of the property to decorate
  33758. */
  33759. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33760. /**
  33761. * Class used to help serialization objects
  33762. */
  33763. export class SerializationHelper {
  33764. /** @hidden */
  33765. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33766. /** @hidden */
  33767. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33768. /** @hidden */
  33769. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33770. /** @hidden */
  33771. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33772. /**
  33773. * Appends the serialized animations from the source animations
  33774. * @param source Source containing the animations
  33775. * @param destination Target to store the animations
  33776. */
  33777. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33778. /**
  33779. * Static function used to serialized a specific entity
  33780. * @param entity defines the entity to serialize
  33781. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33782. * @returns a JSON compatible object representing the serialization of the entity
  33783. */
  33784. static Serialize<T>(entity: T, serializationObject?: any): any;
  33785. /**
  33786. * Creates a new entity from a serialization data object
  33787. * @param creationFunction defines a function used to instanciated the new entity
  33788. * @param source defines the source serialization data
  33789. * @param scene defines the hosting scene
  33790. * @param rootUrl defines the root url for resources
  33791. * @returns a new entity
  33792. */
  33793. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33794. /**
  33795. * Clones an object
  33796. * @param creationFunction defines the function used to instanciate the new object
  33797. * @param source defines the source object
  33798. * @returns the cloned object
  33799. */
  33800. static Clone<T>(creationFunction: () => T, source: T): T;
  33801. /**
  33802. * Instanciates a new object based on a source one (some data will be shared between both object)
  33803. * @param creationFunction defines the function used to instanciate the new object
  33804. * @param source defines the source object
  33805. * @returns the new object
  33806. */
  33807. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33808. }
  33809. }
  33810. declare module BABYLON {
  33811. /**
  33812. * Base class of all the textures in babylon.
  33813. * It groups all the common properties the materials, post process, lights... might need
  33814. * in order to make a correct use of the texture.
  33815. */
  33816. export class BaseTexture implements IAnimatable {
  33817. /**
  33818. * Default anisotropic filtering level for the application.
  33819. * It is set to 4 as a good tradeoff between perf and quality.
  33820. */
  33821. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33822. /**
  33823. * Gets or sets the unique id of the texture
  33824. */
  33825. uniqueId: number;
  33826. /**
  33827. * Define the name of the texture.
  33828. */
  33829. name: string;
  33830. /**
  33831. * Gets or sets an object used to store user defined information.
  33832. */
  33833. metadata: any;
  33834. /**
  33835. * For internal use only. Please do not use.
  33836. */
  33837. reservedDataStore: any;
  33838. private _hasAlpha;
  33839. /**
  33840. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33841. */
  33842. set hasAlpha(value: boolean);
  33843. get hasAlpha(): boolean;
  33844. /**
  33845. * Defines if the alpha value should be determined via the rgb values.
  33846. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33847. */
  33848. getAlphaFromRGB: boolean;
  33849. /**
  33850. * Intensity or strength of the texture.
  33851. * It is commonly used by materials to fine tune the intensity of the texture
  33852. */
  33853. level: number;
  33854. /**
  33855. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33856. * This is part of the texture as textures usually maps to one uv set.
  33857. */
  33858. coordinatesIndex: number;
  33859. protected _coordinatesMode: number;
  33860. /**
  33861. * How a texture is mapped.
  33862. *
  33863. * | Value | Type | Description |
  33864. * | ----- | ----------------------------------- | ----------- |
  33865. * | 0 | EXPLICIT_MODE | |
  33866. * | 1 | SPHERICAL_MODE | |
  33867. * | 2 | PLANAR_MODE | |
  33868. * | 3 | CUBIC_MODE | |
  33869. * | 4 | PROJECTION_MODE | |
  33870. * | 5 | SKYBOX_MODE | |
  33871. * | 6 | INVCUBIC_MODE | |
  33872. * | 7 | EQUIRECTANGULAR_MODE | |
  33873. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33874. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33875. */
  33876. set coordinatesMode(value: number);
  33877. get coordinatesMode(): number;
  33878. private _wrapU;
  33879. /**
  33880. * | Value | Type | Description |
  33881. * | ----- | ------------------ | ----------- |
  33882. * | 0 | CLAMP_ADDRESSMODE | |
  33883. * | 1 | WRAP_ADDRESSMODE | |
  33884. * | 2 | MIRROR_ADDRESSMODE | |
  33885. */
  33886. get wrapU(): number;
  33887. set wrapU(value: number);
  33888. private _wrapV;
  33889. /**
  33890. * | Value | Type | Description |
  33891. * | ----- | ------------------ | ----------- |
  33892. * | 0 | CLAMP_ADDRESSMODE | |
  33893. * | 1 | WRAP_ADDRESSMODE | |
  33894. * | 2 | MIRROR_ADDRESSMODE | |
  33895. */
  33896. get wrapV(): number;
  33897. set wrapV(value: number);
  33898. /**
  33899. * | Value | Type | Description |
  33900. * | ----- | ------------------ | ----------- |
  33901. * | 0 | CLAMP_ADDRESSMODE | |
  33902. * | 1 | WRAP_ADDRESSMODE | |
  33903. * | 2 | MIRROR_ADDRESSMODE | |
  33904. */
  33905. wrapR: number;
  33906. /**
  33907. * With compliant hardware and browser (supporting anisotropic filtering)
  33908. * this defines the level of anisotropic filtering in the texture.
  33909. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33910. */
  33911. anisotropicFilteringLevel: number;
  33912. /**
  33913. * Define if the texture is a cube texture or if false a 2d texture.
  33914. */
  33915. get isCube(): boolean;
  33916. set isCube(value: boolean);
  33917. /**
  33918. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33919. */
  33920. get is3D(): boolean;
  33921. set is3D(value: boolean);
  33922. /**
  33923. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33924. */
  33925. get is2DArray(): boolean;
  33926. set is2DArray(value: boolean);
  33927. /**
  33928. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33929. * HDR texture are usually stored in linear space.
  33930. * This only impacts the PBR and Background materials
  33931. */
  33932. gammaSpace: boolean;
  33933. /**
  33934. * Gets or sets whether or not the texture contains RGBD data.
  33935. */
  33936. get isRGBD(): boolean;
  33937. set isRGBD(value: boolean);
  33938. /**
  33939. * Is Z inverted in the texture (useful in a cube texture).
  33940. */
  33941. invertZ: boolean;
  33942. /**
  33943. * Are mip maps generated for this texture or not.
  33944. */
  33945. get noMipmap(): boolean;
  33946. /**
  33947. * @hidden
  33948. */
  33949. lodLevelInAlpha: boolean;
  33950. /**
  33951. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33952. */
  33953. get lodGenerationOffset(): number;
  33954. set lodGenerationOffset(value: number);
  33955. /**
  33956. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33957. */
  33958. get lodGenerationScale(): number;
  33959. set lodGenerationScale(value: number);
  33960. /**
  33961. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33962. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33963. * average roughness values.
  33964. */
  33965. get linearSpecularLOD(): boolean;
  33966. set linearSpecularLOD(value: boolean);
  33967. /**
  33968. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33969. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33970. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33971. */
  33972. get irradianceTexture(): Nullable<BaseTexture>;
  33973. set irradianceTexture(value: Nullable<BaseTexture>);
  33974. /**
  33975. * Define if the texture is a render target.
  33976. */
  33977. isRenderTarget: boolean;
  33978. /**
  33979. * Define the unique id of the texture in the scene.
  33980. */
  33981. get uid(): string;
  33982. /** @hidden */
  33983. _prefiltered: boolean;
  33984. /**
  33985. * Return a string representation of the texture.
  33986. * @returns the texture as a string
  33987. */
  33988. toString(): string;
  33989. /**
  33990. * Get the class name of the texture.
  33991. * @returns "BaseTexture"
  33992. */
  33993. getClassName(): string;
  33994. /**
  33995. * Define the list of animation attached to the texture.
  33996. */
  33997. animations: Animation[];
  33998. /**
  33999. * An event triggered when the texture is disposed.
  34000. */
  34001. onDisposeObservable: Observable<BaseTexture>;
  34002. private _onDisposeObserver;
  34003. /**
  34004. * Callback triggered when the texture has been disposed.
  34005. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34006. */
  34007. set onDispose(callback: () => void);
  34008. /**
  34009. * Define the current state of the loading sequence when in delayed load mode.
  34010. */
  34011. delayLoadState: number;
  34012. protected _scene: Nullable<Scene>;
  34013. protected _engine: Nullable<ThinEngine>;
  34014. /** @hidden */
  34015. _texture: Nullable<InternalTexture>;
  34016. private _uid;
  34017. /**
  34018. * Define if the texture is preventinga material to render or not.
  34019. * If not and the texture is not ready, the engine will use a default black texture instead.
  34020. */
  34021. get isBlocking(): boolean;
  34022. /**
  34023. * Instantiates a new BaseTexture.
  34024. * Base class of all the textures in babylon.
  34025. * It groups all the common properties the materials, post process, lights... might need
  34026. * in order to make a correct use of the texture.
  34027. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34028. */
  34029. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34030. /**
  34031. * Get the scene the texture belongs to.
  34032. * @returns the scene or null if undefined
  34033. */
  34034. getScene(): Nullable<Scene>;
  34035. /** @hidden */
  34036. protected _getEngine(): Nullable<ThinEngine>;
  34037. /**
  34038. * Get the texture transform matrix used to offset tile the texture for istance.
  34039. * @returns the transformation matrix
  34040. */
  34041. getTextureMatrix(): Matrix;
  34042. /**
  34043. * Get the texture reflection matrix used to rotate/transform the reflection.
  34044. * @returns the reflection matrix
  34045. */
  34046. getReflectionTextureMatrix(): Matrix;
  34047. /**
  34048. * Get the underlying lower level texture from Babylon.
  34049. * @returns the insternal texture
  34050. */
  34051. getInternalTexture(): Nullable<InternalTexture>;
  34052. /**
  34053. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34054. * @returns true if ready or not blocking
  34055. */
  34056. isReadyOrNotBlocking(): boolean;
  34057. /**
  34058. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34059. * @returns true if fully ready
  34060. */
  34061. isReady(): boolean;
  34062. private _cachedSize;
  34063. /**
  34064. * Get the size of the texture.
  34065. * @returns the texture size.
  34066. */
  34067. getSize(): ISize;
  34068. /**
  34069. * Get the base size of the texture.
  34070. * It can be different from the size if the texture has been resized for POT for instance
  34071. * @returns the base size
  34072. */
  34073. getBaseSize(): ISize;
  34074. /**
  34075. * Update the sampling mode of the texture.
  34076. * Default is Trilinear mode.
  34077. *
  34078. * | Value | Type | Description |
  34079. * | ----- | ------------------ | ----------- |
  34080. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34081. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34082. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34083. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34084. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34085. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34086. * | 7 | NEAREST_LINEAR | |
  34087. * | 8 | NEAREST_NEAREST | |
  34088. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34089. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34090. * | 11 | LINEAR_LINEAR | |
  34091. * | 12 | LINEAR_NEAREST | |
  34092. *
  34093. * > _mag_: magnification filter (close to the viewer)
  34094. * > _min_: minification filter (far from the viewer)
  34095. * > _mip_: filter used between mip map levels
  34096. *@param samplingMode Define the new sampling mode of the texture
  34097. */
  34098. updateSamplingMode(samplingMode: number): void;
  34099. /**
  34100. * Scales the texture if is `canRescale()`
  34101. * @param ratio the resize factor we want to use to rescale
  34102. */
  34103. scale(ratio: number): void;
  34104. /**
  34105. * Get if the texture can rescale.
  34106. */
  34107. get canRescale(): boolean;
  34108. /** @hidden */
  34109. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34110. /** @hidden */
  34111. _rebuild(): void;
  34112. /**
  34113. * Triggers the load sequence in delayed load mode.
  34114. */
  34115. delayLoad(): void;
  34116. /**
  34117. * Clones the texture.
  34118. * @returns the cloned texture
  34119. */
  34120. clone(): Nullable<BaseTexture>;
  34121. /**
  34122. * Get the texture underlying type (INT, FLOAT...)
  34123. */
  34124. get textureType(): number;
  34125. /**
  34126. * Get the texture underlying format (RGB, RGBA...)
  34127. */
  34128. get textureFormat(): number;
  34129. /**
  34130. * Indicates that textures need to be re-calculated for all materials
  34131. */
  34132. protected _markAllSubMeshesAsTexturesDirty(): void;
  34133. /**
  34134. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34135. * This will returns an RGBA array buffer containing either in values (0-255) or
  34136. * float values (0-1) depending of the underlying buffer type.
  34137. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34138. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34139. * @param buffer defines a user defined buffer to fill with data (can be null)
  34140. * @returns The Array buffer containing the pixels data.
  34141. */
  34142. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34143. /**
  34144. * Release and destroy the underlying lower level texture aka internalTexture.
  34145. */
  34146. releaseInternalTexture(): void;
  34147. /** @hidden */
  34148. get _lodTextureHigh(): Nullable<BaseTexture>;
  34149. /** @hidden */
  34150. get _lodTextureMid(): Nullable<BaseTexture>;
  34151. /** @hidden */
  34152. get _lodTextureLow(): Nullable<BaseTexture>;
  34153. /**
  34154. * Dispose the texture and release its associated resources.
  34155. */
  34156. dispose(): void;
  34157. /**
  34158. * Serialize the texture into a JSON representation that can be parsed later on.
  34159. * @returns the JSON representation of the texture
  34160. */
  34161. serialize(): any;
  34162. /**
  34163. * Helper function to be called back once a list of texture contains only ready textures.
  34164. * @param textures Define the list of textures to wait for
  34165. * @param callback Define the callback triggered once the entire list will be ready
  34166. */
  34167. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34168. private static _isScene;
  34169. }
  34170. }
  34171. declare module BABYLON {
  34172. /**
  34173. * Options to be used when creating an effect.
  34174. */
  34175. export interface IEffectCreationOptions {
  34176. /**
  34177. * Atrributes that will be used in the shader.
  34178. */
  34179. attributes: string[];
  34180. /**
  34181. * Uniform varible names that will be set in the shader.
  34182. */
  34183. uniformsNames: string[];
  34184. /**
  34185. * Uniform buffer variable names that will be set in the shader.
  34186. */
  34187. uniformBuffersNames: string[];
  34188. /**
  34189. * Sampler texture variable names that will be set in the shader.
  34190. */
  34191. samplers: string[];
  34192. /**
  34193. * Define statements that will be set in the shader.
  34194. */
  34195. defines: any;
  34196. /**
  34197. * Possible fallbacks for this effect to improve performance when needed.
  34198. */
  34199. fallbacks: Nullable<IEffectFallbacks>;
  34200. /**
  34201. * Callback that will be called when the shader is compiled.
  34202. */
  34203. onCompiled: Nullable<(effect: Effect) => void>;
  34204. /**
  34205. * Callback that will be called if an error occurs during shader compilation.
  34206. */
  34207. onError: Nullable<(effect: Effect, errors: string) => void>;
  34208. /**
  34209. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34210. */
  34211. indexParameters?: any;
  34212. /**
  34213. * Max number of lights that can be used in the shader.
  34214. */
  34215. maxSimultaneousLights?: number;
  34216. /**
  34217. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34218. */
  34219. transformFeedbackVaryings?: Nullable<string[]>;
  34220. /**
  34221. * 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
  34222. */
  34223. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34224. /**
  34225. * Is this effect rendering to several color attachments ?
  34226. */
  34227. multiTarget?: boolean;
  34228. }
  34229. /**
  34230. * Effect containing vertex and fragment shader that can be executed on an object.
  34231. */
  34232. export class Effect implements IDisposable {
  34233. /**
  34234. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34235. */
  34236. static ShadersRepository: string;
  34237. /**
  34238. * Enable logging of the shader code when a compilation error occurs
  34239. */
  34240. static LogShaderCodeOnCompilationError: boolean;
  34241. /**
  34242. * Name of the effect.
  34243. */
  34244. name: any;
  34245. /**
  34246. * String container all the define statements that should be set on the shader.
  34247. */
  34248. defines: string;
  34249. /**
  34250. * Callback that will be called when the shader is compiled.
  34251. */
  34252. onCompiled: Nullable<(effect: Effect) => void>;
  34253. /**
  34254. * Callback that will be called if an error occurs during shader compilation.
  34255. */
  34256. onError: Nullable<(effect: Effect, errors: string) => void>;
  34257. /**
  34258. * Callback that will be called when effect is bound.
  34259. */
  34260. onBind: Nullable<(effect: Effect) => void>;
  34261. /**
  34262. * Unique ID of the effect.
  34263. */
  34264. uniqueId: number;
  34265. /**
  34266. * Observable that will be called when the shader is compiled.
  34267. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34268. */
  34269. onCompileObservable: Observable<Effect>;
  34270. /**
  34271. * Observable that will be called if an error occurs during shader compilation.
  34272. */
  34273. onErrorObservable: Observable<Effect>;
  34274. /** @hidden */
  34275. _onBindObservable: Nullable<Observable<Effect>>;
  34276. /**
  34277. * @hidden
  34278. * Specifies if the effect was previously ready
  34279. */
  34280. _wasPreviouslyReady: boolean;
  34281. /**
  34282. * Observable that will be called when effect is bound.
  34283. */
  34284. get onBindObservable(): Observable<Effect>;
  34285. /** @hidden */
  34286. _bonesComputationForcedToCPU: boolean;
  34287. /** @hidden */
  34288. _multiTarget: boolean;
  34289. private static _uniqueIdSeed;
  34290. private _engine;
  34291. private _uniformBuffersNames;
  34292. private _uniformBuffersNamesList;
  34293. private _uniformsNames;
  34294. private _samplerList;
  34295. private _samplers;
  34296. private _isReady;
  34297. private _compilationError;
  34298. private _allFallbacksProcessed;
  34299. private _attributesNames;
  34300. private _attributes;
  34301. private _attributeLocationByName;
  34302. private _uniforms;
  34303. /**
  34304. * Key for the effect.
  34305. * @hidden
  34306. */
  34307. _key: string;
  34308. private _indexParameters;
  34309. private _fallbacks;
  34310. private _vertexSourceCode;
  34311. private _fragmentSourceCode;
  34312. private _vertexSourceCodeOverride;
  34313. private _fragmentSourceCodeOverride;
  34314. private _transformFeedbackVaryings;
  34315. /**
  34316. * Compiled shader to webGL program.
  34317. * @hidden
  34318. */
  34319. _pipelineContext: Nullable<IPipelineContext>;
  34320. private _valueCache;
  34321. private static _baseCache;
  34322. /**
  34323. * Instantiates an effect.
  34324. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34325. * @param baseName Name of the effect.
  34326. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34327. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34328. * @param samplers List of sampler variables that will be passed to the shader.
  34329. * @param engine Engine to be used to render the effect
  34330. * @param defines Define statements to be added to the shader.
  34331. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34332. * @param onCompiled Callback that will be called when the shader is compiled.
  34333. * @param onError Callback that will be called if an error occurs during shader compilation.
  34334. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34335. */
  34336. 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);
  34337. private _useFinalCode;
  34338. /**
  34339. * Unique key for this effect
  34340. */
  34341. get key(): string;
  34342. /**
  34343. * If the effect has been compiled and prepared.
  34344. * @returns if the effect is compiled and prepared.
  34345. */
  34346. isReady(): boolean;
  34347. private _isReadyInternal;
  34348. /**
  34349. * The engine the effect was initialized with.
  34350. * @returns the engine.
  34351. */
  34352. getEngine(): Engine;
  34353. /**
  34354. * The pipeline context for this effect
  34355. * @returns the associated pipeline context
  34356. */
  34357. getPipelineContext(): Nullable<IPipelineContext>;
  34358. /**
  34359. * The set of names of attribute variables for the shader.
  34360. * @returns An array of attribute names.
  34361. */
  34362. getAttributesNames(): string[];
  34363. /**
  34364. * Returns the attribute at the given index.
  34365. * @param index The index of the attribute.
  34366. * @returns The location of the attribute.
  34367. */
  34368. getAttributeLocation(index: number): number;
  34369. /**
  34370. * Returns the attribute based on the name of the variable.
  34371. * @param name of the attribute to look up.
  34372. * @returns the attribute location.
  34373. */
  34374. getAttributeLocationByName(name: string): number;
  34375. /**
  34376. * The number of attributes.
  34377. * @returns the numnber of attributes.
  34378. */
  34379. getAttributesCount(): number;
  34380. /**
  34381. * Gets the index of a uniform variable.
  34382. * @param uniformName of the uniform to look up.
  34383. * @returns the index.
  34384. */
  34385. getUniformIndex(uniformName: string): number;
  34386. /**
  34387. * Returns the attribute based on the name of the variable.
  34388. * @param uniformName of the uniform to look up.
  34389. * @returns the location of the uniform.
  34390. */
  34391. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34392. /**
  34393. * Returns an array of sampler variable names
  34394. * @returns The array of sampler variable names.
  34395. */
  34396. getSamplers(): string[];
  34397. /**
  34398. * Returns an array of uniform variable names
  34399. * @returns The array of uniform variable names.
  34400. */
  34401. getUniformNames(): string[];
  34402. /**
  34403. * Returns an array of uniform buffer variable names
  34404. * @returns The array of uniform buffer variable names.
  34405. */
  34406. getUniformBuffersNames(): string[];
  34407. /**
  34408. * Returns the index parameters used to create the effect
  34409. * @returns The index parameters object
  34410. */
  34411. getIndexParameters(): any;
  34412. /**
  34413. * The error from the last compilation.
  34414. * @returns the error string.
  34415. */
  34416. getCompilationError(): string;
  34417. /**
  34418. * Gets a boolean indicating that all fallbacks were used during compilation
  34419. * @returns true if all fallbacks were used
  34420. */
  34421. allFallbacksProcessed(): boolean;
  34422. /**
  34423. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34424. * @param func The callback to be used.
  34425. */
  34426. executeWhenCompiled(func: (effect: Effect) => void): void;
  34427. private _checkIsReady;
  34428. private _loadShader;
  34429. /**
  34430. * Gets the vertex shader source code of this effect
  34431. */
  34432. get vertexSourceCode(): string;
  34433. /**
  34434. * Gets the fragment shader source code of this effect
  34435. */
  34436. get fragmentSourceCode(): string;
  34437. /**
  34438. * Recompiles the webGL program
  34439. * @param vertexSourceCode The source code for the vertex shader.
  34440. * @param fragmentSourceCode The source code for the fragment shader.
  34441. * @param onCompiled Callback called when completed.
  34442. * @param onError Callback called on error.
  34443. * @hidden
  34444. */
  34445. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34446. /**
  34447. * Prepares the effect
  34448. * @hidden
  34449. */
  34450. _prepareEffect(): void;
  34451. private _getShaderCodeAndErrorLine;
  34452. private _processCompilationErrors;
  34453. /**
  34454. * Checks if the effect is supported. (Must be called after compilation)
  34455. */
  34456. get isSupported(): boolean;
  34457. /**
  34458. * Binds a texture to the engine to be used as output of the shader.
  34459. * @param channel Name of the output variable.
  34460. * @param texture Texture to bind.
  34461. * @hidden
  34462. */
  34463. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34464. /**
  34465. * Sets a texture on the engine to be used in the shader.
  34466. * @param channel Name of the sampler variable.
  34467. * @param texture Texture to set.
  34468. */
  34469. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34470. /**
  34471. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34472. * @param channel Name of the sampler variable.
  34473. * @param texture Texture to set.
  34474. */
  34475. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34476. /**
  34477. * Sets an array of textures on the engine to be used in the shader.
  34478. * @param channel Name of the variable.
  34479. * @param textures Textures to set.
  34480. */
  34481. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34482. /**
  34483. * 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)
  34484. * @param channel Name of the sampler variable.
  34485. * @param postProcess Post process to get the input texture from.
  34486. */
  34487. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34488. /**
  34489. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34490. * 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)
  34491. * @param channel Name of the sampler variable.
  34492. * @param postProcess Post process to get the output texture from.
  34493. */
  34494. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34495. /** @hidden */
  34496. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34497. /** @hidden */
  34498. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34499. /** @hidden */
  34500. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34501. /** @hidden */
  34502. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34503. /**
  34504. * Binds a buffer to a uniform.
  34505. * @param buffer Buffer to bind.
  34506. * @param name Name of the uniform variable to bind to.
  34507. */
  34508. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34509. /**
  34510. * Binds block to a uniform.
  34511. * @param blockName Name of the block to bind.
  34512. * @param index Index to bind.
  34513. */
  34514. bindUniformBlock(blockName: string, index: number): void;
  34515. /**
  34516. * Sets an interger value on a uniform variable.
  34517. * @param uniformName Name of the variable.
  34518. * @param value Value to be set.
  34519. * @returns this effect.
  34520. */
  34521. setInt(uniformName: string, value: number): Effect;
  34522. /**
  34523. * Sets an int array on a uniform variable.
  34524. * @param uniformName Name of the variable.
  34525. * @param array array to be set.
  34526. * @returns this effect.
  34527. */
  34528. setIntArray(uniformName: string, array: Int32Array): Effect;
  34529. /**
  34530. * 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)
  34531. * @param uniformName Name of the variable.
  34532. * @param array array to be set.
  34533. * @returns this effect.
  34534. */
  34535. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34536. /**
  34537. * 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)
  34538. * @param uniformName Name of the variable.
  34539. * @param array array to be set.
  34540. * @returns this effect.
  34541. */
  34542. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34543. /**
  34544. * 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)
  34545. * @param uniformName Name of the variable.
  34546. * @param array array to be set.
  34547. * @returns this effect.
  34548. */
  34549. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34550. /**
  34551. * Sets an float array on a uniform variable.
  34552. * @param uniformName Name of the variable.
  34553. * @param array array to be set.
  34554. * @returns this effect.
  34555. */
  34556. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34557. /**
  34558. * 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)
  34559. * @param uniformName Name of the variable.
  34560. * @param array array to be set.
  34561. * @returns this effect.
  34562. */
  34563. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34564. /**
  34565. * 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)
  34566. * @param uniformName Name of the variable.
  34567. * @param array array to be set.
  34568. * @returns this effect.
  34569. */
  34570. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34571. /**
  34572. * 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)
  34573. * @param uniformName Name of the variable.
  34574. * @param array array to be set.
  34575. * @returns this effect.
  34576. */
  34577. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34578. /**
  34579. * Sets an array on a uniform variable.
  34580. * @param uniformName Name of the variable.
  34581. * @param array array to be set.
  34582. * @returns this effect.
  34583. */
  34584. setArray(uniformName: string, array: number[]): Effect;
  34585. /**
  34586. * 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)
  34587. * @param uniformName Name of the variable.
  34588. * @param array array to be set.
  34589. * @returns this effect.
  34590. */
  34591. setArray2(uniformName: string, array: number[]): Effect;
  34592. /**
  34593. * 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)
  34594. * @param uniformName Name of the variable.
  34595. * @param array array to be set.
  34596. * @returns this effect.
  34597. */
  34598. setArray3(uniformName: string, array: number[]): Effect;
  34599. /**
  34600. * 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)
  34601. * @param uniformName Name of the variable.
  34602. * @param array array to be set.
  34603. * @returns this effect.
  34604. */
  34605. setArray4(uniformName: string, array: number[]): Effect;
  34606. /**
  34607. * Sets matrices on a uniform variable.
  34608. * @param uniformName Name of the variable.
  34609. * @param matrices matrices to be set.
  34610. * @returns this effect.
  34611. */
  34612. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34613. /**
  34614. * Sets matrix on a uniform variable.
  34615. * @param uniformName Name of the variable.
  34616. * @param matrix matrix to be set.
  34617. * @returns this effect.
  34618. */
  34619. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34620. /**
  34621. * 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)
  34622. * @param uniformName Name of the variable.
  34623. * @param matrix matrix to be set.
  34624. * @returns this effect.
  34625. */
  34626. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34627. /**
  34628. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34629. * @param uniformName Name of the variable.
  34630. * @param matrix matrix to be set.
  34631. * @returns this effect.
  34632. */
  34633. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34634. /**
  34635. * Sets a float on a uniform variable.
  34636. * @param uniformName Name of the variable.
  34637. * @param value value to be set.
  34638. * @returns this effect.
  34639. */
  34640. setFloat(uniformName: string, value: number): Effect;
  34641. /**
  34642. * Sets a boolean on a uniform variable.
  34643. * @param uniformName Name of the variable.
  34644. * @param bool value to be set.
  34645. * @returns this effect.
  34646. */
  34647. setBool(uniformName: string, bool: boolean): Effect;
  34648. /**
  34649. * Sets a Vector2 on a uniform variable.
  34650. * @param uniformName Name of the variable.
  34651. * @param vector2 vector2 to be set.
  34652. * @returns this effect.
  34653. */
  34654. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34655. /**
  34656. * Sets a float2 on a uniform variable.
  34657. * @param uniformName Name of the variable.
  34658. * @param x First float in float2.
  34659. * @param y Second float in float2.
  34660. * @returns this effect.
  34661. */
  34662. setFloat2(uniformName: string, x: number, y: number): Effect;
  34663. /**
  34664. * Sets a Vector3 on a uniform variable.
  34665. * @param uniformName Name of the variable.
  34666. * @param vector3 Value to be set.
  34667. * @returns this effect.
  34668. */
  34669. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34670. /**
  34671. * Sets a float3 on a uniform variable.
  34672. * @param uniformName Name of the variable.
  34673. * @param x First float in float3.
  34674. * @param y Second float in float3.
  34675. * @param z Third float in float3.
  34676. * @returns this effect.
  34677. */
  34678. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34679. /**
  34680. * Sets a Vector4 on a uniform variable.
  34681. * @param uniformName Name of the variable.
  34682. * @param vector4 Value to be set.
  34683. * @returns this effect.
  34684. */
  34685. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34686. /**
  34687. * Sets a float4 on a uniform variable.
  34688. * @param uniformName Name of the variable.
  34689. * @param x First float in float4.
  34690. * @param y Second float in float4.
  34691. * @param z Third float in float4.
  34692. * @param w Fourth float in float4.
  34693. * @returns this effect.
  34694. */
  34695. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34696. /**
  34697. * Sets a Color3 on a uniform variable.
  34698. * @param uniformName Name of the variable.
  34699. * @param color3 Value to be set.
  34700. * @returns this effect.
  34701. */
  34702. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34703. /**
  34704. * Sets a Color4 on a uniform variable.
  34705. * @param uniformName Name of the variable.
  34706. * @param color3 Value to be set.
  34707. * @param alpha Alpha value to be set.
  34708. * @returns this effect.
  34709. */
  34710. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34711. /**
  34712. * Sets a Color4 on a uniform variable
  34713. * @param uniformName defines the name of the variable
  34714. * @param color4 defines the value to be set
  34715. * @returns this effect.
  34716. */
  34717. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34718. /** Release all associated resources */
  34719. dispose(): void;
  34720. /**
  34721. * This function will add a new shader to the shader store
  34722. * @param name the name of the shader
  34723. * @param pixelShader optional pixel shader content
  34724. * @param vertexShader optional vertex shader content
  34725. */
  34726. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34727. /**
  34728. * Store of each shader (The can be looked up using effect.key)
  34729. */
  34730. static ShadersStore: {
  34731. [key: string]: string;
  34732. };
  34733. /**
  34734. * Store of each included file for a shader (The can be looked up using effect.key)
  34735. */
  34736. static IncludesShadersStore: {
  34737. [key: string]: string;
  34738. };
  34739. /**
  34740. * Resets the cache of effects.
  34741. */
  34742. static ResetCache(): void;
  34743. }
  34744. }
  34745. declare module BABYLON {
  34746. /**
  34747. * Interface used to describe the capabilities of the engine relatively to the current browser
  34748. */
  34749. export interface EngineCapabilities {
  34750. /** Maximum textures units per fragment shader */
  34751. maxTexturesImageUnits: number;
  34752. /** Maximum texture units per vertex shader */
  34753. maxVertexTextureImageUnits: number;
  34754. /** Maximum textures units in the entire pipeline */
  34755. maxCombinedTexturesImageUnits: number;
  34756. /** Maximum texture size */
  34757. maxTextureSize: number;
  34758. /** Maximum texture samples */
  34759. maxSamples?: number;
  34760. /** Maximum cube texture size */
  34761. maxCubemapTextureSize: number;
  34762. /** Maximum render texture size */
  34763. maxRenderTextureSize: number;
  34764. /** Maximum number of vertex attributes */
  34765. maxVertexAttribs: number;
  34766. /** Maximum number of varyings */
  34767. maxVaryingVectors: number;
  34768. /** Maximum number of uniforms per vertex shader */
  34769. maxVertexUniformVectors: number;
  34770. /** Maximum number of uniforms per fragment shader */
  34771. maxFragmentUniformVectors: number;
  34772. /** Defines if standard derivates (dx/dy) are supported */
  34773. standardDerivatives: boolean;
  34774. /** Defines if s3tc texture compression is supported */
  34775. s3tc?: WEBGL_compressed_texture_s3tc;
  34776. /** Defines if pvrtc texture compression is supported */
  34777. pvrtc: any;
  34778. /** Defines if etc1 texture compression is supported */
  34779. etc1: any;
  34780. /** Defines if etc2 texture compression is supported */
  34781. etc2: any;
  34782. /** Defines if astc texture compression is supported */
  34783. astc: any;
  34784. /** Defines if float textures are supported */
  34785. textureFloat: boolean;
  34786. /** Defines if vertex array objects are supported */
  34787. vertexArrayObject: boolean;
  34788. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34789. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34790. /** Gets the maximum level of anisotropy supported */
  34791. maxAnisotropy: number;
  34792. /** Defines if instancing is supported */
  34793. instancedArrays: boolean;
  34794. /** Defines if 32 bits indices are supported */
  34795. uintIndices: boolean;
  34796. /** Defines if high precision shaders are supported */
  34797. highPrecisionShaderSupported: boolean;
  34798. /** Defines if depth reading in the fragment shader is supported */
  34799. fragmentDepthSupported: boolean;
  34800. /** Defines if float texture linear filtering is supported*/
  34801. textureFloatLinearFiltering: boolean;
  34802. /** Defines if rendering to float textures is supported */
  34803. textureFloatRender: boolean;
  34804. /** Defines if half float textures are supported*/
  34805. textureHalfFloat: boolean;
  34806. /** Defines if half float texture linear filtering is supported*/
  34807. textureHalfFloatLinearFiltering: boolean;
  34808. /** Defines if rendering to half float textures is supported */
  34809. textureHalfFloatRender: boolean;
  34810. /** Defines if textureLOD shader command is supported */
  34811. textureLOD: boolean;
  34812. /** Defines if draw buffers extension is supported */
  34813. drawBuffersExtension: boolean;
  34814. /** Defines if depth textures are supported */
  34815. depthTextureExtension: boolean;
  34816. /** Defines if float color buffer are supported */
  34817. colorBufferFloat: boolean;
  34818. /** Gets disjoint timer query extension (null if not supported) */
  34819. timerQuery?: EXT_disjoint_timer_query;
  34820. /** Defines if timestamp can be used with timer query */
  34821. canUseTimestampForTimerQuery: boolean;
  34822. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34823. multiview?: any;
  34824. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34825. oculusMultiview?: any;
  34826. /** Function used to let the system compiles shaders in background */
  34827. parallelShaderCompile?: {
  34828. COMPLETION_STATUS_KHR: number;
  34829. };
  34830. /** Max number of texture samples for MSAA */
  34831. maxMSAASamples: number;
  34832. /** Defines if the blend min max extension is supported */
  34833. blendMinMax: boolean;
  34834. }
  34835. }
  34836. declare module BABYLON {
  34837. /**
  34838. * @hidden
  34839. **/
  34840. export class DepthCullingState {
  34841. private _isDepthTestDirty;
  34842. private _isDepthMaskDirty;
  34843. private _isDepthFuncDirty;
  34844. private _isCullFaceDirty;
  34845. private _isCullDirty;
  34846. private _isZOffsetDirty;
  34847. private _isFrontFaceDirty;
  34848. private _depthTest;
  34849. private _depthMask;
  34850. private _depthFunc;
  34851. private _cull;
  34852. private _cullFace;
  34853. private _zOffset;
  34854. private _frontFace;
  34855. /**
  34856. * Initializes the state.
  34857. */
  34858. constructor();
  34859. get isDirty(): boolean;
  34860. get zOffset(): number;
  34861. set zOffset(value: number);
  34862. get cullFace(): Nullable<number>;
  34863. set cullFace(value: Nullable<number>);
  34864. get cull(): Nullable<boolean>;
  34865. set cull(value: Nullable<boolean>);
  34866. get depthFunc(): Nullable<number>;
  34867. set depthFunc(value: Nullable<number>);
  34868. get depthMask(): boolean;
  34869. set depthMask(value: boolean);
  34870. get depthTest(): boolean;
  34871. set depthTest(value: boolean);
  34872. get frontFace(): Nullable<number>;
  34873. set frontFace(value: Nullable<number>);
  34874. reset(): void;
  34875. apply(gl: WebGLRenderingContext): void;
  34876. }
  34877. }
  34878. declare module BABYLON {
  34879. /**
  34880. * @hidden
  34881. **/
  34882. export class StencilState {
  34883. /** 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 */
  34884. static readonly ALWAYS: number;
  34885. /** Passed to stencilOperation to specify that stencil value must be kept */
  34886. static readonly KEEP: number;
  34887. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34888. static readonly REPLACE: number;
  34889. private _isStencilTestDirty;
  34890. private _isStencilMaskDirty;
  34891. private _isStencilFuncDirty;
  34892. private _isStencilOpDirty;
  34893. private _stencilTest;
  34894. private _stencilMask;
  34895. private _stencilFunc;
  34896. private _stencilFuncRef;
  34897. private _stencilFuncMask;
  34898. private _stencilOpStencilFail;
  34899. private _stencilOpDepthFail;
  34900. private _stencilOpStencilDepthPass;
  34901. get isDirty(): boolean;
  34902. get stencilFunc(): number;
  34903. set stencilFunc(value: number);
  34904. get stencilFuncRef(): number;
  34905. set stencilFuncRef(value: number);
  34906. get stencilFuncMask(): number;
  34907. set stencilFuncMask(value: number);
  34908. get stencilOpStencilFail(): number;
  34909. set stencilOpStencilFail(value: number);
  34910. get stencilOpDepthFail(): number;
  34911. set stencilOpDepthFail(value: number);
  34912. get stencilOpStencilDepthPass(): number;
  34913. set stencilOpStencilDepthPass(value: number);
  34914. get stencilMask(): number;
  34915. set stencilMask(value: number);
  34916. get stencilTest(): boolean;
  34917. set stencilTest(value: boolean);
  34918. constructor();
  34919. reset(): void;
  34920. apply(gl: WebGLRenderingContext): void;
  34921. }
  34922. }
  34923. declare module BABYLON {
  34924. /**
  34925. * @hidden
  34926. **/
  34927. export class AlphaState {
  34928. private _isAlphaBlendDirty;
  34929. private _isBlendFunctionParametersDirty;
  34930. private _isBlendEquationParametersDirty;
  34931. private _isBlendConstantsDirty;
  34932. private _alphaBlend;
  34933. private _blendFunctionParameters;
  34934. private _blendEquationParameters;
  34935. private _blendConstants;
  34936. /**
  34937. * Initializes the state.
  34938. */
  34939. constructor();
  34940. get isDirty(): boolean;
  34941. get alphaBlend(): boolean;
  34942. set alphaBlend(value: boolean);
  34943. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34944. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34945. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34946. reset(): void;
  34947. apply(gl: WebGLRenderingContext): void;
  34948. }
  34949. }
  34950. declare module BABYLON {
  34951. /** @hidden */
  34952. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34953. attributeProcessor(attribute: string): string;
  34954. varyingProcessor(varying: string, isFragment: boolean): string;
  34955. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34956. }
  34957. }
  34958. declare module BABYLON {
  34959. /**
  34960. * Interface for attribute information associated with buffer instanciation
  34961. */
  34962. export interface InstancingAttributeInfo {
  34963. /**
  34964. * Name of the GLSL attribute
  34965. * if attribute index is not specified, this is used to retrieve the index from the effect
  34966. */
  34967. attributeName: string;
  34968. /**
  34969. * Index/offset of the attribute in the vertex shader
  34970. * if not specified, this will be computes from the name.
  34971. */
  34972. index?: number;
  34973. /**
  34974. * size of the attribute, 1, 2, 3 or 4
  34975. */
  34976. attributeSize: number;
  34977. /**
  34978. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34979. */
  34980. offset: number;
  34981. /**
  34982. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34983. * default to 1
  34984. */
  34985. divisor?: number;
  34986. /**
  34987. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34988. * default is FLOAT
  34989. */
  34990. attributeType?: number;
  34991. /**
  34992. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34993. */
  34994. normalized?: boolean;
  34995. }
  34996. }
  34997. declare module BABYLON {
  34998. interface ThinEngine {
  34999. /**
  35000. * Update a video texture
  35001. * @param texture defines the texture to update
  35002. * @param video defines the video element to use
  35003. * @param invertY defines if data must be stored with Y axis inverted
  35004. */
  35005. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35006. }
  35007. }
  35008. declare module BABYLON {
  35009. interface ThinEngine {
  35010. /**
  35011. * Creates a dynamic texture
  35012. * @param width defines the width of the texture
  35013. * @param height defines the height of the texture
  35014. * @param generateMipMaps defines if the engine should generate the mip levels
  35015. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35016. * @returns the dynamic texture inside an InternalTexture
  35017. */
  35018. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35019. /**
  35020. * Update the content of a dynamic texture
  35021. * @param texture defines the texture to update
  35022. * @param canvas defines the canvas containing the source
  35023. * @param invertY defines if data must be stored with Y axis inverted
  35024. * @param premulAlpha defines if alpha is stored as premultiplied
  35025. * @param format defines the format of the data
  35026. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35027. */
  35028. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35029. }
  35030. }
  35031. declare module BABYLON {
  35032. /**
  35033. * Settings for finer control over video usage
  35034. */
  35035. export interface VideoTextureSettings {
  35036. /**
  35037. * Applies `autoplay` to video, if specified
  35038. */
  35039. autoPlay?: boolean;
  35040. /**
  35041. * Applies `loop` to video, if specified
  35042. */
  35043. loop?: boolean;
  35044. /**
  35045. * Automatically updates internal texture from video at every frame in the render loop
  35046. */
  35047. autoUpdateTexture: boolean;
  35048. /**
  35049. * Image src displayed during the video loading or until the user interacts with the video.
  35050. */
  35051. poster?: string;
  35052. }
  35053. /**
  35054. * If you want to display a video in your scene, this is the special texture for that.
  35055. * This special texture works similar to other textures, with the exception of a few parameters.
  35056. * @see https://doc.babylonjs.com/how_to/video_texture
  35057. */
  35058. export class VideoTexture extends Texture {
  35059. /**
  35060. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35061. */
  35062. readonly autoUpdateTexture: boolean;
  35063. /**
  35064. * The video instance used by the texture internally
  35065. */
  35066. readonly video: HTMLVideoElement;
  35067. private _onUserActionRequestedObservable;
  35068. /**
  35069. * Event triggerd when a dom action is required by the user to play the video.
  35070. * This happens due to recent changes in browser policies preventing video to auto start.
  35071. */
  35072. get onUserActionRequestedObservable(): Observable<Texture>;
  35073. private _generateMipMaps;
  35074. private _stillImageCaptured;
  35075. private _displayingPosterTexture;
  35076. private _settings;
  35077. private _createInternalTextureOnEvent;
  35078. private _frameId;
  35079. private _currentSrc;
  35080. /**
  35081. * Creates a video texture.
  35082. * If you want to display a video in your scene, this is the special texture for that.
  35083. * This special texture works similar to other textures, with the exception of a few parameters.
  35084. * @see https://doc.babylonjs.com/how_to/video_texture
  35085. * @param name optional name, will detect from video source, if not defined
  35086. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35087. * @param scene is obviously the current scene.
  35088. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35089. * @param invertY is false by default but can be used to invert video on Y axis
  35090. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35091. * @param settings allows finer control over video usage
  35092. */
  35093. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35094. private _getName;
  35095. private _getVideo;
  35096. private _createInternalTexture;
  35097. private reset;
  35098. /**
  35099. * @hidden Internal method to initiate `update`.
  35100. */
  35101. _rebuild(): void;
  35102. /**
  35103. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35104. */
  35105. update(): void;
  35106. /**
  35107. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35108. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35109. */
  35110. updateTexture(isVisible: boolean): void;
  35111. protected _updateInternalTexture: () => void;
  35112. /**
  35113. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35114. * @param url New url.
  35115. */
  35116. updateURL(url: string): void;
  35117. /**
  35118. * Clones the texture.
  35119. * @returns the cloned texture
  35120. */
  35121. clone(): VideoTexture;
  35122. /**
  35123. * Dispose the texture and release its associated resources.
  35124. */
  35125. dispose(): void;
  35126. /**
  35127. * Creates a video texture straight from a stream.
  35128. * @param scene Define the scene the texture should be created in
  35129. * @param stream Define the stream the texture should be created from
  35130. * @returns The created video texture as a promise
  35131. */
  35132. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35133. /**
  35134. * Creates a video texture straight from your WebCam video feed.
  35135. * @param scene Define the scene the texture should be created in
  35136. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35137. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35138. * @returns The created video texture as a promise
  35139. */
  35140. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35141. minWidth: number;
  35142. maxWidth: number;
  35143. minHeight: number;
  35144. maxHeight: number;
  35145. deviceId: string;
  35146. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35147. /**
  35148. * Creates a video texture straight from your WebCam video feed.
  35149. * @param scene Define the scene the texture should be created in
  35150. * @param onReady Define a callback to triggered once the texture will be ready
  35151. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35152. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35153. */
  35154. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35155. minWidth: number;
  35156. maxWidth: number;
  35157. minHeight: number;
  35158. maxHeight: number;
  35159. deviceId: string;
  35160. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35161. }
  35162. }
  35163. declare module BABYLON {
  35164. /**
  35165. * Defines the interface used by objects working like Scene
  35166. * @hidden
  35167. */
  35168. export interface ISceneLike {
  35169. _addPendingData(data: any): void;
  35170. _removePendingData(data: any): void;
  35171. offlineProvider: IOfflineProvider;
  35172. }
  35173. /**
  35174. * Information about the current host
  35175. */
  35176. export interface HostInformation {
  35177. /**
  35178. * Defines if the current host is a mobile
  35179. */
  35180. isMobile: boolean;
  35181. }
  35182. /** Interface defining initialization parameters for Engine class */
  35183. export interface EngineOptions extends WebGLContextAttributes {
  35184. /**
  35185. * Defines if the engine should no exceed a specified device ratio
  35186. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35187. */
  35188. limitDeviceRatio?: number;
  35189. /**
  35190. * Defines if webvr should be enabled automatically
  35191. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35192. */
  35193. autoEnableWebVR?: boolean;
  35194. /**
  35195. * Defines if webgl2 should be turned off even if supported
  35196. * @see https://doc.babylonjs.com/features/webgl2
  35197. */
  35198. disableWebGL2Support?: boolean;
  35199. /**
  35200. * Defines if webaudio should be initialized as well
  35201. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35202. */
  35203. audioEngine?: boolean;
  35204. /**
  35205. * Defines if animations should run using a deterministic lock step
  35206. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35207. */
  35208. deterministicLockstep?: boolean;
  35209. /** Defines the maximum steps to use with deterministic lock step mode */
  35210. lockstepMaxSteps?: number;
  35211. /** Defines the seconds between each deterministic lock step */
  35212. timeStep?: number;
  35213. /**
  35214. * Defines that engine should ignore context lost events
  35215. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35216. */
  35217. doNotHandleContextLost?: boolean;
  35218. /**
  35219. * Defines that engine should ignore modifying touch action attribute and style
  35220. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35221. */
  35222. doNotHandleTouchAction?: boolean;
  35223. /**
  35224. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35225. */
  35226. useHighPrecisionFloats?: boolean;
  35227. /**
  35228. * Make the canvas XR Compatible for XR sessions
  35229. */
  35230. xrCompatible?: boolean;
  35231. /**
  35232. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35233. */
  35234. useHighPrecisionMatrix?: boolean;
  35235. }
  35236. /**
  35237. * The base engine class (root of all engines)
  35238. */
  35239. export class ThinEngine {
  35240. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35241. static ExceptionList: ({
  35242. key: string;
  35243. capture: string;
  35244. captureConstraint: number;
  35245. targets: string[];
  35246. } | {
  35247. key: string;
  35248. capture: null;
  35249. captureConstraint: null;
  35250. targets: string[];
  35251. })[];
  35252. /** @hidden */
  35253. static _TextureLoaders: IInternalTextureLoader[];
  35254. /**
  35255. * Returns the current npm package of the sdk
  35256. */
  35257. static get NpmPackage(): string;
  35258. /**
  35259. * Returns the current version of the framework
  35260. */
  35261. static get Version(): string;
  35262. /**
  35263. * Returns a string describing the current engine
  35264. */
  35265. get description(): string;
  35266. /**
  35267. * Gets or sets the epsilon value used by collision engine
  35268. */
  35269. static CollisionsEpsilon: number;
  35270. /**
  35271. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35272. */
  35273. static get ShadersRepository(): string;
  35274. static set ShadersRepository(value: string);
  35275. /** @hidden */
  35276. _shaderProcessor: IShaderProcessor;
  35277. /**
  35278. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35279. */
  35280. forcePOTTextures: boolean;
  35281. /**
  35282. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35283. */
  35284. isFullscreen: boolean;
  35285. /**
  35286. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35287. */
  35288. cullBackFaces: boolean;
  35289. /**
  35290. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35291. */
  35292. renderEvenInBackground: boolean;
  35293. /**
  35294. * Gets or sets a boolean indicating that cache can be kept between frames
  35295. */
  35296. preventCacheWipeBetweenFrames: boolean;
  35297. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35298. validateShaderPrograms: boolean;
  35299. /**
  35300. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35301. * This can provide greater z depth for distant objects.
  35302. */
  35303. useReverseDepthBuffer: boolean;
  35304. /**
  35305. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35306. */
  35307. disableUniformBuffers: boolean;
  35308. /** @hidden */
  35309. _uniformBuffers: UniformBuffer[];
  35310. /**
  35311. * Gets a boolean indicating that the engine supports uniform buffers
  35312. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35313. */
  35314. get supportsUniformBuffers(): boolean;
  35315. /** @hidden */
  35316. _gl: WebGLRenderingContext;
  35317. /** @hidden */
  35318. _webGLVersion: number;
  35319. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35320. protected _windowIsBackground: boolean;
  35321. protected _creationOptions: EngineOptions;
  35322. protected _highPrecisionShadersAllowed: boolean;
  35323. /** @hidden */
  35324. get _shouldUseHighPrecisionShader(): boolean;
  35325. /**
  35326. * Gets a boolean indicating that only power of 2 textures are supported
  35327. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35328. */
  35329. get needPOTTextures(): boolean;
  35330. /** @hidden */
  35331. _badOS: boolean;
  35332. /** @hidden */
  35333. _badDesktopOS: boolean;
  35334. private _hardwareScalingLevel;
  35335. /** @hidden */
  35336. _caps: EngineCapabilities;
  35337. private _isStencilEnable;
  35338. private _glVersion;
  35339. private _glRenderer;
  35340. private _glVendor;
  35341. /** @hidden */
  35342. _videoTextureSupported: boolean;
  35343. protected _renderingQueueLaunched: boolean;
  35344. protected _activeRenderLoops: (() => void)[];
  35345. /**
  35346. * Observable signaled when a context lost event is raised
  35347. */
  35348. onContextLostObservable: Observable<ThinEngine>;
  35349. /**
  35350. * Observable signaled when a context restored event is raised
  35351. */
  35352. onContextRestoredObservable: Observable<ThinEngine>;
  35353. private _onContextLost;
  35354. private _onContextRestored;
  35355. protected _contextWasLost: boolean;
  35356. /** @hidden */
  35357. _doNotHandleContextLost: boolean;
  35358. /**
  35359. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35360. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35361. */
  35362. get doNotHandleContextLost(): boolean;
  35363. set doNotHandleContextLost(value: boolean);
  35364. /**
  35365. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35366. */
  35367. disableVertexArrayObjects: boolean;
  35368. /** @hidden */
  35369. protected _colorWrite: boolean;
  35370. /** @hidden */
  35371. protected _colorWriteChanged: boolean;
  35372. /** @hidden */
  35373. protected _depthCullingState: DepthCullingState;
  35374. /** @hidden */
  35375. protected _stencilState: StencilState;
  35376. /** @hidden */
  35377. _alphaState: AlphaState;
  35378. /** @hidden */
  35379. _alphaMode: number;
  35380. /** @hidden */
  35381. _alphaEquation: number;
  35382. /** @hidden */
  35383. _internalTexturesCache: InternalTexture[];
  35384. /** @hidden */
  35385. protected _activeChannel: number;
  35386. private _currentTextureChannel;
  35387. /** @hidden */
  35388. protected _boundTexturesCache: {
  35389. [key: string]: Nullable<InternalTexture>;
  35390. };
  35391. /** @hidden */
  35392. protected _currentEffect: Nullable<Effect>;
  35393. /** @hidden */
  35394. protected _currentProgram: Nullable<WebGLProgram>;
  35395. private _compiledEffects;
  35396. private _vertexAttribArraysEnabled;
  35397. /** @hidden */
  35398. protected _cachedViewport: Nullable<IViewportLike>;
  35399. private _cachedVertexArrayObject;
  35400. /** @hidden */
  35401. protected _cachedVertexBuffers: any;
  35402. /** @hidden */
  35403. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35404. /** @hidden */
  35405. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35406. /** @hidden */
  35407. _currentRenderTarget: Nullable<InternalTexture>;
  35408. private _uintIndicesCurrentlySet;
  35409. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35410. /** @hidden */
  35411. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35412. /** @hidden */
  35413. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35414. private _currentBufferPointers;
  35415. private _currentInstanceLocations;
  35416. private _currentInstanceBuffers;
  35417. private _textureUnits;
  35418. /** @hidden */
  35419. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35420. /** @hidden */
  35421. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35422. /** @hidden */
  35423. _boundRenderFunction: any;
  35424. private _vaoRecordInProgress;
  35425. private _mustWipeVertexAttributes;
  35426. private _emptyTexture;
  35427. private _emptyCubeTexture;
  35428. private _emptyTexture3D;
  35429. private _emptyTexture2DArray;
  35430. /** @hidden */
  35431. _frameHandler: number;
  35432. private _nextFreeTextureSlots;
  35433. private _maxSimultaneousTextures;
  35434. private _activeRequests;
  35435. /** @hidden */
  35436. _transformTextureUrl: Nullable<(url: string) => string>;
  35437. /**
  35438. * Gets information about the current host
  35439. */
  35440. hostInformation: HostInformation;
  35441. protected get _supportsHardwareTextureRescaling(): boolean;
  35442. private _framebufferDimensionsObject;
  35443. /**
  35444. * sets the object from which width and height will be taken from when getting render width and height
  35445. * Will fallback to the gl object
  35446. * @param dimensions the framebuffer width and height that will be used.
  35447. */
  35448. set framebufferDimensionsObject(dimensions: Nullable<{
  35449. framebufferWidth: number;
  35450. framebufferHeight: number;
  35451. }>);
  35452. /**
  35453. * Gets the current viewport
  35454. */
  35455. get currentViewport(): Nullable<IViewportLike>;
  35456. /**
  35457. * Gets the default empty texture
  35458. */
  35459. get emptyTexture(): InternalTexture;
  35460. /**
  35461. * Gets the default empty 3D texture
  35462. */
  35463. get emptyTexture3D(): InternalTexture;
  35464. /**
  35465. * Gets the default empty 2D array texture
  35466. */
  35467. get emptyTexture2DArray(): InternalTexture;
  35468. /**
  35469. * Gets the default empty cube texture
  35470. */
  35471. get emptyCubeTexture(): InternalTexture;
  35472. /**
  35473. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35474. */
  35475. readonly premultipliedAlpha: boolean;
  35476. /**
  35477. * Observable event triggered before each texture is initialized
  35478. */
  35479. onBeforeTextureInitObservable: Observable<Texture>;
  35480. /**
  35481. * Creates a new engine
  35482. * @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
  35483. * @param antialias defines enable antialiasing (default: false)
  35484. * @param options defines further options to be sent to the getContext() function
  35485. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35486. */
  35487. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35488. private _rebuildInternalTextures;
  35489. private _rebuildEffects;
  35490. /**
  35491. * Gets a boolean indicating if all created effects are ready
  35492. * @returns true if all effects are ready
  35493. */
  35494. areAllEffectsReady(): boolean;
  35495. protected _rebuildBuffers(): void;
  35496. protected _initGLContext(): void;
  35497. /**
  35498. * Gets version of the current webGL context
  35499. */
  35500. get webGLVersion(): number;
  35501. /**
  35502. * Gets a string identifying the name of the class
  35503. * @returns "Engine" string
  35504. */
  35505. getClassName(): string;
  35506. /**
  35507. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35508. */
  35509. get isStencilEnable(): boolean;
  35510. /** @hidden */
  35511. _prepareWorkingCanvas(): void;
  35512. /**
  35513. * Reset the texture cache to empty state
  35514. */
  35515. resetTextureCache(): void;
  35516. /**
  35517. * Gets an object containing information about the current webGL context
  35518. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35519. */
  35520. getGlInfo(): {
  35521. vendor: string;
  35522. renderer: string;
  35523. version: string;
  35524. };
  35525. /**
  35526. * Defines the hardware scaling level.
  35527. * By default the hardware scaling level is computed from the window device ratio.
  35528. * 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.
  35529. * @param level defines the level to use
  35530. */
  35531. setHardwareScalingLevel(level: number): void;
  35532. /**
  35533. * Gets the current hardware scaling level.
  35534. * By default the hardware scaling level is computed from the window device ratio.
  35535. * 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.
  35536. * @returns a number indicating the current hardware scaling level
  35537. */
  35538. getHardwareScalingLevel(): number;
  35539. /**
  35540. * Gets the list of loaded textures
  35541. * @returns an array containing all loaded textures
  35542. */
  35543. getLoadedTexturesCache(): InternalTexture[];
  35544. /**
  35545. * Gets the object containing all engine capabilities
  35546. * @returns the EngineCapabilities object
  35547. */
  35548. getCaps(): EngineCapabilities;
  35549. /**
  35550. * stop executing a render loop function and remove it from the execution array
  35551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35552. */
  35553. stopRenderLoop(renderFunction?: () => void): void;
  35554. /** @hidden */
  35555. _renderLoop(): void;
  35556. /**
  35557. * Gets the HTML canvas attached with the current webGL context
  35558. * @returns a HTML canvas
  35559. */
  35560. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35561. /**
  35562. * Gets host window
  35563. * @returns the host window object
  35564. */
  35565. getHostWindow(): Nullable<Window>;
  35566. /**
  35567. * Gets the current render width
  35568. * @param useScreen defines if screen size must be used (or the current render target if any)
  35569. * @returns a number defining the current render width
  35570. */
  35571. getRenderWidth(useScreen?: boolean): number;
  35572. /**
  35573. * Gets the current render height
  35574. * @param useScreen defines if screen size must be used (or the current render target if any)
  35575. * @returns a number defining the current render height
  35576. */
  35577. getRenderHeight(useScreen?: boolean): number;
  35578. /**
  35579. * Can be used to override the current requestAnimationFrame requester.
  35580. * @hidden
  35581. */
  35582. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35583. /**
  35584. * Register and execute a render loop. The engine can have more than one render function
  35585. * @param renderFunction defines the function to continuously execute
  35586. */
  35587. runRenderLoop(renderFunction: () => void): void;
  35588. /**
  35589. * Clear the current render buffer or the current render target (if any is set up)
  35590. * @param color defines the color to use
  35591. * @param backBuffer defines if the back buffer must be cleared
  35592. * @param depth defines if the depth buffer must be cleared
  35593. * @param stencil defines if the stencil buffer must be cleared
  35594. */
  35595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35596. private _viewportCached;
  35597. /** @hidden */
  35598. _viewport(x: number, y: number, width: number, height: number): void;
  35599. /**
  35600. * Set the WebGL's viewport
  35601. * @param viewport defines the viewport element to be used
  35602. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35603. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35604. */
  35605. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35606. /**
  35607. * Begin a new frame
  35608. */
  35609. beginFrame(): void;
  35610. /**
  35611. * Enf the current frame
  35612. */
  35613. endFrame(): void;
  35614. /**
  35615. * Resize the view according to the canvas' size
  35616. */
  35617. resize(): void;
  35618. /**
  35619. * Force a specific size of the canvas
  35620. * @param width defines the new canvas' width
  35621. * @param height defines the new canvas' height
  35622. * @returns true if the size was changed
  35623. */
  35624. setSize(width: number, height: number): boolean;
  35625. /**
  35626. * Binds the frame buffer to the specified texture.
  35627. * @param texture The texture to render to or null for the default canvas
  35628. * @param faceIndex The face of the texture to render to in case of cube texture
  35629. * @param requiredWidth The width of the target to render to
  35630. * @param requiredHeight The height of the target to render to
  35631. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35632. * @param lodLevel defines the lod level to bind to the frame buffer
  35633. * @param layer defines the 2d array index to bind to frame buffer to
  35634. */
  35635. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35636. /** @hidden */
  35637. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35638. /**
  35639. * Unbind the current render target texture from the webGL context
  35640. * @param texture defines the render target texture to unbind
  35641. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35642. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35643. */
  35644. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35645. /**
  35646. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35647. */
  35648. flushFramebuffer(): void;
  35649. /**
  35650. * Unbind the current render target and bind the default framebuffer
  35651. */
  35652. restoreDefaultFramebuffer(): void;
  35653. /** @hidden */
  35654. protected _resetVertexBufferBinding(): void;
  35655. /**
  35656. * Creates a vertex buffer
  35657. * @param data the data for the vertex buffer
  35658. * @returns the new WebGL static buffer
  35659. */
  35660. createVertexBuffer(data: DataArray): DataBuffer;
  35661. private _createVertexBuffer;
  35662. /**
  35663. * Creates a dynamic vertex buffer
  35664. * @param data the data for the dynamic vertex buffer
  35665. * @returns the new WebGL dynamic buffer
  35666. */
  35667. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35668. protected _resetIndexBufferBinding(): void;
  35669. /**
  35670. * Creates a new index buffer
  35671. * @param indices defines the content of the index buffer
  35672. * @param updatable defines if the index buffer must be updatable
  35673. * @returns a new webGL buffer
  35674. */
  35675. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35676. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35677. /**
  35678. * Bind a webGL buffer to the webGL context
  35679. * @param buffer defines the buffer to bind
  35680. */
  35681. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35682. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35683. private bindBuffer;
  35684. /**
  35685. * update the bound buffer with the given data
  35686. * @param data defines the data to update
  35687. */
  35688. updateArrayBuffer(data: Float32Array): void;
  35689. private _vertexAttribPointer;
  35690. /** @hidden */
  35691. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35692. private _bindVertexBuffersAttributes;
  35693. /**
  35694. * Records a vertex array object
  35695. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35696. * @param vertexBuffers defines the list of vertex buffers to store
  35697. * @param indexBuffer defines the index buffer to store
  35698. * @param effect defines the effect to store
  35699. * @returns the new vertex array object
  35700. */
  35701. recordVertexArrayObject(vertexBuffers: {
  35702. [key: string]: VertexBuffer;
  35703. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35704. /**
  35705. * Bind a specific vertex array object
  35706. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35707. * @param vertexArrayObject defines the vertex array object to bind
  35708. * @param indexBuffer defines the index buffer to bind
  35709. */
  35710. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35711. /**
  35712. * Bind webGl buffers directly to the webGL context
  35713. * @param vertexBuffer defines the vertex buffer to bind
  35714. * @param indexBuffer defines the index buffer to bind
  35715. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35716. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35717. * @param effect defines the effect associated with the vertex buffer
  35718. */
  35719. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35720. private _unbindVertexArrayObject;
  35721. /**
  35722. * Bind a list of vertex buffers to the webGL context
  35723. * @param vertexBuffers defines the list of vertex buffers to bind
  35724. * @param indexBuffer defines the index buffer to bind
  35725. * @param effect defines the effect associated with the vertex buffers
  35726. */
  35727. bindBuffers(vertexBuffers: {
  35728. [key: string]: Nullable<VertexBuffer>;
  35729. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35730. /**
  35731. * Unbind all instance attributes
  35732. */
  35733. unbindInstanceAttributes(): void;
  35734. /**
  35735. * Release and free the memory of a vertex array object
  35736. * @param vao defines the vertex array object to delete
  35737. */
  35738. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35739. /** @hidden */
  35740. _releaseBuffer(buffer: DataBuffer): boolean;
  35741. protected _deleteBuffer(buffer: DataBuffer): void;
  35742. /**
  35743. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35744. * @param instancesBuffer defines the webGL buffer to update and bind
  35745. * @param data defines the data to store in the buffer
  35746. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35747. */
  35748. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35749. /**
  35750. * Bind the content of a webGL buffer used with instantiation
  35751. * @param instancesBuffer defines the webGL buffer to bind
  35752. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35753. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35754. */
  35755. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35756. /**
  35757. * Disable the instance attribute corresponding to the name in parameter
  35758. * @param name defines the name of the attribute to disable
  35759. */
  35760. disableInstanceAttributeByName(name: string): void;
  35761. /**
  35762. * Disable the instance attribute corresponding to the location in parameter
  35763. * @param attributeLocation defines the attribute location of the attribute to disable
  35764. */
  35765. disableInstanceAttribute(attributeLocation: number): void;
  35766. /**
  35767. * Disable the attribute corresponding to the location in parameter
  35768. * @param attributeLocation defines the attribute location of the attribute to disable
  35769. */
  35770. disableAttributeByIndex(attributeLocation: number): void;
  35771. /**
  35772. * Send a draw order
  35773. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35774. * @param indexStart defines the starting index
  35775. * @param indexCount defines the number of index to draw
  35776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35777. */
  35778. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35779. /**
  35780. * Draw a list of points
  35781. * @param verticesStart defines the index of first vertex to draw
  35782. * @param verticesCount defines the count of vertices to draw
  35783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35784. */
  35785. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35786. /**
  35787. * Draw a list of unindexed primitives
  35788. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35789. * @param verticesStart defines the index of first vertex to draw
  35790. * @param verticesCount defines the count of vertices to draw
  35791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35792. */
  35793. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35794. /**
  35795. * Draw a list of indexed primitives
  35796. * @param fillMode defines the primitive to use
  35797. * @param indexStart defines the starting index
  35798. * @param indexCount defines the number of index to draw
  35799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35800. */
  35801. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35802. /**
  35803. * Draw a list of unindexed primitives
  35804. * @param fillMode defines the primitive to use
  35805. * @param verticesStart defines the index of first vertex to draw
  35806. * @param verticesCount defines the count of vertices to draw
  35807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35808. */
  35809. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35810. private _drawMode;
  35811. /** @hidden */
  35812. protected _reportDrawCall(): void;
  35813. /** @hidden */
  35814. _releaseEffect(effect: Effect): void;
  35815. /** @hidden */
  35816. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35817. /**
  35818. * Create a new effect (used to store vertex/fragment shaders)
  35819. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35820. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35821. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35822. * @param samplers defines an array of string used to represent textures
  35823. * @param defines defines the string containing the defines to use to compile the shaders
  35824. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35825. * @param onCompiled defines a function to call when the effect creation is successful
  35826. * @param onError defines a function to call when the effect creation has failed
  35827. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35828. * @returns the new Effect
  35829. */
  35830. 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;
  35831. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35832. private _compileShader;
  35833. private _compileRawShader;
  35834. /** @hidden */
  35835. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35836. /**
  35837. * Directly creates a webGL program
  35838. * @param pipelineContext defines the pipeline context to attach to
  35839. * @param vertexCode defines the vertex shader code to use
  35840. * @param fragmentCode defines the fragment shader code to use
  35841. * @param context defines the webGL context to use (if not set, the current one will be used)
  35842. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35843. * @returns the new webGL program
  35844. */
  35845. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35846. /**
  35847. * Creates a webGL program
  35848. * @param pipelineContext defines the pipeline context to attach to
  35849. * @param vertexCode defines the vertex shader code to use
  35850. * @param fragmentCode defines the fragment shader code to use
  35851. * @param defines defines the string containing the defines to use to compile the shaders
  35852. * @param context defines the webGL context to use (if not set, the current one will be used)
  35853. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35854. * @returns the new webGL program
  35855. */
  35856. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35857. /**
  35858. * Creates a new pipeline context
  35859. * @returns the new pipeline
  35860. */
  35861. createPipelineContext(): IPipelineContext;
  35862. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35863. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35864. /** @hidden */
  35865. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35866. /** @hidden */
  35867. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35868. /** @hidden */
  35869. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35870. /**
  35871. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35872. * @param pipelineContext defines the pipeline context to use
  35873. * @param uniformsNames defines the list of uniform names
  35874. * @returns an array of webGL uniform locations
  35875. */
  35876. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35877. /**
  35878. * Gets the lsit of active attributes for a given webGL program
  35879. * @param pipelineContext defines the pipeline context to use
  35880. * @param attributesNames defines the list of attribute names to get
  35881. * @returns an array of indices indicating the offset of each attribute
  35882. */
  35883. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35884. /**
  35885. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35886. * @param effect defines the effect to activate
  35887. */
  35888. enableEffect(effect: Nullable<Effect>): void;
  35889. /**
  35890. * Set the value of an uniform to a number (int)
  35891. * @param uniform defines the webGL uniform location where to store the value
  35892. * @param value defines the int number to store
  35893. */
  35894. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35895. /**
  35896. * Set the value of an uniform to an array of int32
  35897. * @param uniform defines the webGL uniform location where to store the value
  35898. * @param array defines the array of int32 to store
  35899. */
  35900. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35901. /**
  35902. * Set the value of an uniform to an array of int32 (stored as vec2)
  35903. * @param uniform defines the webGL uniform location where to store the value
  35904. * @param array defines the array of int32 to store
  35905. */
  35906. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35907. /**
  35908. * Set the value of an uniform to an array of int32 (stored as vec3)
  35909. * @param uniform defines the webGL uniform location where to store the value
  35910. * @param array defines the array of int32 to store
  35911. */
  35912. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35913. /**
  35914. * Set the value of an uniform to an array of int32 (stored as vec4)
  35915. * @param uniform defines the webGL uniform location where to store the value
  35916. * @param array defines the array of int32 to store
  35917. */
  35918. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35919. /**
  35920. * Set the value of an uniform to an array of number
  35921. * @param uniform defines the webGL uniform location where to store the value
  35922. * @param array defines the array of number to store
  35923. */
  35924. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35925. /**
  35926. * Set the value of an uniform to an array of number (stored as vec2)
  35927. * @param uniform defines the webGL uniform location where to store the value
  35928. * @param array defines the array of number to store
  35929. */
  35930. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35931. /**
  35932. * Set the value of an uniform to an array of number (stored as vec3)
  35933. * @param uniform defines the webGL uniform location where to store the value
  35934. * @param array defines the array of number to store
  35935. */
  35936. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35937. /**
  35938. * Set the value of an uniform to an array of number (stored as vec4)
  35939. * @param uniform defines the webGL uniform location where to store the value
  35940. * @param array defines the array of number to store
  35941. */
  35942. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35943. /**
  35944. * Set the value of an uniform to an array of float32 (stored as matrices)
  35945. * @param uniform defines the webGL uniform location where to store the value
  35946. * @param matrices defines the array of float32 to store
  35947. */
  35948. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35949. /**
  35950. * Set the value of an uniform to a matrix (3x3)
  35951. * @param uniform defines the webGL uniform location where to store the value
  35952. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35953. */
  35954. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35955. /**
  35956. * Set the value of an uniform to a matrix (2x2)
  35957. * @param uniform defines the webGL uniform location where to store the value
  35958. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35959. */
  35960. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35961. /**
  35962. * Set the value of an uniform to a number (float)
  35963. * @param uniform defines the webGL uniform location where to store the value
  35964. * @param value defines the float number to store
  35965. */
  35966. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35967. /**
  35968. * Set the value of an uniform to a vec2
  35969. * @param uniform defines the webGL uniform location where to store the value
  35970. * @param x defines the 1st component of the value
  35971. * @param y defines the 2nd component of the value
  35972. */
  35973. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35974. /**
  35975. * Set the value of an uniform to a vec3
  35976. * @param uniform defines the webGL uniform location where to store the value
  35977. * @param x defines the 1st component of the value
  35978. * @param y defines the 2nd component of the value
  35979. * @param z defines the 3rd component of the value
  35980. */
  35981. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35982. /**
  35983. * Set the value of an uniform to a vec4
  35984. * @param uniform defines the webGL uniform location where to store the value
  35985. * @param x defines the 1st component of the value
  35986. * @param y defines the 2nd component of the value
  35987. * @param z defines the 3rd component of the value
  35988. * @param w defines the 4th component of the value
  35989. */
  35990. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35991. /**
  35992. * Apply all cached states (depth, culling, stencil and alpha)
  35993. */
  35994. applyStates(): void;
  35995. /**
  35996. * Enable or disable color writing
  35997. * @param enable defines the state to set
  35998. */
  35999. setColorWrite(enable: boolean): void;
  36000. /**
  36001. * Gets a boolean indicating if color writing is enabled
  36002. * @returns the current color writing state
  36003. */
  36004. getColorWrite(): boolean;
  36005. /**
  36006. * Gets the depth culling state manager
  36007. */
  36008. get depthCullingState(): DepthCullingState;
  36009. /**
  36010. * Gets the alpha state manager
  36011. */
  36012. get alphaState(): AlphaState;
  36013. /**
  36014. * Gets the stencil state manager
  36015. */
  36016. get stencilState(): StencilState;
  36017. /**
  36018. * Clears the list of texture accessible through engine.
  36019. * This can help preventing texture load conflict due to name collision.
  36020. */
  36021. clearInternalTexturesCache(): void;
  36022. /**
  36023. * Force the entire cache to be cleared
  36024. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36025. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36026. */
  36027. wipeCaches(bruteForce?: boolean): void;
  36028. /** @hidden */
  36029. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36030. min: number;
  36031. mag: number;
  36032. };
  36033. /** @hidden */
  36034. _createTexture(): WebGLTexture;
  36035. /**
  36036. * Usually called from Texture.ts.
  36037. * Passed information to create a WebGLTexture
  36038. * @param url defines a value which contains one of the following:
  36039. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36040. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36041. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36042. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36043. * @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)
  36044. * @param scene needed for loading to the correct scene
  36045. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36046. * @param onLoad optional callback to be called upon successful completion
  36047. * @param onError optional callback to be called upon failure
  36048. * @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
  36049. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36050. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36051. * @param forcedExtension defines the extension to use to pick the right loader
  36052. * @param mimeType defines an optional mime type
  36053. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36054. */
  36055. 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;
  36056. /**
  36057. * Loads an image as an HTMLImageElement.
  36058. * @param input url string, ArrayBuffer, or Blob to load
  36059. * @param onLoad callback called when the image successfully loads
  36060. * @param onError callback called when the image fails to load
  36061. * @param offlineProvider offline provider for caching
  36062. * @param mimeType optional mime type
  36063. * @returns the HTMLImageElement of the loaded image
  36064. * @hidden
  36065. */
  36066. 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>;
  36067. /**
  36068. * @hidden
  36069. */
  36070. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36071. private _unpackFlipYCached;
  36072. /**
  36073. * In case you are sharing the context with other applications, it might
  36074. * be interested to not cache the unpack flip y state to ensure a consistent
  36075. * value would be set.
  36076. */
  36077. enableUnpackFlipYCached: boolean;
  36078. /** @hidden */
  36079. _unpackFlipY(value: boolean): void;
  36080. /** @hidden */
  36081. _getUnpackAlignement(): number;
  36082. private _getTextureTarget;
  36083. /**
  36084. * Update the sampling mode of a given texture
  36085. * @param samplingMode defines the required sampling mode
  36086. * @param texture defines the texture to update
  36087. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36088. */
  36089. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36090. /**
  36091. * Update the sampling mode of a given texture
  36092. * @param texture defines the texture to update
  36093. * @param wrapU defines the texture wrap mode of the u coordinates
  36094. * @param wrapV defines the texture wrap mode of the v coordinates
  36095. * @param wrapR defines the texture wrap mode of the r coordinates
  36096. */
  36097. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36098. /** @hidden */
  36099. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36100. width: number;
  36101. height: number;
  36102. layers?: number;
  36103. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36104. /** @hidden */
  36105. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36106. /** @hidden */
  36107. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36108. /**
  36109. * Update a portion of an internal texture
  36110. * @param texture defines the texture to update
  36111. * @param imageData defines the data to store into the texture
  36112. * @param xOffset defines the x coordinates of the update rectangle
  36113. * @param yOffset defines the y coordinates of the update rectangle
  36114. * @param width defines the width of the update rectangle
  36115. * @param height defines the height of the update rectangle
  36116. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36117. * @param lod defines the lod level to update (0 by default)
  36118. */
  36119. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36120. /** @hidden */
  36121. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36122. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36123. private _prepareWebGLTexture;
  36124. /** @hidden */
  36125. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36126. private _getDepthStencilBuffer;
  36127. /** @hidden */
  36128. _releaseFramebufferObjects(texture: InternalTexture): void;
  36129. /** @hidden */
  36130. _releaseTexture(texture: InternalTexture): void;
  36131. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36132. protected _setProgram(program: WebGLProgram): void;
  36133. protected _boundUniforms: {
  36134. [key: number]: WebGLUniformLocation;
  36135. };
  36136. /**
  36137. * Binds an effect to the webGL context
  36138. * @param effect defines the effect to bind
  36139. */
  36140. bindSamplers(effect: Effect): void;
  36141. private _activateCurrentTexture;
  36142. /** @hidden */
  36143. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36144. /** @hidden */
  36145. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36146. /**
  36147. * Unbind all textures from the webGL context
  36148. */
  36149. unbindAllTextures(): void;
  36150. /**
  36151. * Sets a texture to the according uniform.
  36152. * @param channel The texture channel
  36153. * @param uniform The uniform to set
  36154. * @param texture The texture to apply
  36155. */
  36156. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36157. private _bindSamplerUniformToChannel;
  36158. private _getTextureWrapMode;
  36159. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36160. /**
  36161. * Sets an array of texture to the webGL context
  36162. * @param channel defines the channel where the texture array must be set
  36163. * @param uniform defines the associated uniform location
  36164. * @param textures defines the array of textures to bind
  36165. */
  36166. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36167. /** @hidden */
  36168. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36169. private _setTextureParameterFloat;
  36170. private _setTextureParameterInteger;
  36171. /**
  36172. * Unbind all vertex attributes from the webGL context
  36173. */
  36174. unbindAllAttributes(): void;
  36175. /**
  36176. * 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
  36177. */
  36178. releaseEffects(): void;
  36179. /**
  36180. * Dispose and release all associated resources
  36181. */
  36182. dispose(): void;
  36183. /**
  36184. * Attach a new callback raised when context lost event is fired
  36185. * @param callback defines the callback to call
  36186. */
  36187. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36188. /**
  36189. * Attach a new callback raised when context restored event is fired
  36190. * @param callback defines the callback to call
  36191. */
  36192. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36193. /**
  36194. * Get the current error code of the webGL context
  36195. * @returns the error code
  36196. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36197. */
  36198. getError(): number;
  36199. private _canRenderToFloatFramebuffer;
  36200. private _canRenderToHalfFloatFramebuffer;
  36201. private _canRenderToFramebuffer;
  36202. /** @hidden */
  36203. _getWebGLTextureType(type: number): number;
  36204. /** @hidden */
  36205. _getInternalFormat(format: number): number;
  36206. /** @hidden */
  36207. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36208. /** @hidden */
  36209. _getRGBAMultiSampleBufferFormat(type: number): number;
  36210. /** @hidden */
  36211. _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;
  36212. /**
  36213. * Loads a file from a url
  36214. * @param url url to load
  36215. * @param onSuccess callback called when the file successfully loads
  36216. * @param onProgress callback called while file is loading (if the server supports this mode)
  36217. * @param offlineProvider defines the offline provider for caching
  36218. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36219. * @param onError callback called when the file fails to load
  36220. * @returns a file request object
  36221. * @hidden
  36222. */
  36223. 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;
  36224. /**
  36225. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36226. * @param x defines the x coordinate of the rectangle where pixels must be read
  36227. * @param y defines the y coordinate of the rectangle where pixels must be read
  36228. * @param width defines the width of the rectangle where pixels must be read
  36229. * @param height defines the height of the rectangle where pixels must be read
  36230. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36231. * @returns a Uint8Array containing RGBA colors
  36232. */
  36233. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36234. private static _isSupported;
  36235. /**
  36236. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36237. * @returns true if the engine can be created
  36238. * @ignorenaming
  36239. */
  36240. static isSupported(): boolean;
  36241. /**
  36242. * Find the next highest power of two.
  36243. * @param x Number to start search from.
  36244. * @return Next highest power of two.
  36245. */
  36246. static CeilingPOT(x: number): number;
  36247. /**
  36248. * Find the next lowest power of two.
  36249. * @param x Number to start search from.
  36250. * @return Next lowest power of two.
  36251. */
  36252. static FloorPOT(x: number): number;
  36253. /**
  36254. * Find the nearest power of two.
  36255. * @param x Number to start search from.
  36256. * @return Next nearest power of two.
  36257. */
  36258. static NearestPOT(x: number): number;
  36259. /**
  36260. * Get the closest exponent of two
  36261. * @param value defines the value to approximate
  36262. * @param max defines the maximum value to return
  36263. * @param mode defines how to define the closest value
  36264. * @returns closest exponent of two of the given value
  36265. */
  36266. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36267. /**
  36268. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36269. * @param func - the function to be called
  36270. * @param requester - the object that will request the next frame. Falls back to window.
  36271. * @returns frame number
  36272. */
  36273. static QueueNewFrame(func: () => void, requester?: any): number;
  36274. /**
  36275. * Gets host document
  36276. * @returns the host document object
  36277. */
  36278. getHostDocument(): Nullable<Document>;
  36279. }
  36280. }
  36281. declare module BABYLON {
  36282. /**
  36283. * Class representing spherical harmonics coefficients to the 3rd degree
  36284. */
  36285. export class SphericalHarmonics {
  36286. /**
  36287. * Defines whether or not the harmonics have been prescaled for rendering.
  36288. */
  36289. preScaled: boolean;
  36290. /**
  36291. * The l0,0 coefficients of the spherical harmonics
  36292. */
  36293. l00: Vector3;
  36294. /**
  36295. * The l1,-1 coefficients of the spherical harmonics
  36296. */
  36297. l1_1: Vector3;
  36298. /**
  36299. * The l1,0 coefficients of the spherical harmonics
  36300. */
  36301. l10: Vector3;
  36302. /**
  36303. * The l1,1 coefficients of the spherical harmonics
  36304. */
  36305. l11: Vector3;
  36306. /**
  36307. * The l2,-2 coefficients of the spherical harmonics
  36308. */
  36309. l2_2: Vector3;
  36310. /**
  36311. * The l2,-1 coefficients of the spherical harmonics
  36312. */
  36313. l2_1: Vector3;
  36314. /**
  36315. * The l2,0 coefficients of the spherical harmonics
  36316. */
  36317. l20: Vector3;
  36318. /**
  36319. * The l2,1 coefficients of the spherical harmonics
  36320. */
  36321. l21: Vector3;
  36322. /**
  36323. * The l2,2 coefficients of the spherical harmonics
  36324. */
  36325. l22: Vector3;
  36326. /**
  36327. * Adds a light to the spherical harmonics
  36328. * @param direction the direction of the light
  36329. * @param color the color of the light
  36330. * @param deltaSolidAngle the delta solid angle of the light
  36331. */
  36332. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36333. /**
  36334. * Scales the spherical harmonics by the given amount
  36335. * @param scale the amount to scale
  36336. */
  36337. scaleInPlace(scale: number): void;
  36338. /**
  36339. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36340. *
  36341. * ```
  36342. * E_lm = A_l * L_lm
  36343. * ```
  36344. *
  36345. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36346. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36347. * the scaling factors are given in equation 9.
  36348. */
  36349. convertIncidentRadianceToIrradiance(): void;
  36350. /**
  36351. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36352. *
  36353. * ```
  36354. * L = (1/pi) * E * rho
  36355. * ```
  36356. *
  36357. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36358. */
  36359. convertIrradianceToLambertianRadiance(): void;
  36360. /**
  36361. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36362. * required operations at run time.
  36363. *
  36364. * This is simply done by scaling back the SH with Ylm constants parameter.
  36365. * The trigonometric part being applied by the shader at run time.
  36366. */
  36367. preScaleForRendering(): void;
  36368. /**
  36369. * Constructs a spherical harmonics from an array.
  36370. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36371. * @returns the spherical harmonics
  36372. */
  36373. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36374. /**
  36375. * Gets the spherical harmonics from polynomial
  36376. * @param polynomial the spherical polynomial
  36377. * @returns the spherical harmonics
  36378. */
  36379. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36380. }
  36381. /**
  36382. * Class representing spherical polynomial coefficients to the 3rd degree
  36383. */
  36384. export class SphericalPolynomial {
  36385. private _harmonics;
  36386. /**
  36387. * The spherical harmonics used to create the polynomials.
  36388. */
  36389. get preScaledHarmonics(): SphericalHarmonics;
  36390. /**
  36391. * The x coefficients of the spherical polynomial
  36392. */
  36393. x: Vector3;
  36394. /**
  36395. * The y coefficients of the spherical polynomial
  36396. */
  36397. y: Vector3;
  36398. /**
  36399. * The z coefficients of the spherical polynomial
  36400. */
  36401. z: Vector3;
  36402. /**
  36403. * The xx coefficients of the spherical polynomial
  36404. */
  36405. xx: Vector3;
  36406. /**
  36407. * The yy coefficients of the spherical polynomial
  36408. */
  36409. yy: Vector3;
  36410. /**
  36411. * The zz coefficients of the spherical polynomial
  36412. */
  36413. zz: Vector3;
  36414. /**
  36415. * The xy coefficients of the spherical polynomial
  36416. */
  36417. xy: Vector3;
  36418. /**
  36419. * The yz coefficients of the spherical polynomial
  36420. */
  36421. yz: Vector3;
  36422. /**
  36423. * The zx coefficients of the spherical polynomial
  36424. */
  36425. zx: Vector3;
  36426. /**
  36427. * Adds an ambient color to the spherical polynomial
  36428. * @param color the color to add
  36429. */
  36430. addAmbient(color: Color3): void;
  36431. /**
  36432. * Scales the spherical polynomial by the given amount
  36433. * @param scale the amount to scale
  36434. */
  36435. scaleInPlace(scale: number): void;
  36436. /**
  36437. * Gets the spherical polynomial from harmonics
  36438. * @param harmonics the spherical harmonics
  36439. * @returns the spherical polynomial
  36440. */
  36441. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36442. /**
  36443. * Constructs a spherical polynomial from an array.
  36444. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36445. * @returns the spherical polynomial
  36446. */
  36447. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36448. }
  36449. }
  36450. declare module BABYLON {
  36451. /**
  36452. * Defines the source of the internal texture
  36453. */
  36454. export enum InternalTextureSource {
  36455. /**
  36456. * The source of the texture data is unknown
  36457. */
  36458. Unknown = 0,
  36459. /**
  36460. * Texture data comes from an URL
  36461. */
  36462. Url = 1,
  36463. /**
  36464. * Texture data is only used for temporary storage
  36465. */
  36466. Temp = 2,
  36467. /**
  36468. * Texture data comes from raw data (ArrayBuffer)
  36469. */
  36470. Raw = 3,
  36471. /**
  36472. * Texture content is dynamic (video or dynamic texture)
  36473. */
  36474. Dynamic = 4,
  36475. /**
  36476. * Texture content is generated by rendering to it
  36477. */
  36478. RenderTarget = 5,
  36479. /**
  36480. * Texture content is part of a multi render target process
  36481. */
  36482. MultiRenderTarget = 6,
  36483. /**
  36484. * Texture data comes from a cube data file
  36485. */
  36486. Cube = 7,
  36487. /**
  36488. * Texture data comes from a raw cube data
  36489. */
  36490. CubeRaw = 8,
  36491. /**
  36492. * Texture data come from a prefiltered cube data file
  36493. */
  36494. CubePrefiltered = 9,
  36495. /**
  36496. * Texture content is raw 3D data
  36497. */
  36498. Raw3D = 10,
  36499. /**
  36500. * Texture content is raw 2D array data
  36501. */
  36502. Raw2DArray = 11,
  36503. /**
  36504. * Texture content is a depth texture
  36505. */
  36506. Depth = 12,
  36507. /**
  36508. * Texture data comes from a raw cube data encoded with RGBD
  36509. */
  36510. CubeRawRGBD = 13
  36511. }
  36512. /**
  36513. * Class used to store data associated with WebGL texture data for the engine
  36514. * This class should not be used directly
  36515. */
  36516. export class InternalTexture {
  36517. /** @hidden */
  36518. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36519. /**
  36520. * Defines if the texture is ready
  36521. */
  36522. isReady: boolean;
  36523. /**
  36524. * Defines if the texture is a cube texture
  36525. */
  36526. isCube: boolean;
  36527. /**
  36528. * Defines if the texture contains 3D data
  36529. */
  36530. is3D: boolean;
  36531. /**
  36532. * Defines if the texture contains 2D array data
  36533. */
  36534. is2DArray: boolean;
  36535. /**
  36536. * Defines if the texture contains multiview data
  36537. */
  36538. isMultiview: boolean;
  36539. /**
  36540. * Gets the URL used to load this texture
  36541. */
  36542. url: string;
  36543. /**
  36544. * Gets the sampling mode of the texture
  36545. */
  36546. samplingMode: number;
  36547. /**
  36548. * Gets a boolean indicating if the texture needs mipmaps generation
  36549. */
  36550. generateMipMaps: boolean;
  36551. /**
  36552. * Gets the number of samples used by the texture (WebGL2+ only)
  36553. */
  36554. samples: number;
  36555. /**
  36556. * Gets the type of the texture (int, float...)
  36557. */
  36558. type: number;
  36559. /**
  36560. * Gets the format of the texture (RGB, RGBA...)
  36561. */
  36562. format: number;
  36563. /**
  36564. * Observable called when the texture is loaded
  36565. */
  36566. onLoadedObservable: Observable<InternalTexture>;
  36567. /**
  36568. * Gets the width of the texture
  36569. */
  36570. width: number;
  36571. /**
  36572. * Gets the height of the texture
  36573. */
  36574. height: number;
  36575. /**
  36576. * Gets the depth of the texture
  36577. */
  36578. depth: number;
  36579. /**
  36580. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36581. */
  36582. baseWidth: number;
  36583. /**
  36584. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36585. */
  36586. baseHeight: number;
  36587. /**
  36588. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36589. */
  36590. baseDepth: number;
  36591. /**
  36592. * Gets a boolean indicating if the texture is inverted on Y axis
  36593. */
  36594. invertY: boolean;
  36595. /** @hidden */
  36596. _invertVScale: boolean;
  36597. /** @hidden */
  36598. _associatedChannel: number;
  36599. /** @hidden */
  36600. _source: InternalTextureSource;
  36601. /** @hidden */
  36602. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36603. /** @hidden */
  36604. _bufferView: Nullable<ArrayBufferView>;
  36605. /** @hidden */
  36606. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36607. /** @hidden */
  36608. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36609. /** @hidden */
  36610. _size: number;
  36611. /** @hidden */
  36612. _extension: string;
  36613. /** @hidden */
  36614. _files: Nullable<string[]>;
  36615. /** @hidden */
  36616. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36617. /** @hidden */
  36618. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36619. /** @hidden */
  36620. _framebuffer: Nullable<WebGLFramebuffer>;
  36621. /** @hidden */
  36622. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36623. /** @hidden */
  36624. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36625. /** @hidden */
  36626. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36627. /** @hidden */
  36628. _attachments: Nullable<number[]>;
  36629. /** @hidden */
  36630. _textureArray: Nullable<InternalTexture[]>;
  36631. /** @hidden */
  36632. _cachedCoordinatesMode: Nullable<number>;
  36633. /** @hidden */
  36634. _cachedWrapU: Nullable<number>;
  36635. /** @hidden */
  36636. _cachedWrapV: Nullable<number>;
  36637. /** @hidden */
  36638. _cachedWrapR: Nullable<number>;
  36639. /** @hidden */
  36640. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36641. /** @hidden */
  36642. _isDisabled: boolean;
  36643. /** @hidden */
  36644. _compression: Nullable<string>;
  36645. /** @hidden */
  36646. _generateStencilBuffer: boolean;
  36647. /** @hidden */
  36648. _generateDepthBuffer: boolean;
  36649. /** @hidden */
  36650. _comparisonFunction: number;
  36651. /** @hidden */
  36652. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36653. /** @hidden */
  36654. _lodGenerationScale: number;
  36655. /** @hidden */
  36656. _lodGenerationOffset: number;
  36657. /** @hidden */
  36658. _depthStencilTexture: Nullable<InternalTexture>;
  36659. /** @hidden */
  36660. _colorTextureArray: Nullable<WebGLTexture>;
  36661. /** @hidden */
  36662. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36663. /** @hidden */
  36664. _lodTextureHigh: Nullable<BaseTexture>;
  36665. /** @hidden */
  36666. _lodTextureMid: Nullable<BaseTexture>;
  36667. /** @hidden */
  36668. _lodTextureLow: Nullable<BaseTexture>;
  36669. /** @hidden */
  36670. _isRGBD: boolean;
  36671. /** @hidden */
  36672. _linearSpecularLOD: boolean;
  36673. /** @hidden */
  36674. _irradianceTexture: Nullable<BaseTexture>;
  36675. /** @hidden */
  36676. _webGLTexture: Nullable<WebGLTexture>;
  36677. /** @hidden */
  36678. _references: number;
  36679. private _engine;
  36680. /**
  36681. * Gets the Engine the texture belongs to.
  36682. * @returns The babylon engine
  36683. */
  36684. getEngine(): ThinEngine;
  36685. /**
  36686. * Gets the data source type of the texture
  36687. */
  36688. get source(): InternalTextureSource;
  36689. /**
  36690. * Creates a new InternalTexture
  36691. * @param engine defines the engine to use
  36692. * @param source defines the type of data that will be used
  36693. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36694. */
  36695. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36696. /**
  36697. * Increments the number of references (ie. the number of Texture that point to it)
  36698. */
  36699. incrementReferences(): void;
  36700. /**
  36701. * Change the size of the texture (not the size of the content)
  36702. * @param width defines the new width
  36703. * @param height defines the new height
  36704. * @param depth defines the new depth (1 by default)
  36705. */
  36706. updateSize(width: int, height: int, depth?: int): void;
  36707. /** @hidden */
  36708. _rebuild(): void;
  36709. /** @hidden */
  36710. _swapAndDie(target: InternalTexture): void;
  36711. /**
  36712. * Dispose the current allocated resources
  36713. */
  36714. dispose(): void;
  36715. }
  36716. }
  36717. declare module BABYLON {
  36718. /**
  36719. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36721. */
  36722. export class Analyser {
  36723. /**
  36724. * Gets or sets the smoothing
  36725. * @ignorenaming
  36726. */
  36727. SMOOTHING: number;
  36728. /**
  36729. * Gets or sets the FFT table size
  36730. * @ignorenaming
  36731. */
  36732. FFT_SIZE: number;
  36733. /**
  36734. * Gets or sets the bar graph amplitude
  36735. * @ignorenaming
  36736. */
  36737. BARGRAPHAMPLITUDE: number;
  36738. /**
  36739. * Gets or sets the position of the debug canvas
  36740. * @ignorenaming
  36741. */
  36742. DEBUGCANVASPOS: {
  36743. x: number;
  36744. y: number;
  36745. };
  36746. /**
  36747. * Gets or sets the debug canvas size
  36748. * @ignorenaming
  36749. */
  36750. DEBUGCANVASSIZE: {
  36751. width: number;
  36752. height: number;
  36753. };
  36754. private _byteFreqs;
  36755. private _byteTime;
  36756. private _floatFreqs;
  36757. private _webAudioAnalyser;
  36758. private _debugCanvas;
  36759. private _debugCanvasContext;
  36760. private _scene;
  36761. private _registerFunc;
  36762. private _audioEngine;
  36763. /**
  36764. * Creates a new analyser
  36765. * @param scene defines hosting scene
  36766. */
  36767. constructor(scene: Scene);
  36768. /**
  36769. * Get the number of data values you will have to play with for the visualization
  36770. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36771. * @returns a number
  36772. */
  36773. getFrequencyBinCount(): number;
  36774. /**
  36775. * Gets the current frequency data as a byte array
  36776. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36777. * @returns a Uint8Array
  36778. */
  36779. getByteFrequencyData(): Uint8Array;
  36780. /**
  36781. * Gets the current waveform as a byte array
  36782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36783. * @returns a Uint8Array
  36784. */
  36785. getByteTimeDomainData(): Uint8Array;
  36786. /**
  36787. * Gets the current frequency data as a float array
  36788. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36789. * @returns a Float32Array
  36790. */
  36791. getFloatFrequencyData(): Float32Array;
  36792. /**
  36793. * Renders the debug canvas
  36794. */
  36795. drawDebugCanvas(): void;
  36796. /**
  36797. * Stops rendering the debug canvas and removes it
  36798. */
  36799. stopDebugCanvas(): void;
  36800. /**
  36801. * Connects two audio nodes
  36802. * @param inputAudioNode defines first node to connect
  36803. * @param outputAudioNode defines second node to connect
  36804. */
  36805. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36806. /**
  36807. * Releases all associated resources
  36808. */
  36809. dispose(): void;
  36810. }
  36811. }
  36812. declare module BABYLON {
  36813. /**
  36814. * This represents an audio engine and it is responsible
  36815. * to play, synchronize and analyse sounds throughout the application.
  36816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36817. */
  36818. export interface IAudioEngine extends IDisposable {
  36819. /**
  36820. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36821. */
  36822. readonly canUseWebAudio: boolean;
  36823. /**
  36824. * Gets the current AudioContext if available.
  36825. */
  36826. readonly audioContext: Nullable<AudioContext>;
  36827. /**
  36828. * The master gain node defines the global audio volume of your audio engine.
  36829. */
  36830. readonly masterGain: GainNode;
  36831. /**
  36832. * Gets whether or not mp3 are supported by your browser.
  36833. */
  36834. readonly isMP3supported: boolean;
  36835. /**
  36836. * Gets whether or not ogg are supported by your browser.
  36837. */
  36838. readonly isOGGsupported: boolean;
  36839. /**
  36840. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36841. * @ignoreNaming
  36842. */
  36843. WarnedWebAudioUnsupported: boolean;
  36844. /**
  36845. * Defines if the audio engine relies on a custom unlocked button.
  36846. * In this case, the embedded button will not be displayed.
  36847. */
  36848. useCustomUnlockedButton: boolean;
  36849. /**
  36850. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36851. */
  36852. readonly unlocked: boolean;
  36853. /**
  36854. * Event raised when audio has been unlocked on the browser.
  36855. */
  36856. onAudioUnlockedObservable: Observable<AudioEngine>;
  36857. /**
  36858. * Event raised when audio has been locked on the browser.
  36859. */
  36860. onAudioLockedObservable: Observable<AudioEngine>;
  36861. /**
  36862. * Flags the audio engine in Locked state.
  36863. * This happens due to new browser policies preventing audio to autoplay.
  36864. */
  36865. lock(): void;
  36866. /**
  36867. * Unlocks the audio engine once a user action has been done on the dom.
  36868. * This is helpful to resume play once browser policies have been satisfied.
  36869. */
  36870. unlock(): void;
  36871. /**
  36872. * Gets the global volume sets on the master gain.
  36873. * @returns the global volume if set or -1 otherwise
  36874. */
  36875. getGlobalVolume(): number;
  36876. /**
  36877. * Sets the global volume of your experience (sets on the master gain).
  36878. * @param newVolume Defines the new global volume of the application
  36879. */
  36880. setGlobalVolume(newVolume: number): void;
  36881. /**
  36882. * Connect the audio engine to an audio analyser allowing some amazing
  36883. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36885. * @param analyser The analyser to connect to the engine
  36886. */
  36887. connectToAnalyser(analyser: Analyser): void;
  36888. }
  36889. /**
  36890. * This represents the default audio engine used in babylon.
  36891. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36892. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36893. */
  36894. export class AudioEngine implements IAudioEngine {
  36895. private _audioContext;
  36896. private _audioContextInitialized;
  36897. private _muteButton;
  36898. private _hostElement;
  36899. /**
  36900. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36901. */
  36902. canUseWebAudio: boolean;
  36903. /**
  36904. * The master gain node defines the global audio volume of your audio engine.
  36905. */
  36906. masterGain: GainNode;
  36907. /**
  36908. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36909. * @ignoreNaming
  36910. */
  36911. WarnedWebAudioUnsupported: boolean;
  36912. /**
  36913. * Gets whether or not mp3 are supported by your browser.
  36914. */
  36915. isMP3supported: boolean;
  36916. /**
  36917. * Gets whether or not ogg are supported by your browser.
  36918. */
  36919. isOGGsupported: boolean;
  36920. /**
  36921. * Gets whether audio has been unlocked on the device.
  36922. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36923. * a user interaction has happened.
  36924. */
  36925. unlocked: boolean;
  36926. /**
  36927. * Defines if the audio engine relies on a custom unlocked button.
  36928. * In this case, the embedded button will not be displayed.
  36929. */
  36930. useCustomUnlockedButton: boolean;
  36931. /**
  36932. * Event raised when audio has been unlocked on the browser.
  36933. */
  36934. onAudioUnlockedObservable: Observable<AudioEngine>;
  36935. /**
  36936. * Event raised when audio has been locked on the browser.
  36937. */
  36938. onAudioLockedObservable: Observable<AudioEngine>;
  36939. /**
  36940. * Gets the current AudioContext if available.
  36941. */
  36942. get audioContext(): Nullable<AudioContext>;
  36943. private _connectedAnalyser;
  36944. /**
  36945. * Instantiates a new audio engine.
  36946. *
  36947. * There should be only one per page as some browsers restrict the number
  36948. * of audio contexts you can create.
  36949. * @param hostElement defines the host element where to display the mute icon if necessary
  36950. */
  36951. constructor(hostElement?: Nullable<HTMLElement>);
  36952. /**
  36953. * Flags the audio engine in Locked state.
  36954. * This happens due to new browser policies preventing audio to autoplay.
  36955. */
  36956. lock(): void;
  36957. /**
  36958. * Unlocks the audio engine once a user action has been done on the dom.
  36959. * This is helpful to resume play once browser policies have been satisfied.
  36960. */
  36961. unlock(): void;
  36962. private _resumeAudioContext;
  36963. private _initializeAudioContext;
  36964. private _tryToRun;
  36965. private _triggerRunningState;
  36966. private _triggerSuspendedState;
  36967. private _displayMuteButton;
  36968. private _moveButtonToTopLeft;
  36969. private _onResize;
  36970. private _hideMuteButton;
  36971. /**
  36972. * Destroy and release the resources associated with the audio ccontext.
  36973. */
  36974. dispose(): void;
  36975. /**
  36976. * Gets the global volume sets on the master gain.
  36977. * @returns the global volume if set or -1 otherwise
  36978. */
  36979. getGlobalVolume(): number;
  36980. /**
  36981. * Sets the global volume of your experience (sets on the master gain).
  36982. * @param newVolume Defines the new global volume of the application
  36983. */
  36984. setGlobalVolume(newVolume: number): void;
  36985. /**
  36986. * Connect the audio engine to an audio analyser allowing some amazing
  36987. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36989. * @param analyser The analyser to connect to the engine
  36990. */
  36991. connectToAnalyser(analyser: Analyser): void;
  36992. }
  36993. }
  36994. declare module BABYLON {
  36995. /**
  36996. * Interface used to present a loading screen while loading a scene
  36997. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36998. */
  36999. export interface ILoadingScreen {
  37000. /**
  37001. * Function called to display the loading screen
  37002. */
  37003. displayLoadingUI: () => void;
  37004. /**
  37005. * Function called to hide the loading screen
  37006. */
  37007. hideLoadingUI: () => void;
  37008. /**
  37009. * Gets or sets the color to use for the background
  37010. */
  37011. loadingUIBackgroundColor: string;
  37012. /**
  37013. * Gets or sets the text to display while loading
  37014. */
  37015. loadingUIText: string;
  37016. }
  37017. /**
  37018. * Class used for the default loading screen
  37019. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37020. */
  37021. export class DefaultLoadingScreen implements ILoadingScreen {
  37022. private _renderingCanvas;
  37023. private _loadingText;
  37024. private _loadingDivBackgroundColor;
  37025. private _loadingDiv;
  37026. private _loadingTextDiv;
  37027. /** Gets or sets the logo url to use for the default loading screen */
  37028. static DefaultLogoUrl: string;
  37029. /** Gets or sets the spinner url to use for the default loading screen */
  37030. static DefaultSpinnerUrl: string;
  37031. /**
  37032. * Creates a new default loading screen
  37033. * @param _renderingCanvas defines the canvas used to render the scene
  37034. * @param _loadingText defines the default text to display
  37035. * @param _loadingDivBackgroundColor defines the default background color
  37036. */
  37037. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37038. /**
  37039. * Function called to display the loading screen
  37040. */
  37041. displayLoadingUI(): void;
  37042. /**
  37043. * Function called to hide the loading screen
  37044. */
  37045. hideLoadingUI(): void;
  37046. /**
  37047. * Gets or sets the text to display while loading
  37048. */
  37049. set loadingUIText(text: string);
  37050. get loadingUIText(): string;
  37051. /**
  37052. * Gets or sets the color to use for the background
  37053. */
  37054. get loadingUIBackgroundColor(): string;
  37055. set loadingUIBackgroundColor(color: string);
  37056. private _resizeLoadingUI;
  37057. }
  37058. }
  37059. declare module BABYLON {
  37060. /**
  37061. * Interface for any object that can request an animation frame
  37062. */
  37063. export interface ICustomAnimationFrameRequester {
  37064. /**
  37065. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37066. */
  37067. renderFunction?: Function;
  37068. /**
  37069. * Called to request the next frame to render to
  37070. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37071. */
  37072. requestAnimationFrame: Function;
  37073. /**
  37074. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37075. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37076. */
  37077. requestID?: number;
  37078. }
  37079. }
  37080. declare module BABYLON {
  37081. /**
  37082. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37083. */
  37084. export class PerformanceMonitor {
  37085. private _enabled;
  37086. private _rollingFrameTime;
  37087. private _lastFrameTimeMs;
  37088. /**
  37089. * constructor
  37090. * @param frameSampleSize The number of samples required to saturate the sliding window
  37091. */
  37092. constructor(frameSampleSize?: number);
  37093. /**
  37094. * Samples current frame
  37095. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37096. */
  37097. sampleFrame(timeMs?: number): void;
  37098. /**
  37099. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37100. */
  37101. get averageFrameTime(): number;
  37102. /**
  37103. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37104. */
  37105. get averageFrameTimeVariance(): number;
  37106. /**
  37107. * Returns the frame time of the most recent frame
  37108. */
  37109. get instantaneousFrameTime(): number;
  37110. /**
  37111. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37112. */
  37113. get averageFPS(): number;
  37114. /**
  37115. * Returns the average framerate in frames per second using the most recent frame time
  37116. */
  37117. get instantaneousFPS(): number;
  37118. /**
  37119. * Returns true if enough samples have been taken to completely fill the sliding window
  37120. */
  37121. get isSaturated(): boolean;
  37122. /**
  37123. * Enables contributions to the sliding window sample set
  37124. */
  37125. enable(): void;
  37126. /**
  37127. * Disables contributions to the sliding window sample set
  37128. * Samples will not be interpolated over the disabled period
  37129. */
  37130. disable(): void;
  37131. /**
  37132. * Returns true if sampling is enabled
  37133. */
  37134. get isEnabled(): boolean;
  37135. /**
  37136. * Resets performance monitor
  37137. */
  37138. reset(): void;
  37139. }
  37140. /**
  37141. * RollingAverage
  37142. *
  37143. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37144. */
  37145. export class RollingAverage {
  37146. /**
  37147. * Current average
  37148. */
  37149. average: number;
  37150. /**
  37151. * Current variance
  37152. */
  37153. variance: number;
  37154. protected _samples: Array<number>;
  37155. protected _sampleCount: number;
  37156. protected _pos: number;
  37157. protected _m2: number;
  37158. /**
  37159. * constructor
  37160. * @param length The number of samples required to saturate the sliding window
  37161. */
  37162. constructor(length: number);
  37163. /**
  37164. * Adds a sample to the sample set
  37165. * @param v The sample value
  37166. */
  37167. add(v: number): void;
  37168. /**
  37169. * Returns previously added values or null if outside of history or outside the sliding window domain
  37170. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37171. * @return Value previously recorded with add() or null if outside of range
  37172. */
  37173. history(i: number): number;
  37174. /**
  37175. * Returns true if enough samples have been taken to completely fill the sliding window
  37176. * @return true if sample-set saturated
  37177. */
  37178. isSaturated(): boolean;
  37179. /**
  37180. * Resets the rolling average (equivalent to 0 samples taken so far)
  37181. */
  37182. reset(): void;
  37183. /**
  37184. * Wraps a value around the sample range boundaries
  37185. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37186. * @return Wrapped position in sample range
  37187. */
  37188. protected _wrapPosition(i: number): number;
  37189. }
  37190. }
  37191. declare module BABYLON {
  37192. /**
  37193. * This class is used to track a performance counter which is number based.
  37194. * The user has access to many properties which give statistics of different nature.
  37195. *
  37196. * The implementer can track two kinds of Performance Counter: time and count.
  37197. * 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.
  37198. * 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.
  37199. */
  37200. export class PerfCounter {
  37201. /**
  37202. * Gets or sets a global boolean to turn on and off all the counters
  37203. */
  37204. static Enabled: boolean;
  37205. /**
  37206. * Returns the smallest value ever
  37207. */
  37208. get min(): number;
  37209. /**
  37210. * Returns the biggest value ever
  37211. */
  37212. get max(): number;
  37213. /**
  37214. * Returns the average value since the performance counter is running
  37215. */
  37216. get average(): number;
  37217. /**
  37218. * Returns the average value of the last second the counter was monitored
  37219. */
  37220. get lastSecAverage(): number;
  37221. /**
  37222. * Returns the current value
  37223. */
  37224. get current(): number;
  37225. /**
  37226. * Gets the accumulated total
  37227. */
  37228. get total(): number;
  37229. /**
  37230. * Gets the total value count
  37231. */
  37232. get count(): number;
  37233. /**
  37234. * Creates a new counter
  37235. */
  37236. constructor();
  37237. /**
  37238. * Call this method to start monitoring a new frame.
  37239. * 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.
  37240. */
  37241. fetchNewFrame(): void;
  37242. /**
  37243. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37244. * @param newCount the count value to add to the monitored count
  37245. * @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.
  37246. */
  37247. addCount(newCount: number, fetchResult: boolean): void;
  37248. /**
  37249. * Start monitoring this performance counter
  37250. */
  37251. beginMonitoring(): void;
  37252. /**
  37253. * Compute the time lapsed since the previous beginMonitoring() call.
  37254. * @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
  37255. */
  37256. endMonitoring(newFrame?: boolean): void;
  37257. private _fetchResult;
  37258. private _startMonitoringTime;
  37259. private _min;
  37260. private _max;
  37261. private _average;
  37262. private _current;
  37263. private _totalValueCount;
  37264. private _totalAccumulated;
  37265. private _lastSecAverage;
  37266. private _lastSecAccumulated;
  37267. private _lastSecTime;
  37268. private _lastSecValueCount;
  37269. }
  37270. }
  37271. declare module BABYLON {
  37272. interface ThinEngine {
  37273. /** @hidden */
  37274. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37275. }
  37276. }
  37277. declare module BABYLON {
  37278. /**
  37279. * Defines the interface used by display changed events
  37280. */
  37281. export interface IDisplayChangedEventArgs {
  37282. /** Gets the vrDisplay object (if any) */
  37283. vrDisplay: Nullable<any>;
  37284. /** Gets a boolean indicating if webVR is supported */
  37285. vrSupported: boolean;
  37286. }
  37287. /**
  37288. * Defines the interface used by objects containing a viewport (like a camera)
  37289. */
  37290. interface IViewportOwnerLike {
  37291. /**
  37292. * Gets or sets the viewport
  37293. */
  37294. viewport: IViewportLike;
  37295. }
  37296. /**
  37297. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37298. */
  37299. export class Engine extends ThinEngine {
  37300. /** Defines that alpha blending is disabled */
  37301. static readonly ALPHA_DISABLE: number;
  37302. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37303. static readonly ALPHA_ADD: number;
  37304. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37305. static readonly ALPHA_COMBINE: number;
  37306. /** Defines that alpha blending to DEST - SRC * DEST */
  37307. static readonly ALPHA_SUBTRACT: number;
  37308. /** Defines that alpha blending to SRC * DEST */
  37309. static readonly ALPHA_MULTIPLY: number;
  37310. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37311. static readonly ALPHA_MAXIMIZED: number;
  37312. /** Defines that alpha blending to SRC + DEST */
  37313. static readonly ALPHA_ONEONE: number;
  37314. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37315. static readonly ALPHA_PREMULTIPLIED: number;
  37316. /**
  37317. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37318. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37319. */
  37320. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37321. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37322. static readonly ALPHA_INTERPOLATE: number;
  37323. /**
  37324. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37325. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37326. */
  37327. static readonly ALPHA_SCREENMODE: number;
  37328. /** Defines that the ressource is not delayed*/
  37329. static readonly DELAYLOADSTATE_NONE: number;
  37330. /** Defines that the ressource was successfully delay loaded */
  37331. static readonly DELAYLOADSTATE_LOADED: number;
  37332. /** Defines that the ressource is currently delay loading */
  37333. static readonly DELAYLOADSTATE_LOADING: number;
  37334. /** Defines that the ressource is delayed and has not started loading */
  37335. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37336. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37337. static readonly NEVER: number;
  37338. /** 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 */
  37339. static readonly ALWAYS: number;
  37340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37341. static readonly LESS: number;
  37342. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37343. static readonly EQUAL: number;
  37344. /** 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 */
  37345. static readonly LEQUAL: number;
  37346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37347. static readonly GREATER: number;
  37348. /** 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 */
  37349. static readonly GEQUAL: number;
  37350. /** 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 */
  37351. static readonly NOTEQUAL: number;
  37352. /** Passed to stencilOperation to specify that stencil value must be kept */
  37353. static readonly KEEP: number;
  37354. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37355. static readonly REPLACE: number;
  37356. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37357. static readonly INCR: number;
  37358. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37359. static readonly DECR: number;
  37360. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37361. static readonly INVERT: number;
  37362. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37363. static readonly INCR_WRAP: number;
  37364. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37365. static readonly DECR_WRAP: number;
  37366. /** Texture is not repeating outside of 0..1 UVs */
  37367. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37368. /** Texture is repeating outside of 0..1 UVs */
  37369. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37370. /** Texture is repeating and mirrored */
  37371. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37372. /** ALPHA */
  37373. static readonly TEXTUREFORMAT_ALPHA: number;
  37374. /** LUMINANCE */
  37375. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37376. /** LUMINANCE_ALPHA */
  37377. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37378. /** RGB */
  37379. static readonly TEXTUREFORMAT_RGB: number;
  37380. /** RGBA */
  37381. static readonly TEXTUREFORMAT_RGBA: number;
  37382. /** RED */
  37383. static readonly TEXTUREFORMAT_RED: number;
  37384. /** RED (2nd reference) */
  37385. static readonly TEXTUREFORMAT_R: number;
  37386. /** RG */
  37387. static readonly TEXTUREFORMAT_RG: number;
  37388. /** RED_INTEGER */
  37389. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37390. /** RED_INTEGER (2nd reference) */
  37391. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37392. /** RG_INTEGER */
  37393. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37394. /** RGB_INTEGER */
  37395. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37396. /** RGBA_INTEGER */
  37397. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37398. /** UNSIGNED_BYTE */
  37399. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37400. /** UNSIGNED_BYTE (2nd reference) */
  37401. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37402. /** FLOAT */
  37403. static readonly TEXTURETYPE_FLOAT: number;
  37404. /** HALF_FLOAT */
  37405. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37406. /** BYTE */
  37407. static readonly TEXTURETYPE_BYTE: number;
  37408. /** SHORT */
  37409. static readonly TEXTURETYPE_SHORT: number;
  37410. /** UNSIGNED_SHORT */
  37411. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37412. /** INT */
  37413. static readonly TEXTURETYPE_INT: number;
  37414. /** UNSIGNED_INT */
  37415. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37416. /** UNSIGNED_SHORT_4_4_4_4 */
  37417. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37418. /** UNSIGNED_SHORT_5_5_5_1 */
  37419. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37420. /** UNSIGNED_SHORT_5_6_5 */
  37421. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37422. /** UNSIGNED_INT_2_10_10_10_REV */
  37423. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37424. /** UNSIGNED_INT_24_8 */
  37425. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37426. /** UNSIGNED_INT_10F_11F_11F_REV */
  37427. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37428. /** UNSIGNED_INT_5_9_9_9_REV */
  37429. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37430. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37431. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37432. /** nearest is mag = nearest and min = nearest and mip = linear */
  37433. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37434. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37435. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37436. /** Trilinear is mag = linear and min = linear and mip = linear */
  37437. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37438. /** nearest is mag = nearest and min = nearest and mip = linear */
  37439. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37440. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37441. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37442. /** Trilinear is mag = linear and min = linear and mip = linear */
  37443. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37444. /** mag = nearest and min = nearest and mip = nearest */
  37445. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37446. /** mag = nearest and min = linear and mip = nearest */
  37447. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37448. /** mag = nearest and min = linear and mip = linear */
  37449. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37450. /** mag = nearest and min = linear and mip = none */
  37451. static readonly TEXTURE_NEAREST_LINEAR: number;
  37452. /** mag = nearest and min = nearest and mip = none */
  37453. static readonly TEXTURE_NEAREST_NEAREST: number;
  37454. /** mag = linear and min = nearest and mip = nearest */
  37455. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37456. /** mag = linear and min = nearest and mip = linear */
  37457. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37458. /** mag = linear and min = linear and mip = none */
  37459. static readonly TEXTURE_LINEAR_LINEAR: number;
  37460. /** mag = linear and min = nearest and mip = none */
  37461. static readonly TEXTURE_LINEAR_NEAREST: number;
  37462. /** Explicit coordinates mode */
  37463. static readonly TEXTURE_EXPLICIT_MODE: number;
  37464. /** Spherical coordinates mode */
  37465. static readonly TEXTURE_SPHERICAL_MODE: number;
  37466. /** Planar coordinates mode */
  37467. static readonly TEXTURE_PLANAR_MODE: number;
  37468. /** Cubic coordinates mode */
  37469. static readonly TEXTURE_CUBIC_MODE: number;
  37470. /** Projection coordinates mode */
  37471. static readonly TEXTURE_PROJECTION_MODE: number;
  37472. /** Skybox coordinates mode */
  37473. static readonly TEXTURE_SKYBOX_MODE: number;
  37474. /** Inverse Cubic coordinates mode */
  37475. static readonly TEXTURE_INVCUBIC_MODE: number;
  37476. /** Equirectangular coordinates mode */
  37477. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37478. /** Equirectangular Fixed coordinates mode */
  37479. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37480. /** Equirectangular Fixed Mirrored coordinates mode */
  37481. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37482. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37483. static readonly SCALEMODE_FLOOR: number;
  37484. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37485. static readonly SCALEMODE_NEAREST: number;
  37486. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37487. static readonly SCALEMODE_CEILING: number;
  37488. /**
  37489. * Returns the current npm package of the sdk
  37490. */
  37491. static get NpmPackage(): string;
  37492. /**
  37493. * Returns the current version of the framework
  37494. */
  37495. static get Version(): string;
  37496. /** Gets the list of created engines */
  37497. static get Instances(): Engine[];
  37498. /**
  37499. * Gets the latest created engine
  37500. */
  37501. static get LastCreatedEngine(): Nullable<Engine>;
  37502. /**
  37503. * Gets the latest created scene
  37504. */
  37505. static get LastCreatedScene(): Nullable<Scene>;
  37506. /**
  37507. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37508. * @param flag defines which part of the materials must be marked as dirty
  37509. * @param predicate defines a predicate used to filter which materials should be affected
  37510. */
  37511. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37512. /**
  37513. * Method called to create the default loading screen.
  37514. * This can be overriden in your own app.
  37515. * @param canvas The rendering canvas element
  37516. * @returns The loading screen
  37517. */
  37518. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37519. /**
  37520. * Method called to create the default rescale post process on each engine.
  37521. */
  37522. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37523. /**
  37524. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37525. **/
  37526. enableOfflineSupport: boolean;
  37527. /**
  37528. * 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)
  37529. **/
  37530. disableManifestCheck: boolean;
  37531. /**
  37532. * Gets the list of created scenes
  37533. */
  37534. scenes: Scene[];
  37535. /**
  37536. * Event raised when a new scene is created
  37537. */
  37538. onNewSceneAddedObservable: Observable<Scene>;
  37539. /**
  37540. * Gets the list of created postprocesses
  37541. */
  37542. postProcesses: PostProcess[];
  37543. /**
  37544. * Gets a boolean indicating if the pointer is currently locked
  37545. */
  37546. isPointerLock: boolean;
  37547. /**
  37548. * Observable event triggered each time the rendering canvas is resized
  37549. */
  37550. onResizeObservable: Observable<Engine>;
  37551. /**
  37552. * Observable event triggered each time the canvas loses focus
  37553. */
  37554. onCanvasBlurObservable: Observable<Engine>;
  37555. /**
  37556. * Observable event triggered each time the canvas gains focus
  37557. */
  37558. onCanvasFocusObservable: Observable<Engine>;
  37559. /**
  37560. * Observable event triggered each time the canvas receives pointerout event
  37561. */
  37562. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37563. /**
  37564. * Observable raised when the engine begins a new frame
  37565. */
  37566. onBeginFrameObservable: Observable<Engine>;
  37567. /**
  37568. * If set, will be used to request the next animation frame for the render loop
  37569. */
  37570. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37571. /**
  37572. * Observable raised when the engine ends the current frame
  37573. */
  37574. onEndFrameObservable: Observable<Engine>;
  37575. /**
  37576. * Observable raised when the engine is about to compile a shader
  37577. */
  37578. onBeforeShaderCompilationObservable: Observable<Engine>;
  37579. /**
  37580. * Observable raised when the engine has jsut compiled a shader
  37581. */
  37582. onAfterShaderCompilationObservable: Observable<Engine>;
  37583. /**
  37584. * Gets the audio engine
  37585. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37586. * @ignorenaming
  37587. */
  37588. static audioEngine: IAudioEngine;
  37589. /**
  37590. * Default AudioEngine factory responsible of creating the Audio Engine.
  37591. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37592. */
  37593. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37594. /**
  37595. * Default offline support factory responsible of creating a tool used to store data locally.
  37596. * By default, this will create a Database object if the workload has been embedded.
  37597. */
  37598. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37599. private _loadingScreen;
  37600. private _pointerLockRequested;
  37601. private _rescalePostProcess;
  37602. private _deterministicLockstep;
  37603. private _lockstepMaxSteps;
  37604. private _timeStep;
  37605. protected get _supportsHardwareTextureRescaling(): boolean;
  37606. private _fps;
  37607. private _deltaTime;
  37608. /** @hidden */
  37609. _drawCalls: PerfCounter;
  37610. /** 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 */
  37611. canvasTabIndex: number;
  37612. /**
  37613. * Turn this value on if you want to pause FPS computation when in background
  37614. */
  37615. disablePerformanceMonitorInBackground: boolean;
  37616. private _performanceMonitor;
  37617. /**
  37618. * Gets the performance monitor attached to this engine
  37619. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37620. */
  37621. get performanceMonitor(): PerformanceMonitor;
  37622. private _onFocus;
  37623. private _onBlur;
  37624. private _onCanvasPointerOut;
  37625. private _onCanvasBlur;
  37626. private _onCanvasFocus;
  37627. private _onFullscreenChange;
  37628. private _onPointerLockChange;
  37629. /**
  37630. * Gets the HTML element used to attach event listeners
  37631. * @returns a HTML element
  37632. */
  37633. getInputElement(): Nullable<HTMLElement>;
  37634. /**
  37635. * Creates a new engine
  37636. * @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
  37637. * @param antialias defines enable antialiasing (default: false)
  37638. * @param options defines further options to be sent to the getContext() function
  37639. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37640. */
  37641. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37642. /**
  37643. * Gets current aspect ratio
  37644. * @param viewportOwner defines the camera to use to get the aspect ratio
  37645. * @param useScreen defines if screen size must be used (or the current render target if any)
  37646. * @returns a number defining the aspect ratio
  37647. */
  37648. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37649. /**
  37650. * Gets current screen aspect ratio
  37651. * @returns a number defining the aspect ratio
  37652. */
  37653. getScreenAspectRatio(): number;
  37654. /**
  37655. * Gets the client rect of the HTML canvas attached with the current webGL context
  37656. * @returns a client rectanglee
  37657. */
  37658. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37659. /**
  37660. * Gets the client rect of the HTML element used for events
  37661. * @returns a client rectanglee
  37662. */
  37663. getInputElementClientRect(): Nullable<ClientRect>;
  37664. /**
  37665. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37666. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37667. * @returns true if engine is in deterministic lock step mode
  37668. */
  37669. isDeterministicLockStep(): boolean;
  37670. /**
  37671. * Gets the max steps when engine is running in deterministic lock step
  37672. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37673. * @returns the max steps
  37674. */
  37675. getLockstepMaxSteps(): number;
  37676. /**
  37677. * Returns the time in ms between steps when using deterministic lock step.
  37678. * @returns time step in (ms)
  37679. */
  37680. getTimeStep(): number;
  37681. /**
  37682. * Force the mipmap generation for the given render target texture
  37683. * @param texture defines the render target texture to use
  37684. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37685. */
  37686. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37687. /** States */
  37688. /**
  37689. * Set various states to the webGL context
  37690. * @param culling defines backface culling state
  37691. * @param zOffset defines the value to apply to zOffset (0 by default)
  37692. * @param force defines if states must be applied even if cache is up to date
  37693. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37694. */
  37695. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37696. /**
  37697. * Set the z offset to apply to current rendering
  37698. * @param value defines the offset to apply
  37699. */
  37700. setZOffset(value: number): void;
  37701. /**
  37702. * Gets the current value of the zOffset
  37703. * @returns the current zOffset state
  37704. */
  37705. getZOffset(): number;
  37706. /**
  37707. * Enable or disable depth buffering
  37708. * @param enable defines the state to set
  37709. */
  37710. setDepthBuffer(enable: boolean): void;
  37711. /**
  37712. * Gets a boolean indicating if depth writing is enabled
  37713. * @returns the current depth writing state
  37714. */
  37715. getDepthWrite(): boolean;
  37716. /**
  37717. * Enable or disable depth writing
  37718. * @param enable defines the state to set
  37719. */
  37720. setDepthWrite(enable: boolean): void;
  37721. /**
  37722. * Gets a boolean indicating if stencil buffer is enabled
  37723. * @returns the current stencil buffer state
  37724. */
  37725. getStencilBuffer(): boolean;
  37726. /**
  37727. * Enable or disable the stencil buffer
  37728. * @param enable defines if the stencil buffer must be enabled or disabled
  37729. */
  37730. setStencilBuffer(enable: boolean): void;
  37731. /**
  37732. * Gets the current stencil mask
  37733. * @returns a number defining the new stencil mask to use
  37734. */
  37735. getStencilMask(): number;
  37736. /**
  37737. * Sets the current stencil mask
  37738. * @param mask defines the new stencil mask to use
  37739. */
  37740. setStencilMask(mask: number): void;
  37741. /**
  37742. * Gets the current stencil function
  37743. * @returns a number defining the stencil function to use
  37744. */
  37745. getStencilFunction(): number;
  37746. /**
  37747. * Gets the current stencil reference value
  37748. * @returns a number defining the stencil reference value to use
  37749. */
  37750. getStencilFunctionReference(): number;
  37751. /**
  37752. * Gets the current stencil mask
  37753. * @returns a number defining the stencil mask to use
  37754. */
  37755. getStencilFunctionMask(): number;
  37756. /**
  37757. * Sets the current stencil function
  37758. * @param stencilFunc defines the new stencil function to use
  37759. */
  37760. setStencilFunction(stencilFunc: number): void;
  37761. /**
  37762. * Sets the current stencil reference
  37763. * @param reference defines the new stencil reference to use
  37764. */
  37765. setStencilFunctionReference(reference: number): void;
  37766. /**
  37767. * Sets the current stencil mask
  37768. * @param mask defines the new stencil mask to use
  37769. */
  37770. setStencilFunctionMask(mask: number): void;
  37771. /**
  37772. * Gets the current stencil operation when stencil fails
  37773. * @returns a number defining stencil operation to use when stencil fails
  37774. */
  37775. getStencilOperationFail(): number;
  37776. /**
  37777. * Gets the current stencil operation when depth fails
  37778. * @returns a number defining stencil operation to use when depth fails
  37779. */
  37780. getStencilOperationDepthFail(): number;
  37781. /**
  37782. * Gets the current stencil operation when stencil passes
  37783. * @returns a number defining stencil operation to use when stencil passes
  37784. */
  37785. getStencilOperationPass(): number;
  37786. /**
  37787. * Sets the stencil operation to use when stencil fails
  37788. * @param operation defines the stencil operation to use when stencil fails
  37789. */
  37790. setStencilOperationFail(operation: number): void;
  37791. /**
  37792. * Sets the stencil operation to use when depth fails
  37793. * @param operation defines the stencil operation to use when depth fails
  37794. */
  37795. setStencilOperationDepthFail(operation: number): void;
  37796. /**
  37797. * Sets the stencil operation to use when stencil passes
  37798. * @param operation defines the stencil operation to use when stencil passes
  37799. */
  37800. setStencilOperationPass(operation: number): void;
  37801. /**
  37802. * Sets a boolean indicating if the dithering state is enabled or disabled
  37803. * @param value defines the dithering state
  37804. */
  37805. setDitheringState(value: boolean): void;
  37806. /**
  37807. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37808. * @param value defines the rasterizer state
  37809. */
  37810. setRasterizerState(value: boolean): void;
  37811. /**
  37812. * Gets the current depth function
  37813. * @returns a number defining the depth function
  37814. */
  37815. getDepthFunction(): Nullable<number>;
  37816. /**
  37817. * Sets the current depth function
  37818. * @param depthFunc defines the function to use
  37819. */
  37820. setDepthFunction(depthFunc: number): void;
  37821. /**
  37822. * Sets the current depth function to GREATER
  37823. */
  37824. setDepthFunctionToGreater(): void;
  37825. /**
  37826. * Sets the current depth function to GEQUAL
  37827. */
  37828. setDepthFunctionToGreaterOrEqual(): void;
  37829. /**
  37830. * Sets the current depth function to LESS
  37831. */
  37832. setDepthFunctionToLess(): void;
  37833. /**
  37834. * Sets the current depth function to LEQUAL
  37835. */
  37836. setDepthFunctionToLessOrEqual(): void;
  37837. private _cachedStencilBuffer;
  37838. private _cachedStencilFunction;
  37839. private _cachedStencilMask;
  37840. private _cachedStencilOperationPass;
  37841. private _cachedStencilOperationFail;
  37842. private _cachedStencilOperationDepthFail;
  37843. private _cachedStencilReference;
  37844. /**
  37845. * Caches the the state of the stencil buffer
  37846. */
  37847. cacheStencilState(): void;
  37848. /**
  37849. * Restores the state of the stencil buffer
  37850. */
  37851. restoreStencilState(): void;
  37852. /**
  37853. * Directly set the WebGL Viewport
  37854. * @param x defines the x coordinate of the viewport (in screen space)
  37855. * @param y defines the y coordinate of the viewport (in screen space)
  37856. * @param width defines the width of the viewport (in screen space)
  37857. * @param height defines the height of the viewport (in screen space)
  37858. * @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
  37859. */
  37860. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37861. /**
  37862. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37863. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37864. * @param y defines the y-coordinate of the corner of the clear rectangle
  37865. * @param width defines the width of the clear rectangle
  37866. * @param height defines the height of the clear rectangle
  37867. * @param clearColor defines the clear color
  37868. */
  37869. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37870. /**
  37871. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37872. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37873. * @param y defines the y-coordinate of the corner of the clear rectangle
  37874. * @param width defines the width of the clear rectangle
  37875. * @param height defines the height of the clear rectangle
  37876. */
  37877. enableScissor(x: number, y: number, width: number, height: number): void;
  37878. /**
  37879. * Disable previously set scissor test rectangle
  37880. */
  37881. disableScissor(): void;
  37882. protected _reportDrawCall(): void;
  37883. /**
  37884. * Initializes a webVR display and starts listening to display change events
  37885. * The onVRDisplayChangedObservable will be notified upon these changes
  37886. * @returns The onVRDisplayChangedObservable
  37887. */
  37888. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37889. /** @hidden */
  37890. _prepareVRComponent(): void;
  37891. /** @hidden */
  37892. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37893. /** @hidden */
  37894. _submitVRFrame(): void;
  37895. /**
  37896. * Call this function to leave webVR mode
  37897. * Will do nothing if webVR is not supported or if there is no webVR device
  37898. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37899. */
  37900. disableVR(): void;
  37901. /**
  37902. * Gets a boolean indicating that the system is in VR mode and is presenting
  37903. * @returns true if VR mode is engaged
  37904. */
  37905. isVRPresenting(): boolean;
  37906. /** @hidden */
  37907. _requestVRFrame(): void;
  37908. /** @hidden */
  37909. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37910. /**
  37911. * Gets the source code of the vertex shader associated with a specific webGL program
  37912. * @param program defines the program to use
  37913. * @returns a string containing the source code of the vertex shader associated with the program
  37914. */
  37915. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37916. /**
  37917. * Gets the source code of the fragment shader associated with a specific webGL program
  37918. * @param program defines the program to use
  37919. * @returns a string containing the source code of the fragment shader associated with the program
  37920. */
  37921. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37922. /**
  37923. * Sets a depth stencil texture from a render target to the according uniform.
  37924. * @param channel The texture channel
  37925. * @param uniform The uniform to set
  37926. * @param texture The render target texture containing the depth stencil texture to apply
  37927. */
  37928. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37929. /**
  37930. * Sets a texture to the webGL context from a postprocess
  37931. * @param channel defines the channel to use
  37932. * @param postProcess defines the source postprocess
  37933. */
  37934. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37935. /**
  37936. * Binds the output of the passed in post process to the texture channel specified
  37937. * @param channel The channel the texture should be bound to
  37938. * @param postProcess The post process which's output should be bound
  37939. */
  37940. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37941. protected _rebuildBuffers(): void;
  37942. /** @hidden */
  37943. _renderFrame(): void;
  37944. _renderLoop(): void;
  37945. /** @hidden */
  37946. _renderViews(): boolean;
  37947. /**
  37948. * Toggle full screen mode
  37949. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37950. */
  37951. switchFullscreen(requestPointerLock: boolean): void;
  37952. /**
  37953. * Enters full screen mode
  37954. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37955. */
  37956. enterFullscreen(requestPointerLock: boolean): void;
  37957. /**
  37958. * Exits full screen mode
  37959. */
  37960. exitFullscreen(): void;
  37961. /**
  37962. * Enters Pointerlock mode
  37963. */
  37964. enterPointerlock(): void;
  37965. /**
  37966. * Exits Pointerlock mode
  37967. */
  37968. exitPointerlock(): void;
  37969. /**
  37970. * Begin a new frame
  37971. */
  37972. beginFrame(): void;
  37973. /**
  37974. * Enf the current frame
  37975. */
  37976. endFrame(): void;
  37977. resize(): void;
  37978. /**
  37979. * Force a specific size of the canvas
  37980. * @param width defines the new canvas' width
  37981. * @param height defines the new canvas' height
  37982. * @returns true if the size was changed
  37983. */
  37984. setSize(width: number, height: number): boolean;
  37985. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37986. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37987. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37988. _releaseTexture(texture: InternalTexture): void;
  37989. /**
  37990. * @hidden
  37991. * Rescales a texture
  37992. * @param source input texutre
  37993. * @param destination destination texture
  37994. * @param scene scene to use to render the resize
  37995. * @param internalFormat format to use when resizing
  37996. * @param onComplete callback to be called when resize has completed
  37997. */
  37998. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37999. /**
  38000. * Gets the current framerate
  38001. * @returns a number representing the framerate
  38002. */
  38003. getFps(): number;
  38004. /**
  38005. * Gets the time spent between current and previous frame
  38006. * @returns a number representing the delta time in ms
  38007. */
  38008. getDeltaTime(): number;
  38009. private _measureFps;
  38010. /** @hidden */
  38011. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38012. /**
  38013. * Updates the sample count of a render target texture
  38014. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38015. * @param texture defines the texture to update
  38016. * @param samples defines the sample count to set
  38017. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38018. */
  38019. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38020. /**
  38021. * Updates a depth texture Comparison Mode and Function.
  38022. * If the comparison Function is equal to 0, the mode will be set to none.
  38023. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38024. * @param texture The texture to set the comparison function for
  38025. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38026. */
  38027. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38028. /**
  38029. * Creates a webGL buffer to use with instanciation
  38030. * @param capacity defines the size of the buffer
  38031. * @returns the webGL buffer
  38032. */
  38033. createInstancesBuffer(capacity: number): DataBuffer;
  38034. /**
  38035. * Delete a webGL buffer used with instanciation
  38036. * @param buffer defines the webGL buffer to delete
  38037. */
  38038. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38039. private _clientWaitAsync;
  38040. /** @hidden */
  38041. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38042. dispose(): void;
  38043. private _disableTouchAction;
  38044. /**
  38045. * Display the loading screen
  38046. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38047. */
  38048. displayLoadingUI(): void;
  38049. /**
  38050. * Hide the loading screen
  38051. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38052. */
  38053. hideLoadingUI(): void;
  38054. /**
  38055. * Gets the current loading screen object
  38056. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38057. */
  38058. get loadingScreen(): ILoadingScreen;
  38059. /**
  38060. * Sets the current loading screen object
  38061. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38062. */
  38063. set loadingScreen(loadingScreen: ILoadingScreen);
  38064. /**
  38065. * Sets the current loading screen text
  38066. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38067. */
  38068. set loadingUIText(text: string);
  38069. /**
  38070. * Sets the current loading screen background color
  38071. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38072. */
  38073. set loadingUIBackgroundColor(color: string);
  38074. /** Pointerlock and fullscreen */
  38075. /**
  38076. * Ask the browser to promote the current element to pointerlock mode
  38077. * @param element defines the DOM element to promote
  38078. */
  38079. static _RequestPointerlock(element: HTMLElement): void;
  38080. /**
  38081. * Asks the browser to exit pointerlock mode
  38082. */
  38083. static _ExitPointerlock(): void;
  38084. /**
  38085. * Ask the browser to promote the current element to fullscreen rendering mode
  38086. * @param element defines the DOM element to promote
  38087. */
  38088. static _RequestFullscreen(element: HTMLElement): void;
  38089. /**
  38090. * Asks the browser to exit fullscreen mode
  38091. */
  38092. static _ExitFullscreen(): void;
  38093. }
  38094. }
  38095. declare module BABYLON {
  38096. /**
  38097. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38098. * during the life time of the application.
  38099. */
  38100. export class EngineStore {
  38101. /** Gets the list of created engines */
  38102. static Instances: Engine[];
  38103. /** @hidden */
  38104. static _LastCreatedScene: Nullable<Scene>;
  38105. /**
  38106. * Gets the latest created engine
  38107. */
  38108. static get LastCreatedEngine(): Nullable<Engine>;
  38109. /**
  38110. * Gets the latest created scene
  38111. */
  38112. static get LastCreatedScene(): Nullable<Scene>;
  38113. /**
  38114. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38115. * @ignorenaming
  38116. */
  38117. static UseFallbackTexture: boolean;
  38118. /**
  38119. * Texture content used if a texture cannot loaded
  38120. * @ignorenaming
  38121. */
  38122. static FallbackTexture: string;
  38123. }
  38124. }
  38125. declare module BABYLON {
  38126. /**
  38127. * Helper class that provides a small promise polyfill
  38128. */
  38129. export class PromisePolyfill {
  38130. /**
  38131. * Static function used to check if the polyfill is required
  38132. * If this is the case then the function will inject the polyfill to window.Promise
  38133. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38134. */
  38135. static Apply(force?: boolean): void;
  38136. }
  38137. }
  38138. declare module BABYLON {
  38139. /**
  38140. * Interface for screenshot methods with describe argument called `size` as object with options
  38141. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38142. */
  38143. export interface IScreenshotSize {
  38144. /**
  38145. * number in pixels for canvas height
  38146. */
  38147. height?: number;
  38148. /**
  38149. * multiplier allowing render at a higher or lower resolution
  38150. * If value is defined then height and width will be ignored and taken from camera
  38151. */
  38152. precision?: number;
  38153. /**
  38154. * number in pixels for canvas width
  38155. */
  38156. width?: number;
  38157. }
  38158. }
  38159. declare module BABYLON {
  38160. interface IColor4Like {
  38161. r: float;
  38162. g: float;
  38163. b: float;
  38164. a: float;
  38165. }
  38166. /**
  38167. * Class containing a set of static utilities functions
  38168. */
  38169. export class Tools {
  38170. /**
  38171. * Gets or sets the base URL to use to load assets
  38172. */
  38173. static get BaseUrl(): string;
  38174. static set BaseUrl(value: string);
  38175. /**
  38176. * Enable/Disable Custom HTTP Request Headers globally.
  38177. * default = false
  38178. * @see CustomRequestHeaders
  38179. */
  38180. static UseCustomRequestHeaders: boolean;
  38181. /**
  38182. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38183. * i.e. when loading files, where the server/service expects an Authorization header
  38184. */
  38185. static CustomRequestHeaders: {
  38186. [key: string]: string;
  38187. };
  38188. /**
  38189. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38190. */
  38191. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38192. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38193. /**
  38194. * Default behaviour for cors in the application.
  38195. * It can be a string if the expected behavior is identical in the entire app.
  38196. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38197. */
  38198. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38199. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38200. /**
  38201. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38202. * @ignorenaming
  38203. */
  38204. static get UseFallbackTexture(): boolean;
  38205. static set UseFallbackTexture(value: boolean);
  38206. /**
  38207. * Use this object to register external classes like custom textures or material
  38208. * to allow the laoders to instantiate them
  38209. */
  38210. static get RegisteredExternalClasses(): {
  38211. [key: string]: Object;
  38212. };
  38213. static set RegisteredExternalClasses(classes: {
  38214. [key: string]: Object;
  38215. });
  38216. /**
  38217. * Texture content used if a texture cannot loaded
  38218. * @ignorenaming
  38219. */
  38220. static get fallbackTexture(): string;
  38221. static set fallbackTexture(value: string);
  38222. /**
  38223. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38224. * @param u defines the coordinate on X axis
  38225. * @param v defines the coordinate on Y axis
  38226. * @param width defines the width of the source data
  38227. * @param height defines the height of the source data
  38228. * @param pixels defines the source byte array
  38229. * @param color defines the output color
  38230. */
  38231. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38232. /**
  38233. * Interpolates between a and b via alpha
  38234. * @param a The lower value (returned when alpha = 0)
  38235. * @param b The upper value (returned when alpha = 1)
  38236. * @param alpha The interpolation-factor
  38237. * @return The mixed value
  38238. */
  38239. static Mix(a: number, b: number, alpha: number): number;
  38240. /**
  38241. * Tries to instantiate a new object from a given class name
  38242. * @param className defines the class name to instantiate
  38243. * @returns the new object or null if the system was not able to do the instantiation
  38244. */
  38245. static Instantiate(className: string): any;
  38246. /**
  38247. * Provides a slice function that will work even on IE
  38248. * @param data defines the array to slice
  38249. * @param start defines the start of the data (optional)
  38250. * @param end defines the end of the data (optional)
  38251. * @returns the new sliced array
  38252. */
  38253. static Slice<T>(data: T, start?: number, end?: number): T;
  38254. /**
  38255. * Polyfill for setImmediate
  38256. * @param action defines the action to execute after the current execution block
  38257. */
  38258. static SetImmediate(action: () => void): void;
  38259. /**
  38260. * Function indicating if a number is an exponent of 2
  38261. * @param value defines the value to test
  38262. * @returns true if the value is an exponent of 2
  38263. */
  38264. static IsExponentOfTwo(value: number): boolean;
  38265. private static _tmpFloatArray;
  38266. /**
  38267. * Returns the nearest 32-bit single precision float representation of a Number
  38268. * @param value A Number. If the parameter is of a different type, it will get converted
  38269. * to a number or to NaN if it cannot be converted
  38270. * @returns number
  38271. */
  38272. static FloatRound(value: number): number;
  38273. /**
  38274. * Extracts the filename from a path
  38275. * @param path defines the path to use
  38276. * @returns the filename
  38277. */
  38278. static GetFilename(path: string): string;
  38279. /**
  38280. * Extracts the "folder" part of a path (everything before the filename).
  38281. * @param uri The URI to extract the info from
  38282. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38283. * @returns The "folder" part of the path
  38284. */
  38285. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38286. /**
  38287. * Extracts text content from a DOM element hierarchy
  38288. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38289. */
  38290. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38291. /**
  38292. * Convert an angle in radians to degrees
  38293. * @param angle defines the angle to convert
  38294. * @returns the angle in degrees
  38295. */
  38296. static ToDegrees(angle: number): number;
  38297. /**
  38298. * Convert an angle in degrees to radians
  38299. * @param angle defines the angle to convert
  38300. * @returns the angle in radians
  38301. */
  38302. static ToRadians(angle: number): number;
  38303. /**
  38304. * Returns an array if obj is not an array
  38305. * @param obj defines the object to evaluate as an array
  38306. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38307. * @returns either obj directly if obj is an array or a new array containing obj
  38308. */
  38309. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38310. /**
  38311. * Gets the pointer prefix to use
  38312. * @param engine defines the engine we are finding the prefix for
  38313. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38314. */
  38315. static GetPointerPrefix(engine: Engine): string;
  38316. /**
  38317. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38318. * @param url define the url we are trying
  38319. * @param element define the dom element where to configure the cors policy
  38320. */
  38321. static SetCorsBehavior(url: string | string[], element: {
  38322. crossOrigin: string | null;
  38323. }): void;
  38324. /**
  38325. * Removes unwanted characters from an url
  38326. * @param url defines the url to clean
  38327. * @returns the cleaned url
  38328. */
  38329. static CleanUrl(url: string): string;
  38330. /**
  38331. * Gets or sets a function used to pre-process url before using them to load assets
  38332. */
  38333. static get PreprocessUrl(): (url: string) => string;
  38334. static set PreprocessUrl(processor: (url: string) => string);
  38335. /**
  38336. * Loads an image as an HTMLImageElement.
  38337. * @param input url string, ArrayBuffer, or Blob to load
  38338. * @param onLoad callback called when the image successfully loads
  38339. * @param onError callback called when the image fails to load
  38340. * @param offlineProvider offline provider for caching
  38341. * @param mimeType optional mime type
  38342. * @returns the HTMLImageElement of the loaded image
  38343. */
  38344. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38345. /**
  38346. * Loads a file from a url
  38347. * @param url url string, ArrayBuffer, or Blob to load
  38348. * @param onSuccess callback called when the file successfully loads
  38349. * @param onProgress callback called while file is loading (if the server supports this mode)
  38350. * @param offlineProvider defines the offline provider for caching
  38351. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38352. * @param onError callback called when the file fails to load
  38353. * @returns a file request object
  38354. */
  38355. 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;
  38356. /**
  38357. * Loads a file from a url
  38358. * @param url the file url to load
  38359. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38360. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38361. */
  38362. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38363. /**
  38364. * Load a script (identified by an url). When the url returns, the
  38365. * content of this file is added into a new script element, attached to the DOM (body element)
  38366. * @param scriptUrl defines the url of the script to laod
  38367. * @param onSuccess defines the callback called when the script is loaded
  38368. * @param onError defines the callback to call if an error occurs
  38369. * @param scriptId defines the id of the script element
  38370. */
  38371. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38372. /**
  38373. * Load an asynchronous script (identified by an url). When the url returns, the
  38374. * content of this file is added into a new script element, attached to the DOM (body element)
  38375. * @param scriptUrl defines the url of the script to laod
  38376. * @param scriptId defines the id of the script element
  38377. * @returns a promise request object
  38378. */
  38379. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38380. /**
  38381. * Loads a file from a blob
  38382. * @param fileToLoad defines the blob to use
  38383. * @param callback defines the callback to call when data is loaded
  38384. * @param progressCallback defines the callback to call during loading process
  38385. * @returns a file request object
  38386. */
  38387. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38388. /**
  38389. * Reads a file from a File object
  38390. * @param file defines the file to load
  38391. * @param onSuccess defines the callback to call when data is loaded
  38392. * @param onProgress defines the callback to call during loading process
  38393. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38394. * @param onError defines the callback to call when an error occurs
  38395. * @returns a file request object
  38396. */
  38397. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38398. /**
  38399. * Creates a data url from a given string content
  38400. * @param content defines the content to convert
  38401. * @returns the new data url link
  38402. */
  38403. static FileAsURL(content: string): string;
  38404. /**
  38405. * Format the given number to a specific decimal format
  38406. * @param value defines the number to format
  38407. * @param decimals defines the number of decimals to use
  38408. * @returns the formatted string
  38409. */
  38410. static Format(value: number, decimals?: number): string;
  38411. /**
  38412. * Tries to copy an object by duplicating every property
  38413. * @param source defines the source object
  38414. * @param destination defines the target object
  38415. * @param doNotCopyList defines a list of properties to avoid
  38416. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38417. */
  38418. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38419. /**
  38420. * Gets a boolean indicating if the given object has no own property
  38421. * @param obj defines the object to test
  38422. * @returns true if object has no own property
  38423. */
  38424. static IsEmpty(obj: any): boolean;
  38425. /**
  38426. * Function used to register events at window level
  38427. * @param windowElement defines the Window object to use
  38428. * @param events defines the events to register
  38429. */
  38430. static RegisterTopRootEvents(windowElement: Window, events: {
  38431. name: string;
  38432. handler: Nullable<(e: FocusEvent) => any>;
  38433. }[]): void;
  38434. /**
  38435. * Function used to unregister events from window level
  38436. * @param windowElement defines the Window object to use
  38437. * @param events defines the events to unregister
  38438. */
  38439. static UnregisterTopRootEvents(windowElement: Window, events: {
  38440. name: string;
  38441. handler: Nullable<(e: FocusEvent) => any>;
  38442. }[]): void;
  38443. /**
  38444. * @ignore
  38445. */
  38446. static _ScreenshotCanvas: HTMLCanvasElement;
  38447. /**
  38448. * Dumps the current bound framebuffer
  38449. * @param width defines the rendering width
  38450. * @param height defines the rendering height
  38451. * @param engine defines the hosting engine
  38452. * @param successCallback defines the callback triggered once the data are available
  38453. * @param mimeType defines the mime type of the result
  38454. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38455. */
  38456. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38457. /**
  38458. * Converts the canvas data to blob.
  38459. * This acts as a polyfill for browsers not supporting the to blob function.
  38460. * @param canvas Defines the canvas to extract the data from
  38461. * @param successCallback Defines the callback triggered once the data are available
  38462. * @param mimeType Defines the mime type of the result
  38463. */
  38464. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38465. /**
  38466. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38467. * @param successCallback defines the callback triggered once the data are available
  38468. * @param mimeType defines the mime type of the result
  38469. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38470. */
  38471. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38472. /**
  38473. * Downloads a blob in the browser
  38474. * @param blob defines the blob to download
  38475. * @param fileName defines the name of the downloaded file
  38476. */
  38477. static Download(blob: Blob, fileName: string): void;
  38478. /**
  38479. * Captures a screenshot of the current rendering
  38480. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38481. * @param engine defines the rendering engine
  38482. * @param camera defines the source camera
  38483. * @param size This parameter can be set to a single number or to an object with the
  38484. * following (optional) properties: precision, width, height. If a single number is passed,
  38485. * it will be used for both width and height. If an object is passed, the screenshot size
  38486. * will be derived from the parameters. The precision property is a multiplier allowing
  38487. * rendering at a higher or lower resolution
  38488. * @param successCallback defines the callback receives a single parameter which contains the
  38489. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38490. * src parameter of an <img> to display it
  38491. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38492. * Check your browser for supported MIME types
  38493. */
  38494. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38495. /**
  38496. * Captures a screenshot of the current rendering
  38497. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38498. * @param engine defines the rendering engine
  38499. * @param camera defines the source camera
  38500. * @param size This parameter can be set to a single number or to an object with the
  38501. * following (optional) properties: precision, width, height. If a single number is passed,
  38502. * it will be used for both width and height. If an object is passed, the screenshot size
  38503. * will be derived from the parameters. The precision property is a multiplier allowing
  38504. * rendering at a higher or lower resolution
  38505. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38506. * Check your browser for supported MIME types
  38507. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38508. * to the src parameter of an <img> to display it
  38509. */
  38510. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38511. /**
  38512. * Generates an image screenshot from the specified camera.
  38513. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38514. * @param engine The engine to use for rendering
  38515. * @param camera The camera to use for rendering
  38516. * @param size This parameter can be set to a single number or to an object with the
  38517. * following (optional) properties: precision, width, height. If a single number is passed,
  38518. * it will be used for both width and height. If an object is passed, the screenshot size
  38519. * will be derived from the parameters. The precision property is a multiplier allowing
  38520. * rendering at a higher or lower resolution
  38521. * @param successCallback The callback receives a single parameter which contains the
  38522. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38523. * src parameter of an <img> to display it
  38524. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38525. * Check your browser for supported MIME types
  38526. * @param samples Texture samples (default: 1)
  38527. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38528. * @param fileName A name for for the downloaded file.
  38529. */
  38530. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38531. /**
  38532. * Generates an image screenshot from the specified camera.
  38533. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38534. * @param engine The engine to use for rendering
  38535. * @param camera The camera to use for rendering
  38536. * @param size This parameter can be set to a single number or to an object with the
  38537. * following (optional) properties: precision, width, height. If a single number is passed,
  38538. * it will be used for both width and height. If an object is passed, the screenshot size
  38539. * will be derived from the parameters. The precision property is a multiplier allowing
  38540. * rendering at a higher or lower resolution
  38541. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38542. * Check your browser for supported MIME types
  38543. * @param samples Texture samples (default: 1)
  38544. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38545. * @param fileName A name for for the downloaded file.
  38546. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38547. * to the src parameter of an <img> to display it
  38548. */
  38549. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38550. /**
  38551. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38552. * Be aware Math.random() could cause collisions, but:
  38553. * "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"
  38554. * @returns a pseudo random id
  38555. */
  38556. static RandomId(): string;
  38557. /**
  38558. * Test if the given uri is a base64 string
  38559. * @param uri The uri to test
  38560. * @return True if the uri is a base64 string or false otherwise
  38561. */
  38562. static IsBase64(uri: string): boolean;
  38563. /**
  38564. * Decode the given base64 uri.
  38565. * @param uri The uri to decode
  38566. * @return The decoded base64 data.
  38567. */
  38568. static DecodeBase64(uri: string): ArrayBuffer;
  38569. /**
  38570. * Gets the absolute url.
  38571. * @param url the input url
  38572. * @return the absolute url
  38573. */
  38574. static GetAbsoluteUrl(url: string): string;
  38575. /**
  38576. * No log
  38577. */
  38578. static readonly NoneLogLevel: number;
  38579. /**
  38580. * Only message logs
  38581. */
  38582. static readonly MessageLogLevel: number;
  38583. /**
  38584. * Only warning logs
  38585. */
  38586. static readonly WarningLogLevel: number;
  38587. /**
  38588. * Only error logs
  38589. */
  38590. static readonly ErrorLogLevel: number;
  38591. /**
  38592. * All logs
  38593. */
  38594. static readonly AllLogLevel: number;
  38595. /**
  38596. * Gets a value indicating the number of loading errors
  38597. * @ignorenaming
  38598. */
  38599. static get errorsCount(): number;
  38600. /**
  38601. * Callback called when a new log is added
  38602. */
  38603. static OnNewCacheEntry: (entry: string) => void;
  38604. /**
  38605. * Log a message to the console
  38606. * @param message defines the message to log
  38607. */
  38608. static Log(message: string): void;
  38609. /**
  38610. * Write a warning message to the console
  38611. * @param message defines the message to log
  38612. */
  38613. static Warn(message: string): void;
  38614. /**
  38615. * Write an error message to the console
  38616. * @param message defines the message to log
  38617. */
  38618. static Error(message: string): void;
  38619. /**
  38620. * Gets current log cache (list of logs)
  38621. */
  38622. static get LogCache(): string;
  38623. /**
  38624. * Clears the log cache
  38625. */
  38626. static ClearLogCache(): void;
  38627. /**
  38628. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38629. */
  38630. static set LogLevels(level: number);
  38631. /**
  38632. * Checks if the window object exists
  38633. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38634. */
  38635. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38636. /**
  38637. * No performance log
  38638. */
  38639. static readonly PerformanceNoneLogLevel: number;
  38640. /**
  38641. * Use user marks to log performance
  38642. */
  38643. static readonly PerformanceUserMarkLogLevel: number;
  38644. /**
  38645. * Log performance to the console
  38646. */
  38647. static readonly PerformanceConsoleLogLevel: number;
  38648. private static _performance;
  38649. /**
  38650. * Sets the current performance log level
  38651. */
  38652. static set PerformanceLogLevel(level: number);
  38653. private static _StartPerformanceCounterDisabled;
  38654. private static _EndPerformanceCounterDisabled;
  38655. private static _StartUserMark;
  38656. private static _EndUserMark;
  38657. private static _StartPerformanceConsole;
  38658. private static _EndPerformanceConsole;
  38659. /**
  38660. * Starts a performance counter
  38661. */
  38662. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38663. /**
  38664. * Ends a specific performance coutner
  38665. */
  38666. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38667. /**
  38668. * Gets either window.performance.now() if supported or Date.now() else
  38669. */
  38670. static get Now(): number;
  38671. /**
  38672. * This method will return the name of the class used to create the instance of the given object.
  38673. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38674. * @param object the object to get the class name from
  38675. * @param isType defines if the object is actually a type
  38676. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38677. */
  38678. static GetClassName(object: any, isType?: boolean): string;
  38679. /**
  38680. * Gets the first element of an array satisfying a given predicate
  38681. * @param array defines the array to browse
  38682. * @param predicate defines the predicate to use
  38683. * @returns null if not found or the element
  38684. */
  38685. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38686. /**
  38687. * This method will return the name of the full name of the class, including its owning module (if any).
  38688. * 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).
  38689. * @param object the object to get the class name from
  38690. * @param isType defines if the object is actually a type
  38691. * @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.
  38692. * @ignorenaming
  38693. */
  38694. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38695. /**
  38696. * Returns a promise that resolves after the given amount of time.
  38697. * @param delay Number of milliseconds to delay
  38698. * @returns Promise that resolves after the given amount of time
  38699. */
  38700. static DelayAsync(delay: number): Promise<void>;
  38701. /**
  38702. * Utility function to detect if the current user agent is Safari
  38703. * @returns whether or not the current user agent is safari
  38704. */
  38705. static IsSafari(): boolean;
  38706. }
  38707. /**
  38708. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38709. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38710. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38711. * @param name The name of the class, case should be preserved
  38712. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38713. */
  38714. export function className(name: string, module?: string): (target: Object) => void;
  38715. /**
  38716. * An implementation of a loop for asynchronous functions.
  38717. */
  38718. export class AsyncLoop {
  38719. /**
  38720. * Defines the number of iterations for the loop
  38721. */
  38722. iterations: number;
  38723. /**
  38724. * Defines the current index of the loop.
  38725. */
  38726. index: number;
  38727. private _done;
  38728. private _fn;
  38729. private _successCallback;
  38730. /**
  38731. * Constructor.
  38732. * @param iterations the number of iterations.
  38733. * @param func the function to run each iteration
  38734. * @param successCallback the callback that will be called upon succesful execution
  38735. * @param offset starting offset.
  38736. */
  38737. constructor(
  38738. /**
  38739. * Defines the number of iterations for the loop
  38740. */
  38741. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38742. /**
  38743. * Execute the next iteration. Must be called after the last iteration was finished.
  38744. */
  38745. executeNext(): void;
  38746. /**
  38747. * Break the loop and run the success callback.
  38748. */
  38749. breakLoop(): void;
  38750. /**
  38751. * Create and run an async loop.
  38752. * @param iterations the number of iterations.
  38753. * @param fn the function to run each iteration
  38754. * @param successCallback the callback that will be called upon succesful execution
  38755. * @param offset starting offset.
  38756. * @returns the created async loop object
  38757. */
  38758. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38759. /**
  38760. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38761. * @param iterations total number of iterations
  38762. * @param syncedIterations number of synchronous iterations in each async iteration.
  38763. * @param fn the function to call each iteration.
  38764. * @param callback a success call back that will be called when iterating stops.
  38765. * @param breakFunction a break condition (optional)
  38766. * @param timeout timeout settings for the setTimeout function. default - 0.
  38767. * @returns the created async loop object
  38768. */
  38769. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /**
  38774. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38775. * The underlying implementation relies on an associative array to ensure the best performances.
  38776. * The value can be anything including 'null' but except 'undefined'
  38777. */
  38778. export class StringDictionary<T> {
  38779. /**
  38780. * This will clear this dictionary and copy the content from the 'source' one.
  38781. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38782. * @param source the dictionary to take the content from and copy to this dictionary
  38783. */
  38784. copyFrom(source: StringDictionary<T>): void;
  38785. /**
  38786. * Get a value based from its key
  38787. * @param key the given key to get the matching value from
  38788. * @return the value if found, otherwise undefined is returned
  38789. */
  38790. get(key: string): T | undefined;
  38791. /**
  38792. * Get a value from its key or add it if it doesn't exist.
  38793. * This method will ensure you that a given key/data will be present in the dictionary.
  38794. * @param key the given key to get the matching value from
  38795. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38796. * The factory will only be invoked if there's no data for the given key.
  38797. * @return the value corresponding to the key.
  38798. */
  38799. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38800. /**
  38801. * Get a value from its key if present in the dictionary otherwise add it
  38802. * @param key the key to get the value from
  38803. * @param val if there's no such key/value pair in the dictionary add it with this value
  38804. * @return the value corresponding to the key
  38805. */
  38806. getOrAdd(key: string, val: T): T;
  38807. /**
  38808. * Check if there's a given key in the dictionary
  38809. * @param key the key to check for
  38810. * @return true if the key is present, false otherwise
  38811. */
  38812. contains(key: string): boolean;
  38813. /**
  38814. * Add a new key and its corresponding value
  38815. * @param key the key to add
  38816. * @param value the value corresponding to the key
  38817. * @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
  38818. */
  38819. add(key: string, value: T): boolean;
  38820. /**
  38821. * Update a specific value associated to a key
  38822. * @param key defines the key to use
  38823. * @param value defines the value to store
  38824. * @returns true if the value was updated (or false if the key was not found)
  38825. */
  38826. set(key: string, value: T): boolean;
  38827. /**
  38828. * Get the element of the given key and remove it from the dictionary
  38829. * @param key defines the key to search
  38830. * @returns the value associated with the key or null if not found
  38831. */
  38832. getAndRemove(key: string): Nullable<T>;
  38833. /**
  38834. * Remove a key/value from the dictionary.
  38835. * @param key the key to remove
  38836. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38837. */
  38838. remove(key: string): boolean;
  38839. /**
  38840. * Clear the whole content of the dictionary
  38841. */
  38842. clear(): void;
  38843. /**
  38844. * Gets the current count
  38845. */
  38846. get count(): number;
  38847. /**
  38848. * Execute a callback on each key/val of the dictionary.
  38849. * Note that you can remove any element in this dictionary in the callback implementation
  38850. * @param callback the callback to execute on a given key/value pair
  38851. */
  38852. forEach(callback: (key: string, val: T) => void): void;
  38853. /**
  38854. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38855. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38856. * Note that you can remove any element in this dictionary in the callback implementation
  38857. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38858. * @returns the first item
  38859. */
  38860. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38861. private _count;
  38862. private _data;
  38863. }
  38864. }
  38865. declare module BABYLON {
  38866. /** @hidden */
  38867. export interface ICollisionCoordinator {
  38868. createCollider(): Collider;
  38869. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38870. init(scene: Scene): void;
  38871. }
  38872. /** @hidden */
  38873. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38874. private _scene;
  38875. private _scaledPosition;
  38876. private _scaledVelocity;
  38877. private _finalPosition;
  38878. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38879. createCollider(): Collider;
  38880. init(scene: Scene): void;
  38881. private _collideWithWorld;
  38882. }
  38883. }
  38884. declare module BABYLON {
  38885. /**
  38886. * Class used to manage all inputs for the scene.
  38887. */
  38888. export class InputManager {
  38889. /** The distance in pixel that you have to move to prevent some events */
  38890. static DragMovementThreshold: number;
  38891. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38892. static LongPressDelay: number;
  38893. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38894. static DoubleClickDelay: number;
  38895. /** If you need to check double click without raising a single click at first click, enable this flag */
  38896. static ExclusiveDoubleClickMode: boolean;
  38897. /** 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. */
  38898. private _alreadyAttached;
  38899. private _wheelEventName;
  38900. private _onPointerMove;
  38901. private _onPointerDown;
  38902. private _onPointerUp;
  38903. private _initClickEvent;
  38904. private _initActionManager;
  38905. private _delayedSimpleClick;
  38906. private _delayedSimpleClickTimeout;
  38907. private _previousDelayedSimpleClickTimeout;
  38908. private _meshPickProceed;
  38909. private _previousButtonPressed;
  38910. private _currentPickResult;
  38911. private _previousPickResult;
  38912. private _totalPointersPressed;
  38913. private _doubleClickOccured;
  38914. private _pointerOverMesh;
  38915. private _pickedDownMesh;
  38916. private _pickedUpMesh;
  38917. private _pointerX;
  38918. private _pointerY;
  38919. private _unTranslatedPointerX;
  38920. private _unTranslatedPointerY;
  38921. private _startingPointerPosition;
  38922. private _previousStartingPointerPosition;
  38923. private _startingPointerTime;
  38924. private _previousStartingPointerTime;
  38925. private _pointerCaptures;
  38926. private _onKeyDown;
  38927. private _onKeyUp;
  38928. private _onCanvasFocusObserver;
  38929. private _onCanvasBlurObserver;
  38930. private _scene;
  38931. /**
  38932. * Creates a new InputManager
  38933. * @param scene defines the hosting scene
  38934. */
  38935. constructor(scene: Scene);
  38936. /**
  38937. * Gets the mesh that is currently under the pointer
  38938. */
  38939. get meshUnderPointer(): Nullable<AbstractMesh>;
  38940. /**
  38941. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38942. */
  38943. get unTranslatedPointer(): Vector2;
  38944. /**
  38945. * Gets or sets the current on-screen X position of the pointer
  38946. */
  38947. get pointerX(): number;
  38948. set pointerX(value: number);
  38949. /**
  38950. * Gets or sets the current on-screen Y position of the pointer
  38951. */
  38952. get pointerY(): number;
  38953. set pointerY(value: number);
  38954. private _updatePointerPosition;
  38955. private _processPointerMove;
  38956. private _setRayOnPointerInfo;
  38957. private _checkPrePointerObservable;
  38958. /**
  38959. * Use this method to simulate a pointer move on a mesh
  38960. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38961. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38962. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38963. */
  38964. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38965. /**
  38966. * Use this method to simulate a pointer down on a mesh
  38967. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38968. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38969. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38970. */
  38971. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38972. private _processPointerDown;
  38973. /** @hidden */
  38974. _isPointerSwiping(): boolean;
  38975. /**
  38976. * Use this method to simulate a pointer up on a mesh
  38977. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38978. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38979. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38980. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38981. */
  38982. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38983. private _processPointerUp;
  38984. /**
  38985. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38986. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38987. * @returns true if the pointer was captured
  38988. */
  38989. isPointerCaptured(pointerId?: number): boolean;
  38990. /**
  38991. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38992. * @param attachUp defines if you want to attach events to pointerup
  38993. * @param attachDown defines if you want to attach events to pointerdown
  38994. * @param attachMove defines if you want to attach events to pointermove
  38995. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38996. */
  38997. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38998. /**
  38999. * Detaches all event handlers
  39000. */
  39001. detachControl(): void;
  39002. /**
  39003. * Force the value of meshUnderPointer
  39004. * @param mesh defines the mesh to use
  39005. */
  39006. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39007. /**
  39008. * Gets the mesh under the pointer
  39009. * @returns a Mesh or null if no mesh is under the pointer
  39010. */
  39011. getPointerOverMesh(): Nullable<AbstractMesh>;
  39012. }
  39013. }
  39014. declare module BABYLON {
  39015. /**
  39016. * This class defines the direct association between an animation and a target
  39017. */
  39018. export class TargetedAnimation {
  39019. /**
  39020. * Animation to perform
  39021. */
  39022. animation: Animation;
  39023. /**
  39024. * Target to animate
  39025. */
  39026. target: any;
  39027. /**
  39028. * Returns the string "TargetedAnimation"
  39029. * @returns "TargetedAnimation"
  39030. */
  39031. getClassName(): string;
  39032. /**
  39033. * Serialize the object
  39034. * @returns the JSON object representing the current entity
  39035. */
  39036. serialize(): any;
  39037. }
  39038. /**
  39039. * Use this class to create coordinated animations on multiple targets
  39040. */
  39041. export class AnimationGroup implements IDisposable {
  39042. /** The name of the animation group */
  39043. name: string;
  39044. private _scene;
  39045. private _targetedAnimations;
  39046. private _animatables;
  39047. private _from;
  39048. private _to;
  39049. private _isStarted;
  39050. private _isPaused;
  39051. private _speedRatio;
  39052. private _loopAnimation;
  39053. private _isAdditive;
  39054. /**
  39055. * Gets or sets the unique id of the node
  39056. */
  39057. uniqueId: number;
  39058. /**
  39059. * This observable will notify when one animation have ended
  39060. */
  39061. onAnimationEndObservable: Observable<TargetedAnimation>;
  39062. /**
  39063. * Observer raised when one animation loops
  39064. */
  39065. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39066. /**
  39067. * Observer raised when all animations have looped
  39068. */
  39069. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39070. /**
  39071. * This observable will notify when all animations have ended.
  39072. */
  39073. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39074. /**
  39075. * This observable will notify when all animations have paused.
  39076. */
  39077. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39078. /**
  39079. * This observable will notify when all animations are playing.
  39080. */
  39081. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39082. /**
  39083. * Gets the first frame
  39084. */
  39085. get from(): number;
  39086. /**
  39087. * Gets the last frame
  39088. */
  39089. get to(): number;
  39090. /**
  39091. * Define if the animations are started
  39092. */
  39093. get isStarted(): boolean;
  39094. /**
  39095. * Gets a value indicating that the current group is playing
  39096. */
  39097. get isPlaying(): boolean;
  39098. /**
  39099. * Gets or sets the speed ratio to use for all animations
  39100. */
  39101. get speedRatio(): number;
  39102. /**
  39103. * Gets or sets the speed ratio to use for all animations
  39104. */
  39105. set speedRatio(value: number);
  39106. /**
  39107. * Gets or sets if all animations should loop or not
  39108. */
  39109. get loopAnimation(): boolean;
  39110. set loopAnimation(value: boolean);
  39111. /**
  39112. * Gets or sets if all animations should be evaluated additively
  39113. */
  39114. get isAdditive(): boolean;
  39115. set isAdditive(value: boolean);
  39116. /**
  39117. * Gets the targeted animations for this animation group
  39118. */
  39119. get targetedAnimations(): Array<TargetedAnimation>;
  39120. /**
  39121. * returning the list of animatables controlled by this animation group.
  39122. */
  39123. get animatables(): Array<Animatable>;
  39124. /**
  39125. * Gets the list of target animations
  39126. */
  39127. get children(): TargetedAnimation[];
  39128. /**
  39129. * Instantiates a new Animation Group.
  39130. * This helps managing several animations at once.
  39131. * @see https://doc.babylonjs.com/how_to/group
  39132. * @param name Defines the name of the group
  39133. * @param scene Defines the scene the group belongs to
  39134. */
  39135. constructor(
  39136. /** The name of the animation group */
  39137. name: string, scene?: Nullable<Scene>);
  39138. /**
  39139. * Add an animation (with its target) in the group
  39140. * @param animation defines the animation we want to add
  39141. * @param target defines the target of the animation
  39142. * @returns the TargetedAnimation object
  39143. */
  39144. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39145. /**
  39146. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39147. * It can add constant keys at begin or end
  39148. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39149. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39150. * @returns the animation group
  39151. */
  39152. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39153. private _animationLoopCount;
  39154. private _animationLoopFlags;
  39155. private _processLoop;
  39156. /**
  39157. * Start all animations on given targets
  39158. * @param loop defines if animations must loop
  39159. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39160. * @param from defines the from key (optional)
  39161. * @param to defines the to key (optional)
  39162. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39163. * @returns the current animation group
  39164. */
  39165. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39166. /**
  39167. * Pause all animations
  39168. * @returns the animation group
  39169. */
  39170. pause(): AnimationGroup;
  39171. /**
  39172. * Play all animations to initial state
  39173. * This function will start() the animations if they were not started or will restart() them if they were paused
  39174. * @param loop defines if animations must loop
  39175. * @returns the animation group
  39176. */
  39177. play(loop?: boolean): AnimationGroup;
  39178. /**
  39179. * Reset all animations to initial state
  39180. * @returns the animation group
  39181. */
  39182. reset(): AnimationGroup;
  39183. /**
  39184. * Restart animations from key 0
  39185. * @returns the animation group
  39186. */
  39187. restart(): AnimationGroup;
  39188. /**
  39189. * Stop all animations
  39190. * @returns the animation group
  39191. */
  39192. stop(): AnimationGroup;
  39193. /**
  39194. * Set animation weight for all animatables
  39195. * @param weight defines the weight to use
  39196. * @return the animationGroup
  39197. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39198. */
  39199. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39200. /**
  39201. * Synchronize and normalize all animatables with a source animatable
  39202. * @param root defines the root animatable to synchronize with
  39203. * @return the animationGroup
  39204. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39205. */
  39206. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39207. /**
  39208. * Goes to a specific frame in this animation group
  39209. * @param frame the frame number to go to
  39210. * @return the animationGroup
  39211. */
  39212. goToFrame(frame: number): AnimationGroup;
  39213. /**
  39214. * Dispose all associated resources
  39215. */
  39216. dispose(): void;
  39217. private _checkAnimationGroupEnded;
  39218. /**
  39219. * Clone the current animation group and returns a copy
  39220. * @param newName defines the name of the new group
  39221. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39222. * @returns the new aniamtion group
  39223. */
  39224. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39225. /**
  39226. * Serializes the animationGroup to an object
  39227. * @returns Serialized object
  39228. */
  39229. serialize(): any;
  39230. /**
  39231. * Returns a new AnimationGroup object parsed from the source provided.
  39232. * @param parsedAnimationGroup defines the source
  39233. * @param scene defines the scene that will receive the animationGroup
  39234. * @returns a new AnimationGroup
  39235. */
  39236. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39237. /**
  39238. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39239. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39240. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39241. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39242. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39243. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39244. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39245. */
  39246. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39247. /**
  39248. * Returns the string "AnimationGroup"
  39249. * @returns "AnimationGroup"
  39250. */
  39251. getClassName(): string;
  39252. /**
  39253. * Creates a detailled string about the object
  39254. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39255. * @returns a string representing the object
  39256. */
  39257. toString(fullDetails?: boolean): string;
  39258. }
  39259. }
  39260. declare module BABYLON {
  39261. /**
  39262. * Define an interface for all classes that will hold resources
  39263. */
  39264. export interface IDisposable {
  39265. /**
  39266. * Releases all held resources
  39267. */
  39268. dispose(): void;
  39269. }
  39270. /** Interface defining initialization parameters for Scene class */
  39271. export interface SceneOptions {
  39272. /**
  39273. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39274. * It will improve performance when the number of geometries becomes important.
  39275. */
  39276. useGeometryUniqueIdsMap?: boolean;
  39277. /**
  39278. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39279. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39280. */
  39281. useMaterialMeshMap?: boolean;
  39282. /**
  39283. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39284. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39285. */
  39286. useClonedMeshMap?: boolean;
  39287. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39288. virtual?: boolean;
  39289. }
  39290. /**
  39291. * Represents a scene to be rendered by the engine.
  39292. * @see https://doc.babylonjs.com/features/scene
  39293. */
  39294. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39295. /** The fog is deactivated */
  39296. static readonly FOGMODE_NONE: number;
  39297. /** The fog density is following an exponential function */
  39298. static readonly FOGMODE_EXP: number;
  39299. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39300. static readonly FOGMODE_EXP2: number;
  39301. /** The fog density is following a linear function. */
  39302. static readonly FOGMODE_LINEAR: number;
  39303. /**
  39304. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39305. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39306. */
  39307. static MinDeltaTime: number;
  39308. /**
  39309. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39310. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39311. */
  39312. static MaxDeltaTime: number;
  39313. /**
  39314. * Factory used to create the default material.
  39315. * @param name The name of the material to create
  39316. * @param scene The scene to create the material for
  39317. * @returns The default material
  39318. */
  39319. static DefaultMaterialFactory(scene: Scene): Material;
  39320. /**
  39321. * Factory used to create the a collision coordinator.
  39322. * @returns The collision coordinator
  39323. */
  39324. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39325. /** @hidden */
  39326. _inputManager: InputManager;
  39327. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39328. cameraToUseForPointers: Nullable<Camera>;
  39329. /** @hidden */
  39330. readonly _isScene: boolean;
  39331. /** @hidden */
  39332. _blockEntityCollection: boolean;
  39333. /**
  39334. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39335. */
  39336. autoClear: boolean;
  39337. /**
  39338. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39339. */
  39340. autoClearDepthAndStencil: boolean;
  39341. /**
  39342. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39343. */
  39344. clearColor: Color4;
  39345. /**
  39346. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39347. */
  39348. ambientColor: Color3;
  39349. /**
  39350. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39351. * It should only be one of the following (if not the default embedded one):
  39352. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39353. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39354. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39355. * The material properties need to be setup according to the type of texture in use.
  39356. */
  39357. environmentBRDFTexture: BaseTexture;
  39358. /**
  39359. * Texture used in all pbr material as the reflection texture.
  39360. * As in the majority of the scene they are the same (exception for multi room and so on),
  39361. * this is easier to reference from here than from all the materials.
  39362. */
  39363. get environmentTexture(): Nullable<BaseTexture>;
  39364. /**
  39365. * Texture used in all pbr material as the reflection texture.
  39366. * As in the majority of the scene they are the same (exception for multi room and so on),
  39367. * this is easier to set here than in all the materials.
  39368. */
  39369. set environmentTexture(value: Nullable<BaseTexture>);
  39370. /** @hidden */
  39371. protected _environmentIntensity: number;
  39372. /**
  39373. * Intensity of the environment in all pbr material.
  39374. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39375. * As in the majority of the scene they are the same (exception for multi room and so on),
  39376. * this is easier to reference from here than from all the materials.
  39377. */
  39378. get environmentIntensity(): number;
  39379. /**
  39380. * Intensity of the environment in all pbr material.
  39381. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39382. * As in the majority of the scene they are the same (exception for multi room and so on),
  39383. * this is easier to set here than in all the materials.
  39384. */
  39385. set environmentIntensity(value: number);
  39386. /** @hidden */
  39387. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39388. /**
  39389. * Default image processing configuration used either in the rendering
  39390. * Forward main pass or through the imageProcessingPostProcess if present.
  39391. * As in the majority of the scene they are the same (exception for multi camera),
  39392. * this is easier to reference from here than from all the materials and post process.
  39393. *
  39394. * No setter as we it is a shared configuration, you can set the values instead.
  39395. */
  39396. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39397. private _forceWireframe;
  39398. /**
  39399. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39400. */
  39401. set forceWireframe(value: boolean);
  39402. get forceWireframe(): boolean;
  39403. private _skipFrustumClipping;
  39404. /**
  39405. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39406. */
  39407. set skipFrustumClipping(value: boolean);
  39408. get skipFrustumClipping(): boolean;
  39409. private _forcePointsCloud;
  39410. /**
  39411. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39412. */
  39413. set forcePointsCloud(value: boolean);
  39414. get forcePointsCloud(): boolean;
  39415. /**
  39416. * Gets or sets the active clipplane 1
  39417. */
  39418. clipPlane: Nullable<Plane>;
  39419. /**
  39420. * Gets or sets the active clipplane 2
  39421. */
  39422. clipPlane2: Nullable<Plane>;
  39423. /**
  39424. * Gets or sets the active clipplane 3
  39425. */
  39426. clipPlane3: Nullable<Plane>;
  39427. /**
  39428. * Gets or sets the active clipplane 4
  39429. */
  39430. clipPlane4: Nullable<Plane>;
  39431. /**
  39432. * Gets or sets the active clipplane 5
  39433. */
  39434. clipPlane5: Nullable<Plane>;
  39435. /**
  39436. * Gets or sets the active clipplane 6
  39437. */
  39438. clipPlane6: Nullable<Plane>;
  39439. /**
  39440. * Gets or sets a boolean indicating if animations are enabled
  39441. */
  39442. animationsEnabled: boolean;
  39443. private _animationPropertiesOverride;
  39444. /**
  39445. * Gets or sets the animation properties override
  39446. */
  39447. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39448. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39449. /**
  39450. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39451. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39452. */
  39453. useConstantAnimationDeltaTime: boolean;
  39454. /**
  39455. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39456. * Please note that it requires to run a ray cast through the scene on every frame
  39457. */
  39458. constantlyUpdateMeshUnderPointer: boolean;
  39459. /**
  39460. * Defines the HTML cursor to use when hovering over interactive elements
  39461. */
  39462. hoverCursor: string;
  39463. /**
  39464. * Defines the HTML default cursor to use (empty by default)
  39465. */
  39466. defaultCursor: string;
  39467. /**
  39468. * Defines whether cursors are handled by the scene.
  39469. */
  39470. doNotHandleCursors: boolean;
  39471. /**
  39472. * This is used to call preventDefault() on pointer down
  39473. * in order to block unwanted artifacts like system double clicks
  39474. */
  39475. preventDefaultOnPointerDown: boolean;
  39476. /**
  39477. * This is used to call preventDefault() on pointer up
  39478. * in order to block unwanted artifacts like system double clicks
  39479. */
  39480. preventDefaultOnPointerUp: boolean;
  39481. /**
  39482. * Gets or sets user defined metadata
  39483. */
  39484. metadata: any;
  39485. /**
  39486. * For internal use only. Please do not use.
  39487. */
  39488. reservedDataStore: any;
  39489. /**
  39490. * Gets the name of the plugin used to load this scene (null by default)
  39491. */
  39492. loadingPluginName: string;
  39493. /**
  39494. * Use this array to add regular expressions used to disable offline support for specific urls
  39495. */
  39496. disableOfflineSupportExceptionRules: RegExp[];
  39497. /**
  39498. * An event triggered when the scene is disposed.
  39499. */
  39500. onDisposeObservable: Observable<Scene>;
  39501. private _onDisposeObserver;
  39502. /** Sets a function to be executed when this scene is disposed. */
  39503. set onDispose(callback: () => void);
  39504. /**
  39505. * An event triggered before rendering the scene (right after animations and physics)
  39506. */
  39507. onBeforeRenderObservable: Observable<Scene>;
  39508. private _onBeforeRenderObserver;
  39509. /** Sets a function to be executed before rendering this scene */
  39510. set beforeRender(callback: Nullable<() => void>);
  39511. /**
  39512. * An event triggered after rendering the scene
  39513. */
  39514. onAfterRenderObservable: Observable<Scene>;
  39515. /**
  39516. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39517. */
  39518. onAfterRenderCameraObservable: Observable<Camera>;
  39519. private _onAfterRenderObserver;
  39520. /** Sets a function to be executed after rendering this scene */
  39521. set afterRender(callback: Nullable<() => void>);
  39522. /**
  39523. * An event triggered before animating the scene
  39524. */
  39525. onBeforeAnimationsObservable: Observable<Scene>;
  39526. /**
  39527. * An event triggered after animations processing
  39528. */
  39529. onAfterAnimationsObservable: Observable<Scene>;
  39530. /**
  39531. * An event triggered before draw calls are ready to be sent
  39532. */
  39533. onBeforeDrawPhaseObservable: Observable<Scene>;
  39534. /**
  39535. * An event triggered after draw calls have been sent
  39536. */
  39537. onAfterDrawPhaseObservable: Observable<Scene>;
  39538. /**
  39539. * An event triggered when the scene is ready
  39540. */
  39541. onReadyObservable: Observable<Scene>;
  39542. /**
  39543. * An event triggered before rendering a camera
  39544. */
  39545. onBeforeCameraRenderObservable: Observable<Camera>;
  39546. private _onBeforeCameraRenderObserver;
  39547. /** Sets a function to be executed before rendering a camera*/
  39548. set beforeCameraRender(callback: () => void);
  39549. /**
  39550. * An event triggered after rendering a camera
  39551. */
  39552. onAfterCameraRenderObservable: Observable<Camera>;
  39553. private _onAfterCameraRenderObserver;
  39554. /** Sets a function to be executed after rendering a camera*/
  39555. set afterCameraRender(callback: () => void);
  39556. /**
  39557. * An event triggered when active meshes evaluation is about to start
  39558. */
  39559. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39560. /**
  39561. * An event triggered when active meshes evaluation is done
  39562. */
  39563. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39564. /**
  39565. * An event triggered when particles rendering is about to start
  39566. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39567. */
  39568. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39569. /**
  39570. * An event triggered when particles rendering is done
  39571. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39572. */
  39573. onAfterParticlesRenderingObservable: Observable<Scene>;
  39574. /**
  39575. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39576. */
  39577. onDataLoadedObservable: Observable<Scene>;
  39578. /**
  39579. * An event triggered when a camera is created
  39580. */
  39581. onNewCameraAddedObservable: Observable<Camera>;
  39582. /**
  39583. * An event triggered when a camera is removed
  39584. */
  39585. onCameraRemovedObservable: Observable<Camera>;
  39586. /**
  39587. * An event triggered when a light is created
  39588. */
  39589. onNewLightAddedObservable: Observable<Light>;
  39590. /**
  39591. * An event triggered when a light is removed
  39592. */
  39593. onLightRemovedObservable: Observable<Light>;
  39594. /**
  39595. * An event triggered when a geometry is created
  39596. */
  39597. onNewGeometryAddedObservable: Observable<Geometry>;
  39598. /**
  39599. * An event triggered when a geometry is removed
  39600. */
  39601. onGeometryRemovedObservable: Observable<Geometry>;
  39602. /**
  39603. * An event triggered when a transform node is created
  39604. */
  39605. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39606. /**
  39607. * An event triggered when a transform node is removed
  39608. */
  39609. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39610. /**
  39611. * An event triggered when a mesh is created
  39612. */
  39613. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39614. /**
  39615. * An event triggered when a mesh is removed
  39616. */
  39617. onMeshRemovedObservable: Observable<AbstractMesh>;
  39618. /**
  39619. * An event triggered when a skeleton is created
  39620. */
  39621. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39622. /**
  39623. * An event triggered when a skeleton is removed
  39624. */
  39625. onSkeletonRemovedObservable: Observable<Skeleton>;
  39626. /**
  39627. * An event triggered when a material is created
  39628. */
  39629. onNewMaterialAddedObservable: Observable<Material>;
  39630. /**
  39631. * An event triggered when a material is removed
  39632. */
  39633. onMaterialRemovedObservable: Observable<Material>;
  39634. /**
  39635. * An event triggered when a texture is created
  39636. */
  39637. onNewTextureAddedObservable: Observable<BaseTexture>;
  39638. /**
  39639. * An event triggered when a texture is removed
  39640. */
  39641. onTextureRemovedObservable: Observable<BaseTexture>;
  39642. /**
  39643. * An event triggered when render targets are about to be rendered
  39644. * Can happen multiple times per frame.
  39645. */
  39646. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39647. /**
  39648. * An event triggered when render targets were rendered.
  39649. * Can happen multiple times per frame.
  39650. */
  39651. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39652. /**
  39653. * An event triggered before calculating deterministic simulation step
  39654. */
  39655. onBeforeStepObservable: Observable<Scene>;
  39656. /**
  39657. * An event triggered after calculating deterministic simulation step
  39658. */
  39659. onAfterStepObservable: Observable<Scene>;
  39660. /**
  39661. * An event triggered when the activeCamera property is updated
  39662. */
  39663. onActiveCameraChanged: Observable<Scene>;
  39664. /**
  39665. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39666. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39667. * 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)
  39668. */
  39669. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39670. /**
  39671. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39672. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39673. * 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)
  39674. */
  39675. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39676. /**
  39677. * This Observable will when a mesh has been imported into the scene.
  39678. */
  39679. onMeshImportedObservable: Observable<AbstractMesh>;
  39680. /**
  39681. * This Observable will when an animation file has been imported into the scene.
  39682. */
  39683. onAnimationFileImportedObservable: Observable<Scene>;
  39684. /**
  39685. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39686. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39687. */
  39688. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39689. /** @hidden */
  39690. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39691. /**
  39692. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39693. */
  39694. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39695. /**
  39696. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39697. */
  39698. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39699. /**
  39700. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39701. */
  39702. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39703. /** Callback called when a pointer move is detected */
  39704. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39705. /** Callback called when a pointer down is detected */
  39706. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39707. /** Callback called when a pointer up is detected */
  39708. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39709. /** Callback called when a pointer pick is detected */
  39710. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39711. /**
  39712. * 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).
  39713. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39714. */
  39715. onPrePointerObservable: Observable<PointerInfoPre>;
  39716. /**
  39717. * Observable event triggered each time an input event is received from the rendering canvas
  39718. */
  39719. onPointerObservable: Observable<PointerInfo>;
  39720. /**
  39721. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39722. */
  39723. get unTranslatedPointer(): Vector2;
  39724. /**
  39725. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39726. */
  39727. static get DragMovementThreshold(): number;
  39728. static set DragMovementThreshold(value: number);
  39729. /**
  39730. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39731. */
  39732. static get LongPressDelay(): number;
  39733. static set LongPressDelay(value: number);
  39734. /**
  39735. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39736. */
  39737. static get DoubleClickDelay(): number;
  39738. static set DoubleClickDelay(value: number);
  39739. /** If you need to check double click without raising a single click at first click, enable this flag */
  39740. static get ExclusiveDoubleClickMode(): boolean;
  39741. static set ExclusiveDoubleClickMode(value: boolean);
  39742. /** @hidden */
  39743. _mirroredCameraPosition: Nullable<Vector3>;
  39744. /**
  39745. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39746. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39747. */
  39748. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39749. /**
  39750. * Observable event triggered each time an keyboard event is received from the hosting window
  39751. */
  39752. onKeyboardObservable: Observable<KeyboardInfo>;
  39753. private _useRightHandedSystem;
  39754. /**
  39755. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39756. */
  39757. set useRightHandedSystem(value: boolean);
  39758. get useRightHandedSystem(): boolean;
  39759. private _timeAccumulator;
  39760. private _currentStepId;
  39761. private _currentInternalStep;
  39762. /**
  39763. * Sets the step Id used by deterministic lock step
  39764. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39765. * @param newStepId defines the step Id
  39766. */
  39767. setStepId(newStepId: number): void;
  39768. /**
  39769. * Gets the step Id used by deterministic lock step
  39770. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39771. * @returns the step Id
  39772. */
  39773. getStepId(): number;
  39774. /**
  39775. * Gets the internal step used by deterministic lock step
  39776. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39777. * @returns the internal step
  39778. */
  39779. getInternalStep(): number;
  39780. private _fogEnabled;
  39781. /**
  39782. * Gets or sets a boolean indicating if fog is enabled on this scene
  39783. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39784. * (Default is true)
  39785. */
  39786. set fogEnabled(value: boolean);
  39787. get fogEnabled(): boolean;
  39788. private _fogMode;
  39789. /**
  39790. * Gets or sets the fog mode to use
  39791. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39792. * | mode | value |
  39793. * | --- | --- |
  39794. * | FOGMODE_NONE | 0 |
  39795. * | FOGMODE_EXP | 1 |
  39796. * | FOGMODE_EXP2 | 2 |
  39797. * | FOGMODE_LINEAR | 3 |
  39798. */
  39799. set fogMode(value: number);
  39800. get fogMode(): number;
  39801. /**
  39802. * Gets or sets the fog color to use
  39803. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39804. * (Default is Color3(0.2, 0.2, 0.3))
  39805. */
  39806. fogColor: Color3;
  39807. /**
  39808. * Gets or sets the fog density to use
  39809. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39810. * (Default is 0.1)
  39811. */
  39812. fogDensity: number;
  39813. /**
  39814. * Gets or sets the fog start distance to use
  39815. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39816. * (Default is 0)
  39817. */
  39818. fogStart: number;
  39819. /**
  39820. * Gets or sets the fog end distance to use
  39821. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39822. * (Default is 1000)
  39823. */
  39824. fogEnd: number;
  39825. /**
  39826. * Flag indicating that the frame buffer binding is handled by another component
  39827. */
  39828. prePass: boolean;
  39829. private _shadowsEnabled;
  39830. /**
  39831. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39832. */
  39833. set shadowsEnabled(value: boolean);
  39834. get shadowsEnabled(): boolean;
  39835. private _lightsEnabled;
  39836. /**
  39837. * Gets or sets a boolean indicating if lights are enabled on this scene
  39838. */
  39839. set lightsEnabled(value: boolean);
  39840. get lightsEnabled(): boolean;
  39841. /** All of the active cameras added to this scene. */
  39842. activeCameras: Camera[];
  39843. /** @hidden */
  39844. _activeCamera: Nullable<Camera>;
  39845. /** Gets or sets the current active camera */
  39846. get activeCamera(): Nullable<Camera>;
  39847. set activeCamera(value: Nullable<Camera>);
  39848. private _defaultMaterial;
  39849. /** The default material used on meshes when no material is affected */
  39850. get defaultMaterial(): Material;
  39851. /** The default material used on meshes when no material is affected */
  39852. set defaultMaterial(value: Material);
  39853. private _texturesEnabled;
  39854. /**
  39855. * Gets or sets a boolean indicating if textures are enabled on this scene
  39856. */
  39857. set texturesEnabled(value: boolean);
  39858. get texturesEnabled(): boolean;
  39859. /**
  39860. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39861. */
  39862. physicsEnabled: boolean;
  39863. /**
  39864. * Gets or sets a boolean indicating if particles are enabled on this scene
  39865. */
  39866. particlesEnabled: boolean;
  39867. /**
  39868. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39869. */
  39870. spritesEnabled: boolean;
  39871. private _skeletonsEnabled;
  39872. /**
  39873. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39874. */
  39875. set skeletonsEnabled(value: boolean);
  39876. get skeletonsEnabled(): boolean;
  39877. /**
  39878. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39879. */
  39880. lensFlaresEnabled: boolean;
  39881. /**
  39882. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39883. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39884. */
  39885. collisionsEnabled: boolean;
  39886. private _collisionCoordinator;
  39887. /** @hidden */
  39888. get collisionCoordinator(): ICollisionCoordinator;
  39889. /**
  39890. * Defines the gravity applied to this scene (used only for collisions)
  39891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39892. */
  39893. gravity: Vector3;
  39894. /**
  39895. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39896. */
  39897. postProcessesEnabled: boolean;
  39898. /**
  39899. * Gets the current postprocess manager
  39900. */
  39901. postProcessManager: PostProcessManager;
  39902. /**
  39903. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39904. */
  39905. renderTargetsEnabled: boolean;
  39906. /**
  39907. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39908. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39909. */
  39910. dumpNextRenderTargets: boolean;
  39911. /**
  39912. * The list of user defined render targets added to the scene
  39913. */
  39914. customRenderTargets: RenderTargetTexture[];
  39915. /**
  39916. * Defines if texture loading must be delayed
  39917. * If true, textures will only be loaded when they need to be rendered
  39918. */
  39919. useDelayedTextureLoading: boolean;
  39920. /**
  39921. * Gets the list of meshes imported to the scene through SceneLoader
  39922. */
  39923. importedMeshesFiles: String[];
  39924. /**
  39925. * Gets or sets a boolean indicating if probes are enabled on this scene
  39926. */
  39927. probesEnabled: boolean;
  39928. /**
  39929. * Gets or sets the current offline provider to use to store scene data
  39930. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39931. */
  39932. offlineProvider: IOfflineProvider;
  39933. /**
  39934. * Gets or sets the action manager associated with the scene
  39935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39936. */
  39937. actionManager: AbstractActionManager;
  39938. private _meshesForIntersections;
  39939. /**
  39940. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39941. */
  39942. proceduralTexturesEnabled: boolean;
  39943. private _engine;
  39944. private _totalVertices;
  39945. /** @hidden */
  39946. _activeIndices: PerfCounter;
  39947. /** @hidden */
  39948. _activeParticles: PerfCounter;
  39949. /** @hidden */
  39950. _activeBones: PerfCounter;
  39951. private _animationRatio;
  39952. /** @hidden */
  39953. _animationTimeLast: number;
  39954. /** @hidden */
  39955. _animationTime: number;
  39956. /**
  39957. * Gets or sets a general scale for animation speed
  39958. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39959. */
  39960. animationTimeScale: number;
  39961. /** @hidden */
  39962. _cachedMaterial: Nullable<Material>;
  39963. /** @hidden */
  39964. _cachedEffect: Nullable<Effect>;
  39965. /** @hidden */
  39966. _cachedVisibility: Nullable<number>;
  39967. private _renderId;
  39968. private _frameId;
  39969. private _executeWhenReadyTimeoutId;
  39970. private _intermediateRendering;
  39971. private _viewUpdateFlag;
  39972. private _projectionUpdateFlag;
  39973. /** @hidden */
  39974. _toBeDisposed: Nullable<IDisposable>[];
  39975. private _activeRequests;
  39976. /** @hidden */
  39977. _pendingData: any[];
  39978. private _isDisposed;
  39979. /**
  39980. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39981. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39982. */
  39983. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39984. private _activeMeshes;
  39985. private _processedMaterials;
  39986. private _renderTargets;
  39987. /** @hidden */
  39988. _activeParticleSystems: SmartArray<IParticleSystem>;
  39989. private _activeSkeletons;
  39990. private _softwareSkinnedMeshes;
  39991. private _renderingManager;
  39992. /** @hidden */
  39993. _activeAnimatables: Animatable[];
  39994. private _transformMatrix;
  39995. private _sceneUbo;
  39996. /** @hidden */
  39997. _viewMatrix: Matrix;
  39998. private _projectionMatrix;
  39999. /** @hidden */
  40000. _forcedViewPosition: Nullable<Vector3>;
  40001. /** @hidden */
  40002. _frustumPlanes: Plane[];
  40003. /**
  40004. * Gets the list of frustum planes (built from the active camera)
  40005. */
  40006. get frustumPlanes(): Plane[];
  40007. /**
  40008. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40009. * This is useful if there are more lights that the maximum simulteanous authorized
  40010. */
  40011. requireLightSorting: boolean;
  40012. /** @hidden */
  40013. readonly useMaterialMeshMap: boolean;
  40014. /** @hidden */
  40015. readonly useClonedMeshMap: boolean;
  40016. private _externalData;
  40017. private _uid;
  40018. /**
  40019. * @hidden
  40020. * Backing store of defined scene components.
  40021. */
  40022. _components: ISceneComponent[];
  40023. /**
  40024. * @hidden
  40025. * Backing store of defined scene components.
  40026. */
  40027. _serializableComponents: ISceneSerializableComponent[];
  40028. /**
  40029. * List of components to register on the next registration step.
  40030. */
  40031. private _transientComponents;
  40032. /**
  40033. * Registers the transient components if needed.
  40034. */
  40035. private _registerTransientComponents;
  40036. /**
  40037. * @hidden
  40038. * Add a component to the scene.
  40039. * Note that the ccomponent could be registered on th next frame if this is called after
  40040. * the register component stage.
  40041. * @param component Defines the component to add to the scene
  40042. */
  40043. _addComponent(component: ISceneComponent): void;
  40044. /**
  40045. * @hidden
  40046. * Gets a component from the scene.
  40047. * @param name defines the name of the component to retrieve
  40048. * @returns the component or null if not present
  40049. */
  40050. _getComponent(name: string): Nullable<ISceneComponent>;
  40051. /**
  40052. * @hidden
  40053. * Defines the actions happening before camera updates.
  40054. */
  40055. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40056. /**
  40057. * @hidden
  40058. * Defines the actions happening before clear the canvas.
  40059. */
  40060. _beforeClearStage: Stage<SimpleStageAction>;
  40061. /**
  40062. * @hidden
  40063. * Defines the actions when collecting render targets for the frame.
  40064. */
  40065. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40066. /**
  40067. * @hidden
  40068. * Defines the actions happening for one camera in the frame.
  40069. */
  40070. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40071. /**
  40072. * @hidden
  40073. * Defines the actions happening during the per mesh ready checks.
  40074. */
  40075. _isReadyForMeshStage: Stage<MeshStageAction>;
  40076. /**
  40077. * @hidden
  40078. * Defines the actions happening before evaluate active mesh checks.
  40079. */
  40080. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40081. /**
  40082. * @hidden
  40083. * Defines the actions happening during the evaluate sub mesh checks.
  40084. */
  40085. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40086. /**
  40087. * @hidden
  40088. * Defines the actions happening during the active mesh stage.
  40089. */
  40090. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40091. /**
  40092. * @hidden
  40093. * Defines the actions happening during the per camera render target step.
  40094. */
  40095. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40096. /**
  40097. * @hidden
  40098. * Defines the actions happening just before the active camera is drawing.
  40099. */
  40100. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40101. /**
  40102. * @hidden
  40103. * Defines the actions happening just before a render target is drawing.
  40104. */
  40105. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40106. /**
  40107. * @hidden
  40108. * Defines the actions happening just before a rendering group is drawing.
  40109. */
  40110. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40111. /**
  40112. * @hidden
  40113. * Defines the actions happening just before a mesh is drawing.
  40114. */
  40115. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40116. /**
  40117. * @hidden
  40118. * Defines the actions happening just after a mesh has been drawn.
  40119. */
  40120. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40121. /**
  40122. * @hidden
  40123. * Defines the actions happening just after a rendering group has been drawn.
  40124. */
  40125. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40126. /**
  40127. * @hidden
  40128. * Defines the actions happening just after the active camera has been drawn.
  40129. */
  40130. _afterCameraDrawStage: Stage<CameraStageAction>;
  40131. /**
  40132. * @hidden
  40133. * Defines the actions happening just after a render target has been drawn.
  40134. */
  40135. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40136. /**
  40137. * @hidden
  40138. * Defines the actions happening just after rendering all cameras and computing intersections.
  40139. */
  40140. _afterRenderStage: Stage<SimpleStageAction>;
  40141. /**
  40142. * @hidden
  40143. * Defines the actions happening when a pointer move event happens.
  40144. */
  40145. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40146. /**
  40147. * @hidden
  40148. * Defines the actions happening when a pointer down event happens.
  40149. */
  40150. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40151. /**
  40152. * @hidden
  40153. * Defines the actions happening when a pointer up event happens.
  40154. */
  40155. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40156. /**
  40157. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40158. */
  40159. private geometriesByUniqueId;
  40160. /**
  40161. * Creates a new Scene
  40162. * @param engine defines the engine to use to render this scene
  40163. * @param options defines the scene options
  40164. */
  40165. constructor(engine: Engine, options?: SceneOptions);
  40166. /**
  40167. * Gets a string identifying the name of the class
  40168. * @returns "Scene" string
  40169. */
  40170. getClassName(): string;
  40171. private _defaultMeshCandidates;
  40172. /**
  40173. * @hidden
  40174. */
  40175. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40176. private _defaultSubMeshCandidates;
  40177. /**
  40178. * @hidden
  40179. */
  40180. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40181. /**
  40182. * Sets the default candidate providers for the scene.
  40183. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40184. * and getCollidingSubMeshCandidates to their default function
  40185. */
  40186. setDefaultCandidateProviders(): void;
  40187. /**
  40188. * Gets the mesh that is currently under the pointer
  40189. */
  40190. get meshUnderPointer(): Nullable<AbstractMesh>;
  40191. /**
  40192. * Gets or sets the current on-screen X position of the pointer
  40193. */
  40194. get pointerX(): number;
  40195. set pointerX(value: number);
  40196. /**
  40197. * Gets or sets the current on-screen Y position of the pointer
  40198. */
  40199. get pointerY(): number;
  40200. set pointerY(value: number);
  40201. /**
  40202. * Gets the cached material (ie. the latest rendered one)
  40203. * @returns the cached material
  40204. */
  40205. getCachedMaterial(): Nullable<Material>;
  40206. /**
  40207. * Gets the cached effect (ie. the latest rendered one)
  40208. * @returns the cached effect
  40209. */
  40210. getCachedEffect(): Nullable<Effect>;
  40211. /**
  40212. * Gets the cached visibility state (ie. the latest rendered one)
  40213. * @returns the cached visibility state
  40214. */
  40215. getCachedVisibility(): Nullable<number>;
  40216. /**
  40217. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40218. * @param material defines the current material
  40219. * @param effect defines the current effect
  40220. * @param visibility defines the current visibility state
  40221. * @returns true if one parameter is not cached
  40222. */
  40223. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40224. /**
  40225. * Gets the engine associated with the scene
  40226. * @returns an Engine
  40227. */
  40228. getEngine(): Engine;
  40229. /**
  40230. * Gets the total number of vertices rendered per frame
  40231. * @returns the total number of vertices rendered per frame
  40232. */
  40233. getTotalVertices(): number;
  40234. /**
  40235. * Gets the performance counter for total vertices
  40236. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40237. */
  40238. get totalVerticesPerfCounter(): PerfCounter;
  40239. /**
  40240. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40241. * @returns the total number of active indices rendered per frame
  40242. */
  40243. getActiveIndices(): number;
  40244. /**
  40245. * Gets the performance counter for active indices
  40246. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40247. */
  40248. get totalActiveIndicesPerfCounter(): PerfCounter;
  40249. /**
  40250. * Gets the total number of active particles rendered per frame
  40251. * @returns the total number of active particles rendered per frame
  40252. */
  40253. getActiveParticles(): number;
  40254. /**
  40255. * Gets the performance counter for active particles
  40256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40257. */
  40258. get activeParticlesPerfCounter(): PerfCounter;
  40259. /**
  40260. * Gets the total number of active bones rendered per frame
  40261. * @returns the total number of active bones rendered per frame
  40262. */
  40263. getActiveBones(): number;
  40264. /**
  40265. * Gets the performance counter for active bones
  40266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40267. */
  40268. get activeBonesPerfCounter(): PerfCounter;
  40269. /**
  40270. * Gets the array of active meshes
  40271. * @returns an array of AbstractMesh
  40272. */
  40273. getActiveMeshes(): SmartArray<AbstractMesh>;
  40274. /**
  40275. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40276. * @returns a number
  40277. */
  40278. getAnimationRatio(): number;
  40279. /**
  40280. * Gets an unique Id for the current render phase
  40281. * @returns a number
  40282. */
  40283. getRenderId(): number;
  40284. /**
  40285. * Gets an unique Id for the current frame
  40286. * @returns a number
  40287. */
  40288. getFrameId(): number;
  40289. /** Call this function if you want to manually increment the render Id*/
  40290. incrementRenderId(): void;
  40291. private _createUbo;
  40292. /**
  40293. * Use this method to simulate a pointer move on a mesh
  40294. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40295. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40296. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40297. * @returns the current scene
  40298. */
  40299. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40300. /**
  40301. * Use this method to simulate a pointer down on a mesh
  40302. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40303. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40304. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40305. * @returns the current scene
  40306. */
  40307. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40308. /**
  40309. * Use this method to simulate a pointer up on a mesh
  40310. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40311. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40312. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40313. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40314. * @returns the current scene
  40315. */
  40316. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40317. /**
  40318. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40319. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40320. * @returns true if the pointer was captured
  40321. */
  40322. isPointerCaptured(pointerId?: number): boolean;
  40323. /**
  40324. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40325. * @param attachUp defines if you want to attach events to pointerup
  40326. * @param attachDown defines if you want to attach events to pointerdown
  40327. * @param attachMove defines if you want to attach events to pointermove
  40328. */
  40329. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40330. /** Detaches all event handlers*/
  40331. detachControl(): void;
  40332. /**
  40333. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40334. * Delay loaded resources are not taking in account
  40335. * @return true if all required resources are ready
  40336. */
  40337. isReady(): boolean;
  40338. /** Resets all cached information relative to material (including effect and visibility) */
  40339. resetCachedMaterial(): void;
  40340. /**
  40341. * Registers a function to be called before every frame render
  40342. * @param func defines the function to register
  40343. */
  40344. registerBeforeRender(func: () => void): void;
  40345. /**
  40346. * Unregisters a function called before every frame render
  40347. * @param func defines the function to unregister
  40348. */
  40349. unregisterBeforeRender(func: () => void): void;
  40350. /**
  40351. * Registers a function to be called after every frame render
  40352. * @param func defines the function to register
  40353. */
  40354. registerAfterRender(func: () => void): void;
  40355. /**
  40356. * Unregisters a function called after every frame render
  40357. * @param func defines the function to unregister
  40358. */
  40359. unregisterAfterRender(func: () => void): void;
  40360. private _executeOnceBeforeRender;
  40361. /**
  40362. * The provided function will run before render once and will be disposed afterwards.
  40363. * A timeout delay can be provided so that the function will be executed in N ms.
  40364. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40365. * @param func The function to be executed.
  40366. * @param timeout optional delay in ms
  40367. */
  40368. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40369. /** @hidden */
  40370. _addPendingData(data: any): void;
  40371. /** @hidden */
  40372. _removePendingData(data: any): void;
  40373. /**
  40374. * Returns the number of items waiting to be loaded
  40375. * @returns the number of items waiting to be loaded
  40376. */
  40377. getWaitingItemsCount(): number;
  40378. /**
  40379. * Returns a boolean indicating if the scene is still loading data
  40380. */
  40381. get isLoading(): boolean;
  40382. /**
  40383. * Registers a function to be executed when the scene is ready
  40384. * @param {Function} func - the function to be executed
  40385. */
  40386. executeWhenReady(func: () => void): void;
  40387. /**
  40388. * Returns a promise that resolves when the scene is ready
  40389. * @returns A promise that resolves when the scene is ready
  40390. */
  40391. whenReadyAsync(): Promise<void>;
  40392. /** @hidden */
  40393. _checkIsReady(): void;
  40394. /**
  40395. * Gets all animatable attached to the scene
  40396. */
  40397. get animatables(): Animatable[];
  40398. /**
  40399. * Resets the last animation time frame.
  40400. * Useful to override when animations start running when loading a scene for the first time.
  40401. */
  40402. resetLastAnimationTimeFrame(): void;
  40403. /**
  40404. * Gets the current view matrix
  40405. * @returns a Matrix
  40406. */
  40407. getViewMatrix(): Matrix;
  40408. /**
  40409. * Gets the current projection matrix
  40410. * @returns a Matrix
  40411. */
  40412. getProjectionMatrix(): Matrix;
  40413. /**
  40414. * Gets the current transform matrix
  40415. * @returns a Matrix made of View * Projection
  40416. */
  40417. getTransformMatrix(): Matrix;
  40418. /**
  40419. * Sets the current transform matrix
  40420. * @param viewL defines the View matrix to use
  40421. * @param projectionL defines the Projection matrix to use
  40422. * @param viewR defines the right View matrix to use (if provided)
  40423. * @param projectionR defines the right Projection matrix to use (if provided)
  40424. */
  40425. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40426. /**
  40427. * Gets the uniform buffer used to store scene data
  40428. * @returns a UniformBuffer
  40429. */
  40430. getSceneUniformBuffer(): UniformBuffer;
  40431. /**
  40432. * Gets an unique (relatively to the current scene) Id
  40433. * @returns an unique number for the scene
  40434. */
  40435. getUniqueId(): number;
  40436. /**
  40437. * Add a mesh to the list of scene's meshes
  40438. * @param newMesh defines the mesh to add
  40439. * @param recursive if all child meshes should also be added to the scene
  40440. */
  40441. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40442. /**
  40443. * Remove a mesh for the list of scene's meshes
  40444. * @param toRemove defines the mesh to remove
  40445. * @param recursive if all child meshes should also be removed from the scene
  40446. * @returns the index where the mesh was in the mesh list
  40447. */
  40448. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40449. /**
  40450. * Add a transform node to the list of scene's transform nodes
  40451. * @param newTransformNode defines the transform node to add
  40452. */
  40453. addTransformNode(newTransformNode: TransformNode): void;
  40454. /**
  40455. * Remove a transform node for the list of scene's transform nodes
  40456. * @param toRemove defines the transform node to remove
  40457. * @returns the index where the transform node was in the transform node list
  40458. */
  40459. removeTransformNode(toRemove: TransformNode): number;
  40460. /**
  40461. * Remove a skeleton for the list of scene's skeletons
  40462. * @param toRemove defines the skeleton to remove
  40463. * @returns the index where the skeleton was in the skeleton list
  40464. */
  40465. removeSkeleton(toRemove: Skeleton): number;
  40466. /**
  40467. * Remove a morph target for the list of scene's morph targets
  40468. * @param toRemove defines the morph target to remove
  40469. * @returns the index where the morph target was in the morph target list
  40470. */
  40471. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40472. /**
  40473. * Remove a light for the list of scene's lights
  40474. * @param toRemove defines the light to remove
  40475. * @returns the index where the light was in the light list
  40476. */
  40477. removeLight(toRemove: Light): number;
  40478. /**
  40479. * Remove a camera for the list of scene's cameras
  40480. * @param toRemove defines the camera to remove
  40481. * @returns the index where the camera was in the camera list
  40482. */
  40483. removeCamera(toRemove: Camera): number;
  40484. /**
  40485. * Remove a particle system for the list of scene's particle systems
  40486. * @param toRemove defines the particle system to remove
  40487. * @returns the index where the particle system was in the particle system list
  40488. */
  40489. removeParticleSystem(toRemove: IParticleSystem): number;
  40490. /**
  40491. * Remove a animation for the list of scene's animations
  40492. * @param toRemove defines the animation to remove
  40493. * @returns the index where the animation was in the animation list
  40494. */
  40495. removeAnimation(toRemove: Animation): number;
  40496. /**
  40497. * Will stop the animation of the given target
  40498. * @param target - the target
  40499. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40500. * @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)
  40501. */
  40502. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40503. /**
  40504. * Removes the given animation group from this scene.
  40505. * @param toRemove The animation group to remove
  40506. * @returns The index of the removed animation group
  40507. */
  40508. removeAnimationGroup(toRemove: AnimationGroup): number;
  40509. /**
  40510. * Removes the given multi-material from this scene.
  40511. * @param toRemove The multi-material to remove
  40512. * @returns The index of the removed multi-material
  40513. */
  40514. removeMultiMaterial(toRemove: MultiMaterial): number;
  40515. /**
  40516. * Removes the given material from this scene.
  40517. * @param toRemove The material to remove
  40518. * @returns The index of the removed material
  40519. */
  40520. removeMaterial(toRemove: Material): number;
  40521. /**
  40522. * Removes the given action manager from this scene.
  40523. * @param toRemove The action manager to remove
  40524. * @returns The index of the removed action manager
  40525. */
  40526. removeActionManager(toRemove: AbstractActionManager): number;
  40527. /**
  40528. * Removes the given texture from this scene.
  40529. * @param toRemove The texture to remove
  40530. * @returns The index of the removed texture
  40531. */
  40532. removeTexture(toRemove: BaseTexture): number;
  40533. /**
  40534. * Adds the given light to this scene
  40535. * @param newLight The light to add
  40536. */
  40537. addLight(newLight: Light): void;
  40538. /**
  40539. * Sorts the list list based on light priorities
  40540. */
  40541. sortLightsByPriority(): void;
  40542. /**
  40543. * Adds the given camera to this scene
  40544. * @param newCamera The camera to add
  40545. */
  40546. addCamera(newCamera: Camera): void;
  40547. /**
  40548. * Adds the given skeleton to this scene
  40549. * @param newSkeleton The skeleton to add
  40550. */
  40551. addSkeleton(newSkeleton: Skeleton): void;
  40552. /**
  40553. * Adds the given particle system to this scene
  40554. * @param newParticleSystem The particle system to add
  40555. */
  40556. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40557. /**
  40558. * Adds the given animation to this scene
  40559. * @param newAnimation The animation to add
  40560. */
  40561. addAnimation(newAnimation: Animation): void;
  40562. /**
  40563. * Adds the given animation group to this scene.
  40564. * @param newAnimationGroup The animation group to add
  40565. */
  40566. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40567. /**
  40568. * Adds the given multi-material to this scene
  40569. * @param newMultiMaterial The multi-material to add
  40570. */
  40571. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40572. /**
  40573. * Adds the given material to this scene
  40574. * @param newMaterial The material to add
  40575. */
  40576. addMaterial(newMaterial: Material): void;
  40577. /**
  40578. * Adds the given morph target to this scene
  40579. * @param newMorphTargetManager The morph target to add
  40580. */
  40581. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40582. /**
  40583. * Adds the given geometry to this scene
  40584. * @param newGeometry The geometry to add
  40585. */
  40586. addGeometry(newGeometry: Geometry): void;
  40587. /**
  40588. * Adds the given action manager to this scene
  40589. * @param newActionManager The action manager to add
  40590. */
  40591. addActionManager(newActionManager: AbstractActionManager): void;
  40592. /**
  40593. * Adds the given texture to this scene.
  40594. * @param newTexture The texture to add
  40595. */
  40596. addTexture(newTexture: BaseTexture): void;
  40597. /**
  40598. * Switch active camera
  40599. * @param newCamera defines the new active camera
  40600. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40601. */
  40602. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40603. /**
  40604. * sets the active camera of the scene using its ID
  40605. * @param id defines the camera's ID
  40606. * @return the new active camera or null if none found.
  40607. */
  40608. setActiveCameraByID(id: string): Nullable<Camera>;
  40609. /**
  40610. * sets the active camera of the scene using its name
  40611. * @param name defines the camera's name
  40612. * @returns the new active camera or null if none found.
  40613. */
  40614. setActiveCameraByName(name: string): Nullable<Camera>;
  40615. /**
  40616. * get an animation group using its name
  40617. * @param name defines the material's name
  40618. * @return the animation group or null if none found.
  40619. */
  40620. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40621. /**
  40622. * Get a material using its unique id
  40623. * @param uniqueId defines the material's unique id
  40624. * @return the material or null if none found.
  40625. */
  40626. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40627. /**
  40628. * get a material using its id
  40629. * @param id defines the material's ID
  40630. * @return the material or null if none found.
  40631. */
  40632. getMaterialByID(id: string): Nullable<Material>;
  40633. /**
  40634. * Gets a the last added material using a given id
  40635. * @param id defines the material's ID
  40636. * @return the last material with the given id or null if none found.
  40637. */
  40638. getLastMaterialByID(id: string): Nullable<Material>;
  40639. /**
  40640. * Gets a material using its name
  40641. * @param name defines the material's name
  40642. * @return the material or null if none found.
  40643. */
  40644. getMaterialByName(name: string): Nullable<Material>;
  40645. /**
  40646. * Get a texture using its unique id
  40647. * @param uniqueId defines the texture's unique id
  40648. * @return the texture or null if none found.
  40649. */
  40650. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40651. /**
  40652. * Gets a camera using its id
  40653. * @param id defines the id to look for
  40654. * @returns the camera or null if not found
  40655. */
  40656. getCameraByID(id: string): Nullable<Camera>;
  40657. /**
  40658. * Gets a camera using its unique id
  40659. * @param uniqueId defines the unique id to look for
  40660. * @returns the camera or null if not found
  40661. */
  40662. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40663. /**
  40664. * Gets a camera using its name
  40665. * @param name defines the camera's name
  40666. * @return the camera or null if none found.
  40667. */
  40668. getCameraByName(name: string): Nullable<Camera>;
  40669. /**
  40670. * Gets a bone using its id
  40671. * @param id defines the bone's id
  40672. * @return the bone or null if not found
  40673. */
  40674. getBoneByID(id: string): Nullable<Bone>;
  40675. /**
  40676. * Gets a bone using its id
  40677. * @param name defines the bone's name
  40678. * @return the bone or null if not found
  40679. */
  40680. getBoneByName(name: string): Nullable<Bone>;
  40681. /**
  40682. * Gets a light node using its name
  40683. * @param name defines the the light's name
  40684. * @return the light or null if none found.
  40685. */
  40686. getLightByName(name: string): Nullable<Light>;
  40687. /**
  40688. * Gets a light node using its id
  40689. * @param id defines the light's id
  40690. * @return the light or null if none found.
  40691. */
  40692. getLightByID(id: string): Nullable<Light>;
  40693. /**
  40694. * Gets a light node using its scene-generated unique ID
  40695. * @param uniqueId defines the light's unique id
  40696. * @return the light or null if none found.
  40697. */
  40698. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40699. /**
  40700. * Gets a particle system by id
  40701. * @param id defines the particle system id
  40702. * @return the corresponding system or null if none found
  40703. */
  40704. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40705. /**
  40706. * Gets a geometry using its ID
  40707. * @param id defines the geometry's id
  40708. * @return the geometry or null if none found.
  40709. */
  40710. getGeometryByID(id: string): Nullable<Geometry>;
  40711. private _getGeometryByUniqueID;
  40712. /**
  40713. * Add a new geometry to this scene
  40714. * @param geometry defines the geometry to be added to the scene.
  40715. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40716. * @return a boolean defining if the geometry was added or not
  40717. */
  40718. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40719. /**
  40720. * Removes an existing geometry
  40721. * @param geometry defines the geometry to be removed from the scene
  40722. * @return a boolean defining if the geometry was removed or not
  40723. */
  40724. removeGeometry(geometry: Geometry): boolean;
  40725. /**
  40726. * Gets the list of geometries attached to the scene
  40727. * @returns an array of Geometry
  40728. */
  40729. getGeometries(): Geometry[];
  40730. /**
  40731. * Gets the first added mesh found of a given ID
  40732. * @param id defines the id to search for
  40733. * @return the mesh found or null if not found at all
  40734. */
  40735. getMeshByID(id: string): Nullable<AbstractMesh>;
  40736. /**
  40737. * Gets a list of meshes using their id
  40738. * @param id defines the id to search for
  40739. * @returns a list of meshes
  40740. */
  40741. getMeshesByID(id: string): Array<AbstractMesh>;
  40742. /**
  40743. * Gets the first added transform node found of a given ID
  40744. * @param id defines the id to search for
  40745. * @return the found transform node or null if not found at all.
  40746. */
  40747. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40748. /**
  40749. * Gets a transform node with its auto-generated unique id
  40750. * @param uniqueId efines the unique id to search for
  40751. * @return the found transform node or null if not found at all.
  40752. */
  40753. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40754. /**
  40755. * Gets a list of transform nodes using their id
  40756. * @param id defines the id to search for
  40757. * @returns a list of transform nodes
  40758. */
  40759. getTransformNodesByID(id: string): Array<TransformNode>;
  40760. /**
  40761. * Gets a mesh with its auto-generated unique id
  40762. * @param uniqueId defines the unique id to search for
  40763. * @return the found mesh or null if not found at all.
  40764. */
  40765. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40766. /**
  40767. * Gets a the last added mesh using a given id
  40768. * @param id defines the id to search for
  40769. * @return the found mesh or null if not found at all.
  40770. */
  40771. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40772. /**
  40773. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40774. * @param id defines the id to search for
  40775. * @return the found node or null if not found at all
  40776. */
  40777. getLastEntryByID(id: string): Nullable<Node>;
  40778. /**
  40779. * Gets a node (Mesh, Camera, Light) using a given id
  40780. * @param id defines the id to search for
  40781. * @return the found node or null if not found at all
  40782. */
  40783. getNodeByID(id: string): Nullable<Node>;
  40784. /**
  40785. * Gets a node (Mesh, Camera, Light) using a given name
  40786. * @param name defines the name to search for
  40787. * @return the found node or null if not found at all.
  40788. */
  40789. getNodeByName(name: string): Nullable<Node>;
  40790. /**
  40791. * Gets a mesh using a given name
  40792. * @param name defines the name to search for
  40793. * @return the found mesh or null if not found at all.
  40794. */
  40795. getMeshByName(name: string): Nullable<AbstractMesh>;
  40796. /**
  40797. * Gets a transform node using a given name
  40798. * @param name defines the name to search for
  40799. * @return the found transform node or null if not found at all.
  40800. */
  40801. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40802. /**
  40803. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40804. * @param id defines the id to search for
  40805. * @return the found skeleton or null if not found at all.
  40806. */
  40807. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40808. /**
  40809. * Gets a skeleton using a given auto generated unique id
  40810. * @param uniqueId defines the unique id to search for
  40811. * @return the found skeleton or null if not found at all.
  40812. */
  40813. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40814. /**
  40815. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40816. * @param id defines the id to search for
  40817. * @return the found skeleton or null if not found at all.
  40818. */
  40819. getSkeletonById(id: string): Nullable<Skeleton>;
  40820. /**
  40821. * Gets a skeleton using a given name
  40822. * @param name defines the name to search for
  40823. * @return the found skeleton or null if not found at all.
  40824. */
  40825. getSkeletonByName(name: string): Nullable<Skeleton>;
  40826. /**
  40827. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40828. * @param id defines the id to search for
  40829. * @return the found morph target manager or null if not found at all.
  40830. */
  40831. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40832. /**
  40833. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40834. * @param id defines the id to search for
  40835. * @return the found morph target or null if not found at all.
  40836. */
  40837. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40838. /**
  40839. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40840. * @param name defines the name to search for
  40841. * @return the found morph target or null if not found at all.
  40842. */
  40843. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40844. /**
  40845. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40846. * @param name defines the name to search for
  40847. * @return the found post process or null if not found at all.
  40848. */
  40849. getPostProcessByName(name: string): Nullable<PostProcess>;
  40850. /**
  40851. * Gets a boolean indicating if the given mesh is active
  40852. * @param mesh defines the mesh to look for
  40853. * @returns true if the mesh is in the active list
  40854. */
  40855. isActiveMesh(mesh: AbstractMesh): boolean;
  40856. /**
  40857. * Return a unique id as a string which can serve as an identifier for the scene
  40858. */
  40859. get uid(): string;
  40860. /**
  40861. * Add an externaly attached data from its key.
  40862. * This method call will fail and return false, if such key already exists.
  40863. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40864. * @param key the unique key that identifies the data
  40865. * @param data the data object to associate to the key for this Engine instance
  40866. * @return true if no such key were already present and the data was added successfully, false otherwise
  40867. */
  40868. addExternalData<T>(key: string, data: T): boolean;
  40869. /**
  40870. * Get an externaly attached data from its key
  40871. * @param key the unique key that identifies the data
  40872. * @return the associated data, if present (can be null), or undefined if not present
  40873. */
  40874. getExternalData<T>(key: string): Nullable<T>;
  40875. /**
  40876. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40877. * @param key the unique key that identifies the data
  40878. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40879. * @return the associated data, can be null if the factory returned null.
  40880. */
  40881. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40882. /**
  40883. * Remove an externaly attached data from the Engine instance
  40884. * @param key the unique key that identifies the data
  40885. * @return true if the data was successfully removed, false if it doesn't exist
  40886. */
  40887. removeExternalData(key: string): boolean;
  40888. private _evaluateSubMesh;
  40889. /**
  40890. * Clear the processed materials smart array preventing retention point in material dispose.
  40891. */
  40892. freeProcessedMaterials(): void;
  40893. private _preventFreeActiveMeshesAndRenderingGroups;
  40894. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40895. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40896. * when disposing several meshes in a row or a hierarchy of meshes.
  40897. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40898. */
  40899. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40900. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40901. /**
  40902. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40903. */
  40904. freeActiveMeshes(): void;
  40905. /**
  40906. * Clear the info related to rendering groups preventing retention points during dispose.
  40907. */
  40908. freeRenderingGroups(): void;
  40909. /** @hidden */
  40910. _isInIntermediateRendering(): boolean;
  40911. /**
  40912. * Lambda returning the list of potentially active meshes.
  40913. */
  40914. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40915. /**
  40916. * Lambda returning the list of potentially active sub meshes.
  40917. */
  40918. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40919. /**
  40920. * Lambda returning the list of potentially intersecting sub meshes.
  40921. */
  40922. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40923. /**
  40924. * Lambda returning the list of potentially colliding sub meshes.
  40925. */
  40926. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40927. private _activeMeshesFrozen;
  40928. private _skipEvaluateActiveMeshesCompletely;
  40929. /**
  40930. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40931. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40932. * @returns the current scene
  40933. */
  40934. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40935. /**
  40936. * Use this function to restart evaluating active meshes on every frame
  40937. * @returns the current scene
  40938. */
  40939. unfreezeActiveMeshes(): Scene;
  40940. private _evaluateActiveMeshes;
  40941. private _activeMesh;
  40942. /**
  40943. * Update the transform matrix to update from the current active camera
  40944. * @param force defines a boolean used to force the update even if cache is up to date
  40945. */
  40946. updateTransformMatrix(force?: boolean): void;
  40947. private _bindFrameBuffer;
  40948. /** @hidden */
  40949. _allowPostProcessClearColor: boolean;
  40950. /** @hidden */
  40951. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40952. private _processSubCameras;
  40953. private _checkIntersections;
  40954. /** @hidden */
  40955. _advancePhysicsEngineStep(step: number): void;
  40956. /**
  40957. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40958. */
  40959. getDeterministicFrameTime: () => number;
  40960. /** @hidden */
  40961. _animate(): void;
  40962. /** Execute all animations (for a frame) */
  40963. animate(): void;
  40964. /**
  40965. * Render the scene
  40966. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40967. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40968. */
  40969. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40970. /**
  40971. * Freeze all materials
  40972. * A frozen material will not be updatable but should be faster to render
  40973. */
  40974. freezeMaterials(): void;
  40975. /**
  40976. * Unfreeze all materials
  40977. * A frozen material will not be updatable but should be faster to render
  40978. */
  40979. unfreezeMaterials(): void;
  40980. /**
  40981. * Releases all held ressources
  40982. */
  40983. dispose(): void;
  40984. /**
  40985. * Gets if the scene is already disposed
  40986. */
  40987. get isDisposed(): boolean;
  40988. /**
  40989. * Call this function to reduce memory footprint of the scene.
  40990. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40991. */
  40992. clearCachedVertexData(): void;
  40993. /**
  40994. * This function will remove the local cached buffer data from texture.
  40995. * It will save memory but will prevent the texture from being rebuilt
  40996. */
  40997. cleanCachedTextureBuffer(): void;
  40998. /**
  40999. * Get the world extend vectors with an optional filter
  41000. *
  41001. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41002. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41003. */
  41004. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41005. min: Vector3;
  41006. max: Vector3;
  41007. };
  41008. /**
  41009. * Creates a ray that can be used to pick in the scene
  41010. * @param x defines the x coordinate of the origin (on-screen)
  41011. * @param y defines the y coordinate of the origin (on-screen)
  41012. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41013. * @param camera defines the camera to use for the picking
  41014. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41015. * @returns a Ray
  41016. */
  41017. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41018. /**
  41019. * Creates a ray that can be used to pick in the scene
  41020. * @param x defines the x coordinate of the origin (on-screen)
  41021. * @param y defines the y coordinate of the origin (on-screen)
  41022. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41023. * @param result defines the ray where to store the picking ray
  41024. * @param camera defines the camera to use for the picking
  41025. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41026. * @returns the current scene
  41027. */
  41028. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41029. /**
  41030. * Creates a ray that can be used to pick in the scene
  41031. * @param x defines the x coordinate of the origin (on-screen)
  41032. * @param y defines the y coordinate of the origin (on-screen)
  41033. * @param camera defines the camera to use for the picking
  41034. * @returns a Ray
  41035. */
  41036. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41037. /**
  41038. * Creates a ray that can be used to pick in the scene
  41039. * @param x defines the x coordinate of the origin (on-screen)
  41040. * @param y defines the y coordinate of the origin (on-screen)
  41041. * @param result defines the ray where to store the picking ray
  41042. * @param camera defines the camera to use for the picking
  41043. * @returns the current scene
  41044. */
  41045. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41046. /** Launch a ray to try to pick a mesh in the scene
  41047. * @param x position on screen
  41048. * @param y position on screen
  41049. * @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
  41050. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41051. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41053. * @returns a PickingInfo
  41054. */
  41055. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41056. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41057. * @param x position on screen
  41058. * @param y position on screen
  41059. * @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
  41060. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41061. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41062. * @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)
  41063. */
  41064. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41065. /** Use the given ray to pick a mesh in the scene
  41066. * @param ray The ray to use to pick meshes
  41067. * @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
  41068. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41069. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41070. * @returns a PickingInfo
  41071. */
  41072. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41073. /**
  41074. * Launch a ray to try to pick a mesh in the scene
  41075. * @param x X position on screen
  41076. * @param y Y position on screen
  41077. * @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
  41078. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41080. * @returns an array of PickingInfo
  41081. */
  41082. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41083. /**
  41084. * Launch a ray to try to pick a mesh in the scene
  41085. * @param ray Ray to use
  41086. * @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
  41087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41088. * @returns an array of PickingInfo
  41089. */
  41090. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41091. /**
  41092. * Force the value of meshUnderPointer
  41093. * @param mesh defines the mesh to use
  41094. */
  41095. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41096. /**
  41097. * Gets the mesh under the pointer
  41098. * @returns a Mesh or null if no mesh is under the pointer
  41099. */
  41100. getPointerOverMesh(): Nullable<AbstractMesh>;
  41101. /** @hidden */
  41102. _rebuildGeometries(): void;
  41103. /** @hidden */
  41104. _rebuildTextures(): void;
  41105. private _getByTags;
  41106. /**
  41107. * Get a list of meshes by tags
  41108. * @param tagsQuery defines the tags query to use
  41109. * @param forEach defines a predicate used to filter results
  41110. * @returns an array of Mesh
  41111. */
  41112. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41113. /**
  41114. * Get a list of cameras by tags
  41115. * @param tagsQuery defines the tags query to use
  41116. * @param forEach defines a predicate used to filter results
  41117. * @returns an array of Camera
  41118. */
  41119. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41120. /**
  41121. * Get a list of lights by tags
  41122. * @param tagsQuery defines the tags query to use
  41123. * @param forEach defines a predicate used to filter results
  41124. * @returns an array of Light
  41125. */
  41126. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41127. /**
  41128. * Get a list of materials by tags
  41129. * @param tagsQuery defines the tags query to use
  41130. * @param forEach defines a predicate used to filter results
  41131. * @returns an array of Material
  41132. */
  41133. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41134. /**
  41135. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41136. * This allowed control for front to back rendering or reversly depending of the special needs.
  41137. *
  41138. * @param renderingGroupId The rendering group id corresponding to its index
  41139. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41140. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41141. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41142. */
  41143. 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;
  41144. /**
  41145. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41146. *
  41147. * @param renderingGroupId The rendering group id corresponding to its index
  41148. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41149. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41150. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41151. */
  41152. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41153. /**
  41154. * Gets the current auto clear configuration for one rendering group of the rendering
  41155. * manager.
  41156. * @param index the rendering group index to get the information for
  41157. * @returns The auto clear setup for the requested rendering group
  41158. */
  41159. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41160. private _blockMaterialDirtyMechanism;
  41161. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41162. get blockMaterialDirtyMechanism(): boolean;
  41163. set blockMaterialDirtyMechanism(value: boolean);
  41164. /**
  41165. * Will flag all materials as dirty to trigger new shader compilation
  41166. * @param flag defines the flag used to specify which material part must be marked as dirty
  41167. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41168. */
  41169. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41170. /** @hidden */
  41171. _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;
  41172. /** @hidden */
  41173. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41174. /** @hidden */
  41175. _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;
  41176. /** @hidden */
  41177. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41178. /** @hidden */
  41179. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41180. /** @hidden */
  41181. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41182. }
  41183. }
  41184. declare module BABYLON {
  41185. /**
  41186. * Set of assets to keep when moving a scene into an asset container.
  41187. */
  41188. export class KeepAssets extends AbstractScene {
  41189. }
  41190. /**
  41191. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41192. */
  41193. export class InstantiatedEntries {
  41194. /**
  41195. * List of new root nodes (eg. nodes with no parent)
  41196. */
  41197. rootNodes: TransformNode[];
  41198. /**
  41199. * List of new skeletons
  41200. */
  41201. skeletons: Skeleton[];
  41202. /**
  41203. * List of new animation groups
  41204. */
  41205. animationGroups: AnimationGroup[];
  41206. }
  41207. /**
  41208. * Container with a set of assets that can be added or removed from a scene.
  41209. */
  41210. export class AssetContainer extends AbstractScene {
  41211. private _wasAddedToScene;
  41212. /**
  41213. * The scene the AssetContainer belongs to.
  41214. */
  41215. scene: Scene;
  41216. /**
  41217. * Instantiates an AssetContainer.
  41218. * @param scene The scene the AssetContainer belongs to.
  41219. */
  41220. constructor(scene: Scene);
  41221. /**
  41222. * Instantiate or clone all meshes and add the new ones to the scene.
  41223. * Skeletons and animation groups will all be cloned
  41224. * @param nameFunction defines an optional function used to get new names for clones
  41225. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41226. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41227. */
  41228. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41229. /**
  41230. * Adds all the assets from the container to the scene.
  41231. */
  41232. addAllToScene(): void;
  41233. /**
  41234. * Removes all the assets in the container from the scene
  41235. */
  41236. removeAllFromScene(): void;
  41237. /**
  41238. * Disposes all the assets in the container
  41239. */
  41240. dispose(): void;
  41241. private _moveAssets;
  41242. /**
  41243. * Removes all the assets contained in the scene and adds them to the container.
  41244. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41245. */
  41246. moveAllFromScene(keepAssets?: KeepAssets): void;
  41247. /**
  41248. * 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.
  41249. * @returns the root mesh
  41250. */
  41251. createRootMesh(): Mesh;
  41252. /**
  41253. * Merge animations (direct and animation groups) from this asset container into a scene
  41254. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41255. * @param animatables set of animatables to retarget to a node from the scene
  41256. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41257. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41258. */
  41259. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41260. }
  41261. }
  41262. declare module BABYLON {
  41263. /**
  41264. * Defines how the parser contract is defined.
  41265. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41266. */
  41267. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41268. /**
  41269. * Defines how the individual parser contract is defined.
  41270. * These parser can parse an individual asset
  41271. */
  41272. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41273. /**
  41274. * Base class of the scene acting as a container for the different elements composing a scene.
  41275. * This class is dynamically extended by the different components of the scene increasing
  41276. * flexibility and reducing coupling
  41277. */
  41278. export abstract class AbstractScene {
  41279. /**
  41280. * Stores the list of available parsers in the application.
  41281. */
  41282. private static _BabylonFileParsers;
  41283. /**
  41284. * Stores the list of available individual parsers in the application.
  41285. */
  41286. private static _IndividualBabylonFileParsers;
  41287. /**
  41288. * Adds a parser in the list of available ones
  41289. * @param name Defines the name of the parser
  41290. * @param parser Defines the parser to add
  41291. */
  41292. static AddParser(name: string, parser: BabylonFileParser): void;
  41293. /**
  41294. * Gets a general parser from the list of avaialble ones
  41295. * @param name Defines the name of the parser
  41296. * @returns the requested parser or null
  41297. */
  41298. static GetParser(name: string): Nullable<BabylonFileParser>;
  41299. /**
  41300. * Adds n individual parser in the list of available ones
  41301. * @param name Defines the name of the parser
  41302. * @param parser Defines the parser to add
  41303. */
  41304. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41305. /**
  41306. * Gets an individual parser from the list of avaialble ones
  41307. * @param name Defines the name of the parser
  41308. * @returns the requested parser or null
  41309. */
  41310. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41311. /**
  41312. * Parser json data and populate both a scene and its associated container object
  41313. * @param jsonData Defines the data to parse
  41314. * @param scene Defines the scene to parse the data for
  41315. * @param container Defines the container attached to the parsing sequence
  41316. * @param rootUrl Defines the root url of the data
  41317. */
  41318. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41319. /**
  41320. * Gets the list of root nodes (ie. nodes with no parent)
  41321. */
  41322. rootNodes: Node[];
  41323. /** All of the cameras added to this scene
  41324. * @see https://doc.babylonjs.com/babylon101/cameras
  41325. */
  41326. cameras: Camera[];
  41327. /**
  41328. * All of the lights added to this scene
  41329. * @see https://doc.babylonjs.com/babylon101/lights
  41330. */
  41331. lights: Light[];
  41332. /**
  41333. * All of the (abstract) meshes added to this scene
  41334. */
  41335. meshes: AbstractMesh[];
  41336. /**
  41337. * The list of skeletons added to the scene
  41338. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41339. */
  41340. skeletons: Skeleton[];
  41341. /**
  41342. * All of the particle systems added to this scene
  41343. * @see https://doc.babylonjs.com/babylon101/particles
  41344. */
  41345. particleSystems: IParticleSystem[];
  41346. /**
  41347. * Gets a list of Animations associated with the scene
  41348. */
  41349. animations: Animation[];
  41350. /**
  41351. * All of the animation groups added to this scene
  41352. * @see https://doc.babylonjs.com/how_to/group
  41353. */
  41354. animationGroups: AnimationGroup[];
  41355. /**
  41356. * All of the multi-materials added to this scene
  41357. * @see https://doc.babylonjs.com/how_to/multi_materials
  41358. */
  41359. multiMaterials: MultiMaterial[];
  41360. /**
  41361. * All of the materials added to this scene
  41362. * In the context of a Scene, it is not supposed to be modified manually.
  41363. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41364. * Note also that the order of the Material within the array is not significant and might change.
  41365. * @see https://doc.babylonjs.com/babylon101/materials
  41366. */
  41367. materials: Material[];
  41368. /**
  41369. * The list of morph target managers added to the scene
  41370. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41371. */
  41372. morphTargetManagers: MorphTargetManager[];
  41373. /**
  41374. * The list of geometries used in the scene.
  41375. */
  41376. geometries: Geometry[];
  41377. /**
  41378. * All of the tranform nodes added to this scene
  41379. * In the context of a Scene, it is not supposed to be modified manually.
  41380. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41381. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41382. * @see https://doc.babylonjs.com/how_to/transformnode
  41383. */
  41384. transformNodes: TransformNode[];
  41385. /**
  41386. * ActionManagers available on the scene.
  41387. */
  41388. actionManagers: AbstractActionManager[];
  41389. /**
  41390. * Textures to keep.
  41391. */
  41392. textures: BaseTexture[];
  41393. /** @hidden */
  41394. protected _environmentTexture: Nullable<BaseTexture>;
  41395. /**
  41396. * Texture used in all pbr material as the reflection texture.
  41397. * As in the majority of the scene they are the same (exception for multi room and so on),
  41398. * this is easier to reference from here than from all the materials.
  41399. */
  41400. get environmentTexture(): Nullable<BaseTexture>;
  41401. set environmentTexture(value: Nullable<BaseTexture>);
  41402. /**
  41403. * The list of postprocesses added to the scene
  41404. */
  41405. postProcesses: PostProcess[];
  41406. /**
  41407. * @returns all meshes, lights, cameras, transformNodes and bones
  41408. */
  41409. getNodes(): Array<Node>;
  41410. }
  41411. }
  41412. declare module BABYLON {
  41413. /**
  41414. * Interface used to define options for Sound class
  41415. */
  41416. export interface ISoundOptions {
  41417. /**
  41418. * Does the sound autoplay once loaded.
  41419. */
  41420. autoplay?: boolean;
  41421. /**
  41422. * Does the sound loop after it finishes playing once.
  41423. */
  41424. loop?: boolean;
  41425. /**
  41426. * Sound's volume
  41427. */
  41428. volume?: number;
  41429. /**
  41430. * Is it a spatial sound?
  41431. */
  41432. spatialSound?: boolean;
  41433. /**
  41434. * Maximum distance to hear that sound
  41435. */
  41436. maxDistance?: number;
  41437. /**
  41438. * Uses user defined attenuation function
  41439. */
  41440. useCustomAttenuation?: boolean;
  41441. /**
  41442. * Define the roll off factor of spatial sounds.
  41443. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41444. */
  41445. rolloffFactor?: number;
  41446. /**
  41447. * Define the reference distance the sound should be heard perfectly.
  41448. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41449. */
  41450. refDistance?: number;
  41451. /**
  41452. * Define the distance attenuation model the sound will follow.
  41453. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41454. */
  41455. distanceModel?: string;
  41456. /**
  41457. * Defines the playback speed (1 by default)
  41458. */
  41459. playbackRate?: number;
  41460. /**
  41461. * Defines if the sound is from a streaming source
  41462. */
  41463. streaming?: boolean;
  41464. /**
  41465. * Defines an optional length (in seconds) inside the sound file
  41466. */
  41467. length?: number;
  41468. /**
  41469. * Defines an optional offset (in seconds) inside the sound file
  41470. */
  41471. offset?: number;
  41472. /**
  41473. * If true, URLs will not be required to state the audio file codec to use.
  41474. */
  41475. skipCodecCheck?: boolean;
  41476. }
  41477. /**
  41478. * Defines a sound that can be played in the application.
  41479. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41480. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41481. */
  41482. export class Sound {
  41483. /**
  41484. * The name of the sound in the scene.
  41485. */
  41486. name: string;
  41487. /**
  41488. * Does the sound autoplay once loaded.
  41489. */
  41490. autoplay: boolean;
  41491. /**
  41492. * Does the sound loop after it finishes playing once.
  41493. */
  41494. loop: boolean;
  41495. /**
  41496. * Does the sound use a custom attenuation curve to simulate the falloff
  41497. * happening when the source gets further away from the camera.
  41498. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41499. */
  41500. useCustomAttenuation: boolean;
  41501. /**
  41502. * The sound track id this sound belongs to.
  41503. */
  41504. soundTrackId: number;
  41505. /**
  41506. * Is this sound currently played.
  41507. */
  41508. isPlaying: boolean;
  41509. /**
  41510. * Is this sound currently paused.
  41511. */
  41512. isPaused: boolean;
  41513. /**
  41514. * Does this sound enables spatial sound.
  41515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41516. */
  41517. spatialSound: boolean;
  41518. /**
  41519. * Define the reference distance the sound should be heard perfectly.
  41520. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41521. */
  41522. refDistance: number;
  41523. /**
  41524. * Define the roll off factor of spatial sounds.
  41525. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41526. */
  41527. rolloffFactor: number;
  41528. /**
  41529. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41531. */
  41532. maxDistance: number;
  41533. /**
  41534. * Define the distance attenuation model the sound will follow.
  41535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41536. */
  41537. distanceModel: string;
  41538. /**
  41539. * @hidden
  41540. * Back Compat
  41541. **/
  41542. onended: () => any;
  41543. /**
  41544. * Gets or sets an object used to store user defined information for the sound.
  41545. */
  41546. metadata: any;
  41547. /**
  41548. * Observable event when the current playing sound finishes.
  41549. */
  41550. onEndedObservable: Observable<Sound>;
  41551. private _panningModel;
  41552. private _playbackRate;
  41553. private _streaming;
  41554. private _startTime;
  41555. private _startOffset;
  41556. private _position;
  41557. /** @hidden */
  41558. _positionInEmitterSpace: boolean;
  41559. private _localDirection;
  41560. private _volume;
  41561. private _isReadyToPlay;
  41562. private _isDirectional;
  41563. private _readyToPlayCallback;
  41564. private _audioBuffer;
  41565. private _soundSource;
  41566. private _streamingSource;
  41567. private _soundPanner;
  41568. private _soundGain;
  41569. private _inputAudioNode;
  41570. private _outputAudioNode;
  41571. private _coneInnerAngle;
  41572. private _coneOuterAngle;
  41573. private _coneOuterGain;
  41574. private _scene;
  41575. private _connectedTransformNode;
  41576. private _customAttenuationFunction;
  41577. private _registerFunc;
  41578. private _isOutputConnected;
  41579. private _htmlAudioElement;
  41580. private _urlType;
  41581. private _length?;
  41582. private _offset?;
  41583. /** @hidden */
  41584. static _SceneComponentInitialization: (scene: Scene) => void;
  41585. /**
  41586. * Create a sound and attach it to a scene
  41587. * @param name Name of your sound
  41588. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41589. * @param scene defines the scene the sound belongs to
  41590. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41591. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41592. */
  41593. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41594. /**
  41595. * Release the sound and its associated resources
  41596. */
  41597. dispose(): void;
  41598. /**
  41599. * Gets if the sounds is ready to be played or not.
  41600. * @returns true if ready, otherwise false
  41601. */
  41602. isReady(): boolean;
  41603. private _soundLoaded;
  41604. /**
  41605. * Sets the data of the sound from an audiobuffer
  41606. * @param audioBuffer The audioBuffer containing the data
  41607. */
  41608. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41609. /**
  41610. * Updates the current sounds options such as maxdistance, loop...
  41611. * @param options A JSON object containing values named as the object properties
  41612. */
  41613. updateOptions(options: ISoundOptions): void;
  41614. private _createSpatialParameters;
  41615. private _updateSpatialParameters;
  41616. /**
  41617. * Switch the panning model to HRTF:
  41618. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41619. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41620. */
  41621. switchPanningModelToHRTF(): void;
  41622. /**
  41623. * Switch the panning model to Equal Power:
  41624. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41626. */
  41627. switchPanningModelToEqualPower(): void;
  41628. private _switchPanningModel;
  41629. /**
  41630. * Connect this sound to a sound track audio node like gain...
  41631. * @param soundTrackAudioNode the sound track audio node to connect to
  41632. */
  41633. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41634. /**
  41635. * Transform this sound into a directional source
  41636. * @param coneInnerAngle Size of the inner cone in degree
  41637. * @param coneOuterAngle Size of the outer cone in degree
  41638. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41639. */
  41640. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41641. /**
  41642. * Gets or sets the inner angle for the directional cone.
  41643. */
  41644. get directionalConeInnerAngle(): number;
  41645. /**
  41646. * Gets or sets the inner angle for the directional cone.
  41647. */
  41648. set directionalConeInnerAngle(value: number);
  41649. /**
  41650. * Gets or sets the outer angle for the directional cone.
  41651. */
  41652. get directionalConeOuterAngle(): number;
  41653. /**
  41654. * Gets or sets the outer angle for the directional cone.
  41655. */
  41656. set directionalConeOuterAngle(value: number);
  41657. /**
  41658. * Sets the position of the emitter if spatial sound is enabled
  41659. * @param newPosition Defines the new posisiton
  41660. */
  41661. setPosition(newPosition: Vector3): void;
  41662. /**
  41663. * Sets the local direction of the emitter if spatial sound is enabled
  41664. * @param newLocalDirection Defines the new local direction
  41665. */
  41666. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41667. private _updateDirection;
  41668. /** @hidden */
  41669. updateDistanceFromListener(): void;
  41670. /**
  41671. * Sets a new custom attenuation function for the sound.
  41672. * @param callback Defines the function used for the attenuation
  41673. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41674. */
  41675. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41676. /**
  41677. * Play the sound
  41678. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41679. * @param offset (optional) Start the sound at a specific time in seconds
  41680. * @param length (optional) Sound duration (in seconds)
  41681. */
  41682. play(time?: number, offset?: number, length?: number): void;
  41683. private _onended;
  41684. /**
  41685. * Stop the sound
  41686. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41687. */
  41688. stop(time?: number): void;
  41689. /**
  41690. * Put the sound in pause
  41691. */
  41692. pause(): void;
  41693. /**
  41694. * Sets a dedicated volume for this sounds
  41695. * @param newVolume Define the new volume of the sound
  41696. * @param time Define time for gradual change to new volume
  41697. */
  41698. setVolume(newVolume: number, time?: number): void;
  41699. /**
  41700. * Set the sound play back rate
  41701. * @param newPlaybackRate Define the playback rate the sound should be played at
  41702. */
  41703. setPlaybackRate(newPlaybackRate: number): void;
  41704. /**
  41705. * Gets the volume of the sound.
  41706. * @returns the volume of the sound
  41707. */
  41708. getVolume(): number;
  41709. /**
  41710. * Attach the sound to a dedicated mesh
  41711. * @param transformNode The transform node to connect the sound with
  41712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41713. */
  41714. attachToMesh(transformNode: TransformNode): void;
  41715. /**
  41716. * Detach the sound from the previously attached mesh
  41717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41718. */
  41719. detachFromMesh(): void;
  41720. private _onRegisterAfterWorldMatrixUpdate;
  41721. /**
  41722. * Clone the current sound in the scene.
  41723. * @returns the new sound clone
  41724. */
  41725. clone(): Nullable<Sound>;
  41726. /**
  41727. * Gets the current underlying audio buffer containing the data
  41728. * @returns the audio buffer
  41729. */
  41730. getAudioBuffer(): Nullable<AudioBuffer>;
  41731. /**
  41732. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41733. * @returns the source node
  41734. */
  41735. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41736. /**
  41737. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41738. * @returns the gain node
  41739. */
  41740. getSoundGain(): Nullable<GainNode>;
  41741. /**
  41742. * Serializes the Sound in a JSON representation
  41743. * @returns the JSON representation of the sound
  41744. */
  41745. serialize(): any;
  41746. /**
  41747. * Parse a JSON representation of a sound to innstantiate in a given scene
  41748. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41749. * @param scene Define the scene the new parsed sound should be created in
  41750. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41751. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41752. * @returns the newly parsed sound
  41753. */
  41754. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41755. }
  41756. }
  41757. declare module BABYLON {
  41758. /**
  41759. * This defines an action helpful to play a defined sound on a triggered action.
  41760. */
  41761. export class PlaySoundAction extends Action {
  41762. private _sound;
  41763. /**
  41764. * Instantiate the action
  41765. * @param triggerOptions defines the trigger options
  41766. * @param sound defines the sound to play
  41767. * @param condition defines the trigger related conditions
  41768. */
  41769. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41770. /** @hidden */
  41771. _prepare(): void;
  41772. /**
  41773. * Execute the action and play the sound.
  41774. */
  41775. execute(): void;
  41776. /**
  41777. * Serializes the actions and its related information.
  41778. * @param parent defines the object to serialize in
  41779. * @returns the serialized object
  41780. */
  41781. serialize(parent: any): any;
  41782. }
  41783. /**
  41784. * This defines an action helpful to stop a defined sound on a triggered action.
  41785. */
  41786. export class StopSoundAction extends Action {
  41787. private _sound;
  41788. /**
  41789. * Instantiate the action
  41790. * @param triggerOptions defines the trigger options
  41791. * @param sound defines the sound to stop
  41792. * @param condition defines the trigger related conditions
  41793. */
  41794. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41795. /** @hidden */
  41796. _prepare(): void;
  41797. /**
  41798. * Execute the action and stop the sound.
  41799. */
  41800. execute(): void;
  41801. /**
  41802. * Serializes the actions and its related information.
  41803. * @param parent defines the object to serialize in
  41804. * @returns the serialized object
  41805. */
  41806. serialize(parent: any): any;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. /**
  41811. * This defines an action responsible to change the value of a property
  41812. * by interpolating between its current value and the newly set one once triggered.
  41813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41814. */
  41815. export class InterpolateValueAction extends Action {
  41816. /**
  41817. * Defines the path of the property where the value should be interpolated
  41818. */
  41819. propertyPath: string;
  41820. /**
  41821. * Defines the target value at the end of the interpolation.
  41822. */
  41823. value: any;
  41824. /**
  41825. * Defines the time it will take for the property to interpolate to the value.
  41826. */
  41827. duration: number;
  41828. /**
  41829. * Defines if the other scene animations should be stopped when the action has been triggered
  41830. */
  41831. stopOtherAnimations?: boolean;
  41832. /**
  41833. * Defines a callback raised once the interpolation animation has been done.
  41834. */
  41835. onInterpolationDone?: () => void;
  41836. /**
  41837. * Observable triggered once the interpolation animation has been done.
  41838. */
  41839. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41840. private _target;
  41841. private _effectiveTarget;
  41842. private _property;
  41843. /**
  41844. * Instantiate the action
  41845. * @param triggerOptions defines the trigger options
  41846. * @param target defines the object containing the value to interpolate
  41847. * @param propertyPath defines the path to the property in the target object
  41848. * @param value defines the target value at the end of the interpolation
  41849. * @param duration deines the time it will take for the property to interpolate to the value.
  41850. * @param condition defines the trigger related conditions
  41851. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41852. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41853. */
  41854. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41855. /** @hidden */
  41856. _prepare(): void;
  41857. /**
  41858. * Execute the action starts the value interpolation.
  41859. */
  41860. execute(): void;
  41861. /**
  41862. * Serializes the actions and its related information.
  41863. * @param parent defines the object to serialize in
  41864. * @returns the serialized object
  41865. */
  41866. serialize(parent: any): any;
  41867. }
  41868. }
  41869. declare module BABYLON {
  41870. /**
  41871. * Options allowed during the creation of a sound track.
  41872. */
  41873. export interface ISoundTrackOptions {
  41874. /**
  41875. * The volume the sound track should take during creation
  41876. */
  41877. volume?: number;
  41878. /**
  41879. * Define if the sound track is the main sound track of the scene
  41880. */
  41881. mainTrack?: boolean;
  41882. }
  41883. /**
  41884. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41885. * It will be also used in a future release to apply effects on a specific track.
  41886. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41887. */
  41888. export class SoundTrack {
  41889. /**
  41890. * The unique identifier of the sound track in the scene.
  41891. */
  41892. id: number;
  41893. /**
  41894. * The list of sounds included in the sound track.
  41895. */
  41896. soundCollection: Array<Sound>;
  41897. private _outputAudioNode;
  41898. private _scene;
  41899. private _connectedAnalyser;
  41900. private _options;
  41901. private _isInitialized;
  41902. /**
  41903. * Creates a new sound track.
  41904. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41905. * @param scene Define the scene the sound track belongs to
  41906. * @param options
  41907. */
  41908. constructor(scene: Scene, options?: ISoundTrackOptions);
  41909. private _initializeSoundTrackAudioGraph;
  41910. /**
  41911. * Release the sound track and its associated resources
  41912. */
  41913. dispose(): void;
  41914. /**
  41915. * Adds a sound to this sound track
  41916. * @param sound define the cound to add
  41917. * @ignoreNaming
  41918. */
  41919. AddSound(sound: Sound): void;
  41920. /**
  41921. * Removes a sound to this sound track
  41922. * @param sound define the cound to remove
  41923. * @ignoreNaming
  41924. */
  41925. RemoveSound(sound: Sound): void;
  41926. /**
  41927. * Set a global volume for the full sound track.
  41928. * @param newVolume Define the new volume of the sound track
  41929. */
  41930. setVolume(newVolume: number): void;
  41931. /**
  41932. * Switch the panning model to HRTF:
  41933. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41934. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41935. */
  41936. switchPanningModelToHRTF(): void;
  41937. /**
  41938. * Switch the panning model to Equal Power:
  41939. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41940. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41941. */
  41942. switchPanningModelToEqualPower(): void;
  41943. /**
  41944. * Connect the sound track to an audio analyser allowing some amazing
  41945. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41946. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41947. * @param analyser The analyser to connect to the engine
  41948. */
  41949. connectToAnalyser(analyser: Analyser): void;
  41950. }
  41951. }
  41952. declare module BABYLON {
  41953. interface AbstractScene {
  41954. /**
  41955. * The list of sounds used in the scene.
  41956. */
  41957. sounds: Nullable<Array<Sound>>;
  41958. }
  41959. interface Scene {
  41960. /**
  41961. * @hidden
  41962. * Backing field
  41963. */
  41964. _mainSoundTrack: SoundTrack;
  41965. /**
  41966. * The main sound track played by the scene.
  41967. * It cotains your primary collection of sounds.
  41968. */
  41969. mainSoundTrack: SoundTrack;
  41970. /**
  41971. * The list of sound tracks added to the scene
  41972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41973. */
  41974. soundTracks: Nullable<Array<SoundTrack>>;
  41975. /**
  41976. * Gets a sound using a given name
  41977. * @param name defines the name to search for
  41978. * @return the found sound or null if not found at all.
  41979. */
  41980. getSoundByName(name: string): Nullable<Sound>;
  41981. /**
  41982. * Gets or sets if audio support is enabled
  41983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41984. */
  41985. audioEnabled: boolean;
  41986. /**
  41987. * Gets or sets if audio will be output to headphones
  41988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41989. */
  41990. headphone: boolean;
  41991. /**
  41992. * Gets or sets custom audio listener position provider
  41993. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41994. */
  41995. audioListenerPositionProvider: Nullable<() => Vector3>;
  41996. /**
  41997. * Gets or sets a refresh rate when using 3D audio positioning
  41998. */
  41999. audioPositioningRefreshRate: number;
  42000. }
  42001. /**
  42002. * Defines the sound scene component responsible to manage any sounds
  42003. * in a given scene.
  42004. */
  42005. export class AudioSceneComponent implements ISceneSerializableComponent {
  42006. /**
  42007. * The component name helpfull to identify the component in the list of scene components.
  42008. */
  42009. readonly name: string;
  42010. /**
  42011. * The scene the component belongs to.
  42012. */
  42013. scene: Scene;
  42014. private _audioEnabled;
  42015. /**
  42016. * Gets whether audio is enabled or not.
  42017. * Please use related enable/disable method to switch state.
  42018. */
  42019. get audioEnabled(): boolean;
  42020. private _headphone;
  42021. /**
  42022. * Gets whether audio is outputing to headphone or not.
  42023. * Please use the according Switch methods to change output.
  42024. */
  42025. get headphone(): boolean;
  42026. /**
  42027. * Gets or sets a refresh rate when using 3D audio positioning
  42028. */
  42029. audioPositioningRefreshRate: number;
  42030. private _audioListenerPositionProvider;
  42031. /**
  42032. * Gets the current audio listener position provider
  42033. */
  42034. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42035. /**
  42036. * Sets a custom listener position for all sounds in the scene
  42037. * By default, this is the position of the first active camera
  42038. */
  42039. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42040. /**
  42041. * Creates a new instance of the component for the given scene
  42042. * @param scene Defines the scene to register the component in
  42043. */
  42044. constructor(scene: Scene);
  42045. /**
  42046. * Registers the component in a given scene
  42047. */
  42048. register(): void;
  42049. /**
  42050. * Rebuilds the elements related to this component in case of
  42051. * context lost for instance.
  42052. */
  42053. rebuild(): void;
  42054. /**
  42055. * Serializes the component data to the specified json object
  42056. * @param serializationObject The object to serialize to
  42057. */
  42058. serialize(serializationObject: any): void;
  42059. /**
  42060. * Adds all the elements from the container to the scene
  42061. * @param container the container holding the elements
  42062. */
  42063. addFromContainer(container: AbstractScene): void;
  42064. /**
  42065. * Removes all the elements in the container from the scene
  42066. * @param container contains the elements to remove
  42067. * @param dispose if the removed element should be disposed (default: false)
  42068. */
  42069. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42070. /**
  42071. * Disposes the component and the associated ressources.
  42072. */
  42073. dispose(): void;
  42074. /**
  42075. * Disables audio in the associated scene.
  42076. */
  42077. disableAudio(): void;
  42078. /**
  42079. * Enables audio in the associated scene.
  42080. */
  42081. enableAudio(): void;
  42082. /**
  42083. * Switch audio to headphone output.
  42084. */
  42085. switchAudioModeForHeadphones(): void;
  42086. /**
  42087. * Switch audio to normal speakers.
  42088. */
  42089. switchAudioModeForNormalSpeakers(): void;
  42090. private _cachedCameraDirection;
  42091. private _cachedCameraPosition;
  42092. private _lastCheck;
  42093. private _afterRender;
  42094. }
  42095. }
  42096. declare module BABYLON {
  42097. /**
  42098. * Wraps one or more Sound objects and selects one with random weight for playback.
  42099. */
  42100. export class WeightedSound {
  42101. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42102. loop: boolean;
  42103. private _coneInnerAngle;
  42104. private _coneOuterAngle;
  42105. private _volume;
  42106. /** A Sound is currently playing. */
  42107. isPlaying: boolean;
  42108. /** A Sound is currently paused. */
  42109. isPaused: boolean;
  42110. private _sounds;
  42111. private _weights;
  42112. private _currentIndex?;
  42113. /**
  42114. * Creates a new WeightedSound from the list of sounds given.
  42115. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42116. * @param sounds Array of Sounds that will be selected from.
  42117. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42118. */
  42119. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42120. /**
  42121. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42122. */
  42123. get directionalConeInnerAngle(): number;
  42124. /**
  42125. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42126. */
  42127. set directionalConeInnerAngle(value: number);
  42128. /**
  42129. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42130. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42131. */
  42132. get directionalConeOuterAngle(): number;
  42133. /**
  42134. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42135. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42136. */
  42137. set directionalConeOuterAngle(value: number);
  42138. /**
  42139. * Playback volume.
  42140. */
  42141. get volume(): number;
  42142. /**
  42143. * Playback volume.
  42144. */
  42145. set volume(value: number);
  42146. private _onended;
  42147. /**
  42148. * Suspend playback
  42149. */
  42150. pause(): void;
  42151. /**
  42152. * Stop playback
  42153. */
  42154. stop(): void;
  42155. /**
  42156. * Start playback.
  42157. * @param startOffset Position the clip head at a specific time in seconds.
  42158. */
  42159. play(startOffset?: number): void;
  42160. }
  42161. }
  42162. declare module BABYLON {
  42163. /**
  42164. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42165. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42166. */
  42167. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42168. /**
  42169. * Gets the name of the behavior.
  42170. */
  42171. get name(): string;
  42172. /**
  42173. * The easing function used by animations
  42174. */
  42175. static EasingFunction: BackEase;
  42176. /**
  42177. * The easing mode used by animations
  42178. */
  42179. static EasingMode: number;
  42180. /**
  42181. * The duration of the animation, in milliseconds
  42182. */
  42183. transitionDuration: number;
  42184. /**
  42185. * Length of the distance animated by the transition when lower radius is reached
  42186. */
  42187. lowerRadiusTransitionRange: number;
  42188. /**
  42189. * Length of the distance animated by the transition when upper radius is reached
  42190. */
  42191. upperRadiusTransitionRange: number;
  42192. private _autoTransitionRange;
  42193. /**
  42194. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42195. */
  42196. get autoTransitionRange(): boolean;
  42197. /**
  42198. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42199. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42200. */
  42201. set autoTransitionRange(value: boolean);
  42202. private _attachedCamera;
  42203. private _onAfterCheckInputsObserver;
  42204. private _onMeshTargetChangedObserver;
  42205. /**
  42206. * Initializes the behavior.
  42207. */
  42208. init(): void;
  42209. /**
  42210. * Attaches the behavior to its arc rotate camera.
  42211. * @param camera Defines the camera to attach the behavior to
  42212. */
  42213. attach(camera: ArcRotateCamera): void;
  42214. /**
  42215. * Detaches the behavior from its current arc rotate camera.
  42216. */
  42217. detach(): void;
  42218. private _radiusIsAnimating;
  42219. private _radiusBounceTransition;
  42220. private _animatables;
  42221. private _cachedWheelPrecision;
  42222. /**
  42223. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42224. * @param radiusLimit The limit to check against.
  42225. * @return Bool to indicate if at limit.
  42226. */
  42227. private _isRadiusAtLimit;
  42228. /**
  42229. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42230. * @param radiusDelta The delta by which to animate to. Can be negative.
  42231. */
  42232. private _applyBoundRadiusAnimation;
  42233. /**
  42234. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42235. */
  42236. protected _clearAnimationLocks(): void;
  42237. /**
  42238. * Stops and removes all animations that have been applied to the camera
  42239. */
  42240. stopAllAnimations(): void;
  42241. }
  42242. }
  42243. declare module BABYLON {
  42244. /**
  42245. * 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.
  42246. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42247. */
  42248. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42249. /**
  42250. * Gets the name of the behavior.
  42251. */
  42252. get name(): string;
  42253. private _mode;
  42254. private _radiusScale;
  42255. private _positionScale;
  42256. private _defaultElevation;
  42257. private _elevationReturnTime;
  42258. private _elevationReturnWaitTime;
  42259. private _zoomStopsAnimation;
  42260. private _framingTime;
  42261. /**
  42262. * The easing function used by animations
  42263. */
  42264. static EasingFunction: ExponentialEase;
  42265. /**
  42266. * The easing mode used by animations
  42267. */
  42268. static EasingMode: number;
  42269. /**
  42270. * Sets the current mode used by the behavior
  42271. */
  42272. set mode(mode: number);
  42273. /**
  42274. * Gets current mode used by the behavior.
  42275. */
  42276. get mode(): number;
  42277. /**
  42278. * Sets the scale applied to the radius (1 by default)
  42279. */
  42280. set radiusScale(radius: number);
  42281. /**
  42282. * Gets the scale applied to the radius
  42283. */
  42284. get radiusScale(): number;
  42285. /**
  42286. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42287. */
  42288. set positionScale(scale: number);
  42289. /**
  42290. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42291. */
  42292. get positionScale(): number;
  42293. /**
  42294. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42295. * behaviour is triggered, in radians.
  42296. */
  42297. set defaultElevation(elevation: number);
  42298. /**
  42299. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42300. * behaviour is triggered, in radians.
  42301. */
  42302. get defaultElevation(): number;
  42303. /**
  42304. * Sets the time (in milliseconds) taken to return to the default beta position.
  42305. * Negative value indicates camera should not return to default.
  42306. */
  42307. set elevationReturnTime(speed: number);
  42308. /**
  42309. * Gets the time (in milliseconds) taken to return to the default beta position.
  42310. * Negative value indicates camera should not return to default.
  42311. */
  42312. get elevationReturnTime(): number;
  42313. /**
  42314. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42315. */
  42316. set elevationReturnWaitTime(time: number);
  42317. /**
  42318. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42319. */
  42320. get elevationReturnWaitTime(): number;
  42321. /**
  42322. * Sets the flag that indicates if user zooming should stop animation.
  42323. */
  42324. set zoomStopsAnimation(flag: boolean);
  42325. /**
  42326. * Gets the flag that indicates if user zooming should stop animation.
  42327. */
  42328. get zoomStopsAnimation(): boolean;
  42329. /**
  42330. * Sets the transition time when framing the mesh, in milliseconds
  42331. */
  42332. set framingTime(time: number);
  42333. /**
  42334. * Gets the transition time when framing the mesh, in milliseconds
  42335. */
  42336. get framingTime(): number;
  42337. /**
  42338. * Define if the behavior should automatically change the configured
  42339. * camera limits and sensibilities.
  42340. */
  42341. autoCorrectCameraLimitsAndSensibility: boolean;
  42342. private _onPrePointerObservableObserver;
  42343. private _onAfterCheckInputsObserver;
  42344. private _onMeshTargetChangedObserver;
  42345. private _attachedCamera;
  42346. private _isPointerDown;
  42347. private _lastInteractionTime;
  42348. /**
  42349. * Initializes the behavior.
  42350. */
  42351. init(): void;
  42352. /**
  42353. * Attaches the behavior to its arc rotate camera.
  42354. * @param camera Defines the camera to attach the behavior to
  42355. */
  42356. attach(camera: ArcRotateCamera): void;
  42357. /**
  42358. * Detaches the behavior from its current arc rotate camera.
  42359. */
  42360. detach(): void;
  42361. private _animatables;
  42362. private _betaIsAnimating;
  42363. private _betaTransition;
  42364. private _radiusTransition;
  42365. private _vectorTransition;
  42366. /**
  42367. * Targets the given mesh and updates zoom level accordingly.
  42368. * @param mesh The mesh to target.
  42369. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42370. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42371. */
  42372. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42373. /**
  42374. * Targets the given mesh with its children and updates zoom level accordingly.
  42375. * @param mesh The mesh to target.
  42376. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42377. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42378. */
  42379. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42380. /**
  42381. * Targets the given meshes with their children and updates zoom level accordingly.
  42382. * @param meshes The mesh to target.
  42383. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42384. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42385. */
  42386. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42387. /**
  42388. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42389. * @param minimumWorld Determines the smaller position of the bounding box extend
  42390. * @param maximumWorld Determines the bigger position of the bounding box extend
  42391. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42392. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42393. */
  42394. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42395. /**
  42396. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42397. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42398. * frustum width.
  42399. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42400. * to fully enclose the mesh in the viewing frustum.
  42401. */
  42402. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42403. /**
  42404. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42405. * is automatically returned to its default position (expected to be above ground plane).
  42406. */
  42407. private _maintainCameraAboveGround;
  42408. /**
  42409. * Returns the frustum slope based on the canvas ratio and camera FOV
  42410. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42411. */
  42412. private _getFrustumSlope;
  42413. /**
  42414. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42415. */
  42416. private _clearAnimationLocks;
  42417. /**
  42418. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42419. */
  42420. private _applyUserInteraction;
  42421. /**
  42422. * Stops and removes all animations that have been applied to the camera
  42423. */
  42424. stopAllAnimations(): void;
  42425. /**
  42426. * Gets a value indicating if the user is moving the camera
  42427. */
  42428. get isUserIsMoving(): boolean;
  42429. /**
  42430. * The camera can move all the way towards the mesh.
  42431. */
  42432. static IgnoreBoundsSizeMode: number;
  42433. /**
  42434. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42435. */
  42436. static FitFrustumSidesMode: number;
  42437. }
  42438. }
  42439. declare module BABYLON {
  42440. /**
  42441. * Base class for Camera Pointer Inputs.
  42442. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42443. * for example usage.
  42444. */
  42445. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42446. /**
  42447. * Defines the camera the input is attached to.
  42448. */
  42449. abstract camera: Camera;
  42450. /**
  42451. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42452. */
  42453. protected _altKey: boolean;
  42454. protected _ctrlKey: boolean;
  42455. protected _metaKey: boolean;
  42456. protected _shiftKey: boolean;
  42457. /**
  42458. * Which mouse buttons were pressed at time of last mouse event.
  42459. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42460. */
  42461. protected _buttonsPressed: number;
  42462. /**
  42463. * Defines the buttons associated with the input to handle camera move.
  42464. */
  42465. buttons: number[];
  42466. /**
  42467. * Attach the input controls to a specific dom element to get the input from.
  42468. * @param element Defines the element the controls should be listened from
  42469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42470. */
  42471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42472. /**
  42473. * Detach the current controls from the specified dom element.
  42474. * @param element Defines the element to stop listening the inputs from
  42475. */
  42476. detachControl(element: Nullable<HTMLElement>): void;
  42477. /**
  42478. * Gets the class name of the current input.
  42479. * @returns the class name
  42480. */
  42481. getClassName(): string;
  42482. /**
  42483. * Get the friendly name associated with the input class.
  42484. * @returns the input friendly name
  42485. */
  42486. getSimpleName(): string;
  42487. /**
  42488. * Called on pointer POINTERDOUBLETAP event.
  42489. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42490. */
  42491. protected onDoubleTap(type: string): void;
  42492. /**
  42493. * Called on pointer POINTERMOVE event if only a single touch is active.
  42494. * Override this method to provide functionality.
  42495. */
  42496. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42497. /**
  42498. * Called on pointer POINTERMOVE event if multiple touches are active.
  42499. * Override this method to provide functionality.
  42500. */
  42501. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42502. /**
  42503. * Called on JS contextmenu event.
  42504. * Override this method to provide functionality.
  42505. */
  42506. protected onContextMenu(evt: PointerEvent): void;
  42507. /**
  42508. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42509. * press.
  42510. * Override this method to provide functionality.
  42511. */
  42512. protected onButtonDown(evt: PointerEvent): void;
  42513. /**
  42514. * Called each time a new POINTERUP event occurs. Ie, for each button
  42515. * release.
  42516. * Override this method to provide functionality.
  42517. */
  42518. protected onButtonUp(evt: PointerEvent): void;
  42519. /**
  42520. * Called when window becomes inactive.
  42521. * Override this method to provide functionality.
  42522. */
  42523. protected onLostFocus(): void;
  42524. private _pointerInput;
  42525. private _observer;
  42526. private _onLostFocus;
  42527. private pointA;
  42528. private pointB;
  42529. }
  42530. }
  42531. declare module BABYLON {
  42532. /**
  42533. * Manage the pointers inputs to control an arc rotate camera.
  42534. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42535. */
  42536. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42537. /**
  42538. * Defines the camera the input is attached to.
  42539. */
  42540. camera: ArcRotateCamera;
  42541. /**
  42542. * Gets the class name of the current input.
  42543. * @returns the class name
  42544. */
  42545. getClassName(): string;
  42546. /**
  42547. * Defines the buttons associated with the input to handle camera move.
  42548. */
  42549. buttons: number[];
  42550. /**
  42551. * Defines the pointer angular sensibility along the X axis or how fast is
  42552. * the camera rotating.
  42553. */
  42554. angularSensibilityX: number;
  42555. /**
  42556. * Defines the pointer angular sensibility along the Y axis or how fast is
  42557. * the camera rotating.
  42558. */
  42559. angularSensibilityY: number;
  42560. /**
  42561. * Defines the pointer pinch precision or how fast is the camera zooming.
  42562. */
  42563. pinchPrecision: number;
  42564. /**
  42565. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42566. * from 0.
  42567. * It defines the percentage of current camera.radius to use as delta when
  42568. * pinch zoom is used.
  42569. */
  42570. pinchDeltaPercentage: number;
  42571. /**
  42572. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42573. * that any object in the plane at the camera's target point will scale
  42574. * perfectly with finger motion.
  42575. * Overrides pinchDeltaPercentage and pinchPrecision.
  42576. */
  42577. useNaturalPinchZoom: boolean;
  42578. /**
  42579. * Defines the pointer panning sensibility or how fast is the camera moving.
  42580. */
  42581. panningSensibility: number;
  42582. /**
  42583. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42584. */
  42585. multiTouchPanning: boolean;
  42586. /**
  42587. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42588. * zoom (pinch) through multitouch.
  42589. */
  42590. multiTouchPanAndZoom: boolean;
  42591. /**
  42592. * Revers pinch action direction.
  42593. */
  42594. pinchInwards: boolean;
  42595. private _isPanClick;
  42596. private _twoFingerActivityCount;
  42597. private _isPinching;
  42598. /**
  42599. * Called on pointer POINTERMOVE event if only a single touch is active.
  42600. */
  42601. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42602. /**
  42603. * Called on pointer POINTERDOUBLETAP event.
  42604. */
  42605. protected onDoubleTap(type: string): void;
  42606. /**
  42607. * Called on pointer POINTERMOVE event if multiple touches are active.
  42608. */
  42609. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42610. /**
  42611. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42612. * press.
  42613. */
  42614. protected onButtonDown(evt: PointerEvent): void;
  42615. /**
  42616. * Called each time a new POINTERUP event occurs. Ie, for each button
  42617. * release.
  42618. */
  42619. protected onButtonUp(evt: PointerEvent): void;
  42620. /**
  42621. * Called when window becomes inactive.
  42622. */
  42623. protected onLostFocus(): void;
  42624. }
  42625. }
  42626. declare module BABYLON {
  42627. /**
  42628. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42629. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42630. */
  42631. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42632. /**
  42633. * Defines the camera the input is attached to.
  42634. */
  42635. camera: ArcRotateCamera;
  42636. /**
  42637. * Defines the list of key codes associated with the up action (increase alpha)
  42638. */
  42639. keysUp: number[];
  42640. /**
  42641. * Defines the list of key codes associated with the down action (decrease alpha)
  42642. */
  42643. keysDown: number[];
  42644. /**
  42645. * Defines the list of key codes associated with the left action (increase beta)
  42646. */
  42647. keysLeft: number[];
  42648. /**
  42649. * Defines the list of key codes associated with the right action (decrease beta)
  42650. */
  42651. keysRight: number[];
  42652. /**
  42653. * Defines the list of key codes associated with the reset action.
  42654. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42655. */
  42656. keysReset: number[];
  42657. /**
  42658. * Defines the panning sensibility of the inputs.
  42659. * (How fast is the camera panning)
  42660. */
  42661. panningSensibility: number;
  42662. /**
  42663. * Defines the zooming sensibility of the inputs.
  42664. * (How fast is the camera zooming)
  42665. */
  42666. zoomingSensibility: number;
  42667. /**
  42668. * Defines whether maintaining the alt key down switch the movement mode from
  42669. * orientation to zoom.
  42670. */
  42671. useAltToZoom: boolean;
  42672. /**
  42673. * Rotation speed of the camera
  42674. */
  42675. angularSpeed: number;
  42676. private _keys;
  42677. private _ctrlPressed;
  42678. private _altPressed;
  42679. private _onCanvasBlurObserver;
  42680. private _onKeyboardObserver;
  42681. private _engine;
  42682. private _scene;
  42683. /**
  42684. * Attach the input controls to a specific dom element to get the input from.
  42685. * @param element Defines the element the controls should be listened from
  42686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42687. */
  42688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42689. /**
  42690. * Detach the current controls from the specified dom element.
  42691. * @param element Defines the element to stop listening the inputs from
  42692. */
  42693. detachControl(element: Nullable<HTMLElement>): void;
  42694. /**
  42695. * Update the current camera state depending on the inputs that have been used this frame.
  42696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42697. */
  42698. checkInputs(): void;
  42699. /**
  42700. * Gets the class name of the current intput.
  42701. * @returns the class name
  42702. */
  42703. getClassName(): string;
  42704. /**
  42705. * Get the friendly name associated with the input class.
  42706. * @returns the input friendly name
  42707. */
  42708. getSimpleName(): string;
  42709. }
  42710. }
  42711. declare module BABYLON {
  42712. /**
  42713. * Manage the mouse wheel inputs to control an arc rotate camera.
  42714. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42715. */
  42716. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42717. /**
  42718. * Defines the camera the input is attached to.
  42719. */
  42720. camera: ArcRotateCamera;
  42721. /**
  42722. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42723. */
  42724. wheelPrecision: number;
  42725. /**
  42726. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42727. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42728. */
  42729. wheelDeltaPercentage: number;
  42730. private _wheel;
  42731. private _observer;
  42732. private computeDeltaFromMouseWheelLegacyEvent;
  42733. /**
  42734. * Attach the input controls to a specific dom element to get the input from.
  42735. * @param element Defines the element the controls should be listened from
  42736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42737. */
  42738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42739. /**
  42740. * Detach the current controls from the specified dom element.
  42741. * @param element Defines the element to stop listening the inputs from
  42742. */
  42743. detachControl(element: Nullable<HTMLElement>): void;
  42744. /**
  42745. * Gets the class name of the current intput.
  42746. * @returns the class name
  42747. */
  42748. getClassName(): string;
  42749. /**
  42750. * Get the friendly name associated with the input class.
  42751. * @returns the input friendly name
  42752. */
  42753. getSimpleName(): string;
  42754. }
  42755. }
  42756. declare module BABYLON {
  42757. /**
  42758. * Default Inputs manager for the ArcRotateCamera.
  42759. * It groups all the default supported inputs for ease of use.
  42760. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42761. */
  42762. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42763. /**
  42764. * Instantiates a new ArcRotateCameraInputsManager.
  42765. * @param camera Defines the camera the inputs belong to
  42766. */
  42767. constructor(camera: ArcRotateCamera);
  42768. /**
  42769. * Add mouse wheel input support to the input manager.
  42770. * @returns the current input manager
  42771. */
  42772. addMouseWheel(): ArcRotateCameraInputsManager;
  42773. /**
  42774. * Add pointers input support to the input manager.
  42775. * @returns the current input manager
  42776. */
  42777. addPointers(): ArcRotateCameraInputsManager;
  42778. /**
  42779. * Add keyboard input support to the input manager.
  42780. * @returns the current input manager
  42781. */
  42782. addKeyboard(): ArcRotateCameraInputsManager;
  42783. }
  42784. }
  42785. declare module BABYLON {
  42786. /**
  42787. * This represents an orbital type of camera.
  42788. *
  42789. * 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.
  42790. * 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.
  42791. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42792. */
  42793. export class ArcRotateCamera extends TargetCamera {
  42794. /**
  42795. * Defines the rotation angle of the camera along the longitudinal axis.
  42796. */
  42797. alpha: number;
  42798. /**
  42799. * Defines the rotation angle of the camera along the latitudinal axis.
  42800. */
  42801. beta: number;
  42802. /**
  42803. * Defines the radius of the camera from it s target point.
  42804. */
  42805. radius: number;
  42806. protected _target: Vector3;
  42807. protected _targetHost: Nullable<AbstractMesh>;
  42808. /**
  42809. * Defines the target point of the camera.
  42810. * The camera looks towards it form the radius distance.
  42811. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42812. */
  42813. get target(): Vector3;
  42814. set target(value: Vector3);
  42815. /**
  42816. * Define the current local position of the camera in the scene
  42817. */
  42818. get position(): Vector3;
  42819. set position(newPosition: Vector3);
  42820. protected _upToYMatrix: Matrix;
  42821. protected _YToUpMatrix: Matrix;
  42822. /**
  42823. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42824. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42825. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42826. */
  42827. set upVector(vec: Vector3);
  42828. get upVector(): Vector3;
  42829. /**
  42830. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42831. */
  42832. setMatUp(): void;
  42833. /**
  42834. * Current inertia value on the longitudinal axis.
  42835. * The bigger this number the longer it will take for the camera to stop.
  42836. */
  42837. inertialAlphaOffset: number;
  42838. /**
  42839. * Current inertia value on the latitudinal axis.
  42840. * The bigger this number the longer it will take for the camera to stop.
  42841. */
  42842. inertialBetaOffset: number;
  42843. /**
  42844. * Current inertia value on the radius axis.
  42845. * The bigger this number the longer it will take for the camera to stop.
  42846. */
  42847. inertialRadiusOffset: number;
  42848. /**
  42849. * Minimum allowed angle on the longitudinal axis.
  42850. * This can help limiting how the Camera is able to move in the scene.
  42851. */
  42852. lowerAlphaLimit: Nullable<number>;
  42853. /**
  42854. * Maximum allowed angle on the longitudinal axis.
  42855. * This can help limiting how the Camera is able to move in the scene.
  42856. */
  42857. upperAlphaLimit: Nullable<number>;
  42858. /**
  42859. * Minimum allowed angle on the latitudinal axis.
  42860. * This can help limiting how the Camera is able to move in the scene.
  42861. */
  42862. lowerBetaLimit: number;
  42863. /**
  42864. * Maximum allowed angle on the latitudinal axis.
  42865. * This can help limiting how the Camera is able to move in the scene.
  42866. */
  42867. upperBetaLimit: number;
  42868. /**
  42869. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42870. * This can help limiting how the Camera is able to move in the scene.
  42871. */
  42872. lowerRadiusLimit: Nullable<number>;
  42873. /**
  42874. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42875. * This can help limiting how the Camera is able to move in the scene.
  42876. */
  42877. upperRadiusLimit: Nullable<number>;
  42878. /**
  42879. * Defines the current inertia value used during panning of the camera along the X axis.
  42880. */
  42881. inertialPanningX: number;
  42882. /**
  42883. * Defines the current inertia value used during panning of the camera along the Y axis.
  42884. */
  42885. inertialPanningY: number;
  42886. /**
  42887. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42888. * Basically if your fingers moves away from more than this distance you will be considered
  42889. * in pinch mode.
  42890. */
  42891. pinchToPanMaxDistance: number;
  42892. /**
  42893. * Defines the maximum distance the camera can pan.
  42894. * This could help keeping the cammera always in your scene.
  42895. */
  42896. panningDistanceLimit: Nullable<number>;
  42897. /**
  42898. * Defines the target of the camera before paning.
  42899. */
  42900. panningOriginTarget: Vector3;
  42901. /**
  42902. * Defines the value of the inertia used during panning.
  42903. * 0 would mean stop inertia and one would mean no decelleration at all.
  42904. */
  42905. panningInertia: number;
  42906. /**
  42907. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42908. */
  42909. get angularSensibilityX(): number;
  42910. set angularSensibilityX(value: number);
  42911. /**
  42912. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42913. */
  42914. get angularSensibilityY(): number;
  42915. set angularSensibilityY(value: number);
  42916. /**
  42917. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42918. */
  42919. get pinchPrecision(): number;
  42920. set pinchPrecision(value: number);
  42921. /**
  42922. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42923. * It will be used instead of pinchDeltaPrecision if different from 0.
  42924. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42925. */
  42926. get pinchDeltaPercentage(): number;
  42927. set pinchDeltaPercentage(value: number);
  42928. /**
  42929. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42930. * and pinch delta percentage.
  42931. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42932. * that any object in the plane at the camera's target point will scale
  42933. * perfectly with finger motion.
  42934. */
  42935. get useNaturalPinchZoom(): boolean;
  42936. set useNaturalPinchZoom(value: boolean);
  42937. /**
  42938. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42939. */
  42940. get panningSensibility(): number;
  42941. set panningSensibility(value: number);
  42942. /**
  42943. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42944. */
  42945. get keysUp(): number[];
  42946. set keysUp(value: number[]);
  42947. /**
  42948. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42949. */
  42950. get keysDown(): number[];
  42951. set keysDown(value: number[]);
  42952. /**
  42953. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42954. */
  42955. get keysLeft(): number[];
  42956. set keysLeft(value: number[]);
  42957. /**
  42958. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42959. */
  42960. get keysRight(): number[];
  42961. set keysRight(value: number[]);
  42962. /**
  42963. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42964. */
  42965. get wheelPrecision(): number;
  42966. set wheelPrecision(value: number);
  42967. /**
  42968. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42969. * It will be used instead of pinchDeltaPrecision if different from 0.
  42970. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42971. */
  42972. get wheelDeltaPercentage(): number;
  42973. set wheelDeltaPercentage(value: number);
  42974. /**
  42975. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42976. */
  42977. zoomOnFactor: number;
  42978. /**
  42979. * Defines a screen offset for the camera position.
  42980. */
  42981. targetScreenOffset: Vector2;
  42982. /**
  42983. * Allows the camera to be completely reversed.
  42984. * If false the camera can not arrive upside down.
  42985. */
  42986. allowUpsideDown: boolean;
  42987. /**
  42988. * Define if double tap/click is used to restore the previously saved state of the camera.
  42989. */
  42990. useInputToRestoreState: boolean;
  42991. /** @hidden */
  42992. _viewMatrix: Matrix;
  42993. /** @hidden */
  42994. _useCtrlForPanning: boolean;
  42995. /** @hidden */
  42996. _panningMouseButton: number;
  42997. /**
  42998. * Defines the input associated to the camera.
  42999. */
  43000. inputs: ArcRotateCameraInputsManager;
  43001. /** @hidden */
  43002. _reset: () => void;
  43003. /**
  43004. * Defines the allowed panning axis.
  43005. */
  43006. panningAxis: Vector3;
  43007. protected _localDirection: Vector3;
  43008. protected _transformedDirection: Vector3;
  43009. private _bouncingBehavior;
  43010. /**
  43011. * Gets the bouncing behavior of the camera if it has been enabled.
  43012. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43013. */
  43014. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43015. /**
  43016. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43017. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43018. */
  43019. get useBouncingBehavior(): boolean;
  43020. set useBouncingBehavior(value: boolean);
  43021. private _framingBehavior;
  43022. /**
  43023. * Gets the framing behavior of the camera if it has been enabled.
  43024. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43025. */
  43026. get framingBehavior(): Nullable<FramingBehavior>;
  43027. /**
  43028. * Defines if the framing behavior of the camera is enabled on the camera.
  43029. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43030. */
  43031. get useFramingBehavior(): boolean;
  43032. set useFramingBehavior(value: boolean);
  43033. private _autoRotationBehavior;
  43034. /**
  43035. * Gets the auto rotation behavior of the camera if it has been enabled.
  43036. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43037. */
  43038. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43039. /**
  43040. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43041. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43042. */
  43043. get useAutoRotationBehavior(): boolean;
  43044. set useAutoRotationBehavior(value: boolean);
  43045. /**
  43046. * Observable triggered when the mesh target has been changed on the camera.
  43047. */
  43048. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43049. /**
  43050. * Event raised when the camera is colliding with a mesh.
  43051. */
  43052. onCollide: (collidedMesh: AbstractMesh) => void;
  43053. /**
  43054. * Defines whether the camera should check collision with the objects oh the scene.
  43055. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43056. */
  43057. checkCollisions: boolean;
  43058. /**
  43059. * Defines the collision radius of the camera.
  43060. * This simulates a sphere around the camera.
  43061. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43062. */
  43063. collisionRadius: Vector3;
  43064. protected _collider: Collider;
  43065. protected _previousPosition: Vector3;
  43066. protected _collisionVelocity: Vector3;
  43067. protected _newPosition: Vector3;
  43068. protected _previousAlpha: number;
  43069. protected _previousBeta: number;
  43070. protected _previousRadius: number;
  43071. protected _collisionTriggered: boolean;
  43072. protected _targetBoundingCenter: Nullable<Vector3>;
  43073. private _computationVector;
  43074. /**
  43075. * Instantiates a new ArcRotateCamera in a given scene
  43076. * @param name Defines the name of the camera
  43077. * @param alpha Defines the camera rotation along the logitudinal axis
  43078. * @param beta Defines the camera rotation along the latitudinal axis
  43079. * @param radius Defines the camera distance from its target
  43080. * @param target Defines the camera target
  43081. * @param scene Defines the scene the camera belongs to
  43082. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43083. */
  43084. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43085. /** @hidden */
  43086. _initCache(): void;
  43087. /** @hidden */
  43088. _updateCache(ignoreParentClass?: boolean): void;
  43089. protected _getTargetPosition(): Vector3;
  43090. private _storedAlpha;
  43091. private _storedBeta;
  43092. private _storedRadius;
  43093. private _storedTarget;
  43094. private _storedTargetScreenOffset;
  43095. /**
  43096. * Stores the current state of the camera (alpha, beta, radius and target)
  43097. * @returns the camera itself
  43098. */
  43099. storeState(): Camera;
  43100. /**
  43101. * @hidden
  43102. * Restored camera state. You must call storeState() first
  43103. */
  43104. _restoreStateValues(): boolean;
  43105. /** @hidden */
  43106. _isSynchronizedViewMatrix(): boolean;
  43107. /**
  43108. * Attached controls to the current camera.
  43109. * @param element Defines the element the controls should be listened from
  43110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43111. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43112. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43113. */
  43114. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43115. /**
  43116. * Detach the current controls from the camera.
  43117. * The camera will stop reacting to inputs.
  43118. * @param element Defines the element to stop listening the inputs from
  43119. */
  43120. detachControl(element: HTMLElement): void;
  43121. /** @hidden */
  43122. _checkInputs(): void;
  43123. protected _checkLimits(): void;
  43124. /**
  43125. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43126. */
  43127. rebuildAnglesAndRadius(): void;
  43128. /**
  43129. * Use a position to define the current camera related information like alpha, beta and radius
  43130. * @param position Defines the position to set the camera at
  43131. */
  43132. setPosition(position: Vector3): void;
  43133. /**
  43134. * Defines the target the camera should look at.
  43135. * This will automatically adapt alpha beta and radius to fit within the new target.
  43136. * @param target Defines the new target as a Vector or a mesh
  43137. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43138. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43139. */
  43140. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43141. /** @hidden */
  43142. _getViewMatrix(): Matrix;
  43143. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43144. /**
  43145. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43146. * @param meshes Defines the mesh to zoom on
  43147. * @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)
  43148. */
  43149. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43150. /**
  43151. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43152. * The target will be changed but the radius
  43153. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43154. * @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)
  43155. */
  43156. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43157. min: Vector3;
  43158. max: Vector3;
  43159. distance: number;
  43160. }, doNotUpdateMaxZ?: boolean): void;
  43161. /**
  43162. * @override
  43163. * Override Camera.createRigCamera
  43164. */
  43165. createRigCamera(name: string, cameraIndex: number): Camera;
  43166. /**
  43167. * @hidden
  43168. * @override
  43169. * Override Camera._updateRigCameras
  43170. */
  43171. _updateRigCameras(): void;
  43172. /**
  43173. * Destroy the camera and release the current resources hold by it.
  43174. */
  43175. dispose(): void;
  43176. /**
  43177. * Gets the current object class name.
  43178. * @return the class name
  43179. */
  43180. getClassName(): string;
  43181. }
  43182. }
  43183. declare module BABYLON {
  43184. /**
  43185. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43186. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43187. */
  43188. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43189. /**
  43190. * Gets the name of the behavior.
  43191. */
  43192. get name(): string;
  43193. private _zoomStopsAnimation;
  43194. private _idleRotationSpeed;
  43195. private _idleRotationWaitTime;
  43196. private _idleRotationSpinupTime;
  43197. /**
  43198. * Sets the flag that indicates if user zooming should stop animation.
  43199. */
  43200. set zoomStopsAnimation(flag: boolean);
  43201. /**
  43202. * Gets the flag that indicates if user zooming should stop animation.
  43203. */
  43204. get zoomStopsAnimation(): boolean;
  43205. /**
  43206. * Sets the default speed at which the camera rotates around the model.
  43207. */
  43208. set idleRotationSpeed(speed: number);
  43209. /**
  43210. * Gets the default speed at which the camera rotates around the model.
  43211. */
  43212. get idleRotationSpeed(): number;
  43213. /**
  43214. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43215. */
  43216. set idleRotationWaitTime(time: number);
  43217. /**
  43218. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43219. */
  43220. get idleRotationWaitTime(): number;
  43221. /**
  43222. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43223. */
  43224. set idleRotationSpinupTime(time: number);
  43225. /**
  43226. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43227. */
  43228. get idleRotationSpinupTime(): number;
  43229. /**
  43230. * Gets a value indicating if the camera is currently rotating because of this behavior
  43231. */
  43232. get rotationInProgress(): boolean;
  43233. private _onPrePointerObservableObserver;
  43234. private _onAfterCheckInputsObserver;
  43235. private _attachedCamera;
  43236. private _isPointerDown;
  43237. private _lastFrameTime;
  43238. private _lastInteractionTime;
  43239. private _cameraRotationSpeed;
  43240. /**
  43241. * Initializes the behavior.
  43242. */
  43243. init(): void;
  43244. /**
  43245. * Attaches the behavior to its arc rotate camera.
  43246. * @param camera Defines the camera to attach the behavior to
  43247. */
  43248. attach(camera: ArcRotateCamera): void;
  43249. /**
  43250. * Detaches the behavior from its current arc rotate camera.
  43251. */
  43252. detach(): void;
  43253. /**
  43254. * Returns true if user is scrolling.
  43255. * @return true if user is scrolling.
  43256. */
  43257. private _userIsZooming;
  43258. private _lastFrameRadius;
  43259. private _shouldAnimationStopForInteraction;
  43260. /**
  43261. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43262. */
  43263. private _applyUserInteraction;
  43264. private _userIsMoving;
  43265. }
  43266. }
  43267. declare module BABYLON {
  43268. /**
  43269. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43270. */
  43271. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43272. private ui;
  43273. /**
  43274. * The name of the behavior
  43275. */
  43276. name: string;
  43277. /**
  43278. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43279. */
  43280. distanceAwayFromFace: number;
  43281. /**
  43282. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43283. */
  43284. distanceAwayFromBottomOfFace: number;
  43285. private _faceVectors;
  43286. private _target;
  43287. private _scene;
  43288. private _onRenderObserver;
  43289. private _tmpMatrix;
  43290. private _tmpVector;
  43291. /**
  43292. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43293. * @param ui The transform node that should be attched to the mesh
  43294. */
  43295. constructor(ui: TransformNode);
  43296. /**
  43297. * Initializes the behavior
  43298. */
  43299. init(): void;
  43300. private _closestFace;
  43301. private _zeroVector;
  43302. private _lookAtTmpMatrix;
  43303. private _lookAtToRef;
  43304. /**
  43305. * Attaches the AttachToBoxBehavior to the passed in mesh
  43306. * @param target The mesh that the specified node will be attached to
  43307. */
  43308. attach(target: Mesh): void;
  43309. /**
  43310. * Detaches the behavior from the mesh
  43311. */
  43312. detach(): void;
  43313. }
  43314. }
  43315. declare module BABYLON {
  43316. /**
  43317. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43318. */
  43319. export class FadeInOutBehavior implements Behavior<Mesh> {
  43320. /**
  43321. * Time in milliseconds to delay before fading in (Default: 0)
  43322. */
  43323. delay: number;
  43324. /**
  43325. * Time in milliseconds for the mesh to fade in (Default: 300)
  43326. */
  43327. fadeInTime: number;
  43328. private _millisecondsPerFrame;
  43329. private _hovered;
  43330. private _hoverValue;
  43331. private _ownerNode;
  43332. /**
  43333. * Instatiates the FadeInOutBehavior
  43334. */
  43335. constructor();
  43336. /**
  43337. * The name of the behavior
  43338. */
  43339. get name(): string;
  43340. /**
  43341. * Initializes the behavior
  43342. */
  43343. init(): void;
  43344. /**
  43345. * Attaches the fade behavior on the passed in mesh
  43346. * @param ownerNode The mesh that will be faded in/out once attached
  43347. */
  43348. attach(ownerNode: Mesh): void;
  43349. /**
  43350. * Detaches the behavior from the mesh
  43351. */
  43352. detach(): void;
  43353. /**
  43354. * Triggers the mesh to begin fading in or out
  43355. * @param value if the object should fade in or out (true to fade in)
  43356. */
  43357. fadeIn(value: boolean): void;
  43358. private _update;
  43359. private _setAllVisibility;
  43360. }
  43361. }
  43362. declare module BABYLON {
  43363. /**
  43364. * Class containing a set of static utilities functions for managing Pivots
  43365. * @hidden
  43366. */
  43367. export class PivotTools {
  43368. private static _PivotCached;
  43369. private static _OldPivotPoint;
  43370. private static _PivotTranslation;
  43371. private static _PivotTmpVector;
  43372. /** @hidden */
  43373. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43374. /** @hidden */
  43375. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43376. }
  43377. }
  43378. declare module BABYLON {
  43379. /**
  43380. * Class containing static functions to help procedurally build meshes
  43381. */
  43382. export class PlaneBuilder {
  43383. /**
  43384. * Creates a plane mesh
  43385. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43386. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43387. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43389. * * 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
  43390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43391. * @param name defines the name of the mesh
  43392. * @param options defines the options used to create the mesh
  43393. * @param scene defines the hosting scene
  43394. * @returns the plane mesh
  43395. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43396. */
  43397. static CreatePlane(name: string, options: {
  43398. size?: number;
  43399. width?: number;
  43400. height?: number;
  43401. sideOrientation?: number;
  43402. frontUVs?: Vector4;
  43403. backUVs?: Vector4;
  43404. updatable?: boolean;
  43405. sourcePlane?: Plane;
  43406. }, scene?: Nullable<Scene>): Mesh;
  43407. }
  43408. }
  43409. declare module BABYLON {
  43410. /**
  43411. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43412. */
  43413. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43414. private static _AnyMouseID;
  43415. /**
  43416. * Abstract mesh the behavior is set on
  43417. */
  43418. attachedNode: AbstractMesh;
  43419. private _dragPlane;
  43420. private _scene;
  43421. private _pointerObserver;
  43422. private _beforeRenderObserver;
  43423. private static _planeScene;
  43424. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43425. /**
  43426. * 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)
  43427. */
  43428. maxDragAngle: number;
  43429. /**
  43430. * @hidden
  43431. */
  43432. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43433. /**
  43434. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43435. */
  43436. currentDraggingPointerID: number;
  43437. /**
  43438. * The last position where the pointer hit the drag plane in world space
  43439. */
  43440. lastDragPosition: Vector3;
  43441. /**
  43442. * If the behavior is currently in a dragging state
  43443. */
  43444. dragging: boolean;
  43445. /**
  43446. * 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)
  43447. */
  43448. dragDeltaRatio: number;
  43449. /**
  43450. * If the drag plane orientation should be updated during the dragging (Default: true)
  43451. */
  43452. updateDragPlane: boolean;
  43453. private _debugMode;
  43454. private _moving;
  43455. /**
  43456. * Fires each time the attached mesh is dragged with the pointer
  43457. * * delta between last drag position and current drag position in world space
  43458. * * dragDistance along the drag axis
  43459. * * dragPlaneNormal normal of the current drag plane used during the drag
  43460. * * dragPlanePoint in world space where the drag intersects the drag plane
  43461. */
  43462. onDragObservable: Observable<{
  43463. delta: Vector3;
  43464. dragPlanePoint: Vector3;
  43465. dragPlaneNormal: Vector3;
  43466. dragDistance: number;
  43467. pointerId: number;
  43468. }>;
  43469. /**
  43470. * Fires each time a drag begins (eg. mouse down on mesh)
  43471. */
  43472. onDragStartObservable: Observable<{
  43473. dragPlanePoint: Vector3;
  43474. pointerId: number;
  43475. }>;
  43476. /**
  43477. * Fires each time a drag ends (eg. mouse release after drag)
  43478. */
  43479. onDragEndObservable: Observable<{
  43480. dragPlanePoint: Vector3;
  43481. pointerId: number;
  43482. }>;
  43483. /**
  43484. * If the attached mesh should be moved when dragged
  43485. */
  43486. moveAttached: boolean;
  43487. /**
  43488. * If the drag behavior will react to drag events (Default: true)
  43489. */
  43490. enabled: boolean;
  43491. /**
  43492. * If pointer events should start and release the drag (Default: true)
  43493. */
  43494. startAndReleaseDragOnPointerEvents: boolean;
  43495. /**
  43496. * If camera controls should be detached during the drag
  43497. */
  43498. detachCameraControls: boolean;
  43499. /**
  43500. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43501. */
  43502. useObjectOrientationForDragging: boolean;
  43503. private _options;
  43504. /**
  43505. * Gets the options used by the behavior
  43506. */
  43507. get options(): {
  43508. dragAxis?: Vector3;
  43509. dragPlaneNormal?: Vector3;
  43510. };
  43511. /**
  43512. * Sets the options used by the behavior
  43513. */
  43514. set options(options: {
  43515. dragAxis?: Vector3;
  43516. dragPlaneNormal?: Vector3;
  43517. });
  43518. /**
  43519. * Creates a pointer drag behavior that can be attached to a mesh
  43520. * @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)
  43521. */
  43522. constructor(options?: {
  43523. dragAxis?: Vector3;
  43524. dragPlaneNormal?: Vector3;
  43525. });
  43526. /**
  43527. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43528. */
  43529. validateDrag: (targetPosition: Vector3) => boolean;
  43530. /**
  43531. * The name of the behavior
  43532. */
  43533. get name(): string;
  43534. /**
  43535. * Initializes the behavior
  43536. */
  43537. init(): void;
  43538. private _tmpVector;
  43539. private _alternatePickedPoint;
  43540. private _worldDragAxis;
  43541. private _targetPosition;
  43542. private _attachedElement;
  43543. /**
  43544. * Attaches the drag behavior the passed in mesh
  43545. * @param ownerNode The mesh that will be dragged around once attached
  43546. * @param predicate Predicate to use for pick filtering
  43547. */
  43548. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43549. /**
  43550. * Force relase the drag action by code.
  43551. */
  43552. releaseDrag(): void;
  43553. private _startDragRay;
  43554. private _lastPointerRay;
  43555. /**
  43556. * Simulates the start of a pointer drag event on the behavior
  43557. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43558. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43559. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43560. */
  43561. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43562. private _startDrag;
  43563. private _dragDelta;
  43564. private _moveDrag;
  43565. private _pickWithRayOnDragPlane;
  43566. private _pointA;
  43567. private _pointC;
  43568. private _localAxis;
  43569. private _lookAt;
  43570. private _updateDragPlanePosition;
  43571. /**
  43572. * Detaches the behavior from the mesh
  43573. */
  43574. detach(): void;
  43575. }
  43576. }
  43577. declare module BABYLON {
  43578. /**
  43579. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43580. */
  43581. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43582. private _dragBehaviorA;
  43583. private _dragBehaviorB;
  43584. private _startDistance;
  43585. private _initialScale;
  43586. private _targetScale;
  43587. private _ownerNode;
  43588. private _sceneRenderObserver;
  43589. /**
  43590. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43591. */
  43592. constructor();
  43593. /**
  43594. * The name of the behavior
  43595. */
  43596. get name(): string;
  43597. /**
  43598. * Initializes the behavior
  43599. */
  43600. init(): void;
  43601. private _getCurrentDistance;
  43602. /**
  43603. * Attaches the scale behavior the passed in mesh
  43604. * @param ownerNode The mesh that will be scaled around once attached
  43605. */
  43606. attach(ownerNode: Mesh): void;
  43607. /**
  43608. * Detaches the behavior from the mesh
  43609. */
  43610. detach(): void;
  43611. }
  43612. }
  43613. declare module BABYLON {
  43614. /**
  43615. * 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
  43616. */
  43617. export class SixDofDragBehavior implements Behavior<Mesh> {
  43618. private static _virtualScene;
  43619. private _ownerNode;
  43620. private _sceneRenderObserver;
  43621. private _scene;
  43622. private _targetPosition;
  43623. private _virtualOriginMesh;
  43624. private _virtualDragMesh;
  43625. private _pointerObserver;
  43626. private _moving;
  43627. private _startingOrientation;
  43628. private _attachedElement;
  43629. /**
  43630. * 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)
  43631. */
  43632. private zDragFactor;
  43633. /**
  43634. * If the object should rotate to face the drag origin
  43635. */
  43636. rotateDraggedObject: boolean;
  43637. /**
  43638. * If the behavior is currently in a dragging state
  43639. */
  43640. dragging: boolean;
  43641. /**
  43642. * 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)
  43643. */
  43644. dragDeltaRatio: number;
  43645. /**
  43646. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43647. */
  43648. currentDraggingPointerID: number;
  43649. /**
  43650. * If camera controls should be detached during the drag
  43651. */
  43652. detachCameraControls: boolean;
  43653. /**
  43654. * Fires each time a drag starts
  43655. */
  43656. onDragStartObservable: Observable<{}>;
  43657. /**
  43658. * Fires each time a drag ends (eg. mouse release after drag)
  43659. */
  43660. onDragEndObservable: Observable<{}>;
  43661. /**
  43662. * 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
  43663. */
  43664. constructor();
  43665. /**
  43666. * The name of the behavior
  43667. */
  43668. get name(): string;
  43669. /**
  43670. * Initializes the behavior
  43671. */
  43672. init(): void;
  43673. /**
  43674. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43675. */
  43676. private get _pointerCamera();
  43677. /**
  43678. * Attaches the scale behavior the passed in mesh
  43679. * @param ownerNode The mesh that will be scaled around once attached
  43680. */
  43681. attach(ownerNode: Mesh): void;
  43682. /**
  43683. * Detaches the behavior from the mesh
  43684. */
  43685. detach(): void;
  43686. }
  43687. }
  43688. declare module BABYLON {
  43689. /**
  43690. * Class used to apply inverse kinematics to bones
  43691. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43692. */
  43693. export class BoneIKController {
  43694. private static _tmpVecs;
  43695. private static _tmpQuat;
  43696. private static _tmpMats;
  43697. /**
  43698. * Gets or sets the target mesh
  43699. */
  43700. targetMesh: AbstractMesh;
  43701. /** Gets or sets the mesh used as pole */
  43702. poleTargetMesh: AbstractMesh;
  43703. /**
  43704. * Gets or sets the bone used as pole
  43705. */
  43706. poleTargetBone: Nullable<Bone>;
  43707. /**
  43708. * Gets or sets the target position
  43709. */
  43710. targetPosition: Vector3;
  43711. /**
  43712. * Gets or sets the pole target position
  43713. */
  43714. poleTargetPosition: Vector3;
  43715. /**
  43716. * Gets or sets the pole target local offset
  43717. */
  43718. poleTargetLocalOffset: Vector3;
  43719. /**
  43720. * Gets or sets the pole angle
  43721. */
  43722. poleAngle: number;
  43723. /**
  43724. * Gets or sets the mesh associated with the controller
  43725. */
  43726. mesh: AbstractMesh;
  43727. /**
  43728. * 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)
  43729. */
  43730. slerpAmount: number;
  43731. private _bone1Quat;
  43732. private _bone1Mat;
  43733. private _bone2Ang;
  43734. private _bone1;
  43735. private _bone2;
  43736. private _bone1Length;
  43737. private _bone2Length;
  43738. private _maxAngle;
  43739. private _maxReach;
  43740. private _rightHandedSystem;
  43741. private _bendAxis;
  43742. private _slerping;
  43743. private _adjustRoll;
  43744. /**
  43745. * Gets or sets maximum allowed angle
  43746. */
  43747. get maxAngle(): number;
  43748. set maxAngle(value: number);
  43749. /**
  43750. * Creates a new BoneIKController
  43751. * @param mesh defines the mesh to control
  43752. * @param bone defines the bone to control
  43753. * @param options defines options to set up the controller
  43754. */
  43755. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43756. targetMesh?: AbstractMesh;
  43757. poleTargetMesh?: AbstractMesh;
  43758. poleTargetBone?: Bone;
  43759. poleTargetLocalOffset?: Vector3;
  43760. poleAngle?: number;
  43761. bendAxis?: Vector3;
  43762. maxAngle?: number;
  43763. slerpAmount?: number;
  43764. });
  43765. private _setMaxAngle;
  43766. /**
  43767. * Force the controller to update the bones
  43768. */
  43769. update(): void;
  43770. }
  43771. }
  43772. declare module BABYLON {
  43773. /**
  43774. * Class used to make a bone look toward a point in space
  43775. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43776. */
  43777. export class BoneLookController {
  43778. private static _tmpVecs;
  43779. private static _tmpQuat;
  43780. private static _tmpMats;
  43781. /**
  43782. * The target Vector3 that the bone will look at
  43783. */
  43784. target: Vector3;
  43785. /**
  43786. * The mesh that the bone is attached to
  43787. */
  43788. mesh: AbstractMesh;
  43789. /**
  43790. * The bone that will be looking to the target
  43791. */
  43792. bone: Bone;
  43793. /**
  43794. * The up axis of the coordinate system that is used when the bone is rotated
  43795. */
  43796. upAxis: Vector3;
  43797. /**
  43798. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43799. */
  43800. upAxisSpace: Space;
  43801. /**
  43802. * Used to make an adjustment to the yaw of the bone
  43803. */
  43804. adjustYaw: number;
  43805. /**
  43806. * Used to make an adjustment to the pitch of the bone
  43807. */
  43808. adjustPitch: number;
  43809. /**
  43810. * Used to make an adjustment to the roll of the bone
  43811. */
  43812. adjustRoll: number;
  43813. /**
  43814. * 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)
  43815. */
  43816. slerpAmount: number;
  43817. private _minYaw;
  43818. private _maxYaw;
  43819. private _minPitch;
  43820. private _maxPitch;
  43821. private _minYawSin;
  43822. private _minYawCos;
  43823. private _maxYawSin;
  43824. private _maxYawCos;
  43825. private _midYawConstraint;
  43826. private _minPitchTan;
  43827. private _maxPitchTan;
  43828. private _boneQuat;
  43829. private _slerping;
  43830. private _transformYawPitch;
  43831. private _transformYawPitchInv;
  43832. private _firstFrameSkipped;
  43833. private _yawRange;
  43834. private _fowardAxis;
  43835. /**
  43836. * Gets or sets the minimum yaw angle that the bone can look to
  43837. */
  43838. get minYaw(): number;
  43839. set minYaw(value: number);
  43840. /**
  43841. * Gets or sets the maximum yaw angle that the bone can look to
  43842. */
  43843. get maxYaw(): number;
  43844. set maxYaw(value: number);
  43845. /**
  43846. * Gets or sets the minimum pitch angle that the bone can look to
  43847. */
  43848. get minPitch(): number;
  43849. set minPitch(value: number);
  43850. /**
  43851. * Gets or sets the maximum pitch angle that the bone can look to
  43852. */
  43853. get maxPitch(): number;
  43854. set maxPitch(value: number);
  43855. /**
  43856. * Create a BoneLookController
  43857. * @param mesh the mesh that the bone belongs to
  43858. * @param bone the bone that will be looking to the target
  43859. * @param target the target Vector3 to look at
  43860. * @param options optional settings:
  43861. * * maxYaw: the maximum angle the bone will yaw to
  43862. * * minYaw: the minimum angle the bone will yaw to
  43863. * * maxPitch: the maximum angle the bone will pitch to
  43864. * * minPitch: the minimum angle the bone will yaw to
  43865. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43866. * * upAxis: the up axis of the coordinate system
  43867. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43868. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43869. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43870. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43871. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43872. * * adjustRoll: used to make an adjustment to the roll of the bone
  43873. **/
  43874. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43875. maxYaw?: number;
  43876. minYaw?: number;
  43877. maxPitch?: number;
  43878. minPitch?: number;
  43879. slerpAmount?: number;
  43880. upAxis?: Vector3;
  43881. upAxisSpace?: Space;
  43882. yawAxis?: Vector3;
  43883. pitchAxis?: Vector3;
  43884. adjustYaw?: number;
  43885. adjustPitch?: number;
  43886. adjustRoll?: number;
  43887. });
  43888. /**
  43889. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43890. */
  43891. update(): void;
  43892. private _getAngleDiff;
  43893. private _getAngleBetween;
  43894. private _isAngleBetween;
  43895. }
  43896. }
  43897. declare module BABYLON {
  43898. /**
  43899. * Manage the gamepad inputs to control an arc rotate camera.
  43900. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43901. */
  43902. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43903. /**
  43904. * Defines the camera the input is attached to.
  43905. */
  43906. camera: ArcRotateCamera;
  43907. /**
  43908. * Defines the gamepad the input is gathering event from.
  43909. */
  43910. gamepad: Nullable<Gamepad>;
  43911. /**
  43912. * Defines the gamepad rotation sensiblity.
  43913. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43914. */
  43915. gamepadRotationSensibility: number;
  43916. /**
  43917. * Defines the gamepad move sensiblity.
  43918. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43919. */
  43920. gamepadMoveSensibility: number;
  43921. private _yAxisScale;
  43922. /**
  43923. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43924. */
  43925. get invertYAxis(): boolean;
  43926. set invertYAxis(value: boolean);
  43927. private _onGamepadConnectedObserver;
  43928. private _onGamepadDisconnectedObserver;
  43929. /**
  43930. * Attach the input controls to a specific dom element to get the input from.
  43931. * @param element Defines the element the controls should be listened from
  43932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43933. */
  43934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43935. /**
  43936. * Detach the current controls from the specified dom element.
  43937. * @param element Defines the element to stop listening the inputs from
  43938. */
  43939. detachControl(element: Nullable<HTMLElement>): void;
  43940. /**
  43941. * Update the current camera state depending on the inputs that have been used this frame.
  43942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43943. */
  43944. checkInputs(): void;
  43945. /**
  43946. * Gets the class name of the current intput.
  43947. * @returns the class name
  43948. */
  43949. getClassName(): string;
  43950. /**
  43951. * Get the friendly name associated with the input class.
  43952. * @returns the input friendly name
  43953. */
  43954. getSimpleName(): string;
  43955. }
  43956. }
  43957. declare module BABYLON {
  43958. interface ArcRotateCameraInputsManager {
  43959. /**
  43960. * Add orientation input support to the input manager.
  43961. * @returns the current input manager
  43962. */
  43963. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43964. }
  43965. /**
  43966. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43967. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43968. */
  43969. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43970. /**
  43971. * Defines the camera the input is attached to.
  43972. */
  43973. camera: ArcRotateCamera;
  43974. /**
  43975. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43976. */
  43977. alphaCorrection: number;
  43978. /**
  43979. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43980. */
  43981. gammaCorrection: number;
  43982. private _alpha;
  43983. private _gamma;
  43984. private _dirty;
  43985. private _deviceOrientationHandler;
  43986. /**
  43987. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43988. */
  43989. constructor();
  43990. /**
  43991. * Attach the input controls to a specific dom element to get the input from.
  43992. * @param element Defines the element the controls should be listened from
  43993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43994. */
  43995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43996. /** @hidden */
  43997. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43998. /**
  43999. * Update the current camera state depending on the inputs that have been used this frame.
  44000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44001. */
  44002. checkInputs(): void;
  44003. /**
  44004. * Detach the current controls from the specified dom element.
  44005. * @param element Defines the element to stop listening the inputs from
  44006. */
  44007. detachControl(element: Nullable<HTMLElement>): void;
  44008. /**
  44009. * Gets the class name of the current intput.
  44010. * @returns the class name
  44011. */
  44012. getClassName(): string;
  44013. /**
  44014. * Get the friendly name associated with the input class.
  44015. * @returns the input friendly name
  44016. */
  44017. getSimpleName(): string;
  44018. }
  44019. }
  44020. declare module BABYLON {
  44021. /**
  44022. * Listen to mouse events to control the camera.
  44023. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44024. */
  44025. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44026. /**
  44027. * Defines the camera the input is attached to.
  44028. */
  44029. camera: FlyCamera;
  44030. /**
  44031. * Defines if touch is enabled. (Default is true.)
  44032. */
  44033. touchEnabled: boolean;
  44034. /**
  44035. * Defines the buttons associated with the input to handle camera rotation.
  44036. */
  44037. buttons: number[];
  44038. /**
  44039. * Assign buttons for Yaw control.
  44040. */
  44041. buttonsYaw: number[];
  44042. /**
  44043. * Assign buttons for Pitch control.
  44044. */
  44045. buttonsPitch: number[];
  44046. /**
  44047. * Assign buttons for Roll control.
  44048. */
  44049. buttonsRoll: number[];
  44050. /**
  44051. * Detect if any button is being pressed while mouse is moved.
  44052. * -1 = Mouse locked.
  44053. * 0 = Left button.
  44054. * 1 = Middle Button.
  44055. * 2 = Right Button.
  44056. */
  44057. activeButton: number;
  44058. /**
  44059. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44060. * Higher values reduce its sensitivity.
  44061. */
  44062. angularSensibility: number;
  44063. private _mousemoveCallback;
  44064. private _observer;
  44065. private _rollObserver;
  44066. private previousPosition;
  44067. private noPreventDefault;
  44068. private element;
  44069. /**
  44070. * Listen to mouse events to control the camera.
  44071. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44072. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44073. */
  44074. constructor(touchEnabled?: boolean);
  44075. /**
  44076. * Attach the mouse control to the HTML DOM element.
  44077. * @param element Defines the element that listens to the input events.
  44078. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44079. */
  44080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44081. /**
  44082. * Detach the current controls from the specified dom element.
  44083. * @param element Defines the element to stop listening the inputs from
  44084. */
  44085. detachControl(element: Nullable<HTMLElement>): void;
  44086. /**
  44087. * Gets the class name of the current input.
  44088. * @returns the class name.
  44089. */
  44090. getClassName(): string;
  44091. /**
  44092. * Get the friendly name associated with the input class.
  44093. * @returns the input's friendly name.
  44094. */
  44095. getSimpleName(): string;
  44096. private _pointerInput;
  44097. private _onMouseMove;
  44098. /**
  44099. * Rotate camera by mouse offset.
  44100. */
  44101. private rotateCamera;
  44102. }
  44103. }
  44104. declare module BABYLON {
  44105. /**
  44106. * Default Inputs manager for the FlyCamera.
  44107. * It groups all the default supported inputs for ease of use.
  44108. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44109. */
  44110. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44111. /**
  44112. * Instantiates a new FlyCameraInputsManager.
  44113. * @param camera Defines the camera the inputs belong to.
  44114. */
  44115. constructor(camera: FlyCamera);
  44116. /**
  44117. * Add keyboard input support to the input manager.
  44118. * @returns the new FlyCameraKeyboardMoveInput().
  44119. */
  44120. addKeyboard(): FlyCameraInputsManager;
  44121. /**
  44122. * Add mouse input support to the input manager.
  44123. * @param touchEnabled Enable touch screen support.
  44124. * @returns the new FlyCameraMouseInput().
  44125. */
  44126. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44127. }
  44128. }
  44129. declare module BABYLON {
  44130. /**
  44131. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44132. * such as in a 3D Space Shooter or a Flight Simulator.
  44133. */
  44134. export class FlyCamera extends TargetCamera {
  44135. /**
  44136. * Define the collision ellipsoid of the camera.
  44137. * This is helpful for simulating a camera body, like a player's body.
  44138. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44139. */
  44140. ellipsoid: Vector3;
  44141. /**
  44142. * Define an offset for the position of the ellipsoid around the camera.
  44143. * This can be helpful if the camera is attached away from the player's body center,
  44144. * such as at its head.
  44145. */
  44146. ellipsoidOffset: Vector3;
  44147. /**
  44148. * Enable or disable collisions of the camera with the rest of the scene objects.
  44149. */
  44150. checkCollisions: boolean;
  44151. /**
  44152. * Enable or disable gravity on the camera.
  44153. */
  44154. applyGravity: boolean;
  44155. /**
  44156. * Define the current direction the camera is moving to.
  44157. */
  44158. cameraDirection: Vector3;
  44159. /**
  44160. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44161. * This overrides and empties cameraRotation.
  44162. */
  44163. rotationQuaternion: Quaternion;
  44164. /**
  44165. * Track Roll to maintain the wanted Rolling when looking around.
  44166. */
  44167. _trackRoll: number;
  44168. /**
  44169. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44170. */
  44171. rollCorrect: number;
  44172. /**
  44173. * Mimic a banked turn, Rolling the camera when Yawing.
  44174. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44175. */
  44176. bankedTurn: boolean;
  44177. /**
  44178. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44179. */
  44180. bankedTurnLimit: number;
  44181. /**
  44182. * Value of 0 disables the banked Roll.
  44183. * Value of 1 is equal to the Yaw angle in radians.
  44184. */
  44185. bankedTurnMultiplier: number;
  44186. /**
  44187. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44188. */
  44189. inputs: FlyCameraInputsManager;
  44190. /**
  44191. * Gets the input sensibility for mouse input.
  44192. * Higher values reduce sensitivity.
  44193. */
  44194. get angularSensibility(): number;
  44195. /**
  44196. * Sets the input sensibility for a mouse input.
  44197. * Higher values reduce sensitivity.
  44198. */
  44199. set angularSensibility(value: number);
  44200. /**
  44201. * Get the keys for camera movement forward.
  44202. */
  44203. get keysForward(): number[];
  44204. /**
  44205. * Set the keys for camera movement forward.
  44206. */
  44207. set keysForward(value: number[]);
  44208. /**
  44209. * Get the keys for camera movement backward.
  44210. */
  44211. get keysBackward(): number[];
  44212. set keysBackward(value: number[]);
  44213. /**
  44214. * Get the keys for camera movement up.
  44215. */
  44216. get keysUp(): number[];
  44217. /**
  44218. * Set the keys for camera movement up.
  44219. */
  44220. set keysUp(value: number[]);
  44221. /**
  44222. * Get the keys for camera movement down.
  44223. */
  44224. get keysDown(): number[];
  44225. /**
  44226. * Set the keys for camera movement down.
  44227. */
  44228. set keysDown(value: number[]);
  44229. /**
  44230. * Get the keys for camera movement left.
  44231. */
  44232. get keysLeft(): number[];
  44233. /**
  44234. * Set the keys for camera movement left.
  44235. */
  44236. set keysLeft(value: number[]);
  44237. /**
  44238. * Set the keys for camera movement right.
  44239. */
  44240. get keysRight(): number[];
  44241. /**
  44242. * Set the keys for camera movement right.
  44243. */
  44244. set keysRight(value: number[]);
  44245. /**
  44246. * Event raised when the camera collides with a mesh in the scene.
  44247. */
  44248. onCollide: (collidedMesh: AbstractMesh) => void;
  44249. private _collider;
  44250. private _needMoveForGravity;
  44251. private _oldPosition;
  44252. private _diffPosition;
  44253. private _newPosition;
  44254. /** @hidden */
  44255. _localDirection: Vector3;
  44256. /** @hidden */
  44257. _transformedDirection: Vector3;
  44258. /**
  44259. * Instantiates a FlyCamera.
  44260. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44261. * such as in a 3D Space Shooter or a Flight Simulator.
  44262. * @param name Define the name of the camera in the scene.
  44263. * @param position Define the starting position of the camera in the scene.
  44264. * @param scene Define the scene the camera belongs to.
  44265. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44266. */
  44267. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44268. /**
  44269. * Attach a control to the HTML DOM element.
  44270. * @param element Defines the element that listens to the input events.
  44271. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44272. */
  44273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44274. /**
  44275. * Detach a control from the HTML DOM element.
  44276. * The camera will stop reacting to that input.
  44277. * @param element Defines the element that listens to the input events.
  44278. */
  44279. detachControl(element: HTMLElement): void;
  44280. private _collisionMask;
  44281. /**
  44282. * Get the mask that the camera ignores in collision events.
  44283. */
  44284. get collisionMask(): number;
  44285. /**
  44286. * Set the mask that the camera ignores in collision events.
  44287. */
  44288. set collisionMask(mask: number);
  44289. /** @hidden */
  44290. _collideWithWorld(displacement: Vector3): void;
  44291. /** @hidden */
  44292. private _onCollisionPositionChange;
  44293. /** @hidden */
  44294. _checkInputs(): void;
  44295. /** @hidden */
  44296. _decideIfNeedsToMove(): boolean;
  44297. /** @hidden */
  44298. _updatePosition(): void;
  44299. /**
  44300. * Restore the Roll to its target value at the rate specified.
  44301. * @param rate - Higher means slower restoring.
  44302. * @hidden
  44303. */
  44304. restoreRoll(rate: number): void;
  44305. /**
  44306. * Destroy the camera and release the current resources held by it.
  44307. */
  44308. dispose(): void;
  44309. /**
  44310. * Get the current object class name.
  44311. * @returns the class name.
  44312. */
  44313. getClassName(): string;
  44314. }
  44315. }
  44316. declare module BABYLON {
  44317. /**
  44318. * Listen to keyboard events to control the camera.
  44319. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44320. */
  44321. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44322. /**
  44323. * Defines the camera the input is attached to.
  44324. */
  44325. camera: FlyCamera;
  44326. /**
  44327. * The list of keyboard keys used to control the forward move of the camera.
  44328. */
  44329. keysForward: number[];
  44330. /**
  44331. * The list of keyboard keys used to control the backward move of the camera.
  44332. */
  44333. keysBackward: number[];
  44334. /**
  44335. * The list of keyboard keys used to control the forward move of the camera.
  44336. */
  44337. keysUp: number[];
  44338. /**
  44339. * The list of keyboard keys used to control the backward move of the camera.
  44340. */
  44341. keysDown: number[];
  44342. /**
  44343. * The list of keyboard keys used to control the right strafe move of the camera.
  44344. */
  44345. keysRight: number[];
  44346. /**
  44347. * The list of keyboard keys used to control the left strafe move of the camera.
  44348. */
  44349. keysLeft: number[];
  44350. private _keys;
  44351. private _onCanvasBlurObserver;
  44352. private _onKeyboardObserver;
  44353. private _engine;
  44354. private _scene;
  44355. /**
  44356. * Attach the input controls to a specific dom element to get the input from.
  44357. * @param element Defines the element the controls should be listened from
  44358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44359. */
  44360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44361. /**
  44362. * Detach the current controls from the specified dom element.
  44363. * @param element Defines the element to stop listening the inputs from
  44364. */
  44365. detachControl(element: Nullable<HTMLElement>): void;
  44366. /**
  44367. * Gets the class name of the current intput.
  44368. * @returns the class name
  44369. */
  44370. getClassName(): string;
  44371. /** @hidden */
  44372. _onLostFocus(e: FocusEvent): void;
  44373. /**
  44374. * Get the friendly name associated with the input class.
  44375. * @returns the input friendly name
  44376. */
  44377. getSimpleName(): string;
  44378. /**
  44379. * Update the current camera state depending on the inputs that have been used this frame.
  44380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44381. */
  44382. checkInputs(): void;
  44383. }
  44384. }
  44385. declare module BABYLON {
  44386. /**
  44387. * Manage the mouse wheel inputs to control a follow camera.
  44388. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44389. */
  44390. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44391. /**
  44392. * Defines the camera the input is attached to.
  44393. */
  44394. camera: FollowCamera;
  44395. /**
  44396. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44397. */
  44398. axisControlRadius: boolean;
  44399. /**
  44400. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44401. */
  44402. axisControlHeight: boolean;
  44403. /**
  44404. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44405. */
  44406. axisControlRotation: boolean;
  44407. /**
  44408. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44409. * relation to mouseWheel events.
  44410. */
  44411. wheelPrecision: number;
  44412. /**
  44413. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44414. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44415. */
  44416. wheelDeltaPercentage: number;
  44417. private _wheel;
  44418. private _observer;
  44419. /**
  44420. * Attach the input controls to a specific dom element to get the input from.
  44421. * @param element Defines the element the controls should be listened from
  44422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44423. */
  44424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44425. /**
  44426. * Detach the current controls from the specified dom element.
  44427. * @param element Defines the element to stop listening the inputs from
  44428. */
  44429. detachControl(element: Nullable<HTMLElement>): void;
  44430. /**
  44431. * Gets the class name of the current intput.
  44432. * @returns the class name
  44433. */
  44434. getClassName(): string;
  44435. /**
  44436. * Get the friendly name associated with the input class.
  44437. * @returns the input friendly name
  44438. */
  44439. getSimpleName(): string;
  44440. }
  44441. }
  44442. declare module BABYLON {
  44443. /**
  44444. * Manage the pointers inputs to control an follow camera.
  44445. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44446. */
  44447. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44448. /**
  44449. * Defines the camera the input is attached to.
  44450. */
  44451. camera: FollowCamera;
  44452. /**
  44453. * Gets the class name of the current input.
  44454. * @returns the class name
  44455. */
  44456. getClassName(): string;
  44457. /**
  44458. * Defines the pointer angular sensibility along the X axis or how fast is
  44459. * the camera rotating.
  44460. * A negative number will reverse the axis direction.
  44461. */
  44462. angularSensibilityX: number;
  44463. /**
  44464. * Defines the pointer angular sensibility along the Y axis or how fast is
  44465. * the camera rotating.
  44466. * A negative number will reverse the axis direction.
  44467. */
  44468. angularSensibilityY: number;
  44469. /**
  44470. * Defines the pointer pinch precision or how fast is the camera zooming.
  44471. * A negative number will reverse the axis direction.
  44472. */
  44473. pinchPrecision: number;
  44474. /**
  44475. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44476. * from 0.
  44477. * It defines the percentage of current camera.radius to use as delta when
  44478. * pinch zoom is used.
  44479. */
  44480. pinchDeltaPercentage: number;
  44481. /**
  44482. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44483. */
  44484. axisXControlRadius: boolean;
  44485. /**
  44486. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44487. */
  44488. axisXControlHeight: boolean;
  44489. /**
  44490. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44491. */
  44492. axisXControlRotation: boolean;
  44493. /**
  44494. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44495. */
  44496. axisYControlRadius: boolean;
  44497. /**
  44498. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44499. */
  44500. axisYControlHeight: boolean;
  44501. /**
  44502. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44503. */
  44504. axisYControlRotation: boolean;
  44505. /**
  44506. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44507. */
  44508. axisPinchControlRadius: boolean;
  44509. /**
  44510. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44511. */
  44512. axisPinchControlHeight: boolean;
  44513. /**
  44514. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44515. */
  44516. axisPinchControlRotation: boolean;
  44517. /**
  44518. * Log error messages if basic misconfiguration has occurred.
  44519. */
  44520. warningEnable: boolean;
  44521. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44522. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44523. private _warningCounter;
  44524. private _warning;
  44525. }
  44526. }
  44527. declare module BABYLON {
  44528. /**
  44529. * Default Inputs manager for the FollowCamera.
  44530. * It groups all the default supported inputs for ease of use.
  44531. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44532. */
  44533. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44534. /**
  44535. * Instantiates a new FollowCameraInputsManager.
  44536. * @param camera Defines the camera the inputs belong to
  44537. */
  44538. constructor(camera: FollowCamera);
  44539. /**
  44540. * Add keyboard input support to the input manager.
  44541. * @returns the current input manager
  44542. */
  44543. addKeyboard(): FollowCameraInputsManager;
  44544. /**
  44545. * Add mouse wheel input support to the input manager.
  44546. * @returns the current input manager
  44547. */
  44548. addMouseWheel(): FollowCameraInputsManager;
  44549. /**
  44550. * Add pointers input support to the input manager.
  44551. * @returns the current input manager
  44552. */
  44553. addPointers(): FollowCameraInputsManager;
  44554. /**
  44555. * Add orientation input support to the input manager.
  44556. * @returns the current input manager
  44557. */
  44558. addVRDeviceOrientation(): FollowCameraInputsManager;
  44559. }
  44560. }
  44561. declare module BABYLON {
  44562. /**
  44563. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44564. * an arc rotate version arcFollowCamera are available.
  44565. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44566. */
  44567. export class FollowCamera extends TargetCamera {
  44568. /**
  44569. * Distance the follow camera should follow an object at
  44570. */
  44571. radius: number;
  44572. /**
  44573. * Minimum allowed distance of the camera to the axis of rotation
  44574. * (The camera can not get closer).
  44575. * This can help limiting how the Camera is able to move in the scene.
  44576. */
  44577. lowerRadiusLimit: Nullable<number>;
  44578. /**
  44579. * Maximum allowed distance of the camera to the axis of rotation
  44580. * (The camera can not get further).
  44581. * This can help limiting how the Camera is able to move in the scene.
  44582. */
  44583. upperRadiusLimit: Nullable<number>;
  44584. /**
  44585. * Define a rotation offset between the camera and the object it follows
  44586. */
  44587. rotationOffset: number;
  44588. /**
  44589. * Minimum allowed angle to camera position relative to target object.
  44590. * This can help limiting how the Camera is able to move in the scene.
  44591. */
  44592. lowerRotationOffsetLimit: Nullable<number>;
  44593. /**
  44594. * Maximum allowed angle to camera position relative to target object.
  44595. * This can help limiting how the Camera is able to move in the scene.
  44596. */
  44597. upperRotationOffsetLimit: Nullable<number>;
  44598. /**
  44599. * Define a height offset between the camera and the object it follows.
  44600. * It can help following an object from the top (like a car chaing a plane)
  44601. */
  44602. heightOffset: number;
  44603. /**
  44604. * Minimum allowed height of camera position relative to target object.
  44605. * This can help limiting how the Camera is able to move in the scene.
  44606. */
  44607. lowerHeightOffsetLimit: Nullable<number>;
  44608. /**
  44609. * Maximum allowed height of camera position relative to target object.
  44610. * This can help limiting how the Camera is able to move in the scene.
  44611. */
  44612. upperHeightOffsetLimit: Nullable<number>;
  44613. /**
  44614. * Define how fast the camera can accelerate to follow it s target.
  44615. */
  44616. cameraAcceleration: number;
  44617. /**
  44618. * Define the speed limit of the camera following an object.
  44619. */
  44620. maxCameraSpeed: number;
  44621. /**
  44622. * Define the target of the camera.
  44623. */
  44624. lockedTarget: Nullable<AbstractMesh>;
  44625. /**
  44626. * Defines the input associated with the camera.
  44627. */
  44628. inputs: FollowCameraInputsManager;
  44629. /**
  44630. * Instantiates the follow camera.
  44631. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44632. * @param name Define the name of the camera in the scene
  44633. * @param position Define the position of the camera
  44634. * @param scene Define the scene the camera belong to
  44635. * @param lockedTarget Define the target of the camera
  44636. */
  44637. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44638. private _follow;
  44639. /**
  44640. * Attached controls to the current camera.
  44641. * @param element Defines the element the controls should be listened from
  44642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44643. */
  44644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44645. /**
  44646. * Detach the current controls from the camera.
  44647. * The camera will stop reacting to inputs.
  44648. * @param element Defines the element to stop listening the inputs from
  44649. */
  44650. detachControl(element: HTMLElement): void;
  44651. /** @hidden */
  44652. _checkInputs(): void;
  44653. private _checkLimits;
  44654. /**
  44655. * Gets the camera class name.
  44656. * @returns the class name
  44657. */
  44658. getClassName(): string;
  44659. }
  44660. /**
  44661. * Arc Rotate version of the follow camera.
  44662. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44663. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44664. */
  44665. export class ArcFollowCamera extends TargetCamera {
  44666. /** The longitudinal angle of the camera */
  44667. alpha: number;
  44668. /** The latitudinal angle of the camera */
  44669. beta: number;
  44670. /** The radius of the camera from its target */
  44671. radius: number;
  44672. private _cartesianCoordinates;
  44673. /** Define the camera target (the mesh it should follow) */
  44674. private _meshTarget;
  44675. /**
  44676. * Instantiates a new ArcFollowCamera
  44677. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44678. * @param name Define the name of the camera
  44679. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44680. * @param beta Define the rotation angle of the camera around the elevation axis
  44681. * @param radius Define the radius of the camera from its target point
  44682. * @param target Define the target of the camera
  44683. * @param scene Define the scene the camera belongs to
  44684. */
  44685. constructor(name: string,
  44686. /** The longitudinal angle of the camera */
  44687. alpha: number,
  44688. /** The latitudinal angle of the camera */
  44689. beta: number,
  44690. /** The radius of the camera from its target */
  44691. radius: number,
  44692. /** Define the camera target (the mesh it should follow) */
  44693. target: Nullable<AbstractMesh>, scene: Scene);
  44694. private _follow;
  44695. /** @hidden */
  44696. _checkInputs(): void;
  44697. /**
  44698. * Returns the class name of the object.
  44699. * It is mostly used internally for serialization purposes.
  44700. */
  44701. getClassName(): string;
  44702. }
  44703. }
  44704. declare module BABYLON {
  44705. /**
  44706. * Manage the keyboard inputs to control the movement of a follow camera.
  44707. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44708. */
  44709. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44710. /**
  44711. * Defines the camera the input is attached to.
  44712. */
  44713. camera: FollowCamera;
  44714. /**
  44715. * Defines the list of key codes associated with the up action (increase heightOffset)
  44716. */
  44717. keysHeightOffsetIncr: number[];
  44718. /**
  44719. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44720. */
  44721. keysHeightOffsetDecr: number[];
  44722. /**
  44723. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44724. */
  44725. keysHeightOffsetModifierAlt: boolean;
  44726. /**
  44727. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44728. */
  44729. keysHeightOffsetModifierCtrl: boolean;
  44730. /**
  44731. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44732. */
  44733. keysHeightOffsetModifierShift: boolean;
  44734. /**
  44735. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44736. */
  44737. keysRotationOffsetIncr: number[];
  44738. /**
  44739. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44740. */
  44741. keysRotationOffsetDecr: number[];
  44742. /**
  44743. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44744. */
  44745. keysRotationOffsetModifierAlt: boolean;
  44746. /**
  44747. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44748. */
  44749. keysRotationOffsetModifierCtrl: boolean;
  44750. /**
  44751. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44752. */
  44753. keysRotationOffsetModifierShift: boolean;
  44754. /**
  44755. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44756. */
  44757. keysRadiusIncr: number[];
  44758. /**
  44759. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44760. */
  44761. keysRadiusDecr: number[];
  44762. /**
  44763. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44764. */
  44765. keysRadiusModifierAlt: boolean;
  44766. /**
  44767. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44768. */
  44769. keysRadiusModifierCtrl: boolean;
  44770. /**
  44771. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44772. */
  44773. keysRadiusModifierShift: boolean;
  44774. /**
  44775. * Defines the rate of change of heightOffset.
  44776. */
  44777. heightSensibility: number;
  44778. /**
  44779. * Defines the rate of change of rotationOffset.
  44780. */
  44781. rotationSensibility: number;
  44782. /**
  44783. * Defines the rate of change of radius.
  44784. */
  44785. radiusSensibility: number;
  44786. private _keys;
  44787. private _ctrlPressed;
  44788. private _altPressed;
  44789. private _shiftPressed;
  44790. private _onCanvasBlurObserver;
  44791. private _onKeyboardObserver;
  44792. private _engine;
  44793. private _scene;
  44794. /**
  44795. * Attach the input controls to a specific dom element to get the input from.
  44796. * @param element Defines the element the controls should be listened from
  44797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44798. */
  44799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44800. /**
  44801. * Detach the current controls from the specified dom element.
  44802. * @param element Defines the element to stop listening the inputs from
  44803. */
  44804. detachControl(element: Nullable<HTMLElement>): void;
  44805. /**
  44806. * Update the current camera state depending on the inputs that have been used this frame.
  44807. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44808. */
  44809. checkInputs(): void;
  44810. /**
  44811. * Gets the class name of the current input.
  44812. * @returns the class name
  44813. */
  44814. getClassName(): string;
  44815. /**
  44816. * Get the friendly name associated with the input class.
  44817. * @returns the input friendly name
  44818. */
  44819. getSimpleName(): string;
  44820. /**
  44821. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44822. * allow modification of the heightOffset value.
  44823. */
  44824. private _modifierHeightOffset;
  44825. /**
  44826. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44827. * allow modification of the rotationOffset value.
  44828. */
  44829. private _modifierRotationOffset;
  44830. /**
  44831. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44832. * allow modification of the radius value.
  44833. */
  44834. private _modifierRadius;
  44835. }
  44836. }
  44837. declare module BABYLON {
  44838. interface FreeCameraInputsManager {
  44839. /**
  44840. * @hidden
  44841. */
  44842. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44843. /**
  44844. * Add orientation input support to the input manager.
  44845. * @returns the current input manager
  44846. */
  44847. addDeviceOrientation(): FreeCameraInputsManager;
  44848. }
  44849. /**
  44850. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44851. * Screen rotation is taken into account.
  44852. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44853. */
  44854. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44855. private _camera;
  44856. private _screenOrientationAngle;
  44857. private _constantTranform;
  44858. private _screenQuaternion;
  44859. private _alpha;
  44860. private _beta;
  44861. private _gamma;
  44862. /**
  44863. * Can be used to detect if a device orientation sensor is available on a device
  44864. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44865. * @returns a promise that will resolve on orientation change
  44866. */
  44867. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44868. /**
  44869. * @hidden
  44870. */
  44871. _onDeviceOrientationChangedObservable: Observable<void>;
  44872. /**
  44873. * Instantiates a new input
  44874. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44875. */
  44876. constructor();
  44877. /**
  44878. * Define the camera controlled by the input.
  44879. */
  44880. get camera(): FreeCamera;
  44881. set camera(camera: FreeCamera);
  44882. /**
  44883. * Attach the input controls to a specific dom element to get the input from.
  44884. * @param element Defines the element the controls should be listened from
  44885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44886. */
  44887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44888. private _orientationChanged;
  44889. private _deviceOrientation;
  44890. /**
  44891. * Detach the current controls from the specified dom element.
  44892. * @param element Defines the element to stop listening the inputs from
  44893. */
  44894. detachControl(element: Nullable<HTMLElement>): void;
  44895. /**
  44896. * Update the current camera state depending on the inputs that have been used this frame.
  44897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44898. */
  44899. checkInputs(): void;
  44900. /**
  44901. * Gets the class name of the current intput.
  44902. * @returns the class name
  44903. */
  44904. getClassName(): string;
  44905. /**
  44906. * Get the friendly name associated with the input class.
  44907. * @returns the input friendly name
  44908. */
  44909. getSimpleName(): string;
  44910. }
  44911. }
  44912. declare module BABYLON {
  44913. /**
  44914. * Manage the gamepad inputs to control a free camera.
  44915. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44916. */
  44917. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44918. /**
  44919. * Define the camera the input is attached to.
  44920. */
  44921. camera: FreeCamera;
  44922. /**
  44923. * Define the Gamepad controlling the input
  44924. */
  44925. gamepad: Nullable<Gamepad>;
  44926. /**
  44927. * Defines the gamepad rotation sensiblity.
  44928. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44929. */
  44930. gamepadAngularSensibility: number;
  44931. /**
  44932. * Defines the gamepad move sensiblity.
  44933. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44934. */
  44935. gamepadMoveSensibility: number;
  44936. private _yAxisScale;
  44937. /**
  44938. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44939. */
  44940. get invertYAxis(): boolean;
  44941. set invertYAxis(value: boolean);
  44942. private _onGamepadConnectedObserver;
  44943. private _onGamepadDisconnectedObserver;
  44944. private _cameraTransform;
  44945. private _deltaTransform;
  44946. private _vector3;
  44947. private _vector2;
  44948. /**
  44949. * Attach the input controls to a specific dom element to get the input from.
  44950. * @param element Defines the element the controls should be listened from
  44951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44952. */
  44953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44954. /**
  44955. * Detach the current controls from the specified dom element.
  44956. * @param element Defines the element to stop listening the inputs from
  44957. */
  44958. detachControl(element: Nullable<HTMLElement>): void;
  44959. /**
  44960. * Update the current camera state depending on the inputs that have been used this frame.
  44961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44962. */
  44963. checkInputs(): void;
  44964. /**
  44965. * Gets the class name of the current intput.
  44966. * @returns the class name
  44967. */
  44968. getClassName(): string;
  44969. /**
  44970. * Get the friendly name associated with the input class.
  44971. * @returns the input friendly name
  44972. */
  44973. getSimpleName(): string;
  44974. }
  44975. }
  44976. declare module BABYLON {
  44977. /**
  44978. * Defines the potential axis of a Joystick
  44979. */
  44980. export enum JoystickAxis {
  44981. /** X axis */
  44982. X = 0,
  44983. /** Y axis */
  44984. Y = 1,
  44985. /** Z axis */
  44986. Z = 2
  44987. }
  44988. /**
  44989. * Represents the different customization options available
  44990. * for VirtualJoystick
  44991. */
  44992. interface VirtualJoystickCustomizations {
  44993. /**
  44994. * Size of the joystick's puck
  44995. */
  44996. puckSize: number;
  44997. /**
  44998. * Size of the joystick's container
  44999. */
  45000. containerSize: number;
  45001. /**
  45002. * Color of the joystick && puck
  45003. */
  45004. color: string;
  45005. /**
  45006. * Image URL for the joystick's puck
  45007. */
  45008. puckImage?: string;
  45009. /**
  45010. * Image URL for the joystick's container
  45011. */
  45012. containerImage?: string;
  45013. /**
  45014. * Defines the unmoving position of the joystick container
  45015. */
  45016. position?: {
  45017. x: number;
  45018. y: number;
  45019. };
  45020. /**
  45021. * Defines whether or not the joystick container is always visible
  45022. */
  45023. alwaysVisible: boolean;
  45024. /**
  45025. * Defines whether or not to limit the movement of the puck to the joystick's container
  45026. */
  45027. limitToContainer: boolean;
  45028. }
  45029. /**
  45030. * Class used to define virtual joystick (used in touch mode)
  45031. */
  45032. export class VirtualJoystick {
  45033. /**
  45034. * Gets or sets a boolean indicating that left and right values must be inverted
  45035. */
  45036. reverseLeftRight: boolean;
  45037. /**
  45038. * Gets or sets a boolean indicating that up and down values must be inverted
  45039. */
  45040. reverseUpDown: boolean;
  45041. /**
  45042. * Gets the offset value for the position (ie. the change of the position value)
  45043. */
  45044. deltaPosition: Vector3;
  45045. /**
  45046. * Gets a boolean indicating if the virtual joystick was pressed
  45047. */
  45048. pressed: boolean;
  45049. /**
  45050. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45051. */
  45052. static Canvas: Nullable<HTMLCanvasElement>;
  45053. /**
  45054. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45055. */
  45056. limitToContainer: boolean;
  45057. private static _globalJoystickIndex;
  45058. private static _alwaysVisibleSticks;
  45059. private static vjCanvasContext;
  45060. private static vjCanvasWidth;
  45061. private static vjCanvasHeight;
  45062. private static halfWidth;
  45063. private static _GetDefaultOptions;
  45064. private _action;
  45065. private _axisTargetedByLeftAndRight;
  45066. private _axisTargetedByUpAndDown;
  45067. private _joystickSensibility;
  45068. private _inversedSensibility;
  45069. private _joystickPointerID;
  45070. private _joystickColor;
  45071. private _joystickPointerPos;
  45072. private _joystickPreviousPointerPos;
  45073. private _joystickPointerStartPos;
  45074. private _deltaJoystickVector;
  45075. private _leftJoystick;
  45076. private _touches;
  45077. private _joystickPosition;
  45078. private _alwaysVisible;
  45079. private _puckImage;
  45080. private _containerImage;
  45081. private _joystickPuckSize;
  45082. private _joystickContainerSize;
  45083. private _clearPuckSize;
  45084. private _clearContainerSize;
  45085. private _clearPuckSizeOffset;
  45086. private _clearContainerSizeOffset;
  45087. private _onPointerDownHandlerRef;
  45088. private _onPointerMoveHandlerRef;
  45089. private _onPointerUpHandlerRef;
  45090. private _onResize;
  45091. /**
  45092. * Creates a new virtual joystick
  45093. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45094. * @param customizations Defines the options we want to customize the VirtualJoystick
  45095. */
  45096. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45097. /**
  45098. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45099. * @param newJoystickSensibility defines the new sensibility
  45100. */
  45101. setJoystickSensibility(newJoystickSensibility: number): void;
  45102. private _onPointerDown;
  45103. private _onPointerMove;
  45104. private _onPointerUp;
  45105. /**
  45106. * Change the color of the virtual joystick
  45107. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45108. */
  45109. setJoystickColor(newColor: string): void;
  45110. /**
  45111. * Size of the joystick's container
  45112. */
  45113. set containerSize(newSize: number);
  45114. get containerSize(): number;
  45115. /**
  45116. * Size of the joystick's puck
  45117. */
  45118. set puckSize(newSize: number);
  45119. get puckSize(): number;
  45120. /**
  45121. * Clears the set position of the joystick
  45122. */
  45123. clearPosition(): void;
  45124. /**
  45125. * Defines whether or not the joystick container is always visible
  45126. */
  45127. set alwaysVisible(value: boolean);
  45128. get alwaysVisible(): boolean;
  45129. /**
  45130. * Sets the constant position of the Joystick container
  45131. * @param x X axis coordinate
  45132. * @param y Y axis coordinate
  45133. */
  45134. setPosition(x: number, y: number): void;
  45135. /**
  45136. * Defines a callback to call when the joystick is touched
  45137. * @param action defines the callback
  45138. */
  45139. setActionOnTouch(action: () => any): void;
  45140. /**
  45141. * Defines which axis you'd like to control for left & right
  45142. * @param axis defines the axis to use
  45143. */
  45144. setAxisForLeftRight(axis: JoystickAxis): void;
  45145. /**
  45146. * Defines which axis you'd like to control for up & down
  45147. * @param axis defines the axis to use
  45148. */
  45149. setAxisForUpDown(axis: JoystickAxis): void;
  45150. /**
  45151. * Clears the canvas from the previous puck / container draw
  45152. */
  45153. private _clearPreviousDraw;
  45154. /**
  45155. * Loads `urlPath` to be used for the container's image
  45156. * @param urlPath defines the urlPath of an image to use
  45157. */
  45158. setContainerImage(urlPath: string): void;
  45159. /**
  45160. * Loads `urlPath` to be used for the puck's image
  45161. * @param urlPath defines the urlPath of an image to use
  45162. */
  45163. setPuckImage(urlPath: string): void;
  45164. /**
  45165. * Draws the Virtual Joystick's container
  45166. */
  45167. private _drawContainer;
  45168. /**
  45169. * Draws the Virtual Joystick's puck
  45170. */
  45171. private _drawPuck;
  45172. private _drawVirtualJoystick;
  45173. /**
  45174. * Release internal HTML canvas
  45175. */
  45176. releaseCanvas(): void;
  45177. }
  45178. }
  45179. declare module BABYLON {
  45180. interface FreeCameraInputsManager {
  45181. /**
  45182. * Add virtual joystick input support to the input manager.
  45183. * @returns the current input manager
  45184. */
  45185. addVirtualJoystick(): FreeCameraInputsManager;
  45186. }
  45187. /**
  45188. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45189. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45190. */
  45191. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45192. /**
  45193. * Defines the camera the input is attached to.
  45194. */
  45195. camera: FreeCamera;
  45196. private _leftjoystick;
  45197. private _rightjoystick;
  45198. /**
  45199. * Gets the left stick of the virtual joystick.
  45200. * @returns The virtual Joystick
  45201. */
  45202. getLeftJoystick(): VirtualJoystick;
  45203. /**
  45204. * Gets the right stick of the virtual joystick.
  45205. * @returns The virtual Joystick
  45206. */
  45207. getRightJoystick(): VirtualJoystick;
  45208. /**
  45209. * Update the current camera state depending on the inputs that have been used this frame.
  45210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45211. */
  45212. checkInputs(): void;
  45213. /**
  45214. * Attach the input controls to a specific dom element to get the input from.
  45215. * @param element Defines the element the controls should be listened from
  45216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45217. */
  45218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45219. /**
  45220. * Detach the current controls from the specified dom element.
  45221. * @param element Defines the element to stop listening the inputs from
  45222. */
  45223. detachControl(element: Nullable<HTMLElement>): void;
  45224. /**
  45225. * Gets the class name of the current intput.
  45226. * @returns the class name
  45227. */
  45228. getClassName(): string;
  45229. /**
  45230. * Get the friendly name associated with the input class.
  45231. * @returns the input friendly name
  45232. */
  45233. getSimpleName(): string;
  45234. }
  45235. }
  45236. declare module BABYLON {
  45237. /**
  45238. * This represents a FPS type of camera controlled by touch.
  45239. * This is like a universal camera minus the Gamepad controls.
  45240. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45241. */
  45242. export class TouchCamera extends FreeCamera {
  45243. /**
  45244. * Defines the touch sensibility for rotation.
  45245. * The higher the faster.
  45246. */
  45247. get touchAngularSensibility(): number;
  45248. set touchAngularSensibility(value: number);
  45249. /**
  45250. * Defines the touch sensibility for move.
  45251. * The higher the faster.
  45252. */
  45253. get touchMoveSensibility(): number;
  45254. set touchMoveSensibility(value: number);
  45255. /**
  45256. * Instantiates a new touch camera.
  45257. * This represents a FPS type of camera controlled by touch.
  45258. * This is like a universal camera minus the Gamepad controls.
  45259. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45260. * @param name Define the name of the camera in the scene
  45261. * @param position Define the start position of the camera in the scene
  45262. * @param scene Define the scene the camera belongs to
  45263. */
  45264. constructor(name: string, position: Vector3, scene: Scene);
  45265. /**
  45266. * Gets the current object class name.
  45267. * @return the class name
  45268. */
  45269. getClassName(): string;
  45270. /** @hidden */
  45271. _setupInputs(): void;
  45272. }
  45273. }
  45274. declare module BABYLON {
  45275. /**
  45276. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45277. * being tilted forward or back and left or right.
  45278. */
  45279. export class DeviceOrientationCamera extends FreeCamera {
  45280. private _initialQuaternion;
  45281. private _quaternionCache;
  45282. private _tmpDragQuaternion;
  45283. private _disablePointerInputWhenUsingDeviceOrientation;
  45284. /**
  45285. * Creates a new device orientation camera
  45286. * @param name The name of the camera
  45287. * @param position The start position camera
  45288. * @param scene The scene the camera belongs to
  45289. */
  45290. constructor(name: string, position: Vector3, scene: Scene);
  45291. /**
  45292. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45293. */
  45294. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45295. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45296. private _dragFactor;
  45297. /**
  45298. * Enabled turning on the y axis when the orientation sensor is active
  45299. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45300. */
  45301. enableHorizontalDragging(dragFactor?: number): void;
  45302. /**
  45303. * Gets the current instance class name ("DeviceOrientationCamera").
  45304. * This helps avoiding instanceof at run time.
  45305. * @returns the class name
  45306. */
  45307. getClassName(): string;
  45308. /**
  45309. * @hidden
  45310. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45311. */
  45312. _checkInputs(): void;
  45313. /**
  45314. * Reset the camera to its default orientation on the specified axis only.
  45315. * @param axis The axis to reset
  45316. */
  45317. resetToCurrentRotation(axis?: Axis): void;
  45318. }
  45319. }
  45320. declare module BABYLON {
  45321. /**
  45322. * Defines supported buttons for XBox360 compatible gamepads
  45323. */
  45324. export enum Xbox360Button {
  45325. /** A */
  45326. A = 0,
  45327. /** B */
  45328. B = 1,
  45329. /** X */
  45330. X = 2,
  45331. /** Y */
  45332. Y = 3,
  45333. /** Left button */
  45334. LB = 4,
  45335. /** Right button */
  45336. RB = 5,
  45337. /** Back */
  45338. Back = 8,
  45339. /** Start */
  45340. Start = 9,
  45341. /** Left stick */
  45342. LeftStick = 10,
  45343. /** Right stick */
  45344. RightStick = 11
  45345. }
  45346. /** Defines values for XBox360 DPad */
  45347. export enum Xbox360Dpad {
  45348. /** Up */
  45349. Up = 12,
  45350. /** Down */
  45351. Down = 13,
  45352. /** Left */
  45353. Left = 14,
  45354. /** Right */
  45355. Right = 15
  45356. }
  45357. /**
  45358. * Defines a XBox360 gamepad
  45359. */
  45360. export class Xbox360Pad extends Gamepad {
  45361. private _leftTrigger;
  45362. private _rightTrigger;
  45363. private _onlefttriggerchanged;
  45364. private _onrighttriggerchanged;
  45365. private _onbuttondown;
  45366. private _onbuttonup;
  45367. private _ondpaddown;
  45368. private _ondpadup;
  45369. /** Observable raised when a button is pressed */
  45370. onButtonDownObservable: Observable<Xbox360Button>;
  45371. /** Observable raised when a button is released */
  45372. onButtonUpObservable: Observable<Xbox360Button>;
  45373. /** Observable raised when a pad is pressed */
  45374. onPadDownObservable: Observable<Xbox360Dpad>;
  45375. /** Observable raised when a pad is released */
  45376. onPadUpObservable: Observable<Xbox360Dpad>;
  45377. private _buttonA;
  45378. private _buttonB;
  45379. private _buttonX;
  45380. private _buttonY;
  45381. private _buttonBack;
  45382. private _buttonStart;
  45383. private _buttonLB;
  45384. private _buttonRB;
  45385. private _buttonLeftStick;
  45386. private _buttonRightStick;
  45387. private _dPadUp;
  45388. private _dPadDown;
  45389. private _dPadLeft;
  45390. private _dPadRight;
  45391. private _isXboxOnePad;
  45392. /**
  45393. * Creates a new XBox360 gamepad object
  45394. * @param id defines the id of this gamepad
  45395. * @param index defines its index
  45396. * @param gamepad defines the internal HTML gamepad object
  45397. * @param xboxOne defines if it is a XBox One gamepad
  45398. */
  45399. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45400. /**
  45401. * Defines the callback to call when left trigger is pressed
  45402. * @param callback defines the callback to use
  45403. */
  45404. onlefttriggerchanged(callback: (value: number) => void): void;
  45405. /**
  45406. * Defines the callback to call when right trigger is pressed
  45407. * @param callback defines the callback to use
  45408. */
  45409. onrighttriggerchanged(callback: (value: number) => void): void;
  45410. /**
  45411. * Gets the left trigger value
  45412. */
  45413. get leftTrigger(): number;
  45414. /**
  45415. * Sets the left trigger value
  45416. */
  45417. set leftTrigger(newValue: number);
  45418. /**
  45419. * Gets the right trigger value
  45420. */
  45421. get rightTrigger(): number;
  45422. /**
  45423. * Sets the right trigger value
  45424. */
  45425. set rightTrigger(newValue: number);
  45426. /**
  45427. * Defines the callback to call when a button is pressed
  45428. * @param callback defines the callback to use
  45429. */
  45430. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45431. /**
  45432. * Defines the callback to call when a button is released
  45433. * @param callback defines the callback to use
  45434. */
  45435. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45436. /**
  45437. * Defines the callback to call when a pad is pressed
  45438. * @param callback defines the callback to use
  45439. */
  45440. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45441. /**
  45442. * Defines the callback to call when a pad is released
  45443. * @param callback defines the callback to use
  45444. */
  45445. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45446. private _setButtonValue;
  45447. private _setDPadValue;
  45448. /**
  45449. * Gets the value of the `A` button
  45450. */
  45451. get buttonA(): number;
  45452. /**
  45453. * Sets the value of the `A` button
  45454. */
  45455. set buttonA(value: number);
  45456. /**
  45457. * Gets the value of the `B` button
  45458. */
  45459. get buttonB(): number;
  45460. /**
  45461. * Sets the value of the `B` button
  45462. */
  45463. set buttonB(value: number);
  45464. /**
  45465. * Gets the value of the `X` button
  45466. */
  45467. get buttonX(): number;
  45468. /**
  45469. * Sets the value of the `X` button
  45470. */
  45471. set buttonX(value: number);
  45472. /**
  45473. * Gets the value of the `Y` button
  45474. */
  45475. get buttonY(): number;
  45476. /**
  45477. * Sets the value of the `Y` button
  45478. */
  45479. set buttonY(value: number);
  45480. /**
  45481. * Gets the value of the `Start` button
  45482. */
  45483. get buttonStart(): number;
  45484. /**
  45485. * Sets the value of the `Start` button
  45486. */
  45487. set buttonStart(value: number);
  45488. /**
  45489. * Gets the value of the `Back` button
  45490. */
  45491. get buttonBack(): number;
  45492. /**
  45493. * Sets the value of the `Back` button
  45494. */
  45495. set buttonBack(value: number);
  45496. /**
  45497. * Gets the value of the `Left` button
  45498. */
  45499. get buttonLB(): number;
  45500. /**
  45501. * Sets the value of the `Left` button
  45502. */
  45503. set buttonLB(value: number);
  45504. /**
  45505. * Gets the value of the `Right` button
  45506. */
  45507. get buttonRB(): number;
  45508. /**
  45509. * Sets the value of the `Right` button
  45510. */
  45511. set buttonRB(value: number);
  45512. /**
  45513. * Gets the value of the Left joystick
  45514. */
  45515. get buttonLeftStick(): number;
  45516. /**
  45517. * Sets the value of the Left joystick
  45518. */
  45519. set buttonLeftStick(value: number);
  45520. /**
  45521. * Gets the value of the Right joystick
  45522. */
  45523. get buttonRightStick(): number;
  45524. /**
  45525. * Sets the value of the Right joystick
  45526. */
  45527. set buttonRightStick(value: number);
  45528. /**
  45529. * Gets the value of D-pad up
  45530. */
  45531. get dPadUp(): number;
  45532. /**
  45533. * Sets the value of D-pad up
  45534. */
  45535. set dPadUp(value: number);
  45536. /**
  45537. * Gets the value of D-pad down
  45538. */
  45539. get dPadDown(): number;
  45540. /**
  45541. * Sets the value of D-pad down
  45542. */
  45543. set dPadDown(value: number);
  45544. /**
  45545. * Gets the value of D-pad left
  45546. */
  45547. get dPadLeft(): number;
  45548. /**
  45549. * Sets the value of D-pad left
  45550. */
  45551. set dPadLeft(value: number);
  45552. /**
  45553. * Gets the value of D-pad right
  45554. */
  45555. get dPadRight(): number;
  45556. /**
  45557. * Sets the value of D-pad right
  45558. */
  45559. set dPadRight(value: number);
  45560. /**
  45561. * Force the gamepad to synchronize with device values
  45562. */
  45563. update(): void;
  45564. /**
  45565. * Disposes the gamepad
  45566. */
  45567. dispose(): void;
  45568. }
  45569. }
  45570. declare module BABYLON {
  45571. /**
  45572. * Defines supported buttons for DualShock compatible gamepads
  45573. */
  45574. export enum DualShockButton {
  45575. /** Cross */
  45576. Cross = 0,
  45577. /** Circle */
  45578. Circle = 1,
  45579. /** Square */
  45580. Square = 2,
  45581. /** Triangle */
  45582. Triangle = 3,
  45583. /** L1 */
  45584. L1 = 4,
  45585. /** R1 */
  45586. R1 = 5,
  45587. /** Share */
  45588. Share = 8,
  45589. /** Options */
  45590. Options = 9,
  45591. /** Left stick */
  45592. LeftStick = 10,
  45593. /** Right stick */
  45594. RightStick = 11
  45595. }
  45596. /** Defines values for DualShock DPad */
  45597. export enum DualShockDpad {
  45598. /** Up */
  45599. Up = 12,
  45600. /** Down */
  45601. Down = 13,
  45602. /** Left */
  45603. Left = 14,
  45604. /** Right */
  45605. Right = 15
  45606. }
  45607. /**
  45608. * Defines a DualShock gamepad
  45609. */
  45610. export class DualShockPad extends Gamepad {
  45611. private _leftTrigger;
  45612. private _rightTrigger;
  45613. private _onlefttriggerchanged;
  45614. private _onrighttriggerchanged;
  45615. private _onbuttondown;
  45616. private _onbuttonup;
  45617. private _ondpaddown;
  45618. private _ondpadup;
  45619. /** Observable raised when a button is pressed */
  45620. onButtonDownObservable: Observable<DualShockButton>;
  45621. /** Observable raised when a button is released */
  45622. onButtonUpObservable: Observable<DualShockButton>;
  45623. /** Observable raised when a pad is pressed */
  45624. onPadDownObservable: Observable<DualShockDpad>;
  45625. /** Observable raised when a pad is released */
  45626. onPadUpObservable: Observable<DualShockDpad>;
  45627. private _buttonCross;
  45628. private _buttonCircle;
  45629. private _buttonSquare;
  45630. private _buttonTriangle;
  45631. private _buttonShare;
  45632. private _buttonOptions;
  45633. private _buttonL1;
  45634. private _buttonR1;
  45635. private _buttonLeftStick;
  45636. private _buttonRightStick;
  45637. private _dPadUp;
  45638. private _dPadDown;
  45639. private _dPadLeft;
  45640. private _dPadRight;
  45641. /**
  45642. * Creates a new DualShock gamepad object
  45643. * @param id defines the id of this gamepad
  45644. * @param index defines its index
  45645. * @param gamepad defines the internal HTML gamepad object
  45646. */
  45647. constructor(id: string, index: number, gamepad: any);
  45648. /**
  45649. * Defines the callback to call when left trigger is pressed
  45650. * @param callback defines the callback to use
  45651. */
  45652. onlefttriggerchanged(callback: (value: number) => void): void;
  45653. /**
  45654. * Defines the callback to call when right trigger is pressed
  45655. * @param callback defines the callback to use
  45656. */
  45657. onrighttriggerchanged(callback: (value: number) => void): void;
  45658. /**
  45659. * Gets the left trigger value
  45660. */
  45661. get leftTrigger(): number;
  45662. /**
  45663. * Sets the left trigger value
  45664. */
  45665. set leftTrigger(newValue: number);
  45666. /**
  45667. * Gets the right trigger value
  45668. */
  45669. get rightTrigger(): number;
  45670. /**
  45671. * Sets the right trigger value
  45672. */
  45673. set rightTrigger(newValue: number);
  45674. /**
  45675. * Defines the callback to call when a button is pressed
  45676. * @param callback defines the callback to use
  45677. */
  45678. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45679. /**
  45680. * Defines the callback to call when a button is released
  45681. * @param callback defines the callback to use
  45682. */
  45683. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45684. /**
  45685. * Defines the callback to call when a pad is pressed
  45686. * @param callback defines the callback to use
  45687. */
  45688. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45689. /**
  45690. * Defines the callback to call when a pad is released
  45691. * @param callback defines the callback to use
  45692. */
  45693. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45694. private _setButtonValue;
  45695. private _setDPadValue;
  45696. /**
  45697. * Gets the value of the `Cross` button
  45698. */
  45699. get buttonCross(): number;
  45700. /**
  45701. * Sets the value of the `Cross` button
  45702. */
  45703. set buttonCross(value: number);
  45704. /**
  45705. * Gets the value of the `Circle` button
  45706. */
  45707. get buttonCircle(): number;
  45708. /**
  45709. * Sets the value of the `Circle` button
  45710. */
  45711. set buttonCircle(value: number);
  45712. /**
  45713. * Gets the value of the `Square` button
  45714. */
  45715. get buttonSquare(): number;
  45716. /**
  45717. * Sets the value of the `Square` button
  45718. */
  45719. set buttonSquare(value: number);
  45720. /**
  45721. * Gets the value of the `Triangle` button
  45722. */
  45723. get buttonTriangle(): number;
  45724. /**
  45725. * Sets the value of the `Triangle` button
  45726. */
  45727. set buttonTriangle(value: number);
  45728. /**
  45729. * Gets the value of the `Options` button
  45730. */
  45731. get buttonOptions(): number;
  45732. /**
  45733. * Sets the value of the `Options` button
  45734. */
  45735. set buttonOptions(value: number);
  45736. /**
  45737. * Gets the value of the `Share` button
  45738. */
  45739. get buttonShare(): number;
  45740. /**
  45741. * Sets the value of the `Share` button
  45742. */
  45743. set buttonShare(value: number);
  45744. /**
  45745. * Gets the value of the `L1` button
  45746. */
  45747. get buttonL1(): number;
  45748. /**
  45749. * Sets the value of the `L1` button
  45750. */
  45751. set buttonL1(value: number);
  45752. /**
  45753. * Gets the value of the `R1` button
  45754. */
  45755. get buttonR1(): number;
  45756. /**
  45757. * Sets the value of the `R1` button
  45758. */
  45759. set buttonR1(value: number);
  45760. /**
  45761. * Gets the value of the Left joystick
  45762. */
  45763. get buttonLeftStick(): number;
  45764. /**
  45765. * Sets the value of the Left joystick
  45766. */
  45767. set buttonLeftStick(value: number);
  45768. /**
  45769. * Gets the value of the Right joystick
  45770. */
  45771. get buttonRightStick(): number;
  45772. /**
  45773. * Sets the value of the Right joystick
  45774. */
  45775. set buttonRightStick(value: number);
  45776. /**
  45777. * Gets the value of D-pad up
  45778. */
  45779. get dPadUp(): number;
  45780. /**
  45781. * Sets the value of D-pad up
  45782. */
  45783. set dPadUp(value: number);
  45784. /**
  45785. * Gets the value of D-pad down
  45786. */
  45787. get dPadDown(): number;
  45788. /**
  45789. * Sets the value of D-pad down
  45790. */
  45791. set dPadDown(value: number);
  45792. /**
  45793. * Gets the value of D-pad left
  45794. */
  45795. get dPadLeft(): number;
  45796. /**
  45797. * Sets the value of D-pad left
  45798. */
  45799. set dPadLeft(value: number);
  45800. /**
  45801. * Gets the value of D-pad right
  45802. */
  45803. get dPadRight(): number;
  45804. /**
  45805. * Sets the value of D-pad right
  45806. */
  45807. set dPadRight(value: number);
  45808. /**
  45809. * Force the gamepad to synchronize with device values
  45810. */
  45811. update(): void;
  45812. /**
  45813. * Disposes the gamepad
  45814. */
  45815. dispose(): void;
  45816. }
  45817. }
  45818. declare module BABYLON {
  45819. /**
  45820. * Manager for handling gamepads
  45821. */
  45822. export class GamepadManager {
  45823. private _scene?;
  45824. private _babylonGamepads;
  45825. private _oneGamepadConnected;
  45826. /** @hidden */
  45827. _isMonitoring: boolean;
  45828. private _gamepadEventSupported;
  45829. private _gamepadSupport?;
  45830. /**
  45831. * observable to be triggered when the gamepad controller has been connected
  45832. */
  45833. onGamepadConnectedObservable: Observable<Gamepad>;
  45834. /**
  45835. * observable to be triggered when the gamepad controller has been disconnected
  45836. */
  45837. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45838. private _onGamepadConnectedEvent;
  45839. private _onGamepadDisconnectedEvent;
  45840. /**
  45841. * Initializes the gamepad manager
  45842. * @param _scene BabylonJS scene
  45843. */
  45844. constructor(_scene?: Scene | undefined);
  45845. /**
  45846. * The gamepads in the game pad manager
  45847. */
  45848. get gamepads(): Gamepad[];
  45849. /**
  45850. * Get the gamepad controllers based on type
  45851. * @param type The type of gamepad controller
  45852. * @returns Nullable gamepad
  45853. */
  45854. getGamepadByType(type?: number): Nullable<Gamepad>;
  45855. /**
  45856. * Disposes the gamepad manager
  45857. */
  45858. dispose(): void;
  45859. private _addNewGamepad;
  45860. private _startMonitoringGamepads;
  45861. private _stopMonitoringGamepads;
  45862. /** @hidden */
  45863. _checkGamepadsStatus(): void;
  45864. private _updateGamepadObjects;
  45865. }
  45866. }
  45867. declare module BABYLON {
  45868. interface Scene {
  45869. /** @hidden */
  45870. _gamepadManager: Nullable<GamepadManager>;
  45871. /**
  45872. * Gets the gamepad manager associated with the scene
  45873. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45874. */
  45875. gamepadManager: GamepadManager;
  45876. }
  45877. /**
  45878. * Interface representing a free camera inputs manager
  45879. */
  45880. interface FreeCameraInputsManager {
  45881. /**
  45882. * Adds gamepad input support to the FreeCameraInputsManager.
  45883. * @returns the FreeCameraInputsManager
  45884. */
  45885. addGamepad(): FreeCameraInputsManager;
  45886. }
  45887. /**
  45888. * Interface representing an arc rotate camera inputs manager
  45889. */
  45890. interface ArcRotateCameraInputsManager {
  45891. /**
  45892. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45893. * @returns the camera inputs manager
  45894. */
  45895. addGamepad(): ArcRotateCameraInputsManager;
  45896. }
  45897. /**
  45898. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45899. */
  45900. export class GamepadSystemSceneComponent implements ISceneComponent {
  45901. /**
  45902. * The component name helpfull to identify the component in the list of scene components.
  45903. */
  45904. readonly name: string;
  45905. /**
  45906. * The scene the component belongs to.
  45907. */
  45908. scene: Scene;
  45909. /**
  45910. * Creates a new instance of the component for the given scene
  45911. * @param scene Defines the scene to register the component in
  45912. */
  45913. constructor(scene: Scene);
  45914. /**
  45915. * Registers the component in a given scene
  45916. */
  45917. register(): void;
  45918. /**
  45919. * Rebuilds the elements related to this component in case of
  45920. * context lost for instance.
  45921. */
  45922. rebuild(): void;
  45923. /**
  45924. * Disposes the component and the associated ressources
  45925. */
  45926. dispose(): void;
  45927. private _beforeCameraUpdate;
  45928. }
  45929. }
  45930. declare module BABYLON {
  45931. /**
  45932. * 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,
  45933. * which still works and will still be found in many Playgrounds.
  45934. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45935. */
  45936. export class UniversalCamera extends TouchCamera {
  45937. /**
  45938. * Defines the gamepad rotation sensiblity.
  45939. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45940. */
  45941. get gamepadAngularSensibility(): number;
  45942. set gamepadAngularSensibility(value: number);
  45943. /**
  45944. * Defines the gamepad move sensiblity.
  45945. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45946. */
  45947. get gamepadMoveSensibility(): number;
  45948. set gamepadMoveSensibility(value: number);
  45949. /**
  45950. * 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,
  45951. * which still works and will still be found in many Playgrounds.
  45952. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45953. * @param name Define the name of the camera in the scene
  45954. * @param position Define the start position of the camera in the scene
  45955. * @param scene Define the scene the camera belongs to
  45956. */
  45957. constructor(name: string, position: Vector3, scene: Scene);
  45958. /**
  45959. * Gets the current object class name.
  45960. * @return the class name
  45961. */
  45962. getClassName(): string;
  45963. }
  45964. }
  45965. declare module BABYLON {
  45966. /**
  45967. * This represents a FPS type of camera. This is only here for back compat purpose.
  45968. * Please use the UniversalCamera instead as both are identical.
  45969. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45970. */
  45971. export class GamepadCamera extends UniversalCamera {
  45972. /**
  45973. * Instantiates a new Gamepad Camera
  45974. * This represents a FPS type of camera. This is only here for back compat purpose.
  45975. * Please use the UniversalCamera instead as both are identical.
  45976. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45977. * @param name Define the name of the camera in the scene
  45978. * @param position Define the start position of the camera in the scene
  45979. * @param scene Define the scene the camera belongs to
  45980. */
  45981. constructor(name: string, position: Vector3, scene: Scene);
  45982. /**
  45983. * Gets the current object class name.
  45984. * @return the class name
  45985. */
  45986. getClassName(): string;
  45987. }
  45988. }
  45989. declare module BABYLON {
  45990. /** @hidden */
  45991. export var passPixelShader: {
  45992. name: string;
  45993. shader: string;
  45994. };
  45995. }
  45996. declare module BABYLON {
  45997. /** @hidden */
  45998. export var passCubePixelShader: {
  45999. name: string;
  46000. shader: string;
  46001. };
  46002. }
  46003. declare module BABYLON {
  46004. /**
  46005. * PassPostProcess which produces an output the same as it's input
  46006. */
  46007. export class PassPostProcess extends PostProcess {
  46008. /**
  46009. * Gets a string identifying the name of the class
  46010. * @returns "PassPostProcess" string
  46011. */
  46012. getClassName(): string;
  46013. /**
  46014. * Creates the PassPostProcess
  46015. * @param name The name of the effect.
  46016. * @param options The required width/height ratio to downsize to before computing the render pass.
  46017. * @param camera The camera to apply the render pass to.
  46018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46019. * @param engine The engine which the post process will be applied. (default: current engine)
  46020. * @param reusable If the post process can be reused on the same frame. (default: false)
  46021. * @param textureType The type of texture to be used when performing the post processing.
  46022. * @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)
  46023. */
  46024. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46025. /** @hidden */
  46026. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46027. }
  46028. /**
  46029. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46030. */
  46031. export class PassCubePostProcess extends PostProcess {
  46032. private _face;
  46033. /**
  46034. * Gets or sets the cube face to display.
  46035. * * 0 is +X
  46036. * * 1 is -X
  46037. * * 2 is +Y
  46038. * * 3 is -Y
  46039. * * 4 is +Z
  46040. * * 5 is -Z
  46041. */
  46042. get face(): number;
  46043. set face(value: number);
  46044. /**
  46045. * Gets a string identifying the name of the class
  46046. * @returns "PassCubePostProcess" string
  46047. */
  46048. getClassName(): string;
  46049. /**
  46050. * Creates the PassCubePostProcess
  46051. * @param name The name of the effect.
  46052. * @param options The required width/height ratio to downsize to before computing the render pass.
  46053. * @param camera The camera to apply the render pass to.
  46054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46055. * @param engine The engine which the post process will be applied. (default: current engine)
  46056. * @param reusable If the post process can be reused on the same frame. (default: false)
  46057. * @param textureType The type of texture to be used when performing the post processing.
  46058. * @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)
  46059. */
  46060. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46061. /** @hidden */
  46062. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46063. }
  46064. }
  46065. declare module BABYLON {
  46066. /** @hidden */
  46067. export var anaglyphPixelShader: {
  46068. name: string;
  46069. shader: string;
  46070. };
  46071. }
  46072. declare module BABYLON {
  46073. /**
  46074. * Postprocess used to generate anaglyphic rendering
  46075. */
  46076. export class AnaglyphPostProcess extends PostProcess {
  46077. private _passedProcess;
  46078. /**
  46079. * Gets a string identifying the name of the class
  46080. * @returns "AnaglyphPostProcess" string
  46081. */
  46082. getClassName(): string;
  46083. /**
  46084. * Creates a new AnaglyphPostProcess
  46085. * @param name defines postprocess name
  46086. * @param options defines creation options or target ratio scale
  46087. * @param rigCameras defines cameras using this postprocess
  46088. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46089. * @param engine defines hosting engine
  46090. * @param reusable defines if the postprocess will be reused multiple times per frame
  46091. */
  46092. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46093. }
  46094. }
  46095. declare module BABYLON {
  46096. /**
  46097. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46098. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46099. */
  46100. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46101. /**
  46102. * Creates a new AnaglyphArcRotateCamera
  46103. * @param name defines camera name
  46104. * @param alpha defines alpha angle (in radians)
  46105. * @param beta defines beta angle (in radians)
  46106. * @param radius defines radius
  46107. * @param target defines camera target
  46108. * @param interaxialDistance defines distance between each color axis
  46109. * @param scene defines the hosting scene
  46110. */
  46111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46112. /**
  46113. * Gets camera class name
  46114. * @returns AnaglyphArcRotateCamera
  46115. */
  46116. getClassName(): string;
  46117. }
  46118. }
  46119. declare module BABYLON {
  46120. /**
  46121. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46122. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46123. */
  46124. export class AnaglyphFreeCamera extends FreeCamera {
  46125. /**
  46126. * Creates a new AnaglyphFreeCamera
  46127. * @param name defines camera name
  46128. * @param position defines initial position
  46129. * @param interaxialDistance defines distance between each color axis
  46130. * @param scene defines the hosting scene
  46131. */
  46132. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46133. /**
  46134. * Gets camera class name
  46135. * @returns AnaglyphFreeCamera
  46136. */
  46137. getClassName(): string;
  46138. }
  46139. }
  46140. declare module BABYLON {
  46141. /**
  46142. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46143. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46144. */
  46145. export class AnaglyphGamepadCamera extends GamepadCamera {
  46146. /**
  46147. * Creates a new AnaglyphGamepadCamera
  46148. * @param name defines camera name
  46149. * @param position defines initial position
  46150. * @param interaxialDistance defines distance between each color axis
  46151. * @param scene defines the hosting scene
  46152. */
  46153. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46154. /**
  46155. * Gets camera class name
  46156. * @returns AnaglyphGamepadCamera
  46157. */
  46158. getClassName(): string;
  46159. }
  46160. }
  46161. declare module BABYLON {
  46162. /**
  46163. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46164. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46165. */
  46166. export class AnaglyphUniversalCamera extends UniversalCamera {
  46167. /**
  46168. * Creates a new AnaglyphUniversalCamera
  46169. * @param name defines camera name
  46170. * @param position defines initial position
  46171. * @param interaxialDistance defines distance between each color axis
  46172. * @param scene defines the hosting scene
  46173. */
  46174. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46175. /**
  46176. * Gets camera class name
  46177. * @returns AnaglyphUniversalCamera
  46178. */
  46179. getClassName(): string;
  46180. }
  46181. }
  46182. declare module BABYLON {
  46183. /**
  46184. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46185. * @see https://doc.babylonjs.com/features/cameras
  46186. */
  46187. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46188. /**
  46189. * Creates a new StereoscopicArcRotateCamera
  46190. * @param name defines camera name
  46191. * @param alpha defines alpha angle (in radians)
  46192. * @param beta defines beta angle (in radians)
  46193. * @param radius defines radius
  46194. * @param target defines camera target
  46195. * @param interaxialDistance defines distance between each color axis
  46196. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46197. * @param scene defines the hosting scene
  46198. */
  46199. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46200. /**
  46201. * Gets camera class name
  46202. * @returns StereoscopicArcRotateCamera
  46203. */
  46204. getClassName(): string;
  46205. }
  46206. }
  46207. declare module BABYLON {
  46208. /**
  46209. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46210. * @see https://doc.babylonjs.com/features/cameras
  46211. */
  46212. export class StereoscopicFreeCamera extends FreeCamera {
  46213. /**
  46214. * Creates a new StereoscopicFreeCamera
  46215. * @param name defines camera name
  46216. * @param position defines initial position
  46217. * @param interaxialDistance defines distance between each color axis
  46218. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46219. * @param scene defines the hosting scene
  46220. */
  46221. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46222. /**
  46223. * Gets camera class name
  46224. * @returns StereoscopicFreeCamera
  46225. */
  46226. getClassName(): string;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46232. * @see https://doc.babylonjs.com/features/cameras
  46233. */
  46234. export class StereoscopicGamepadCamera extends GamepadCamera {
  46235. /**
  46236. * Creates a new StereoscopicGamepadCamera
  46237. * @param name defines camera name
  46238. * @param position defines initial position
  46239. * @param interaxialDistance defines distance between each color axis
  46240. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46241. * @param scene defines the hosting scene
  46242. */
  46243. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46244. /**
  46245. * Gets camera class name
  46246. * @returns StereoscopicGamepadCamera
  46247. */
  46248. getClassName(): string;
  46249. }
  46250. }
  46251. declare module BABYLON {
  46252. /**
  46253. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46254. * @see https://doc.babylonjs.com/features/cameras
  46255. */
  46256. export class StereoscopicUniversalCamera extends UniversalCamera {
  46257. /**
  46258. * Creates a new StereoscopicUniversalCamera
  46259. * @param name defines camera name
  46260. * @param position defines initial position
  46261. * @param interaxialDistance defines distance between each color axis
  46262. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46263. * @param scene defines the hosting scene
  46264. */
  46265. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46266. /**
  46267. * Gets camera class name
  46268. * @returns StereoscopicUniversalCamera
  46269. */
  46270. getClassName(): string;
  46271. }
  46272. }
  46273. declare module BABYLON {
  46274. /**
  46275. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46276. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46277. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46278. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46279. */
  46280. export class VirtualJoysticksCamera extends FreeCamera {
  46281. /**
  46282. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46283. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46284. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46285. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46286. * @param name Define the name of the camera in the scene
  46287. * @param position Define the start position of the camera in the scene
  46288. * @param scene Define the scene the camera belongs to
  46289. */
  46290. constructor(name: string, position: Vector3, scene: Scene);
  46291. /**
  46292. * Gets the current object class name.
  46293. * @return the class name
  46294. */
  46295. getClassName(): string;
  46296. }
  46297. }
  46298. declare module BABYLON {
  46299. /**
  46300. * This represents all the required metrics to create a VR camera.
  46301. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46302. */
  46303. export class VRCameraMetrics {
  46304. /**
  46305. * Define the horizontal resolution off the screen.
  46306. */
  46307. hResolution: number;
  46308. /**
  46309. * Define the vertical resolution off the screen.
  46310. */
  46311. vResolution: number;
  46312. /**
  46313. * Define the horizontal screen size.
  46314. */
  46315. hScreenSize: number;
  46316. /**
  46317. * Define the vertical screen size.
  46318. */
  46319. vScreenSize: number;
  46320. /**
  46321. * Define the vertical screen center position.
  46322. */
  46323. vScreenCenter: number;
  46324. /**
  46325. * Define the distance of the eyes to the screen.
  46326. */
  46327. eyeToScreenDistance: number;
  46328. /**
  46329. * Define the distance between both lenses
  46330. */
  46331. lensSeparationDistance: number;
  46332. /**
  46333. * Define the distance between both viewer's eyes.
  46334. */
  46335. interpupillaryDistance: number;
  46336. /**
  46337. * Define the distortion factor of the VR postprocess.
  46338. * Please, touch with care.
  46339. */
  46340. distortionK: number[];
  46341. /**
  46342. * Define the chromatic aberration correction factors for the VR post process.
  46343. */
  46344. chromaAbCorrection: number[];
  46345. /**
  46346. * Define the scale factor of the post process.
  46347. * The smaller the better but the slower.
  46348. */
  46349. postProcessScaleFactor: number;
  46350. /**
  46351. * Define an offset for the lens center.
  46352. */
  46353. lensCenterOffset: number;
  46354. /**
  46355. * Define if the current vr camera should compensate the distortion of the lense or not.
  46356. */
  46357. compensateDistortion: boolean;
  46358. /**
  46359. * Defines if multiview should be enabled when rendering (Default: false)
  46360. */
  46361. multiviewEnabled: boolean;
  46362. /**
  46363. * Gets the rendering aspect ratio based on the provided resolutions.
  46364. */
  46365. get aspectRatio(): number;
  46366. /**
  46367. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46368. */
  46369. get aspectRatioFov(): number;
  46370. /**
  46371. * @hidden
  46372. */
  46373. get leftHMatrix(): Matrix;
  46374. /**
  46375. * @hidden
  46376. */
  46377. get rightHMatrix(): Matrix;
  46378. /**
  46379. * @hidden
  46380. */
  46381. get leftPreViewMatrix(): Matrix;
  46382. /**
  46383. * @hidden
  46384. */
  46385. get rightPreViewMatrix(): Matrix;
  46386. /**
  46387. * Get the default VRMetrics based on the most generic setup.
  46388. * @returns the default vr metrics
  46389. */
  46390. static GetDefault(): VRCameraMetrics;
  46391. }
  46392. }
  46393. declare module BABYLON {
  46394. /** @hidden */
  46395. export var vrDistortionCorrectionPixelShader: {
  46396. name: string;
  46397. shader: string;
  46398. };
  46399. }
  46400. declare module BABYLON {
  46401. /**
  46402. * VRDistortionCorrectionPostProcess used for mobile VR
  46403. */
  46404. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46405. private _isRightEye;
  46406. private _distortionFactors;
  46407. private _postProcessScaleFactor;
  46408. private _lensCenterOffset;
  46409. private _scaleIn;
  46410. private _scaleFactor;
  46411. private _lensCenter;
  46412. /**
  46413. * Gets a string identifying the name of the class
  46414. * @returns "VRDistortionCorrectionPostProcess" string
  46415. */
  46416. getClassName(): string;
  46417. /**
  46418. * Initializes the VRDistortionCorrectionPostProcess
  46419. * @param name The name of the effect.
  46420. * @param camera The camera to apply the render pass to.
  46421. * @param isRightEye If this is for the right eye distortion
  46422. * @param vrMetrics All the required metrics for the VR camera
  46423. */
  46424. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46425. }
  46426. }
  46427. declare module BABYLON {
  46428. /**
  46429. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46430. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46431. */
  46432. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46433. /**
  46434. * Creates a new VRDeviceOrientationArcRotateCamera
  46435. * @param name defines camera name
  46436. * @param alpha defines the camera rotation along the logitudinal axis
  46437. * @param beta defines the camera rotation along the latitudinal axis
  46438. * @param radius defines the camera distance from its target
  46439. * @param target defines the camera target
  46440. * @param scene defines the scene the camera belongs to
  46441. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46442. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46443. */
  46444. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46445. /**
  46446. * Gets camera class name
  46447. * @returns VRDeviceOrientationArcRotateCamera
  46448. */
  46449. getClassName(): string;
  46450. }
  46451. }
  46452. declare module BABYLON {
  46453. /**
  46454. * Camera used to simulate VR rendering (based on FreeCamera)
  46455. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46456. */
  46457. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46458. /**
  46459. * Creates a new VRDeviceOrientationFreeCamera
  46460. * @param name defines camera name
  46461. * @param position defines the start position of the camera
  46462. * @param scene defines the scene the camera belongs to
  46463. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46464. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46465. */
  46466. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46467. /**
  46468. * Gets camera class name
  46469. * @returns VRDeviceOrientationFreeCamera
  46470. */
  46471. getClassName(): string;
  46472. }
  46473. }
  46474. declare module BABYLON {
  46475. /**
  46476. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46477. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46478. */
  46479. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46480. /**
  46481. * Creates a new VRDeviceOrientationGamepadCamera
  46482. * @param name defines camera name
  46483. * @param position defines the start position of the camera
  46484. * @param scene defines the scene the camera belongs to
  46485. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46486. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46487. */
  46488. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46489. /**
  46490. * Gets camera class name
  46491. * @returns VRDeviceOrientationGamepadCamera
  46492. */
  46493. getClassName(): string;
  46494. }
  46495. }
  46496. declare module BABYLON {
  46497. /**
  46498. * A class extending Texture allowing drawing on a texture
  46499. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46500. */
  46501. export class DynamicTexture extends Texture {
  46502. private _generateMipMaps;
  46503. private _canvas;
  46504. private _context;
  46505. /**
  46506. * Creates a DynamicTexture
  46507. * @param name defines the name of the texture
  46508. * @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
  46509. * @param scene defines the scene where you want the texture
  46510. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46511. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46512. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46513. */
  46514. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46515. /**
  46516. * Get the current class name of the texture useful for serialization or dynamic coding.
  46517. * @returns "DynamicTexture"
  46518. */
  46519. getClassName(): string;
  46520. /**
  46521. * Gets the current state of canRescale
  46522. */
  46523. get canRescale(): boolean;
  46524. private _recreate;
  46525. /**
  46526. * Scales the texture
  46527. * @param ratio the scale factor to apply to both width and height
  46528. */
  46529. scale(ratio: number): void;
  46530. /**
  46531. * Resizes the texture
  46532. * @param width the new width
  46533. * @param height the new height
  46534. */
  46535. scaleTo(width: number, height: number): void;
  46536. /**
  46537. * Gets the context of the canvas used by the texture
  46538. * @returns the canvas context of the dynamic texture
  46539. */
  46540. getContext(): CanvasRenderingContext2D;
  46541. /**
  46542. * Clears the texture
  46543. */
  46544. clear(): void;
  46545. /**
  46546. * Updates the texture
  46547. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46548. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46549. */
  46550. update(invertY?: boolean, premulAlpha?: boolean): void;
  46551. /**
  46552. * Draws text onto the texture
  46553. * @param text defines the text to be drawn
  46554. * @param x defines the placement of the text from the left
  46555. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46556. * @param font defines the font to be used with font-style, font-size, font-name
  46557. * @param color defines the color used for the text
  46558. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46559. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46560. * @param update defines whether texture is immediately update (default is true)
  46561. */
  46562. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46563. /**
  46564. * Clones the texture
  46565. * @returns the clone of the texture.
  46566. */
  46567. clone(): DynamicTexture;
  46568. /**
  46569. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46570. * @returns a serialized dynamic texture object
  46571. */
  46572. serialize(): any;
  46573. private _IsCanvasElement;
  46574. /** @hidden */
  46575. _rebuild(): void;
  46576. }
  46577. }
  46578. declare module BABYLON {
  46579. /**
  46580. * Class containing static functions to help procedurally build meshes
  46581. */
  46582. export class GroundBuilder {
  46583. /**
  46584. * Creates a ground mesh
  46585. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46586. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46588. * @param name defines the name of the mesh
  46589. * @param options defines the options used to create the mesh
  46590. * @param scene defines the hosting scene
  46591. * @returns the ground mesh
  46592. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46593. */
  46594. static CreateGround(name: string, options: {
  46595. width?: number;
  46596. height?: number;
  46597. subdivisions?: number;
  46598. subdivisionsX?: number;
  46599. subdivisionsY?: number;
  46600. updatable?: boolean;
  46601. }, scene: any): Mesh;
  46602. /**
  46603. * Creates a tiled ground mesh
  46604. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46605. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46606. * * 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
  46607. * * 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
  46608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46609. * @param name defines the name of the mesh
  46610. * @param options defines the options used to create the mesh
  46611. * @param scene defines the hosting scene
  46612. * @returns the tiled ground mesh
  46613. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46614. */
  46615. static CreateTiledGround(name: string, options: {
  46616. xmin: number;
  46617. zmin: number;
  46618. xmax: number;
  46619. zmax: number;
  46620. subdivisions?: {
  46621. w: number;
  46622. h: number;
  46623. };
  46624. precision?: {
  46625. w: number;
  46626. h: number;
  46627. };
  46628. updatable?: boolean;
  46629. }, scene?: Nullable<Scene>): Mesh;
  46630. /**
  46631. * Creates a ground mesh from a height map
  46632. * * The parameter `url` sets the URL of the height map image resource.
  46633. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46634. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46635. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46636. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46637. * * 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.
  46638. * * 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).
  46639. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46641. * @param name defines the name of the mesh
  46642. * @param url defines the url to the height map
  46643. * @param options defines the options used to create the mesh
  46644. * @param scene defines the hosting scene
  46645. * @returns the ground mesh
  46646. * @see https://doc.babylonjs.com/babylon101/height_map
  46647. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46648. */
  46649. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46650. width?: number;
  46651. height?: number;
  46652. subdivisions?: number;
  46653. minHeight?: number;
  46654. maxHeight?: number;
  46655. colorFilter?: Color3;
  46656. alphaFilter?: number;
  46657. updatable?: boolean;
  46658. onReady?: (mesh: GroundMesh) => void;
  46659. }, scene?: Nullable<Scene>): GroundMesh;
  46660. }
  46661. }
  46662. declare module BABYLON {
  46663. /**
  46664. * Class containing static functions to help procedurally build meshes
  46665. */
  46666. export class TorusBuilder {
  46667. /**
  46668. * Creates a torus mesh
  46669. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46670. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46671. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46673. * * 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
  46674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46675. * @param name defines the name of the mesh
  46676. * @param options defines the options used to create the mesh
  46677. * @param scene defines the hosting scene
  46678. * @returns the torus mesh
  46679. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46680. */
  46681. static CreateTorus(name: string, options: {
  46682. diameter?: number;
  46683. thickness?: number;
  46684. tessellation?: number;
  46685. updatable?: boolean;
  46686. sideOrientation?: number;
  46687. frontUVs?: Vector4;
  46688. backUVs?: Vector4;
  46689. }, scene: any): Mesh;
  46690. }
  46691. }
  46692. declare module BABYLON {
  46693. /**
  46694. * Class containing static functions to help procedurally build meshes
  46695. */
  46696. export class CylinderBuilder {
  46697. /**
  46698. * Creates a cylinder or a cone mesh
  46699. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46700. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46701. * * 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.
  46702. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46703. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46704. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46705. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46706. * * 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).
  46707. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46708. * * 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).
  46709. * * 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
  46710. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46711. * * 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
  46712. * * 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.
  46713. * * If `enclose` is false, a ring surface is one element.
  46714. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46715. * * 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
  46716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46717. * * 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
  46718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46719. * @param name defines the name of the mesh
  46720. * @param options defines the options used to create the mesh
  46721. * @param scene defines the hosting scene
  46722. * @returns the cylinder mesh
  46723. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46724. */
  46725. static CreateCylinder(name: string, options: {
  46726. height?: number;
  46727. diameterTop?: number;
  46728. diameterBottom?: number;
  46729. diameter?: number;
  46730. tessellation?: number;
  46731. subdivisions?: number;
  46732. arc?: number;
  46733. faceColors?: Color4[];
  46734. faceUV?: Vector4[];
  46735. updatable?: boolean;
  46736. hasRings?: boolean;
  46737. enclose?: boolean;
  46738. cap?: number;
  46739. sideOrientation?: number;
  46740. frontUVs?: Vector4;
  46741. backUVs?: Vector4;
  46742. }, scene: any): Mesh;
  46743. }
  46744. }
  46745. declare module BABYLON {
  46746. /**
  46747. * States of the webXR experience
  46748. */
  46749. export enum WebXRState {
  46750. /**
  46751. * Transitioning to being in XR mode
  46752. */
  46753. ENTERING_XR = 0,
  46754. /**
  46755. * Transitioning to non XR mode
  46756. */
  46757. EXITING_XR = 1,
  46758. /**
  46759. * In XR mode and presenting
  46760. */
  46761. IN_XR = 2,
  46762. /**
  46763. * Not entered XR mode
  46764. */
  46765. NOT_IN_XR = 3
  46766. }
  46767. /**
  46768. * Abstraction of the XR render target
  46769. */
  46770. export interface WebXRRenderTarget extends IDisposable {
  46771. /**
  46772. * xrpresent context of the canvas which can be used to display/mirror xr content
  46773. */
  46774. canvasContext: WebGLRenderingContext;
  46775. /**
  46776. * xr layer for the canvas
  46777. */
  46778. xrLayer: Nullable<XRWebGLLayer>;
  46779. /**
  46780. * Initializes the xr layer for the session
  46781. * @param xrSession xr session
  46782. * @returns a promise that will resolve once the XR Layer has been created
  46783. */
  46784. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46785. }
  46786. }
  46787. declare module BABYLON {
  46788. /**
  46789. * COnfiguration object for WebXR output canvas
  46790. */
  46791. export class WebXRManagedOutputCanvasOptions {
  46792. /**
  46793. * An optional canvas in case you wish to create it yourself and provide it here.
  46794. * If not provided, a new canvas will be created
  46795. */
  46796. canvasElement?: HTMLCanvasElement;
  46797. /**
  46798. * Options for this XR Layer output
  46799. */
  46800. canvasOptions?: XRWebGLLayerOptions;
  46801. /**
  46802. * CSS styling for a newly created canvas (if not provided)
  46803. */
  46804. newCanvasCssStyle?: string;
  46805. /**
  46806. * Get the default values of the configuration object
  46807. * @param engine defines the engine to use (can be null)
  46808. * @returns default values of this configuration object
  46809. */
  46810. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46811. }
  46812. /**
  46813. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46814. */
  46815. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46816. private _options;
  46817. private _canvas;
  46818. private _engine;
  46819. private _originalCanvasSize;
  46820. /**
  46821. * Rendering context of the canvas which can be used to display/mirror xr content
  46822. */
  46823. canvasContext: WebGLRenderingContext;
  46824. /**
  46825. * xr layer for the canvas
  46826. */
  46827. xrLayer: Nullable<XRWebGLLayer>;
  46828. /**
  46829. * Obseervers registered here will be triggered when the xr layer was initialized
  46830. */
  46831. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46832. /**
  46833. * Initializes the canvas to be added/removed upon entering/exiting xr
  46834. * @param _xrSessionManager The XR Session manager
  46835. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46836. */
  46837. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46838. /**
  46839. * Disposes of the object
  46840. */
  46841. dispose(): void;
  46842. /**
  46843. * Initializes the xr layer for the session
  46844. * @param xrSession xr session
  46845. * @returns a promise that will resolve once the XR Layer has been created
  46846. */
  46847. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46848. private _addCanvas;
  46849. private _removeCanvas;
  46850. private _setCanvasSize;
  46851. private _setManagedOutputCanvas;
  46852. }
  46853. }
  46854. declare module BABYLON {
  46855. /**
  46856. * Manages an XRSession to work with Babylon's engine
  46857. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46858. */
  46859. export class WebXRSessionManager implements IDisposable {
  46860. /** The scene which the session should be created for */
  46861. scene: Scene;
  46862. private _referenceSpace;
  46863. private _rttProvider;
  46864. private _sessionEnded;
  46865. private _xrNavigator;
  46866. private baseLayer;
  46867. /**
  46868. * The base reference space from which the session started. good if you want to reset your
  46869. * reference space
  46870. */
  46871. baseReferenceSpace: XRReferenceSpace;
  46872. /**
  46873. * Current XR frame
  46874. */
  46875. currentFrame: Nullable<XRFrame>;
  46876. /** WebXR timestamp updated every frame */
  46877. currentTimestamp: number;
  46878. /**
  46879. * Used just in case of a failure to initialize an immersive session.
  46880. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46881. */
  46882. defaultHeightCompensation: number;
  46883. /**
  46884. * Fires every time a new xrFrame arrives which can be used to update the camera
  46885. */
  46886. onXRFrameObservable: Observable<XRFrame>;
  46887. /**
  46888. * Fires when the reference space changed
  46889. */
  46890. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46891. /**
  46892. * Fires when the xr session is ended either by the device or manually done
  46893. */
  46894. onXRSessionEnded: Observable<any>;
  46895. /**
  46896. * Fires when the xr session is ended either by the device or manually done
  46897. */
  46898. onXRSessionInit: Observable<XRSession>;
  46899. /**
  46900. * Underlying xr session
  46901. */
  46902. session: XRSession;
  46903. /**
  46904. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46905. * or get the offset the player is currently at.
  46906. */
  46907. viewerReferenceSpace: XRReferenceSpace;
  46908. /**
  46909. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46910. * @param scene The scene which the session should be created for
  46911. */
  46912. constructor(
  46913. /** The scene which the session should be created for */
  46914. scene: Scene);
  46915. /**
  46916. * The current reference space used in this session. This reference space can constantly change!
  46917. * It is mainly used to offset the camera's position.
  46918. */
  46919. get referenceSpace(): XRReferenceSpace;
  46920. /**
  46921. * Set a new reference space and triggers the observable
  46922. */
  46923. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46924. /**
  46925. * Disposes of the session manager
  46926. */
  46927. dispose(): void;
  46928. /**
  46929. * Stops the xrSession and restores the render loop
  46930. * @returns Promise which resolves after it exits XR
  46931. */
  46932. exitXRAsync(): Promise<void>;
  46933. /**
  46934. * Gets the correct render target texture to be rendered this frame for this eye
  46935. * @param eye the eye for which to get the render target
  46936. * @returns the render target for the specified eye
  46937. */
  46938. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46939. /**
  46940. * Creates a WebXRRenderTarget object for the XR session
  46941. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46942. * @param options optional options to provide when creating a new render target
  46943. * @returns a WebXR render target to which the session can render
  46944. */
  46945. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46946. /**
  46947. * Initializes the manager
  46948. * After initialization enterXR can be called to start an XR session
  46949. * @returns Promise which resolves after it is initialized
  46950. */
  46951. initializeAsync(): Promise<void>;
  46952. /**
  46953. * Initializes an xr session
  46954. * @param xrSessionMode mode to initialize
  46955. * @param xrSessionInit defines optional and required values to pass to the session builder
  46956. * @returns a promise which will resolve once the session has been initialized
  46957. */
  46958. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46959. /**
  46960. * Checks if a session would be supported for the creation options specified
  46961. * @param sessionMode session mode to check if supported eg. immersive-vr
  46962. * @returns A Promise that resolves to true if supported and false if not
  46963. */
  46964. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46965. /**
  46966. * Resets the reference space to the one started the session
  46967. */
  46968. resetReferenceSpace(): void;
  46969. /**
  46970. * Starts rendering to the xr layer
  46971. */
  46972. runXRRenderLoop(): void;
  46973. /**
  46974. * Sets the reference space on the xr session
  46975. * @param referenceSpaceType space to set
  46976. * @returns a promise that will resolve once the reference space has been set
  46977. */
  46978. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46979. /**
  46980. * Updates the render state of the session
  46981. * @param state state to set
  46982. * @returns a promise that resolves once the render state has been updated
  46983. */
  46984. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46985. /**
  46986. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46987. * @param sessionMode defines the session to test
  46988. * @returns a promise with boolean as final value
  46989. */
  46990. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46991. private _createRenderTargetTexture;
  46992. }
  46993. }
  46994. declare module BABYLON {
  46995. /**
  46996. * WebXR Camera which holds the views for the xrSession
  46997. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46998. */
  46999. export class WebXRCamera extends FreeCamera {
  47000. private _xrSessionManager;
  47001. private _firstFrame;
  47002. private _referenceQuaternion;
  47003. private _referencedPosition;
  47004. private _xrInvPositionCache;
  47005. private _xrInvQuaternionCache;
  47006. /**
  47007. * Observable raised before camera teleportation
  47008. */
  47009. onBeforeCameraTeleport: Observable<Vector3>;
  47010. /**
  47011. * Observable raised after camera teleportation
  47012. */
  47013. onAfterCameraTeleport: Observable<Vector3>;
  47014. /**
  47015. * Should position compensation execute on first frame.
  47016. * This is used when copying the position from a native (non XR) camera
  47017. */
  47018. compensateOnFirstFrame: boolean;
  47019. /**
  47020. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47021. * @param name the name of the camera
  47022. * @param scene the scene to add the camera to
  47023. * @param _xrSessionManager a constructed xr session manager
  47024. */
  47025. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47026. /**
  47027. * Return the user's height, unrelated to the current ground.
  47028. * This will be the y position of this camera, when ground level is 0.
  47029. */
  47030. get realWorldHeight(): number;
  47031. /** @hidden */
  47032. _updateForDualEyeDebugging(): void;
  47033. /**
  47034. * Sets this camera's transformation based on a non-vr camera
  47035. * @param otherCamera the non-vr camera to copy the transformation from
  47036. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47037. */
  47038. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47039. /**
  47040. * Gets the current instance class name ("WebXRCamera").
  47041. * @returns the class name
  47042. */
  47043. getClassName(): string;
  47044. private _rotate180;
  47045. private _updateFromXRSession;
  47046. private _updateNumberOfRigCameras;
  47047. private _updateReferenceSpace;
  47048. private _updateReferenceSpaceOffset;
  47049. }
  47050. }
  47051. declare module BABYLON {
  47052. /**
  47053. * Defining the interface required for a (webxr) feature
  47054. */
  47055. export interface IWebXRFeature extends IDisposable {
  47056. /**
  47057. * Is this feature attached
  47058. */
  47059. attached: boolean;
  47060. /**
  47061. * Should auto-attach be disabled?
  47062. */
  47063. disableAutoAttach: boolean;
  47064. /**
  47065. * Attach the feature to the session
  47066. * Will usually be called by the features manager
  47067. *
  47068. * @param force should attachment be forced (even when already attached)
  47069. * @returns true if successful.
  47070. */
  47071. attach(force?: boolean): boolean;
  47072. /**
  47073. * Detach the feature from the session
  47074. * Will usually be called by the features manager
  47075. *
  47076. * @returns true if successful.
  47077. */
  47078. detach(): boolean;
  47079. /**
  47080. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47081. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47082. *
  47083. * @returns whether or not the feature is compatible in this environment
  47084. */
  47085. isCompatible(): boolean;
  47086. /**
  47087. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47088. */
  47089. xrNativeFeatureName?: string;
  47090. /**
  47091. * A list of (Babylon WebXR) features this feature depends on
  47092. */
  47093. dependsOn?: string[];
  47094. }
  47095. /**
  47096. * A list of the currently available features without referencing them
  47097. */
  47098. export class WebXRFeatureName {
  47099. /**
  47100. * The name of the anchor system feature
  47101. */
  47102. static readonly ANCHOR_SYSTEM: string;
  47103. /**
  47104. * The name of the background remover feature
  47105. */
  47106. static readonly BACKGROUND_REMOVER: string;
  47107. /**
  47108. * The name of the hit test feature
  47109. */
  47110. static readonly HIT_TEST: string;
  47111. /**
  47112. * physics impostors for xr controllers feature
  47113. */
  47114. static readonly PHYSICS_CONTROLLERS: string;
  47115. /**
  47116. * The name of the plane detection feature
  47117. */
  47118. static readonly PLANE_DETECTION: string;
  47119. /**
  47120. * The name of the pointer selection feature
  47121. */
  47122. static readonly POINTER_SELECTION: string;
  47123. /**
  47124. * The name of the teleportation feature
  47125. */
  47126. static readonly TELEPORTATION: string;
  47127. /**
  47128. * The name of the feature points feature.
  47129. */
  47130. static readonly FEATURE_POINTS: string;
  47131. /**
  47132. * The name of the hand tracking feature.
  47133. */
  47134. static readonly HAND_TRACKING: string;
  47135. }
  47136. /**
  47137. * Defining the constructor of a feature. Used to register the modules.
  47138. */
  47139. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47140. /**
  47141. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47142. * It is mainly used in AR sessions.
  47143. *
  47144. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47145. */
  47146. export class WebXRFeaturesManager implements IDisposable {
  47147. private _xrSessionManager;
  47148. private static readonly _AvailableFeatures;
  47149. private _features;
  47150. /**
  47151. * constructs a new features manages.
  47152. *
  47153. * @param _xrSessionManager an instance of WebXRSessionManager
  47154. */
  47155. constructor(_xrSessionManager: WebXRSessionManager);
  47156. /**
  47157. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47158. * Mainly used internally.
  47159. *
  47160. * @param featureName the name of the feature to register
  47161. * @param constructorFunction the function used to construct the module
  47162. * @param version the (babylon) version of the module
  47163. * @param stable is that a stable version of this module
  47164. */
  47165. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47166. /**
  47167. * Returns a constructor of a specific feature.
  47168. *
  47169. * @param featureName the name of the feature to construct
  47170. * @param version the version of the feature to load
  47171. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47172. * @param options optional options provided to the module.
  47173. * @returns a function that, when called, will return a new instance of this feature
  47174. */
  47175. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47176. /**
  47177. * Can be used to return the list of features currently registered
  47178. *
  47179. * @returns an Array of available features
  47180. */
  47181. static GetAvailableFeatures(): string[];
  47182. /**
  47183. * Gets the versions available for a specific feature
  47184. * @param featureName the name of the feature
  47185. * @returns an array with the available versions
  47186. */
  47187. static GetAvailableVersions(featureName: string): string[];
  47188. /**
  47189. * Return the latest unstable version of this feature
  47190. * @param featureName the name of the feature to search
  47191. * @returns the version number. if not found will return -1
  47192. */
  47193. static GetLatestVersionOfFeature(featureName: string): number;
  47194. /**
  47195. * Return the latest stable version of this feature
  47196. * @param featureName the name of the feature to search
  47197. * @returns the version number. if not found will return -1
  47198. */
  47199. static GetStableVersionOfFeature(featureName: string): number;
  47200. /**
  47201. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47202. * Can be used during a session to start a feature
  47203. * @param featureName the name of feature to attach
  47204. */
  47205. attachFeature(featureName: string): void;
  47206. /**
  47207. * Can be used inside a session or when the session ends to detach a specific feature
  47208. * @param featureName the name of the feature to detach
  47209. */
  47210. detachFeature(featureName: string): void;
  47211. /**
  47212. * Used to disable an already-enabled feature
  47213. * The feature will be disposed and will be recreated once enabled.
  47214. * @param featureName the feature to disable
  47215. * @returns true if disable was successful
  47216. */
  47217. disableFeature(featureName: string | {
  47218. Name: string;
  47219. }): boolean;
  47220. /**
  47221. * dispose this features manager
  47222. */
  47223. dispose(): void;
  47224. /**
  47225. * 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.
  47226. * 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.
  47227. *
  47228. * @param featureName the name of the feature to load or the class of the feature
  47229. * @param version optional version to load. if not provided the latest version will be enabled
  47230. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47231. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47232. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47233. * @returns a new constructed feature or throws an error if feature not found.
  47234. */
  47235. enableFeature(featureName: string | {
  47236. Name: string;
  47237. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47238. /**
  47239. * get the implementation of an enabled feature.
  47240. * @param featureName the name of the feature to load
  47241. * @returns the feature class, if found
  47242. */
  47243. getEnabledFeature(featureName: string): IWebXRFeature;
  47244. /**
  47245. * Get the list of enabled features
  47246. * @returns an array of enabled features
  47247. */
  47248. getEnabledFeatures(): string[];
  47249. /**
  47250. * This function will exten the session creation configuration object with enabled features.
  47251. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47252. * according to the defined "required" variable, provided during enableFeature call
  47253. * @param xrSessionInit the xr Session init object to extend
  47254. *
  47255. * @returns an extended XRSessionInit object
  47256. */
  47257. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47258. }
  47259. }
  47260. declare module BABYLON {
  47261. /**
  47262. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47263. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47264. */
  47265. export class WebXRExperienceHelper implements IDisposable {
  47266. private scene;
  47267. private _nonVRCamera;
  47268. private _originalSceneAutoClear;
  47269. private _supported;
  47270. /**
  47271. * Camera used to render xr content
  47272. */
  47273. camera: WebXRCamera;
  47274. /** A features manager for this xr session */
  47275. featuresManager: WebXRFeaturesManager;
  47276. /**
  47277. * Observers registered here will be triggered after the camera's initial transformation is set
  47278. * This can be used to set a different ground level or an extra rotation.
  47279. *
  47280. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47281. * to the position set after this observable is done executing.
  47282. */
  47283. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47284. /**
  47285. * Fires when the state of the experience helper has changed
  47286. */
  47287. onStateChangedObservable: Observable<WebXRState>;
  47288. /** Session manager used to keep track of xr session */
  47289. sessionManager: WebXRSessionManager;
  47290. /**
  47291. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47292. */
  47293. state: WebXRState;
  47294. /**
  47295. * Creates a WebXRExperienceHelper
  47296. * @param scene The scene the helper should be created in
  47297. */
  47298. private constructor();
  47299. /**
  47300. * Creates the experience helper
  47301. * @param scene the scene to attach the experience helper to
  47302. * @returns a promise for the experience helper
  47303. */
  47304. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47305. /**
  47306. * Disposes of the experience helper
  47307. */
  47308. dispose(): void;
  47309. /**
  47310. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47311. * @param sessionMode options for the XR session
  47312. * @param referenceSpaceType frame of reference of the XR session
  47313. * @param renderTarget the output canvas that will be used to enter XR mode
  47314. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47315. * @returns promise that resolves after xr mode has entered
  47316. */
  47317. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47318. /**
  47319. * Exits XR mode and returns the scene to its original state
  47320. * @returns promise that resolves after xr mode has exited
  47321. */
  47322. exitXRAsync(): Promise<void>;
  47323. private _nonXRToXRCamera;
  47324. private _setState;
  47325. }
  47326. }
  47327. declare module BABYLON {
  47328. /**
  47329. * X-Y values for axes in WebXR
  47330. */
  47331. export interface IWebXRMotionControllerAxesValue {
  47332. /**
  47333. * The value of the x axis
  47334. */
  47335. x: number;
  47336. /**
  47337. * The value of the y-axis
  47338. */
  47339. y: number;
  47340. }
  47341. /**
  47342. * changed / previous values for the values of this component
  47343. */
  47344. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47345. /**
  47346. * current (this frame) value
  47347. */
  47348. current: T;
  47349. /**
  47350. * previous (last change) value
  47351. */
  47352. previous: T;
  47353. }
  47354. /**
  47355. * Represents changes in the component between current frame and last values recorded
  47356. */
  47357. export interface IWebXRMotionControllerComponentChanges {
  47358. /**
  47359. * will be populated with previous and current values if axes changed
  47360. */
  47361. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47362. /**
  47363. * will be populated with previous and current values if pressed changed
  47364. */
  47365. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47366. /**
  47367. * will be populated with previous and current values if touched changed
  47368. */
  47369. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47370. /**
  47371. * will be populated with previous and current values if value changed
  47372. */
  47373. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47374. }
  47375. /**
  47376. * This class represents a single component (for example button or thumbstick) of a motion controller
  47377. */
  47378. export class WebXRControllerComponent implements IDisposable {
  47379. /**
  47380. * the id of this component
  47381. */
  47382. id: string;
  47383. /**
  47384. * the type of the component
  47385. */
  47386. type: MotionControllerComponentType;
  47387. private _buttonIndex;
  47388. private _axesIndices;
  47389. private _axes;
  47390. private _changes;
  47391. private _currentValue;
  47392. private _hasChanges;
  47393. private _pressed;
  47394. private _touched;
  47395. /**
  47396. * button component type
  47397. */
  47398. static BUTTON_TYPE: MotionControllerComponentType;
  47399. /**
  47400. * squeeze component type
  47401. */
  47402. static SQUEEZE_TYPE: MotionControllerComponentType;
  47403. /**
  47404. * Thumbstick component type
  47405. */
  47406. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47407. /**
  47408. * Touchpad component type
  47409. */
  47410. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47411. /**
  47412. * trigger component type
  47413. */
  47414. static TRIGGER_TYPE: MotionControllerComponentType;
  47415. /**
  47416. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47417. * the axes data changes
  47418. */
  47419. onAxisValueChangedObservable: Observable<{
  47420. x: number;
  47421. y: number;
  47422. }>;
  47423. /**
  47424. * Observers registered here will be triggered when the state of a button changes
  47425. * State change is either pressed / touched / value
  47426. */
  47427. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47428. /**
  47429. * Creates a new component for a motion controller.
  47430. * It is created by the motion controller itself
  47431. *
  47432. * @param id the id of this component
  47433. * @param type the type of the component
  47434. * @param _buttonIndex index in the buttons array of the gamepad
  47435. * @param _axesIndices indices of the values in the axes array of the gamepad
  47436. */
  47437. constructor(
  47438. /**
  47439. * the id of this component
  47440. */
  47441. id: string,
  47442. /**
  47443. * the type of the component
  47444. */
  47445. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47446. /**
  47447. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47448. */
  47449. get axes(): IWebXRMotionControllerAxesValue;
  47450. /**
  47451. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47452. */
  47453. get changes(): IWebXRMotionControllerComponentChanges;
  47454. /**
  47455. * Return whether or not the component changed the last frame
  47456. */
  47457. get hasChanges(): boolean;
  47458. /**
  47459. * is the button currently pressed
  47460. */
  47461. get pressed(): boolean;
  47462. /**
  47463. * is the button currently touched
  47464. */
  47465. get touched(): boolean;
  47466. /**
  47467. * Get the current value of this component
  47468. */
  47469. get value(): number;
  47470. /**
  47471. * Dispose this component
  47472. */
  47473. dispose(): void;
  47474. /**
  47475. * Are there axes correlating to this component
  47476. * @return true is axes data is available
  47477. */
  47478. isAxes(): boolean;
  47479. /**
  47480. * Is this component a button (hence - pressable)
  47481. * @returns true if can be pressed
  47482. */
  47483. isButton(): boolean;
  47484. /**
  47485. * update this component using the gamepad object it is in. Called on every frame
  47486. * @param nativeController the native gamepad controller object
  47487. */
  47488. update(nativeController: IMinimalMotionControllerObject): void;
  47489. }
  47490. }
  47491. declare module BABYLON {
  47492. /**
  47493. * Interface used to represent data loading progression
  47494. */
  47495. export interface ISceneLoaderProgressEvent {
  47496. /**
  47497. * Defines if data length to load can be evaluated
  47498. */
  47499. readonly lengthComputable: boolean;
  47500. /**
  47501. * Defines the loaded data length
  47502. */
  47503. readonly loaded: number;
  47504. /**
  47505. * Defines the data length to load
  47506. */
  47507. readonly total: number;
  47508. }
  47509. /**
  47510. * Interface used by SceneLoader plugins to define supported file extensions
  47511. */
  47512. export interface ISceneLoaderPluginExtensions {
  47513. /**
  47514. * Defines the list of supported extensions
  47515. */
  47516. [extension: string]: {
  47517. isBinary: boolean;
  47518. };
  47519. }
  47520. /**
  47521. * Interface used by SceneLoader plugin factory
  47522. */
  47523. export interface ISceneLoaderPluginFactory {
  47524. /**
  47525. * Defines the name of the factory
  47526. */
  47527. name: string;
  47528. /**
  47529. * Function called to create a new plugin
  47530. * @return the new plugin
  47531. */
  47532. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47533. /**
  47534. * The callback that returns true if the data can be directly loaded.
  47535. * @param data string containing the file data
  47536. * @returns if the data can be loaded directly
  47537. */
  47538. canDirectLoad?(data: string): boolean;
  47539. }
  47540. /**
  47541. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47542. */
  47543. export interface ISceneLoaderPluginBase {
  47544. /**
  47545. * The friendly name of this plugin.
  47546. */
  47547. name: string;
  47548. /**
  47549. * The file extensions supported by this plugin.
  47550. */
  47551. extensions: string | ISceneLoaderPluginExtensions;
  47552. /**
  47553. * The callback called when loading from a url.
  47554. * @param scene scene loading this url
  47555. * @param url url to load
  47556. * @param onSuccess callback called when the file successfully loads
  47557. * @param onProgress callback called while file is loading (if the server supports this mode)
  47558. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47559. * @param onError callback called when the file fails to load
  47560. * @returns a file request object
  47561. */
  47562. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47563. /**
  47564. * The callback called when loading from a file object.
  47565. * @param scene scene loading this file
  47566. * @param file defines the file to load
  47567. * @param onSuccess defines the callback to call when data is loaded
  47568. * @param onProgress defines the callback to call during loading process
  47569. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47570. * @param onError defines the callback to call when an error occurs
  47571. * @returns a file request object
  47572. */
  47573. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47574. /**
  47575. * The callback that returns true if the data can be directly loaded.
  47576. * @param data string containing the file data
  47577. * @returns if the data can be loaded directly
  47578. */
  47579. canDirectLoad?(data: string): boolean;
  47580. /**
  47581. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47582. * @param scene scene loading this data
  47583. * @param data string containing the data
  47584. * @returns data to pass to the plugin
  47585. */
  47586. directLoad?(scene: Scene, data: string): any;
  47587. /**
  47588. * The callback that allows custom handling of the root url based on the response url.
  47589. * @param rootUrl the original root url
  47590. * @param responseURL the response url if available
  47591. * @returns the new root url
  47592. */
  47593. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47594. }
  47595. /**
  47596. * Interface used to define a SceneLoader plugin
  47597. */
  47598. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47599. /**
  47600. * Import meshes into a scene.
  47601. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47602. * @param scene The scene to import into
  47603. * @param data The data to import
  47604. * @param rootUrl The root url for scene and resources
  47605. * @param meshes The meshes array to import into
  47606. * @param particleSystems The particle systems array to import into
  47607. * @param skeletons The skeletons array to import into
  47608. * @param onError The callback when import fails
  47609. * @returns True if successful or false otherwise
  47610. */
  47611. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47612. /**
  47613. * Load into a scene.
  47614. * @param scene The scene to load into
  47615. * @param data The data to import
  47616. * @param rootUrl The root url for scene and resources
  47617. * @param onError The callback when import fails
  47618. * @returns True if successful or false otherwise
  47619. */
  47620. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47621. /**
  47622. * Load into an asset container.
  47623. * @param scene The scene to load into
  47624. * @param data The data to import
  47625. * @param rootUrl The root url for scene and resources
  47626. * @param onError The callback when import fails
  47627. * @returns The loaded asset container
  47628. */
  47629. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47630. }
  47631. /**
  47632. * Interface used to define an async SceneLoader plugin
  47633. */
  47634. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47635. /**
  47636. * Import meshes into a scene.
  47637. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47638. * @param scene The scene to import into
  47639. * @param data The data to import
  47640. * @param rootUrl The root url for scene and resources
  47641. * @param onProgress The callback when the load progresses
  47642. * @param fileName Defines the name of the file to load
  47643. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47644. */
  47645. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47646. meshes: AbstractMesh[];
  47647. particleSystems: IParticleSystem[];
  47648. skeletons: Skeleton[];
  47649. animationGroups: AnimationGroup[];
  47650. }>;
  47651. /**
  47652. * Load into a scene.
  47653. * @param scene The scene to load into
  47654. * @param data The data to import
  47655. * @param rootUrl The root url for scene and resources
  47656. * @param onProgress The callback when the load progresses
  47657. * @param fileName Defines the name of the file to load
  47658. * @returns Nothing
  47659. */
  47660. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47661. /**
  47662. * Load into an asset container.
  47663. * @param scene The scene to load into
  47664. * @param data The data to import
  47665. * @param rootUrl The root url for scene and resources
  47666. * @param onProgress The callback when the load progresses
  47667. * @param fileName Defines the name of the file to load
  47668. * @returns The loaded asset container
  47669. */
  47670. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47671. }
  47672. /**
  47673. * Mode that determines how to handle old animation groups before loading new ones.
  47674. */
  47675. export enum SceneLoaderAnimationGroupLoadingMode {
  47676. /**
  47677. * Reset all old animations to initial state then dispose them.
  47678. */
  47679. Clean = 0,
  47680. /**
  47681. * Stop all old animations.
  47682. */
  47683. Stop = 1,
  47684. /**
  47685. * Restart old animations from first frame.
  47686. */
  47687. Sync = 2,
  47688. /**
  47689. * Old animations remains untouched.
  47690. */
  47691. NoSync = 3
  47692. }
  47693. /**
  47694. * Defines a plugin registered by the SceneLoader
  47695. */
  47696. interface IRegisteredPlugin {
  47697. /**
  47698. * Defines the plugin to use
  47699. */
  47700. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47701. /**
  47702. * Defines if the plugin supports binary data
  47703. */
  47704. isBinary: boolean;
  47705. }
  47706. /**
  47707. * Class used to load scene from various file formats using registered plugins
  47708. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47709. */
  47710. export class SceneLoader {
  47711. /**
  47712. * No logging while loading
  47713. */
  47714. static readonly NO_LOGGING: number;
  47715. /**
  47716. * Minimal logging while loading
  47717. */
  47718. static readonly MINIMAL_LOGGING: number;
  47719. /**
  47720. * Summary logging while loading
  47721. */
  47722. static readonly SUMMARY_LOGGING: number;
  47723. /**
  47724. * Detailled logging while loading
  47725. */
  47726. static readonly DETAILED_LOGGING: number;
  47727. /**
  47728. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47729. */
  47730. static get ForceFullSceneLoadingForIncremental(): boolean;
  47731. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47732. /**
  47733. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47734. */
  47735. static get ShowLoadingScreen(): boolean;
  47736. static set ShowLoadingScreen(value: boolean);
  47737. /**
  47738. * Defines the current logging level (while loading the scene)
  47739. * @ignorenaming
  47740. */
  47741. static get loggingLevel(): number;
  47742. static set loggingLevel(value: number);
  47743. /**
  47744. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47745. */
  47746. static get CleanBoneMatrixWeights(): boolean;
  47747. static set CleanBoneMatrixWeights(value: boolean);
  47748. /**
  47749. * Event raised when a plugin is used to load a scene
  47750. */
  47751. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47752. private static _registeredPlugins;
  47753. private static _showingLoadingScreen;
  47754. /**
  47755. * Gets the default plugin (used to load Babylon files)
  47756. * @returns the .babylon plugin
  47757. */
  47758. static GetDefaultPlugin(): IRegisteredPlugin;
  47759. private static _GetPluginForExtension;
  47760. private static _GetPluginForDirectLoad;
  47761. private static _GetPluginForFilename;
  47762. private static _GetDirectLoad;
  47763. private static _LoadData;
  47764. private static _GetFileInfo;
  47765. /**
  47766. * Gets a plugin that can load the given extension
  47767. * @param extension defines the extension to load
  47768. * @returns a plugin or null if none works
  47769. */
  47770. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47771. /**
  47772. * Gets a boolean indicating that the given extension can be loaded
  47773. * @param extension defines the extension to load
  47774. * @returns true if the extension is supported
  47775. */
  47776. static IsPluginForExtensionAvailable(extension: string): boolean;
  47777. /**
  47778. * Adds a new plugin to the list of registered plugins
  47779. * @param plugin defines the plugin to add
  47780. */
  47781. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47782. /**
  47783. * Import meshes into a scene
  47784. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47785. * @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)
  47786. * @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)
  47787. * @param scene the instance of BABYLON.Scene to append to
  47788. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47789. * @param onProgress a callback with a progress event for each file being loaded
  47790. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47791. * @param pluginExtension the extension used to determine the plugin
  47792. * @returns The loaded plugin
  47793. */
  47794. 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>;
  47795. /**
  47796. * Import meshes into a scene
  47797. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47798. * @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)
  47799. * @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)
  47800. * @param scene the instance of BABYLON.Scene to append to
  47801. * @param onProgress a callback with a progress event for each file being loaded
  47802. * @param pluginExtension the extension used to determine the plugin
  47803. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47804. */
  47805. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47806. meshes: AbstractMesh[];
  47807. particleSystems: IParticleSystem[];
  47808. skeletons: Skeleton[];
  47809. animationGroups: AnimationGroup[];
  47810. }>;
  47811. /**
  47812. * Load a scene
  47813. * @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)
  47814. * @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)
  47815. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47816. * @param onSuccess a callback with the scene when import succeeds
  47817. * @param onProgress a callback with a progress event for each file being loaded
  47818. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47819. * @param pluginExtension the extension used to determine the plugin
  47820. * @returns The loaded plugin
  47821. */
  47822. 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>;
  47823. /**
  47824. * Load a scene
  47825. * @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)
  47826. * @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)
  47827. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47828. * @param onProgress a callback with a progress event for each file being loaded
  47829. * @param pluginExtension the extension used to determine the plugin
  47830. * @returns The loaded scene
  47831. */
  47832. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47833. /**
  47834. * Append a scene
  47835. * @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)
  47836. * @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)
  47837. * @param scene is the instance of BABYLON.Scene to append to
  47838. * @param onSuccess a callback with the scene when import succeeds
  47839. * @param onProgress a callback with a progress event for each file being loaded
  47840. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47841. * @param pluginExtension the extension used to determine the plugin
  47842. * @returns The loaded plugin
  47843. */
  47844. 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>;
  47845. /**
  47846. * Append a scene
  47847. * @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)
  47848. * @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)
  47849. * @param scene is the instance of BABYLON.Scene to append to
  47850. * @param onProgress a callback with a progress event for each file being loaded
  47851. * @param pluginExtension the extension used to determine the plugin
  47852. * @returns The given scene
  47853. */
  47854. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47855. /**
  47856. * Load a scene into an asset container
  47857. * @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)
  47858. * @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)
  47859. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47860. * @param onSuccess a callback with the scene when import succeeds
  47861. * @param onProgress a callback with a progress event for each file being loaded
  47862. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47863. * @param pluginExtension the extension used to determine the plugin
  47864. * @returns The loaded plugin
  47865. */
  47866. 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>;
  47867. /**
  47868. * Load a scene into an asset container
  47869. * @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)
  47870. * @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)
  47871. * @param scene is the instance of Scene to append to
  47872. * @param onProgress a callback with a progress event for each file being loaded
  47873. * @param pluginExtension the extension used to determine the plugin
  47874. * @returns The loaded asset container
  47875. */
  47876. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47877. /**
  47878. * Import animations from a file into a scene
  47879. * @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)
  47880. * @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)
  47881. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47882. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47883. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47884. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47885. * @param onSuccess a callback with the scene when import succeeds
  47886. * @param onProgress a callback with a progress event for each file being loaded
  47887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47888. * @param pluginExtension the extension used to determine the plugin
  47889. */
  47890. 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;
  47891. /**
  47892. * Import animations from a file into a scene
  47893. * @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)
  47894. * @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)
  47895. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47896. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47897. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47898. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47899. * @param onSuccess a callback with the scene when import succeeds
  47900. * @param onProgress a callback with a progress event for each file being loaded
  47901. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47902. * @param pluginExtension the extension used to determine the plugin
  47903. * @returns the updated scene with imported animations
  47904. */
  47905. 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>;
  47906. }
  47907. }
  47908. declare module BABYLON {
  47909. /**
  47910. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47911. */
  47912. export type MotionControllerHandedness = "none" | "left" | "right";
  47913. /**
  47914. * The type of components available in motion controllers.
  47915. * This is not the name of the component.
  47916. */
  47917. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47918. /**
  47919. * The state of a controller component
  47920. */
  47921. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47922. /**
  47923. * The schema of motion controller layout.
  47924. * No object will be initialized using this interface
  47925. * This is used just to define the profile.
  47926. */
  47927. export interface IMotionControllerLayout {
  47928. /**
  47929. * Path to load the assets. Usually relative to the base path
  47930. */
  47931. assetPath: string;
  47932. /**
  47933. * Available components (unsorted)
  47934. */
  47935. components: {
  47936. /**
  47937. * A map of component Ids
  47938. */
  47939. [componentId: string]: {
  47940. /**
  47941. * The type of input the component outputs
  47942. */
  47943. type: MotionControllerComponentType;
  47944. /**
  47945. * The indices of this component in the gamepad object
  47946. */
  47947. gamepadIndices: {
  47948. /**
  47949. * Index of button
  47950. */
  47951. button?: number;
  47952. /**
  47953. * If available, index of x-axis
  47954. */
  47955. xAxis?: number;
  47956. /**
  47957. * If available, index of y-axis
  47958. */
  47959. yAxis?: number;
  47960. };
  47961. /**
  47962. * The mesh's root node name
  47963. */
  47964. rootNodeName: string;
  47965. /**
  47966. * Animation definitions for this model
  47967. */
  47968. visualResponses: {
  47969. [stateKey: string]: {
  47970. /**
  47971. * What property will be animated
  47972. */
  47973. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47974. /**
  47975. * What states influence this visual response
  47976. */
  47977. states: MotionControllerComponentStateType[];
  47978. /**
  47979. * Type of animation - movement or visibility
  47980. */
  47981. valueNodeProperty: "transform" | "visibility";
  47982. /**
  47983. * Base node name to move. Its position will be calculated according to the min and max nodes
  47984. */
  47985. valueNodeName?: string;
  47986. /**
  47987. * Minimum movement node
  47988. */
  47989. minNodeName?: string;
  47990. /**
  47991. * Max movement node
  47992. */
  47993. maxNodeName?: string;
  47994. };
  47995. };
  47996. /**
  47997. * If touch enabled, what is the name of node to display user feedback
  47998. */
  47999. touchPointNodeName?: string;
  48000. };
  48001. };
  48002. /**
  48003. * Is it xr standard mapping or not
  48004. */
  48005. gamepadMapping: "" | "xr-standard";
  48006. /**
  48007. * Base root node of this entire model
  48008. */
  48009. rootNodeName: string;
  48010. /**
  48011. * Defines the main button component id
  48012. */
  48013. selectComponentId: string;
  48014. }
  48015. /**
  48016. * A definition for the layout map in the input profile
  48017. */
  48018. export interface IMotionControllerLayoutMap {
  48019. /**
  48020. * Layouts with handedness type as a key
  48021. */
  48022. [handedness: string]: IMotionControllerLayout;
  48023. }
  48024. /**
  48025. * The XR Input profile schema
  48026. * Profiles can be found here:
  48027. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48028. */
  48029. export interface IMotionControllerProfile {
  48030. /**
  48031. * fallback profiles for this profileId
  48032. */
  48033. fallbackProfileIds: string[];
  48034. /**
  48035. * The layout map, with handedness as key
  48036. */
  48037. layouts: IMotionControllerLayoutMap;
  48038. /**
  48039. * The id of this profile
  48040. * correlates to the profile(s) in the xrInput.profiles array
  48041. */
  48042. profileId: string;
  48043. }
  48044. /**
  48045. * A helper-interface for the 3 meshes needed for controller button animation
  48046. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48047. */
  48048. export interface IMotionControllerButtonMeshMap {
  48049. /**
  48050. * the mesh that defines the pressed value mesh position.
  48051. * This is used to find the max-position of this button
  48052. */
  48053. pressedMesh: AbstractMesh;
  48054. /**
  48055. * the mesh that defines the unpressed value mesh position.
  48056. * This is used to find the min (or initial) position of this button
  48057. */
  48058. unpressedMesh: AbstractMesh;
  48059. /**
  48060. * The mesh that will be changed when value changes
  48061. */
  48062. valueMesh: AbstractMesh;
  48063. }
  48064. /**
  48065. * A helper-interface for the 3 meshes needed for controller axis animation.
  48066. * This will be expanded when touchpad animations are fully supported
  48067. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48068. */
  48069. export interface IMotionControllerMeshMap {
  48070. /**
  48071. * the mesh that defines the maximum value mesh position.
  48072. */
  48073. maxMesh?: AbstractMesh;
  48074. /**
  48075. * the mesh that defines the minimum value mesh position.
  48076. */
  48077. minMesh?: AbstractMesh;
  48078. /**
  48079. * The mesh that will be changed when axis value changes
  48080. */
  48081. valueMesh?: AbstractMesh;
  48082. }
  48083. /**
  48084. * The elements needed for change-detection of the gamepad objects in motion controllers
  48085. */
  48086. export interface IMinimalMotionControllerObject {
  48087. /**
  48088. * Available axes of this controller
  48089. */
  48090. axes: number[];
  48091. /**
  48092. * An array of available buttons
  48093. */
  48094. buttons: Array<{
  48095. /**
  48096. * Value of the button/trigger
  48097. */
  48098. value: number;
  48099. /**
  48100. * If the button/trigger is currently touched
  48101. */
  48102. touched: boolean;
  48103. /**
  48104. * If the button/trigger is currently pressed
  48105. */
  48106. pressed: boolean;
  48107. }>;
  48108. /**
  48109. * EXPERIMENTAL haptic support.
  48110. */
  48111. hapticActuators?: Array<{
  48112. pulse: (value: number, duration: number) => Promise<boolean>;
  48113. }>;
  48114. }
  48115. /**
  48116. * An Abstract Motion controller
  48117. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48118. * Each component has an observable to check for changes in value and state
  48119. */
  48120. export abstract class WebXRAbstractMotionController implements IDisposable {
  48121. protected scene: Scene;
  48122. protected layout: IMotionControllerLayout;
  48123. /**
  48124. * The gamepad object correlating to this controller
  48125. */
  48126. gamepadObject: IMinimalMotionControllerObject;
  48127. /**
  48128. * handedness (left/right/none) of this controller
  48129. */
  48130. handedness: MotionControllerHandedness;
  48131. private _initComponent;
  48132. private _modelReady;
  48133. /**
  48134. * A map of components (WebXRControllerComponent) in this motion controller
  48135. * Components have a ComponentType and can also have both button and axis definitions
  48136. */
  48137. readonly components: {
  48138. [id: string]: WebXRControllerComponent;
  48139. };
  48140. /**
  48141. * Disable the model's animation. Can be set at any time.
  48142. */
  48143. disableAnimation: boolean;
  48144. /**
  48145. * Observers registered here will be triggered when the model of this controller is done loading
  48146. */
  48147. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48148. /**
  48149. * The profile id of this motion controller
  48150. */
  48151. abstract profileId: string;
  48152. /**
  48153. * The root mesh of the model. It is null if the model was not yet initialized
  48154. */
  48155. rootMesh: Nullable<AbstractMesh>;
  48156. /**
  48157. * constructs a new abstract motion controller
  48158. * @param scene the scene to which the model of the controller will be added
  48159. * @param layout The profile layout to load
  48160. * @param gamepadObject The gamepad object correlating to this controller
  48161. * @param handedness handedness (left/right/none) of this controller
  48162. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48163. */
  48164. constructor(scene: Scene, layout: IMotionControllerLayout,
  48165. /**
  48166. * The gamepad object correlating to this controller
  48167. */
  48168. gamepadObject: IMinimalMotionControllerObject,
  48169. /**
  48170. * handedness (left/right/none) of this controller
  48171. */
  48172. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48173. /**
  48174. * Dispose this controller, the model mesh and all its components
  48175. */
  48176. dispose(): void;
  48177. /**
  48178. * Returns all components of specific type
  48179. * @param type the type to search for
  48180. * @return an array of components with this type
  48181. */
  48182. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48183. /**
  48184. * get a component based an its component id as defined in layout.components
  48185. * @param id the id of the component
  48186. * @returns the component correlates to the id or undefined if not found
  48187. */
  48188. getComponent(id: string): WebXRControllerComponent;
  48189. /**
  48190. * Get the list of components available in this motion controller
  48191. * @returns an array of strings correlating to available components
  48192. */
  48193. getComponentIds(): string[];
  48194. /**
  48195. * Get the first component of specific type
  48196. * @param type type of component to find
  48197. * @return a controller component or null if not found
  48198. */
  48199. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48200. /**
  48201. * Get the main (Select) component of this controller as defined in the layout
  48202. * @returns the main component of this controller
  48203. */
  48204. getMainComponent(): WebXRControllerComponent;
  48205. /**
  48206. * Loads the model correlating to this controller
  48207. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48208. * @returns A promise fulfilled with the result of the model loading
  48209. */
  48210. loadModel(): Promise<boolean>;
  48211. /**
  48212. * Update this model using the current XRFrame
  48213. * @param xrFrame the current xr frame to use and update the model
  48214. */
  48215. updateFromXRFrame(xrFrame: XRFrame): void;
  48216. /**
  48217. * Backwards compatibility due to a deeply-integrated typo
  48218. */
  48219. get handness(): XREye;
  48220. /**
  48221. * Pulse (vibrate) this controller
  48222. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48223. * Consecutive calls to this function will cancel the last pulse call
  48224. *
  48225. * @param value the strength of the pulse in 0.0...1.0 range
  48226. * @param duration Duration of the pulse in milliseconds
  48227. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48228. * @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
  48229. */
  48230. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48231. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48232. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48233. /**
  48234. * Moves the axis on the controller mesh based on its current state
  48235. * @param axis the index of the axis
  48236. * @param axisValue the value of the axis which determines the meshes new position
  48237. * @hidden
  48238. */
  48239. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48240. /**
  48241. * Update the model itself with the current frame data
  48242. * @param xrFrame the frame to use for updating the model mesh
  48243. */
  48244. protected updateModel(xrFrame: XRFrame): void;
  48245. /**
  48246. * Get the filename and path for this controller's model
  48247. * @returns a map of filename and path
  48248. */
  48249. protected abstract _getFilenameAndPath(): {
  48250. filename: string;
  48251. path: string;
  48252. };
  48253. /**
  48254. * This function is called before the mesh is loaded. It checks for loading constraints.
  48255. * For example, this function can check if the GLB loader is available
  48256. * If this function returns false, the generic controller will be loaded instead
  48257. * @returns Is the client ready to load the mesh
  48258. */
  48259. protected abstract _getModelLoadingConstraints(): boolean;
  48260. /**
  48261. * This function will be called after the model was successfully loaded and can be used
  48262. * for mesh transformations before it is available for the user
  48263. * @param meshes the loaded meshes
  48264. */
  48265. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48266. /**
  48267. * Set the root mesh for this controller. Important for the WebXR controller class
  48268. * @param meshes the loaded meshes
  48269. */
  48270. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48271. /**
  48272. * A function executed each frame that updates the mesh (if needed)
  48273. * @param xrFrame the current xrFrame
  48274. */
  48275. protected abstract _updateModel(xrFrame: XRFrame): void;
  48276. private _getGenericFilenameAndPath;
  48277. private _getGenericParentMesh;
  48278. }
  48279. }
  48280. declare module BABYLON {
  48281. /**
  48282. * A generic trigger-only motion controller for WebXR
  48283. */
  48284. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48285. /**
  48286. * Static version of the profile id of this controller
  48287. */
  48288. static ProfileId: string;
  48289. profileId: string;
  48290. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48291. protected _getFilenameAndPath(): {
  48292. filename: string;
  48293. path: string;
  48294. };
  48295. protected _getModelLoadingConstraints(): boolean;
  48296. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48297. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48298. protected _updateModel(): void;
  48299. }
  48300. }
  48301. declare module BABYLON {
  48302. /**
  48303. * Class containing static functions to help procedurally build meshes
  48304. */
  48305. export class SphereBuilder {
  48306. /**
  48307. * Creates a sphere mesh
  48308. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48309. * * 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`)
  48310. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48311. * * 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
  48312. * * 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)
  48313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48314. * * 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
  48315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48316. * @param name defines the name of the mesh
  48317. * @param options defines the options used to create the mesh
  48318. * @param scene defines the hosting scene
  48319. * @returns the sphere mesh
  48320. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48321. */
  48322. static CreateSphere(name: string, options: {
  48323. segments?: number;
  48324. diameter?: number;
  48325. diameterX?: number;
  48326. diameterY?: number;
  48327. diameterZ?: number;
  48328. arc?: number;
  48329. slice?: number;
  48330. sideOrientation?: number;
  48331. frontUVs?: Vector4;
  48332. backUVs?: Vector4;
  48333. updatable?: boolean;
  48334. }, scene?: Nullable<Scene>): Mesh;
  48335. }
  48336. }
  48337. declare module BABYLON {
  48338. /**
  48339. * A profiled motion controller has its profile loaded from an online repository.
  48340. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48341. */
  48342. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48343. private _repositoryUrl;
  48344. private _buttonMeshMapping;
  48345. private _touchDots;
  48346. /**
  48347. * The profile ID of this controller. Will be populated when the controller initializes.
  48348. */
  48349. profileId: string;
  48350. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48351. dispose(): void;
  48352. protected _getFilenameAndPath(): {
  48353. filename: string;
  48354. path: string;
  48355. };
  48356. protected _getModelLoadingConstraints(): boolean;
  48357. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48358. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48359. protected _updateModel(_xrFrame: XRFrame): void;
  48360. }
  48361. }
  48362. declare module BABYLON {
  48363. /**
  48364. * A construction function type to create a new controller based on an xrInput object
  48365. */
  48366. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48367. /**
  48368. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48369. *
  48370. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48371. * it should be replaced with auto-loaded controllers.
  48372. *
  48373. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48374. */
  48375. export class WebXRMotionControllerManager {
  48376. private static _AvailableControllers;
  48377. private static _Fallbacks;
  48378. private static _ProfileLoadingPromises;
  48379. private static _ProfilesList;
  48380. /**
  48381. * The base URL of the online controller repository. Can be changed at any time.
  48382. */
  48383. static BaseRepositoryUrl: string;
  48384. /**
  48385. * Which repository gets priority - local or online
  48386. */
  48387. static PrioritizeOnlineRepository: boolean;
  48388. /**
  48389. * Use the online repository, or use only locally-defined controllers
  48390. */
  48391. static UseOnlineRepository: boolean;
  48392. /**
  48393. * Clear the cache used for profile loading and reload when requested again
  48394. */
  48395. static ClearProfilesCache(): void;
  48396. /**
  48397. * Register the default fallbacks.
  48398. * This function is called automatically when this file is imported.
  48399. */
  48400. static DefaultFallbacks(): void;
  48401. /**
  48402. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48403. * @param profileId the profile to which a fallback needs to be found
  48404. * @return an array with corresponding fallback profiles
  48405. */
  48406. static FindFallbackWithProfileId(profileId: string): string[];
  48407. /**
  48408. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48409. * The order of search:
  48410. *
  48411. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48412. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48413. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48414. * 4) return the generic trigger controller if none were found
  48415. *
  48416. * @param xrInput the xrInput to which a new controller is initialized
  48417. * @param scene the scene to which the model will be added
  48418. * @param forceProfile force a certain profile for this controller
  48419. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48420. */
  48421. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48422. /**
  48423. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48424. *
  48425. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48426. *
  48427. * @param type the profile type to register
  48428. * @param constructFunction the function to be called when loading this profile
  48429. */
  48430. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48431. /**
  48432. * Register a fallback to a specific profile.
  48433. * @param profileId the profileId that will receive the fallbacks
  48434. * @param fallbacks A list of fallback profiles
  48435. */
  48436. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48437. /**
  48438. * Will update the list of profiles available in the repository
  48439. * @return a promise that resolves to a map of profiles available online
  48440. */
  48441. static UpdateProfilesList(): Promise<{
  48442. [profile: string]: string;
  48443. }>;
  48444. private static _LoadProfileFromRepository;
  48445. private static _LoadProfilesFromAvailableControllers;
  48446. }
  48447. }
  48448. declare module BABYLON {
  48449. /**
  48450. * Configuration options for the WebXR controller creation
  48451. */
  48452. export interface IWebXRControllerOptions {
  48453. /**
  48454. * Should the controller mesh be animated when a user interacts with it
  48455. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48456. */
  48457. disableMotionControllerAnimation?: boolean;
  48458. /**
  48459. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48460. */
  48461. doNotLoadControllerMesh?: boolean;
  48462. /**
  48463. * Force a specific controller type for this controller.
  48464. * This can be used when creating your own profile or when testing different controllers
  48465. */
  48466. forceControllerProfile?: string;
  48467. /**
  48468. * Defines a rendering group ID for meshes that will be loaded.
  48469. * This is for the default controllers only.
  48470. */
  48471. renderingGroupId?: number;
  48472. }
  48473. /**
  48474. * Represents an XR controller
  48475. */
  48476. export class WebXRInputSource {
  48477. private _scene;
  48478. /** The underlying input source for the controller */
  48479. inputSource: XRInputSource;
  48480. private _options;
  48481. private _tmpVector;
  48482. private _uniqueId;
  48483. private _disposed;
  48484. /**
  48485. * 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
  48486. */
  48487. grip?: AbstractMesh;
  48488. /**
  48489. * If available, this is the gamepad object related to this controller.
  48490. * Using this object it is possible to get click events and trackpad changes of the
  48491. * webxr controller that is currently being used.
  48492. */
  48493. motionController?: WebXRAbstractMotionController;
  48494. /**
  48495. * Event that fires when the controller is removed/disposed.
  48496. * The object provided as event data is this controller, after associated assets were disposed.
  48497. * uniqueId is still available.
  48498. */
  48499. onDisposeObservable: Observable<WebXRInputSource>;
  48500. /**
  48501. * Will be triggered when the mesh associated with the motion controller is done loading.
  48502. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48503. * A shortened version of controller -> motion controller -> on mesh loaded.
  48504. */
  48505. onMeshLoadedObservable: Observable<AbstractMesh>;
  48506. /**
  48507. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48508. */
  48509. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48510. /**
  48511. * Pointer which can be used to select objects or attach a visible laser to
  48512. */
  48513. pointer: AbstractMesh;
  48514. /**
  48515. * Creates the input source object
  48516. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48517. * @param _scene the scene which the controller should be associated to
  48518. * @param inputSource the underlying input source for the controller
  48519. * @param _options options for this controller creation
  48520. */
  48521. constructor(_scene: Scene,
  48522. /** The underlying input source for the controller */
  48523. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48524. /**
  48525. * Get this controllers unique id
  48526. */
  48527. get uniqueId(): string;
  48528. /**
  48529. * Disposes of the object
  48530. */
  48531. dispose(): void;
  48532. /**
  48533. * Gets a world space ray coming from the pointer or grip
  48534. * @param result the resulting ray
  48535. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48536. */
  48537. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48538. /**
  48539. * Updates the controller pose based on the given XRFrame
  48540. * @param xrFrame xr frame to update the pose with
  48541. * @param referenceSpace reference space to use
  48542. */
  48543. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48544. }
  48545. }
  48546. declare module BABYLON {
  48547. /**
  48548. * The schema for initialization options of the XR Input class
  48549. */
  48550. export interface IWebXRInputOptions {
  48551. /**
  48552. * If set to true no model will be automatically loaded
  48553. */
  48554. doNotLoadControllerMeshes?: boolean;
  48555. /**
  48556. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48557. * If not found, the xr input profile data will be used.
  48558. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48559. */
  48560. forceInputProfile?: string;
  48561. /**
  48562. * Do not send a request to the controller repository to load the profile.
  48563. *
  48564. * Instead, use the controllers available in babylon itself.
  48565. */
  48566. disableOnlineControllerRepository?: boolean;
  48567. /**
  48568. * A custom URL for the controllers repository
  48569. */
  48570. customControllersRepositoryURL?: string;
  48571. /**
  48572. * Should the controller model's components not move according to the user input
  48573. */
  48574. disableControllerAnimation?: boolean;
  48575. /**
  48576. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48577. */
  48578. controllerOptions?: IWebXRControllerOptions;
  48579. }
  48580. /**
  48581. * XR input used to track XR inputs such as controllers/rays
  48582. */
  48583. export class WebXRInput implements IDisposable {
  48584. /**
  48585. * the xr session manager for this session
  48586. */
  48587. xrSessionManager: WebXRSessionManager;
  48588. /**
  48589. * the WebXR camera for this session. Mainly used for teleportation
  48590. */
  48591. xrCamera: WebXRCamera;
  48592. private readonly options;
  48593. /**
  48594. * XR controllers being tracked
  48595. */
  48596. controllers: Array<WebXRInputSource>;
  48597. private _frameObserver;
  48598. private _sessionEndedObserver;
  48599. private _sessionInitObserver;
  48600. /**
  48601. * Event when a controller has been connected/added
  48602. */
  48603. onControllerAddedObservable: Observable<WebXRInputSource>;
  48604. /**
  48605. * Event when a controller has been removed/disconnected
  48606. */
  48607. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48608. /**
  48609. * Initializes the WebXRInput
  48610. * @param xrSessionManager the xr session manager for this session
  48611. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48612. * @param options = initialization options for this xr input
  48613. */
  48614. constructor(
  48615. /**
  48616. * the xr session manager for this session
  48617. */
  48618. xrSessionManager: WebXRSessionManager,
  48619. /**
  48620. * the WebXR camera for this session. Mainly used for teleportation
  48621. */
  48622. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48623. private _onInputSourcesChange;
  48624. private _addAndRemoveControllers;
  48625. /**
  48626. * Disposes of the object
  48627. */
  48628. dispose(): void;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /**
  48633. * This is the base class for all WebXR features.
  48634. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48635. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48636. */
  48637. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48638. protected _xrSessionManager: WebXRSessionManager;
  48639. private _attached;
  48640. private _removeOnDetach;
  48641. /**
  48642. * Should auto-attach be disabled?
  48643. */
  48644. disableAutoAttach: boolean;
  48645. /**
  48646. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48647. */
  48648. xrNativeFeatureName: string;
  48649. /**
  48650. * Construct a new (abstract) WebXR feature
  48651. * @param _xrSessionManager the xr session manager for this feature
  48652. */
  48653. constructor(_xrSessionManager: WebXRSessionManager);
  48654. /**
  48655. * Is this feature attached
  48656. */
  48657. get attached(): boolean;
  48658. /**
  48659. * attach this feature
  48660. *
  48661. * @param force should attachment be forced (even when already attached)
  48662. * @returns true if successful, false is failed or already attached
  48663. */
  48664. attach(force?: boolean): boolean;
  48665. /**
  48666. * detach this feature.
  48667. *
  48668. * @returns true if successful, false if failed or already detached
  48669. */
  48670. detach(): boolean;
  48671. /**
  48672. * Dispose this feature and all of the resources attached
  48673. */
  48674. dispose(): void;
  48675. /**
  48676. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48677. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48678. *
  48679. * @returns whether or not the feature is compatible in this environment
  48680. */
  48681. isCompatible(): boolean;
  48682. /**
  48683. * This is used to register callbacks that will automatically be removed when detach is called.
  48684. * @param observable the observable to which the observer will be attached
  48685. * @param callback the callback to register
  48686. */
  48687. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48688. /**
  48689. * Code in this function will be executed on each xrFrame received from the browser.
  48690. * This function will not execute after the feature is detached.
  48691. * @param _xrFrame the current frame
  48692. */
  48693. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48694. }
  48695. }
  48696. declare module BABYLON {
  48697. /**
  48698. * Renders a layer on top of an existing scene
  48699. */
  48700. export class UtilityLayerRenderer implements IDisposable {
  48701. /** the original scene that will be rendered on top of */
  48702. originalScene: Scene;
  48703. private _pointerCaptures;
  48704. private _lastPointerEvents;
  48705. private static _DefaultUtilityLayer;
  48706. private static _DefaultKeepDepthUtilityLayer;
  48707. private _sharedGizmoLight;
  48708. private _renderCamera;
  48709. /**
  48710. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48711. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48712. * @returns the camera that is used when rendering the utility layer
  48713. */
  48714. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48715. /**
  48716. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48717. * @param cam the camera that should be used when rendering the utility layer
  48718. */
  48719. setRenderCamera(cam: Nullable<Camera>): void;
  48720. /**
  48721. * @hidden
  48722. * Light which used by gizmos to get light shading
  48723. */
  48724. _getSharedGizmoLight(): HemisphericLight;
  48725. /**
  48726. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48727. */
  48728. pickUtilitySceneFirst: boolean;
  48729. /**
  48730. * 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)
  48731. */
  48732. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48733. /**
  48734. * 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)
  48735. */
  48736. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48737. /**
  48738. * The scene that is rendered on top of the original scene
  48739. */
  48740. utilityLayerScene: Scene;
  48741. /**
  48742. * If the utility layer should automatically be rendered on top of existing scene
  48743. */
  48744. shouldRender: boolean;
  48745. /**
  48746. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48747. */
  48748. onlyCheckPointerDownEvents: boolean;
  48749. /**
  48750. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48751. */
  48752. processAllEvents: boolean;
  48753. /**
  48754. * Observable raised when the pointer move from the utility layer scene to the main scene
  48755. */
  48756. onPointerOutObservable: Observable<number>;
  48757. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48758. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48759. private _afterRenderObserver;
  48760. private _sceneDisposeObserver;
  48761. private _originalPointerObserver;
  48762. /**
  48763. * Instantiates a UtilityLayerRenderer
  48764. * @param originalScene the original scene that will be rendered on top of
  48765. * @param handleEvents boolean indicating if the utility layer should handle events
  48766. */
  48767. constructor(
  48768. /** the original scene that will be rendered on top of */
  48769. originalScene: Scene, handleEvents?: boolean);
  48770. private _notifyObservers;
  48771. /**
  48772. * Renders the utility layers scene on top of the original scene
  48773. */
  48774. render(): void;
  48775. /**
  48776. * Disposes of the renderer
  48777. */
  48778. dispose(): void;
  48779. private _updateCamera;
  48780. }
  48781. }
  48782. declare module BABYLON {
  48783. /**
  48784. * Options interface for the pointer selection module
  48785. */
  48786. export interface IWebXRControllerPointerSelectionOptions {
  48787. /**
  48788. * if provided, this scene will be used to render meshes.
  48789. */
  48790. customUtilityLayerScene?: Scene;
  48791. /**
  48792. * 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)
  48793. * If not disabled, the last picked point will be used to execute a pointer up event
  48794. * If disabled, pointer up event will be triggered right after the pointer down event.
  48795. * Used in screen and gaze target ray mode only
  48796. */
  48797. disablePointerUpOnTouchOut: boolean;
  48798. /**
  48799. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48800. */
  48801. forceGazeMode: boolean;
  48802. /**
  48803. * 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
  48804. * to start a new countdown to the pointer down event.
  48805. * Defaults to 1.
  48806. */
  48807. gazeModePointerMovedFactor?: number;
  48808. /**
  48809. * Different button type to use instead of the main component
  48810. */
  48811. overrideButtonId?: string;
  48812. /**
  48813. * use this rendering group id for the meshes (optional)
  48814. */
  48815. renderingGroupId?: number;
  48816. /**
  48817. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48818. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48819. * 3000 means 3 seconds between pointing at something and selecting it
  48820. */
  48821. timeToSelect?: number;
  48822. /**
  48823. * Should meshes created here be added to a utility layer or the main scene
  48824. */
  48825. useUtilityLayer?: boolean;
  48826. /**
  48827. * Optional WebXR camera to be used for gaze selection
  48828. */
  48829. gazeCamera?: WebXRCamera;
  48830. /**
  48831. * the xr input to use with this pointer selection
  48832. */
  48833. xrInput: WebXRInput;
  48834. }
  48835. /**
  48836. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48837. */
  48838. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48839. private readonly _options;
  48840. private static _idCounter;
  48841. private _attachController;
  48842. private _controllers;
  48843. private _scene;
  48844. private _tmpVectorForPickCompare;
  48845. /**
  48846. * The module's name
  48847. */
  48848. static readonly Name: string;
  48849. /**
  48850. * The (Babylon) version of this module.
  48851. * This is an integer representing the implementation version.
  48852. * This number does not correspond to the WebXR specs version
  48853. */
  48854. static readonly Version: number;
  48855. /**
  48856. * Disable lighting on the laser pointer (so it will always be visible)
  48857. */
  48858. disablePointerLighting: boolean;
  48859. /**
  48860. * Disable lighting on the selection mesh (so it will always be visible)
  48861. */
  48862. disableSelectionMeshLighting: boolean;
  48863. /**
  48864. * Should the laser pointer be displayed
  48865. */
  48866. displayLaserPointer: boolean;
  48867. /**
  48868. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48869. */
  48870. displaySelectionMesh: boolean;
  48871. /**
  48872. * This color will be set to the laser pointer when selection is triggered
  48873. */
  48874. laserPointerPickedColor: Color3;
  48875. /**
  48876. * Default color of the laser pointer
  48877. */
  48878. laserPointerDefaultColor: Color3;
  48879. /**
  48880. * default color of the selection ring
  48881. */
  48882. selectionMeshDefaultColor: Color3;
  48883. /**
  48884. * This color will be applied to the selection ring when selection is triggered
  48885. */
  48886. selectionMeshPickedColor: Color3;
  48887. /**
  48888. * Optional filter to be used for ray selection. This predicate shares behavior with
  48889. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48890. */
  48891. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48892. /**
  48893. * constructs a new background remover module
  48894. * @param _xrSessionManager the session manager for this module
  48895. * @param _options read-only options to be used in this module
  48896. */
  48897. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48898. /**
  48899. * attach this feature
  48900. * Will usually be called by the features manager
  48901. *
  48902. * @returns true if successful.
  48903. */
  48904. attach(): boolean;
  48905. /**
  48906. * detach this feature.
  48907. * Will usually be called by the features manager
  48908. *
  48909. * @returns true if successful.
  48910. */
  48911. detach(): boolean;
  48912. /**
  48913. * Will get the mesh under a specific pointer.
  48914. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48915. * @param controllerId the controllerId to check
  48916. * @returns The mesh under pointer or null if no mesh is under the pointer
  48917. */
  48918. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48919. /**
  48920. * Get the xr controller that correlates to the pointer id in the pointer event
  48921. *
  48922. * @param id the pointer id to search for
  48923. * @returns the controller that correlates to this id or null if not found
  48924. */
  48925. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48926. protected _onXRFrame(_xrFrame: XRFrame): void;
  48927. private _attachGazeMode;
  48928. private _attachScreenRayMode;
  48929. private _attachTrackedPointerRayMode;
  48930. private _convertNormalToDirectionOfRay;
  48931. private _detachController;
  48932. private _generateNewMeshPair;
  48933. private _pickingMoved;
  48934. private _updatePointerDistance;
  48935. /** @hidden */
  48936. get lasterPointerDefaultColor(): Color3;
  48937. }
  48938. }
  48939. declare module BABYLON {
  48940. /**
  48941. * Button which can be used to enter a different mode of XR
  48942. */
  48943. export class WebXREnterExitUIButton {
  48944. /** button element */
  48945. element: HTMLElement;
  48946. /** XR initialization options for the button */
  48947. sessionMode: XRSessionMode;
  48948. /** Reference space type */
  48949. referenceSpaceType: XRReferenceSpaceType;
  48950. /**
  48951. * Creates a WebXREnterExitUIButton
  48952. * @param element button element
  48953. * @param sessionMode XR initialization session mode
  48954. * @param referenceSpaceType the type of reference space to be used
  48955. */
  48956. constructor(
  48957. /** button element */
  48958. element: HTMLElement,
  48959. /** XR initialization options for the button */
  48960. sessionMode: XRSessionMode,
  48961. /** Reference space type */
  48962. referenceSpaceType: XRReferenceSpaceType);
  48963. /**
  48964. * Extendable function which can be used to update the button's visuals when the state changes
  48965. * @param activeButton the current active button in the UI
  48966. */
  48967. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48968. }
  48969. /**
  48970. * Options to create the webXR UI
  48971. */
  48972. export class WebXREnterExitUIOptions {
  48973. /**
  48974. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48975. */
  48976. customButtons?: Array<WebXREnterExitUIButton>;
  48977. /**
  48978. * A reference space type to use when creating the default button.
  48979. * Default is local-floor
  48980. */
  48981. referenceSpaceType?: XRReferenceSpaceType;
  48982. /**
  48983. * Context to enter xr with
  48984. */
  48985. renderTarget?: Nullable<WebXRRenderTarget>;
  48986. /**
  48987. * A session mode to use when creating the default button.
  48988. * Default is immersive-vr
  48989. */
  48990. sessionMode?: XRSessionMode;
  48991. /**
  48992. * A list of optional features to init the session with
  48993. */
  48994. optionalFeatures?: string[];
  48995. /**
  48996. * A list of optional features to init the session with
  48997. */
  48998. requiredFeatures?: string[];
  48999. }
  49000. /**
  49001. * UI to allow the user to enter/exit XR mode
  49002. */
  49003. export class WebXREnterExitUI implements IDisposable {
  49004. private scene;
  49005. /** version of the options passed to this UI */
  49006. options: WebXREnterExitUIOptions;
  49007. private _activeButton;
  49008. private _buttons;
  49009. /**
  49010. * The HTML Div Element to which buttons are added.
  49011. */
  49012. readonly overlay: HTMLDivElement;
  49013. /**
  49014. * Fired every time the active button is changed.
  49015. *
  49016. * When xr is entered via a button that launches xr that button will be the callback parameter
  49017. *
  49018. * When exiting xr the callback parameter will be null)
  49019. */
  49020. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49021. /**
  49022. *
  49023. * @param scene babylon scene object to use
  49024. * @param options (read-only) version of the options passed to this UI
  49025. */
  49026. private constructor();
  49027. /**
  49028. * Creates UI to allow the user to enter/exit XR mode
  49029. * @param scene the scene to add the ui to
  49030. * @param helper the xr experience helper to enter/exit xr with
  49031. * @param options options to configure the UI
  49032. * @returns the created ui
  49033. */
  49034. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49035. /**
  49036. * Disposes of the XR UI component
  49037. */
  49038. dispose(): void;
  49039. private _updateButtons;
  49040. }
  49041. }
  49042. declare module BABYLON {
  49043. /**
  49044. * Class containing static functions to help procedurally build meshes
  49045. */
  49046. export class LinesBuilder {
  49047. /**
  49048. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49049. * * 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
  49050. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49051. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49052. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49053. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49054. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49055. * * 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
  49056. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49059. * @param name defines the name of the new line system
  49060. * @param options defines the options used to create the line system
  49061. * @param scene defines the hosting scene
  49062. * @returns a new line system mesh
  49063. */
  49064. static CreateLineSystem(name: string, options: {
  49065. lines: Vector3[][];
  49066. updatable?: boolean;
  49067. instance?: Nullable<LinesMesh>;
  49068. colors?: Nullable<Color4[][]>;
  49069. useVertexAlpha?: boolean;
  49070. }, scene: Nullable<Scene>): LinesMesh;
  49071. /**
  49072. * Creates a line mesh
  49073. * 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
  49074. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49075. * * The parameter `points` is an array successive Vector3
  49076. * * 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
  49077. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49078. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49079. * * When updating an instance, remember that only point positions can change, not the number of points
  49080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49082. * @param name defines the name of the new line system
  49083. * @param options defines the options used to create the line system
  49084. * @param scene defines the hosting scene
  49085. * @returns a new line mesh
  49086. */
  49087. static CreateLines(name: string, options: {
  49088. points: Vector3[];
  49089. updatable?: boolean;
  49090. instance?: Nullable<LinesMesh>;
  49091. colors?: Color4[];
  49092. useVertexAlpha?: boolean;
  49093. }, scene?: Nullable<Scene>): LinesMesh;
  49094. /**
  49095. * Creates a dashed line mesh
  49096. * * 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
  49097. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49098. * * The parameter `points` is an array successive Vector3
  49099. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49100. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49101. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49102. * * 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
  49103. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49104. * * When updating an instance, remember that only point positions can change, not the number of points
  49105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49106. * @param name defines the name of the mesh
  49107. * @param options defines the options used to create the mesh
  49108. * @param scene defines the hosting scene
  49109. * @returns the dashed line mesh
  49110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49111. */
  49112. static CreateDashedLines(name: string, options: {
  49113. points: Vector3[];
  49114. dashSize?: number;
  49115. gapSize?: number;
  49116. dashNb?: number;
  49117. updatable?: boolean;
  49118. instance?: LinesMesh;
  49119. useVertexAlpha?: boolean;
  49120. }, scene?: Nullable<Scene>): LinesMesh;
  49121. }
  49122. }
  49123. declare module BABYLON {
  49124. /**
  49125. * Construction options for a timer
  49126. */
  49127. export interface ITimerOptions<T> {
  49128. /**
  49129. * Time-to-end
  49130. */
  49131. timeout: number;
  49132. /**
  49133. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49134. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49135. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49136. */
  49137. contextObservable: Observable<T>;
  49138. /**
  49139. * Optional parameters when adding an observer to the observable
  49140. */
  49141. observableParameters?: {
  49142. mask?: number;
  49143. insertFirst?: boolean;
  49144. scope?: any;
  49145. };
  49146. /**
  49147. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49148. */
  49149. breakCondition?: (data?: ITimerData<T>) => boolean;
  49150. /**
  49151. * Will be triggered when the time condition has met
  49152. */
  49153. onEnded?: (data: ITimerData<any>) => void;
  49154. /**
  49155. * Will be triggered when the break condition has met (prematurely ended)
  49156. */
  49157. onAborted?: (data: ITimerData<any>) => void;
  49158. /**
  49159. * Optional function to execute on each tick (or count)
  49160. */
  49161. onTick?: (data: ITimerData<any>) => void;
  49162. }
  49163. /**
  49164. * An interface defining the data sent by the timer
  49165. */
  49166. export interface ITimerData<T> {
  49167. /**
  49168. * When did it start
  49169. */
  49170. startTime: number;
  49171. /**
  49172. * Time now
  49173. */
  49174. currentTime: number;
  49175. /**
  49176. * Time passed since started
  49177. */
  49178. deltaTime: number;
  49179. /**
  49180. * How much is completed, in [0.0...1.0].
  49181. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49182. */
  49183. completeRate: number;
  49184. /**
  49185. * What the registered observable sent in the last count
  49186. */
  49187. payload: T;
  49188. }
  49189. /**
  49190. * The current state of the timer
  49191. */
  49192. export enum TimerState {
  49193. /**
  49194. * Timer initialized, not yet started
  49195. */
  49196. INIT = 0,
  49197. /**
  49198. * Timer started and counting
  49199. */
  49200. STARTED = 1,
  49201. /**
  49202. * Timer ended (whether aborted or time reached)
  49203. */
  49204. ENDED = 2
  49205. }
  49206. /**
  49207. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49208. *
  49209. * @param options options with which to initialize this timer
  49210. */
  49211. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49212. /**
  49213. * An advanced implementation of a timer class
  49214. */
  49215. export class AdvancedTimer<T = any> implements IDisposable {
  49216. /**
  49217. * Will notify each time the timer calculates the remaining time
  49218. */
  49219. onEachCountObservable: Observable<ITimerData<T>>;
  49220. /**
  49221. * Will trigger when the timer was aborted due to the break condition
  49222. */
  49223. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49224. /**
  49225. * Will trigger when the timer ended successfully
  49226. */
  49227. onTimerEndedObservable: Observable<ITimerData<T>>;
  49228. /**
  49229. * Will trigger when the timer state has changed
  49230. */
  49231. onStateChangedObservable: Observable<TimerState>;
  49232. private _observer;
  49233. private _contextObservable;
  49234. private _observableParameters;
  49235. private _startTime;
  49236. private _timer;
  49237. private _state;
  49238. private _breakCondition;
  49239. private _timeToEnd;
  49240. private _breakOnNextTick;
  49241. /**
  49242. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49243. * @param options construction options for this advanced timer
  49244. */
  49245. constructor(options: ITimerOptions<T>);
  49246. /**
  49247. * set a breaking condition for this timer. Default is to never break during count
  49248. * @param predicate the new break condition. Returns true to break, false otherwise
  49249. */
  49250. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49251. /**
  49252. * Reset ALL associated observables in this advanced timer
  49253. */
  49254. clearObservables(): void;
  49255. /**
  49256. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49257. *
  49258. * @param timeToEnd how much time to measure until timer ended
  49259. */
  49260. start(timeToEnd?: number): void;
  49261. /**
  49262. * Will force a stop on the next tick.
  49263. */
  49264. stop(): void;
  49265. /**
  49266. * Dispose this timer, clearing all resources
  49267. */
  49268. dispose(): void;
  49269. private _setState;
  49270. private _tick;
  49271. private _stop;
  49272. }
  49273. }
  49274. declare module BABYLON {
  49275. /**
  49276. * The options container for the teleportation module
  49277. */
  49278. export interface IWebXRTeleportationOptions {
  49279. /**
  49280. * if provided, this scene will be used to render meshes.
  49281. */
  49282. customUtilityLayerScene?: Scene;
  49283. /**
  49284. * Values to configure the default target mesh
  49285. */
  49286. defaultTargetMeshOptions?: {
  49287. /**
  49288. * Fill color of the teleportation area
  49289. */
  49290. teleportationFillColor?: string;
  49291. /**
  49292. * Border color for the teleportation area
  49293. */
  49294. teleportationBorderColor?: string;
  49295. /**
  49296. * Disable the mesh's animation sequence
  49297. */
  49298. disableAnimation?: boolean;
  49299. /**
  49300. * Disable lighting on the material or the ring and arrow
  49301. */
  49302. disableLighting?: boolean;
  49303. /**
  49304. * Override the default material of the torus and arrow
  49305. */
  49306. torusArrowMaterial?: Material;
  49307. };
  49308. /**
  49309. * A list of meshes to use as floor meshes.
  49310. * Meshes can be added and removed after initializing the feature using the
  49311. * addFloorMesh and removeFloorMesh functions
  49312. * If empty, rotation will still work
  49313. */
  49314. floorMeshes?: AbstractMesh[];
  49315. /**
  49316. * use this rendering group id for the meshes (optional)
  49317. */
  49318. renderingGroupId?: number;
  49319. /**
  49320. * Should teleportation move only to snap points
  49321. */
  49322. snapPointsOnly?: boolean;
  49323. /**
  49324. * An array of points to which the teleportation will snap to.
  49325. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49326. */
  49327. snapPositions?: Vector3[];
  49328. /**
  49329. * How close should the teleportation ray be in order to snap to position.
  49330. * Default to 0.8 units (meters)
  49331. */
  49332. snapToPositionRadius?: number;
  49333. /**
  49334. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49335. * If you want to support rotation, make sure your mesh has a direction indicator.
  49336. *
  49337. * When left untouched, the default mesh will be initialized.
  49338. */
  49339. teleportationTargetMesh?: AbstractMesh;
  49340. /**
  49341. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49342. */
  49343. timeToTeleport?: number;
  49344. /**
  49345. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49346. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49347. */
  49348. useMainComponentOnly?: boolean;
  49349. /**
  49350. * Should meshes created here be added to a utility layer or the main scene
  49351. */
  49352. useUtilityLayer?: boolean;
  49353. /**
  49354. * Babylon XR Input class for controller
  49355. */
  49356. xrInput: WebXRInput;
  49357. }
  49358. /**
  49359. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49360. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49361. * the input of the attached controllers.
  49362. */
  49363. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49364. private _options;
  49365. private _controllers;
  49366. private _currentTeleportationControllerId;
  49367. private _floorMeshes;
  49368. private _quadraticBezierCurve;
  49369. private _selectionFeature;
  49370. private _snapToPositions;
  49371. private _snappedToPoint;
  49372. private _teleportationRingMaterial?;
  49373. private _tmpRay;
  49374. private _tmpVector;
  49375. /**
  49376. * The module's name
  49377. */
  49378. static readonly Name: string;
  49379. /**
  49380. * The (Babylon) version of this module.
  49381. * This is an integer representing the implementation version.
  49382. * This number does not correspond to the webxr specs version
  49383. */
  49384. static readonly Version: number;
  49385. /**
  49386. * Is movement backwards enabled
  49387. */
  49388. backwardsMovementEnabled: boolean;
  49389. /**
  49390. * Distance to travel when moving backwards
  49391. */
  49392. backwardsTeleportationDistance: number;
  49393. /**
  49394. * The distance from the user to the inspection point in the direction of the controller
  49395. * A higher number will allow the user to move further
  49396. * defaults to 5 (meters, in xr units)
  49397. */
  49398. parabolicCheckRadius: number;
  49399. /**
  49400. * Should the module support parabolic ray on top of direct ray
  49401. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49402. * Very helpful when moving between floors / different heights
  49403. */
  49404. parabolicRayEnabled: boolean;
  49405. /**
  49406. * How much rotation should be applied when rotating right and left
  49407. */
  49408. rotationAngle: number;
  49409. /**
  49410. * Is rotation enabled when moving forward?
  49411. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49412. */
  49413. rotationEnabled: boolean;
  49414. /**
  49415. * constructs a new anchor system
  49416. * @param _xrSessionManager an instance of WebXRSessionManager
  49417. * @param _options configuration object for this feature
  49418. */
  49419. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49420. /**
  49421. * Get the snapPointsOnly flag
  49422. */
  49423. get snapPointsOnly(): boolean;
  49424. /**
  49425. * Sets the snapPointsOnly flag
  49426. * @param snapToPoints should teleportation be exclusively to snap points
  49427. */
  49428. set snapPointsOnly(snapToPoints: boolean);
  49429. /**
  49430. * Add a new mesh to the floor meshes array
  49431. * @param mesh the mesh to use as floor mesh
  49432. */
  49433. addFloorMesh(mesh: AbstractMesh): void;
  49434. /**
  49435. * Add a new snap-to point to fix teleportation to this position
  49436. * @param newSnapPoint The new Snap-To point
  49437. */
  49438. addSnapPoint(newSnapPoint: Vector3): void;
  49439. attach(): boolean;
  49440. detach(): boolean;
  49441. dispose(): void;
  49442. /**
  49443. * Remove a mesh from the floor meshes array
  49444. * @param mesh the mesh to remove
  49445. */
  49446. removeFloorMesh(mesh: AbstractMesh): void;
  49447. /**
  49448. * Remove a mesh from the floor meshes array using its name
  49449. * @param name the mesh name to remove
  49450. */
  49451. removeFloorMeshByName(name: string): void;
  49452. /**
  49453. * 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
  49454. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49455. * @returns was the point found and removed or not
  49456. */
  49457. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49458. /**
  49459. * This function sets a selection feature that will be disabled when
  49460. * the forward ray is shown and will be reattached when hidden.
  49461. * This is used to remove the selection rays when moving.
  49462. * @param selectionFeature the feature to disable when forward movement is enabled
  49463. */
  49464. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49465. protected _onXRFrame(_xrFrame: XRFrame): void;
  49466. private _attachController;
  49467. private _createDefaultTargetMesh;
  49468. private _detachController;
  49469. private _findClosestSnapPointWithRadius;
  49470. private _setTargetMeshPosition;
  49471. private _setTargetMeshVisibility;
  49472. private _showParabolicPath;
  49473. private _teleportForward;
  49474. }
  49475. }
  49476. declare module BABYLON {
  49477. /**
  49478. * Options for the default xr helper
  49479. */
  49480. export class WebXRDefaultExperienceOptions {
  49481. /**
  49482. * Enable or disable default UI to enter XR
  49483. */
  49484. disableDefaultUI?: boolean;
  49485. /**
  49486. * Should teleportation not initialize. defaults to false.
  49487. */
  49488. disableTeleportation?: boolean;
  49489. /**
  49490. * Floor meshes that will be used for teleport
  49491. */
  49492. floorMeshes?: Array<AbstractMesh>;
  49493. /**
  49494. * If set to true, the first frame will not be used to reset position
  49495. * The first frame is mainly used when copying transformation from the old camera
  49496. * Mainly used in AR
  49497. */
  49498. ignoreNativeCameraTransformation?: boolean;
  49499. /**
  49500. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49501. */
  49502. inputOptions?: IWebXRInputOptions;
  49503. /**
  49504. * optional configuration for the output canvas
  49505. */
  49506. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49507. /**
  49508. * optional UI options. This can be used among other to change session mode and reference space type
  49509. */
  49510. uiOptions?: WebXREnterExitUIOptions;
  49511. /**
  49512. * When loading teleportation and pointer select, use stable versions instead of latest.
  49513. */
  49514. useStablePlugins?: boolean;
  49515. /**
  49516. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49517. */
  49518. renderingGroupId?: number;
  49519. /**
  49520. * A list of optional features to init the session with
  49521. * If set to true, all features we support will be added
  49522. */
  49523. optionalFeatures?: boolean | string[];
  49524. }
  49525. /**
  49526. * Default experience which provides a similar setup to the previous webVRExperience
  49527. */
  49528. export class WebXRDefaultExperience {
  49529. /**
  49530. * Base experience
  49531. */
  49532. baseExperience: WebXRExperienceHelper;
  49533. /**
  49534. * Enables ui for entering/exiting xr
  49535. */
  49536. enterExitUI: WebXREnterExitUI;
  49537. /**
  49538. * Input experience extension
  49539. */
  49540. input: WebXRInput;
  49541. /**
  49542. * Enables laser pointer and selection
  49543. */
  49544. pointerSelection: WebXRControllerPointerSelection;
  49545. /**
  49546. * Default target xr should render to
  49547. */
  49548. renderTarget: WebXRRenderTarget;
  49549. /**
  49550. * Enables teleportation
  49551. */
  49552. teleportation: WebXRMotionControllerTeleportation;
  49553. private constructor();
  49554. /**
  49555. * Creates the default xr experience
  49556. * @param scene scene
  49557. * @param options options for basic configuration
  49558. * @returns resulting WebXRDefaultExperience
  49559. */
  49560. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49561. /**
  49562. * DIsposes of the experience helper
  49563. */
  49564. dispose(): void;
  49565. }
  49566. }
  49567. declare module BABYLON {
  49568. /**
  49569. * Options to modify the vr teleportation behavior.
  49570. */
  49571. export interface VRTeleportationOptions {
  49572. /**
  49573. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49574. */
  49575. floorMeshName?: string;
  49576. /**
  49577. * A list of meshes to be used as the teleportation floor. (default: empty)
  49578. */
  49579. floorMeshes?: Mesh[];
  49580. /**
  49581. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49582. */
  49583. teleportationMode?: number;
  49584. /**
  49585. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49586. */
  49587. teleportationTime?: number;
  49588. /**
  49589. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49590. */
  49591. teleportationSpeed?: number;
  49592. /**
  49593. * The easing function used in the animation or null for Linear. (default CircleEase)
  49594. */
  49595. easingFunction?: EasingFunction;
  49596. }
  49597. /**
  49598. * Options to modify the vr experience helper's behavior.
  49599. */
  49600. export interface VRExperienceHelperOptions extends WebVROptions {
  49601. /**
  49602. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49603. */
  49604. createDeviceOrientationCamera?: boolean;
  49605. /**
  49606. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49607. */
  49608. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49609. /**
  49610. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49611. */
  49612. laserToggle?: boolean;
  49613. /**
  49614. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49615. */
  49616. floorMeshes?: Mesh[];
  49617. /**
  49618. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49619. */
  49620. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49621. /**
  49622. * Defines if WebXR should be used instead of WebVR (if available)
  49623. */
  49624. useXR?: boolean;
  49625. }
  49626. /**
  49627. * Event containing information after VR has been entered
  49628. */
  49629. export class OnAfterEnteringVRObservableEvent {
  49630. /**
  49631. * If entering vr was successful
  49632. */
  49633. success: boolean;
  49634. }
  49635. /**
  49636. * Helps to quickly add VR support to an existing scene.
  49637. * See https://doc.babylonjs.com/how_to/webvr_helper
  49638. */
  49639. export class VRExperienceHelper {
  49640. /** Options to modify the vr experience helper's behavior. */
  49641. webVROptions: VRExperienceHelperOptions;
  49642. private _scene;
  49643. private _position;
  49644. private _btnVR;
  49645. private _btnVRDisplayed;
  49646. private _webVRsupported;
  49647. private _webVRready;
  49648. private _webVRrequesting;
  49649. private _webVRpresenting;
  49650. private _hasEnteredVR;
  49651. private _fullscreenVRpresenting;
  49652. private _inputElement;
  49653. private _webVRCamera;
  49654. private _vrDeviceOrientationCamera;
  49655. private _deviceOrientationCamera;
  49656. private _existingCamera;
  49657. private _onKeyDown;
  49658. private _onVrDisplayPresentChange;
  49659. private _onVRDisplayChanged;
  49660. private _onVRRequestPresentStart;
  49661. private _onVRRequestPresentComplete;
  49662. /**
  49663. * 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)
  49664. */
  49665. enableGazeEvenWhenNoPointerLock: boolean;
  49666. /**
  49667. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49668. */
  49669. exitVROnDoubleTap: boolean;
  49670. /**
  49671. * Observable raised right before entering VR.
  49672. */
  49673. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49674. /**
  49675. * Observable raised when entering VR has completed.
  49676. */
  49677. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49678. /**
  49679. * Observable raised when exiting VR.
  49680. */
  49681. onExitingVRObservable: Observable<VRExperienceHelper>;
  49682. /**
  49683. * Observable raised when controller mesh is loaded.
  49684. */
  49685. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49686. /** Return this.onEnteringVRObservable
  49687. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49688. */
  49689. get onEnteringVR(): Observable<VRExperienceHelper>;
  49690. /** Return this.onExitingVRObservable
  49691. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49692. */
  49693. get onExitingVR(): Observable<VRExperienceHelper>;
  49694. /** Return this.onControllerMeshLoadedObservable
  49695. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49696. */
  49697. get onControllerMeshLoaded(): Observable<WebVRController>;
  49698. private _rayLength;
  49699. private _useCustomVRButton;
  49700. private _teleportationRequested;
  49701. private _teleportActive;
  49702. private _floorMeshName;
  49703. private _floorMeshesCollection;
  49704. private _teleportationMode;
  49705. private _teleportationTime;
  49706. private _teleportationSpeed;
  49707. private _teleportationEasing;
  49708. private _rotationAllowed;
  49709. private _teleportBackwardsVector;
  49710. private _teleportationTarget;
  49711. private _isDefaultTeleportationTarget;
  49712. private _postProcessMove;
  49713. private _teleportationFillColor;
  49714. private _teleportationBorderColor;
  49715. private _rotationAngle;
  49716. private _haloCenter;
  49717. private _cameraGazer;
  49718. private _padSensibilityUp;
  49719. private _padSensibilityDown;
  49720. private _leftController;
  49721. private _rightController;
  49722. private _gazeColor;
  49723. private _laserColor;
  49724. private _pickedLaserColor;
  49725. private _pickedGazeColor;
  49726. /**
  49727. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49728. */
  49729. onNewMeshSelected: Observable<AbstractMesh>;
  49730. /**
  49731. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49732. * This observable will provide the mesh and the controller used to select the mesh
  49733. */
  49734. onMeshSelectedWithController: Observable<{
  49735. mesh: AbstractMesh;
  49736. controller: WebVRController;
  49737. }>;
  49738. /**
  49739. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49740. */
  49741. onNewMeshPicked: Observable<PickingInfo>;
  49742. private _circleEase;
  49743. /**
  49744. * Observable raised before camera teleportation
  49745. */
  49746. onBeforeCameraTeleport: Observable<Vector3>;
  49747. /**
  49748. * Observable raised after camera teleportation
  49749. */
  49750. onAfterCameraTeleport: Observable<Vector3>;
  49751. /**
  49752. * Observable raised when current selected mesh gets unselected
  49753. */
  49754. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49755. private _raySelectionPredicate;
  49756. /**
  49757. * To be optionaly changed by user to define custom ray selection
  49758. */
  49759. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49760. /**
  49761. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49762. */
  49763. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49764. /**
  49765. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49766. */
  49767. teleportationEnabled: boolean;
  49768. private _defaultHeight;
  49769. private _teleportationInitialized;
  49770. private _interactionsEnabled;
  49771. private _interactionsRequested;
  49772. private _displayGaze;
  49773. private _displayLaserPointer;
  49774. /**
  49775. * The mesh used to display where the user is going to teleport.
  49776. */
  49777. get teleportationTarget(): Mesh;
  49778. /**
  49779. * Sets the mesh to be used to display where the user is going to teleport.
  49780. */
  49781. set teleportationTarget(value: Mesh);
  49782. /**
  49783. * 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
  49784. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49785. * See https://doc.babylonjs.com/resources/baking_transformations
  49786. */
  49787. get gazeTrackerMesh(): Mesh;
  49788. set gazeTrackerMesh(value: Mesh);
  49789. /**
  49790. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49791. */
  49792. updateGazeTrackerScale: boolean;
  49793. /**
  49794. * If the gaze trackers color should be updated when selecting meshes
  49795. */
  49796. updateGazeTrackerColor: boolean;
  49797. /**
  49798. * If the controller laser color should be updated when selecting meshes
  49799. */
  49800. updateControllerLaserColor: boolean;
  49801. /**
  49802. * The gaze tracking mesh corresponding to the left controller
  49803. */
  49804. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49805. /**
  49806. * The gaze tracking mesh corresponding to the right controller
  49807. */
  49808. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49809. /**
  49810. * If the ray of the gaze should be displayed.
  49811. */
  49812. get displayGaze(): boolean;
  49813. /**
  49814. * Sets if the ray of the gaze should be displayed.
  49815. */
  49816. set displayGaze(value: boolean);
  49817. /**
  49818. * If the ray of the LaserPointer should be displayed.
  49819. */
  49820. get displayLaserPointer(): boolean;
  49821. /**
  49822. * Sets if the ray of the LaserPointer should be displayed.
  49823. */
  49824. set displayLaserPointer(value: boolean);
  49825. /**
  49826. * The deviceOrientationCamera used as the camera when not in VR.
  49827. */
  49828. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49829. /**
  49830. * Based on the current WebVR support, returns the current VR camera used.
  49831. */
  49832. get currentVRCamera(): Nullable<Camera>;
  49833. /**
  49834. * The webVRCamera which is used when in VR.
  49835. */
  49836. get webVRCamera(): WebVRFreeCamera;
  49837. /**
  49838. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49839. */
  49840. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49841. /**
  49842. * The html button that is used to trigger entering into VR.
  49843. */
  49844. get vrButton(): Nullable<HTMLButtonElement>;
  49845. private get _teleportationRequestInitiated();
  49846. /**
  49847. * Defines whether or not Pointer lock should be requested when switching to
  49848. * full screen.
  49849. */
  49850. requestPointerLockOnFullScreen: boolean;
  49851. /**
  49852. * If asking to force XR, this will be populated with the default xr experience
  49853. */
  49854. xr: WebXRDefaultExperience;
  49855. /**
  49856. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49857. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49858. */
  49859. xrTestDone: boolean;
  49860. /**
  49861. * Instantiates a VRExperienceHelper.
  49862. * Helps to quickly add VR support to an existing scene.
  49863. * @param scene The scene the VRExperienceHelper belongs to.
  49864. * @param webVROptions Options to modify the vr experience helper's behavior.
  49865. */
  49866. constructor(scene: Scene,
  49867. /** Options to modify the vr experience helper's behavior. */
  49868. webVROptions?: VRExperienceHelperOptions);
  49869. private completeVRInit;
  49870. private _onDefaultMeshLoaded;
  49871. private _onResize;
  49872. private _onFullscreenChange;
  49873. /**
  49874. * Gets a value indicating if we are currently in VR mode.
  49875. */
  49876. get isInVRMode(): boolean;
  49877. private onVrDisplayPresentChange;
  49878. private onVRDisplayChanged;
  49879. private moveButtonToBottomRight;
  49880. private displayVRButton;
  49881. private updateButtonVisibility;
  49882. private _cachedAngularSensibility;
  49883. /**
  49884. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49885. * Otherwise, will use the fullscreen API.
  49886. */
  49887. enterVR(): void;
  49888. /**
  49889. * Attempt to exit VR, or fullscreen.
  49890. */
  49891. exitVR(): void;
  49892. /**
  49893. * The position of the vr experience helper.
  49894. */
  49895. get position(): Vector3;
  49896. /**
  49897. * Sets the position of the vr experience helper.
  49898. */
  49899. set position(value: Vector3);
  49900. /**
  49901. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49902. */
  49903. enableInteractions(): void;
  49904. private get _noControllerIsActive();
  49905. private beforeRender;
  49906. private _isTeleportationFloor;
  49907. /**
  49908. * Adds a floor mesh to be used for teleportation.
  49909. * @param floorMesh the mesh to be used for teleportation.
  49910. */
  49911. addFloorMesh(floorMesh: Mesh): void;
  49912. /**
  49913. * Removes a floor mesh from being used for teleportation.
  49914. * @param floorMesh the mesh to be removed.
  49915. */
  49916. removeFloorMesh(floorMesh: Mesh): void;
  49917. /**
  49918. * Enables interactions and teleportation using the VR controllers and gaze.
  49919. * @param vrTeleportationOptions options to modify teleportation behavior.
  49920. */
  49921. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49922. private _onNewGamepadConnected;
  49923. private _tryEnableInteractionOnController;
  49924. private _onNewGamepadDisconnected;
  49925. private _enableInteractionOnController;
  49926. private _checkTeleportWithRay;
  49927. private _checkRotate;
  49928. private _checkTeleportBackwards;
  49929. private _enableTeleportationOnController;
  49930. private _createTeleportationCircles;
  49931. private _displayTeleportationTarget;
  49932. private _hideTeleportationTarget;
  49933. private _rotateCamera;
  49934. private _moveTeleportationSelectorTo;
  49935. private _workingVector;
  49936. private _workingQuaternion;
  49937. private _workingMatrix;
  49938. /**
  49939. * Time Constant Teleportation Mode
  49940. */
  49941. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49942. /**
  49943. * Speed Constant Teleportation Mode
  49944. */
  49945. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49946. /**
  49947. * Teleports the users feet to the desired location
  49948. * @param location The location where the user's feet should be placed
  49949. */
  49950. teleportCamera(location: Vector3): void;
  49951. private _convertNormalToDirectionOfRay;
  49952. private _castRayAndSelectObject;
  49953. private _notifySelectedMeshUnselected;
  49954. /**
  49955. * Permanently set new colors for the laser pointer
  49956. * @param color the new laser color
  49957. * @param pickedColor the new laser color when picked mesh detected
  49958. */
  49959. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49960. /**
  49961. * Set lighting enabled / disabled on the laser pointer of both controllers
  49962. * @param enabled should the lighting be enabled on the laser pointer
  49963. */
  49964. setLaserLightingState(enabled?: boolean): void;
  49965. /**
  49966. * Permanently set new colors for the gaze pointer
  49967. * @param color the new gaze color
  49968. * @param pickedColor the new gaze color when picked mesh detected
  49969. */
  49970. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49971. /**
  49972. * Sets the color of the laser ray from the vr controllers.
  49973. * @param color new color for the ray.
  49974. */
  49975. changeLaserColor(color: Color3): void;
  49976. /**
  49977. * Sets the color of the ray from the vr headsets gaze.
  49978. * @param color new color for the ray.
  49979. */
  49980. changeGazeColor(color: Color3): void;
  49981. /**
  49982. * Exits VR and disposes of the vr experience helper
  49983. */
  49984. dispose(): void;
  49985. /**
  49986. * Gets the name of the VRExperienceHelper class
  49987. * @returns "VRExperienceHelper"
  49988. */
  49989. getClassName(): string;
  49990. }
  49991. }
  49992. declare module BABYLON {
  49993. /**
  49994. * Contains an array of blocks representing the octree
  49995. */
  49996. export interface IOctreeContainer<T> {
  49997. /**
  49998. * Blocks within the octree
  49999. */
  50000. blocks: Array<OctreeBlock<T>>;
  50001. }
  50002. /**
  50003. * Class used to store a cell in an octree
  50004. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50005. */
  50006. export class OctreeBlock<T> {
  50007. /**
  50008. * Gets the content of the current block
  50009. */
  50010. entries: T[];
  50011. /**
  50012. * Gets the list of block children
  50013. */
  50014. blocks: Array<OctreeBlock<T>>;
  50015. private _depth;
  50016. private _maxDepth;
  50017. private _capacity;
  50018. private _minPoint;
  50019. private _maxPoint;
  50020. private _boundingVectors;
  50021. private _creationFunc;
  50022. /**
  50023. * Creates a new block
  50024. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50025. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50026. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50027. * @param depth defines the current depth of this block in the octree
  50028. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50029. * @param creationFunc defines a callback to call when an element is added to the block
  50030. */
  50031. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50032. /**
  50033. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50034. */
  50035. get capacity(): number;
  50036. /**
  50037. * Gets the minimum vector (in world space) of the block's bounding box
  50038. */
  50039. get minPoint(): Vector3;
  50040. /**
  50041. * Gets the maximum vector (in world space) of the block's bounding box
  50042. */
  50043. get maxPoint(): Vector3;
  50044. /**
  50045. * Add a new element to this block
  50046. * @param entry defines the element to add
  50047. */
  50048. addEntry(entry: T): void;
  50049. /**
  50050. * Remove an element from this block
  50051. * @param entry defines the element to remove
  50052. */
  50053. removeEntry(entry: T): void;
  50054. /**
  50055. * Add an array of elements to this block
  50056. * @param entries defines the array of elements to add
  50057. */
  50058. addEntries(entries: T[]): void;
  50059. /**
  50060. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50061. * @param frustumPlanes defines the frustum planes to test
  50062. * @param selection defines the array to store current content if selection is positive
  50063. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50064. */
  50065. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50066. /**
  50067. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50068. * @param sphereCenter defines the bounding sphere center
  50069. * @param sphereRadius defines the bounding sphere radius
  50070. * @param selection defines the array to store current content if selection is positive
  50071. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50072. */
  50073. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50074. /**
  50075. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50076. * @param ray defines the ray to test with
  50077. * @param selection defines the array to store current content if selection is positive
  50078. */
  50079. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50080. /**
  50081. * Subdivide the content into child blocks (this block will then be empty)
  50082. */
  50083. createInnerBlocks(): void;
  50084. /**
  50085. * @hidden
  50086. */
  50087. 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;
  50088. }
  50089. }
  50090. declare module BABYLON {
  50091. /**
  50092. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50093. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50094. */
  50095. export class Octree<T> {
  50096. /** 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.) */
  50097. maxDepth: number;
  50098. /**
  50099. * Blocks within the octree containing objects
  50100. */
  50101. blocks: Array<OctreeBlock<T>>;
  50102. /**
  50103. * Content stored in the octree
  50104. */
  50105. dynamicContent: T[];
  50106. private _maxBlockCapacity;
  50107. private _selectionContent;
  50108. private _creationFunc;
  50109. /**
  50110. * Creates a octree
  50111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50112. * @param creationFunc function to be used to instatiate the octree
  50113. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50114. * @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.)
  50115. */
  50116. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50117. /** 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.) */
  50118. maxDepth?: number);
  50119. /**
  50120. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50121. * @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);
  50122. * @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);
  50123. * @param entries meshes to be added to the octree blocks
  50124. */
  50125. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50126. /**
  50127. * Adds a mesh to the octree
  50128. * @param entry Mesh to add to the octree
  50129. */
  50130. addMesh(entry: T): void;
  50131. /**
  50132. * Remove an element from the octree
  50133. * @param entry defines the element to remove
  50134. */
  50135. removeMesh(entry: T): void;
  50136. /**
  50137. * Selects an array of meshes within the frustum
  50138. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50139. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50140. * @returns array of meshes within the frustum
  50141. */
  50142. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50143. /**
  50144. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50145. * @param sphereCenter defines the bounding sphere center
  50146. * @param sphereRadius defines the bounding sphere radius
  50147. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50148. * @returns an array of objects that intersect the sphere
  50149. */
  50150. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50151. /**
  50152. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50153. * @param ray defines the ray to test with
  50154. * @returns array of intersected objects
  50155. */
  50156. intersectsRay(ray: Ray): SmartArray<T>;
  50157. /**
  50158. * Adds a mesh into the octree block if it intersects the block
  50159. */
  50160. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50161. /**
  50162. * Adds a submesh into the octree block if it intersects the block
  50163. */
  50164. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50165. }
  50166. }
  50167. declare module BABYLON {
  50168. interface Scene {
  50169. /**
  50170. * @hidden
  50171. * Backing Filed
  50172. */
  50173. _selectionOctree: Octree<AbstractMesh>;
  50174. /**
  50175. * Gets the octree used to boost mesh selection (picking)
  50176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50177. */
  50178. selectionOctree: Octree<AbstractMesh>;
  50179. /**
  50180. * Creates or updates the octree used to boost selection (picking)
  50181. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50182. * @param maxCapacity defines the maximum capacity per leaf
  50183. * @param maxDepth defines the maximum depth of the octree
  50184. * @returns an octree of AbstractMesh
  50185. */
  50186. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50187. }
  50188. interface AbstractMesh {
  50189. /**
  50190. * @hidden
  50191. * Backing Field
  50192. */
  50193. _submeshesOctree: Octree<SubMesh>;
  50194. /**
  50195. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50196. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50197. * @param maxCapacity defines the maximum size of each block (64 by default)
  50198. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50199. * @returns the new octree
  50200. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50201. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50202. */
  50203. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50204. }
  50205. /**
  50206. * Defines the octree scene component responsible to manage any octrees
  50207. * in a given scene.
  50208. */
  50209. export class OctreeSceneComponent {
  50210. /**
  50211. * The component name help to identify the component in the list of scene components.
  50212. */
  50213. readonly name: string;
  50214. /**
  50215. * The scene the component belongs to.
  50216. */
  50217. scene: Scene;
  50218. /**
  50219. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50220. */
  50221. readonly checksIsEnabled: boolean;
  50222. /**
  50223. * Creates a new instance of the component for the given scene
  50224. * @param scene Defines the scene to register the component in
  50225. */
  50226. constructor(scene: Scene);
  50227. /**
  50228. * Registers the component in a given scene
  50229. */
  50230. register(): void;
  50231. /**
  50232. * Return the list of active meshes
  50233. * @returns the list of active meshes
  50234. */
  50235. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50236. /**
  50237. * Return the list of active sub meshes
  50238. * @param mesh The mesh to get the candidates sub meshes from
  50239. * @returns the list of active sub meshes
  50240. */
  50241. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50242. private _tempRay;
  50243. /**
  50244. * Return the list of sub meshes intersecting with a given local ray
  50245. * @param mesh defines the mesh to find the submesh for
  50246. * @param localRay defines the ray in local space
  50247. * @returns the list of intersecting sub meshes
  50248. */
  50249. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50250. /**
  50251. * Return the list of sub meshes colliding with a collider
  50252. * @param mesh defines the mesh to find the submesh for
  50253. * @param collider defines the collider to evaluate the collision against
  50254. * @returns the list of colliding sub meshes
  50255. */
  50256. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50257. /**
  50258. * Rebuilds the elements related to this component in case of
  50259. * context lost for instance.
  50260. */
  50261. rebuild(): void;
  50262. /**
  50263. * Disposes the component and the associated ressources.
  50264. */
  50265. dispose(): void;
  50266. }
  50267. }
  50268. declare module BABYLON {
  50269. /**
  50270. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50271. */
  50272. export class Gizmo implements IDisposable {
  50273. /** The utility layer the gizmo will be added to */
  50274. gizmoLayer: UtilityLayerRenderer;
  50275. /**
  50276. * The root mesh of the gizmo
  50277. */
  50278. _rootMesh: Mesh;
  50279. private _attachedMesh;
  50280. private _attachedNode;
  50281. /**
  50282. * Ratio for the scale of the gizmo (Default: 1)
  50283. */
  50284. protected _scaleRatio: number;
  50285. /**
  50286. * Ratio for the scale of the gizmo (Default: 1)
  50287. */
  50288. set scaleRatio(value: number);
  50289. get scaleRatio(): number;
  50290. /**
  50291. * If a custom mesh has been set (Default: false)
  50292. */
  50293. protected _customMeshSet: boolean;
  50294. /**
  50295. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50296. * * When set, interactions will be enabled
  50297. */
  50298. get attachedMesh(): Nullable<AbstractMesh>;
  50299. set attachedMesh(value: Nullable<AbstractMesh>);
  50300. /**
  50301. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50302. * * When set, interactions will be enabled
  50303. */
  50304. get attachedNode(): Nullable<Node>;
  50305. set attachedNode(value: Nullable<Node>);
  50306. /**
  50307. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50308. * @param mesh The mesh to replace the default mesh of the gizmo
  50309. */
  50310. setCustomMesh(mesh: Mesh): void;
  50311. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50312. /**
  50313. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50314. */
  50315. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50316. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50317. /**
  50318. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50319. */
  50320. updateGizmoPositionToMatchAttachedMesh: boolean;
  50321. /**
  50322. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50323. */
  50324. updateScale: boolean;
  50325. protected _interactionsEnabled: boolean;
  50326. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50327. private _beforeRenderObserver;
  50328. private _tempQuaternion;
  50329. private _tempVector;
  50330. private _tempVector2;
  50331. /**
  50332. * Creates a gizmo
  50333. * @param gizmoLayer The utility layer the gizmo will be added to
  50334. */
  50335. constructor(
  50336. /** The utility layer the gizmo will be added to */
  50337. gizmoLayer?: UtilityLayerRenderer);
  50338. /**
  50339. * Updates the gizmo to match the attached mesh's position/rotation
  50340. */
  50341. protected _update(): void;
  50342. /**
  50343. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50344. * @param value Node, TransformNode or mesh
  50345. */
  50346. protected _matrixChanged(): void;
  50347. /**
  50348. * Disposes of the gizmo
  50349. */
  50350. dispose(): void;
  50351. }
  50352. }
  50353. declare module BABYLON {
  50354. /**
  50355. * Single plane drag gizmo
  50356. */
  50357. export class PlaneDragGizmo extends Gizmo {
  50358. /**
  50359. * Drag behavior responsible for the gizmos dragging interactions
  50360. */
  50361. dragBehavior: PointerDragBehavior;
  50362. private _pointerObserver;
  50363. /**
  50364. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50365. */
  50366. snapDistance: number;
  50367. /**
  50368. * Event that fires each time the gizmo snaps to a new location.
  50369. * * snapDistance is the the change in distance
  50370. */
  50371. onSnapObservable: Observable<{
  50372. snapDistance: number;
  50373. }>;
  50374. private _plane;
  50375. private _coloredMaterial;
  50376. private _hoverMaterial;
  50377. private _isEnabled;
  50378. private _parent;
  50379. /** @hidden */
  50380. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50381. /** @hidden */
  50382. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50383. /**
  50384. * Creates a PlaneDragGizmo
  50385. * @param gizmoLayer The utility layer the gizmo will be added to
  50386. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50387. * @param color The color of the gizmo
  50388. */
  50389. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50390. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50391. /**
  50392. * If the gizmo is enabled
  50393. */
  50394. set isEnabled(value: boolean);
  50395. get isEnabled(): boolean;
  50396. /**
  50397. * Disposes of the gizmo
  50398. */
  50399. dispose(): void;
  50400. }
  50401. }
  50402. declare module BABYLON {
  50403. /**
  50404. * Gizmo that enables dragging a mesh along 3 axis
  50405. */
  50406. export class PositionGizmo extends Gizmo {
  50407. /**
  50408. * Internal gizmo used for interactions on the x axis
  50409. */
  50410. xGizmo: AxisDragGizmo;
  50411. /**
  50412. * Internal gizmo used for interactions on the y axis
  50413. */
  50414. yGizmo: AxisDragGizmo;
  50415. /**
  50416. * Internal gizmo used for interactions on the z axis
  50417. */
  50418. zGizmo: AxisDragGizmo;
  50419. /**
  50420. * Internal gizmo used for interactions on the yz plane
  50421. */
  50422. xPlaneGizmo: PlaneDragGizmo;
  50423. /**
  50424. * Internal gizmo used for interactions on the xz plane
  50425. */
  50426. yPlaneGizmo: PlaneDragGizmo;
  50427. /**
  50428. * Internal gizmo used for interactions on the xy plane
  50429. */
  50430. zPlaneGizmo: PlaneDragGizmo;
  50431. /**
  50432. * private variables
  50433. */
  50434. private _meshAttached;
  50435. private _nodeAttached;
  50436. private _snapDistance;
  50437. /** Fires an event when any of it's sub gizmos are dragged */
  50438. onDragStartObservable: Observable<unknown>;
  50439. /** Fires an event when any of it's sub gizmos are released from dragging */
  50440. onDragEndObservable: Observable<unknown>;
  50441. /**
  50442. * If set to true, planar drag is enabled
  50443. */
  50444. private _planarGizmoEnabled;
  50445. get attachedMesh(): Nullable<AbstractMesh>;
  50446. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50447. get attachedNode(): Nullable<Node>;
  50448. set attachedNode(node: Nullable<Node>);
  50449. /**
  50450. * Creates a PositionGizmo
  50451. * @param gizmoLayer The utility layer the gizmo will be added to
  50452. @param thickness display gizmo axis thickness
  50453. */
  50454. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50455. /**
  50456. * If the planar drag gizmo is enabled
  50457. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50458. */
  50459. set planarGizmoEnabled(value: boolean);
  50460. get planarGizmoEnabled(): boolean;
  50461. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50462. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50463. /**
  50464. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50465. */
  50466. set snapDistance(value: number);
  50467. get snapDistance(): number;
  50468. /**
  50469. * Ratio for the scale of the gizmo (Default: 1)
  50470. */
  50471. set scaleRatio(value: number);
  50472. get scaleRatio(): number;
  50473. /**
  50474. * Disposes of the gizmo
  50475. */
  50476. dispose(): void;
  50477. /**
  50478. * CustomMeshes are not supported by this gizmo
  50479. * @param mesh The mesh to replace the default mesh of the gizmo
  50480. */
  50481. setCustomMesh(mesh: Mesh): void;
  50482. }
  50483. }
  50484. declare module BABYLON {
  50485. /**
  50486. * Single axis drag gizmo
  50487. */
  50488. export class AxisDragGizmo extends Gizmo {
  50489. /**
  50490. * Drag behavior responsible for the gizmos dragging interactions
  50491. */
  50492. dragBehavior: PointerDragBehavior;
  50493. private _pointerObserver;
  50494. /**
  50495. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50496. */
  50497. snapDistance: number;
  50498. /**
  50499. * Event that fires each time the gizmo snaps to a new location.
  50500. * * snapDistance is the the change in distance
  50501. */
  50502. onSnapObservable: Observable<{
  50503. snapDistance: number;
  50504. }>;
  50505. private _isEnabled;
  50506. private _parent;
  50507. private _arrow;
  50508. private _coloredMaterial;
  50509. private _hoverMaterial;
  50510. /** @hidden */
  50511. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50512. /** @hidden */
  50513. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50514. /**
  50515. * Creates an AxisDragGizmo
  50516. * @param gizmoLayer The utility layer the gizmo will be added to
  50517. * @param dragAxis The axis which the gizmo will be able to drag on
  50518. * @param color The color of the gizmo
  50519. * @param thickness display gizmo axis thickness
  50520. */
  50521. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50522. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50523. /**
  50524. * If the gizmo is enabled
  50525. */
  50526. set isEnabled(value: boolean);
  50527. get isEnabled(): boolean;
  50528. /**
  50529. * Disposes of the gizmo
  50530. */
  50531. dispose(): void;
  50532. }
  50533. }
  50534. declare module BABYLON.Debug {
  50535. /**
  50536. * The Axes viewer will show 3 axes in a specific point in space
  50537. */
  50538. export class AxesViewer {
  50539. private _xAxis;
  50540. private _yAxis;
  50541. private _zAxis;
  50542. private _scaleLinesFactor;
  50543. private _instanced;
  50544. /**
  50545. * Gets the hosting scene
  50546. */
  50547. scene: Nullable<Scene>;
  50548. /**
  50549. * Gets or sets a number used to scale line length
  50550. */
  50551. scaleLines: number;
  50552. /** Gets the node hierarchy used to render x-axis */
  50553. get xAxis(): TransformNode;
  50554. /** Gets the node hierarchy used to render y-axis */
  50555. get yAxis(): TransformNode;
  50556. /** Gets the node hierarchy used to render z-axis */
  50557. get zAxis(): TransformNode;
  50558. /**
  50559. * Creates a new AxesViewer
  50560. * @param scene defines the hosting scene
  50561. * @param scaleLines defines a number used to scale line length (1 by default)
  50562. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50563. * @param xAxis defines the node hierarchy used to render the x-axis
  50564. * @param yAxis defines the node hierarchy used to render the y-axis
  50565. * @param zAxis defines the node hierarchy used to render the z-axis
  50566. */
  50567. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50568. /**
  50569. * Force the viewer to update
  50570. * @param position defines the position of the viewer
  50571. * @param xaxis defines the x axis of the viewer
  50572. * @param yaxis defines the y axis of the viewer
  50573. * @param zaxis defines the z axis of the viewer
  50574. */
  50575. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50576. /**
  50577. * Creates an instance of this axes viewer.
  50578. * @returns a new axes viewer with instanced meshes
  50579. */
  50580. createInstance(): AxesViewer;
  50581. /** Releases resources */
  50582. dispose(): void;
  50583. private static _SetRenderingGroupId;
  50584. }
  50585. }
  50586. declare module BABYLON.Debug {
  50587. /**
  50588. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50589. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50590. */
  50591. export class BoneAxesViewer extends AxesViewer {
  50592. /**
  50593. * Gets or sets the target mesh where to display the axes viewer
  50594. */
  50595. mesh: Nullable<Mesh>;
  50596. /**
  50597. * Gets or sets the target bone where to display the axes viewer
  50598. */
  50599. bone: Nullable<Bone>;
  50600. /** Gets current position */
  50601. pos: Vector3;
  50602. /** Gets direction of X axis */
  50603. xaxis: Vector3;
  50604. /** Gets direction of Y axis */
  50605. yaxis: Vector3;
  50606. /** Gets direction of Z axis */
  50607. zaxis: Vector3;
  50608. /**
  50609. * Creates a new BoneAxesViewer
  50610. * @param scene defines the hosting scene
  50611. * @param bone defines the target bone
  50612. * @param mesh defines the target mesh
  50613. * @param scaleLines defines a scaling factor for line length (1 by default)
  50614. */
  50615. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50616. /**
  50617. * Force the viewer to update
  50618. */
  50619. update(): void;
  50620. /** Releases resources */
  50621. dispose(): void;
  50622. }
  50623. }
  50624. declare module BABYLON {
  50625. /**
  50626. * Interface used to define scene explorer extensibility option
  50627. */
  50628. export interface IExplorerExtensibilityOption {
  50629. /**
  50630. * Define the option label
  50631. */
  50632. label: string;
  50633. /**
  50634. * Defines the action to execute on click
  50635. */
  50636. action: (entity: any) => void;
  50637. }
  50638. /**
  50639. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50640. */
  50641. export interface IExplorerExtensibilityGroup {
  50642. /**
  50643. * Defines a predicate to test if a given type mut be extended
  50644. */
  50645. predicate: (entity: any) => boolean;
  50646. /**
  50647. * Gets the list of options added to a type
  50648. */
  50649. entries: IExplorerExtensibilityOption[];
  50650. }
  50651. /**
  50652. * Interface used to define the options to use to create the Inspector
  50653. */
  50654. export interface IInspectorOptions {
  50655. /**
  50656. * Display in overlay mode (default: false)
  50657. */
  50658. overlay?: boolean;
  50659. /**
  50660. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50661. */
  50662. globalRoot?: HTMLElement;
  50663. /**
  50664. * Display the Scene explorer
  50665. */
  50666. showExplorer?: boolean;
  50667. /**
  50668. * Display the property inspector
  50669. */
  50670. showInspector?: boolean;
  50671. /**
  50672. * Display in embed mode (both panes on the right)
  50673. */
  50674. embedMode?: boolean;
  50675. /**
  50676. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50677. */
  50678. handleResize?: boolean;
  50679. /**
  50680. * Allow the panes to popup (default: true)
  50681. */
  50682. enablePopup?: boolean;
  50683. /**
  50684. * Allow the panes to be closed by users (default: true)
  50685. */
  50686. enableClose?: boolean;
  50687. /**
  50688. * Optional list of extensibility entries
  50689. */
  50690. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50691. /**
  50692. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50693. */
  50694. inspectorURL?: string;
  50695. /**
  50696. * Optional initial tab (default to DebugLayerTab.Properties)
  50697. */
  50698. initialTab?: DebugLayerTab;
  50699. }
  50700. interface Scene {
  50701. /**
  50702. * @hidden
  50703. * Backing field
  50704. */
  50705. _debugLayer: DebugLayer;
  50706. /**
  50707. * Gets the debug layer (aka Inspector) associated with the scene
  50708. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50709. */
  50710. debugLayer: DebugLayer;
  50711. }
  50712. /**
  50713. * Enum of inspector action tab
  50714. */
  50715. export enum DebugLayerTab {
  50716. /**
  50717. * Properties tag (default)
  50718. */
  50719. Properties = 0,
  50720. /**
  50721. * Debug tab
  50722. */
  50723. Debug = 1,
  50724. /**
  50725. * Statistics tab
  50726. */
  50727. Statistics = 2,
  50728. /**
  50729. * Tools tab
  50730. */
  50731. Tools = 3,
  50732. /**
  50733. * Settings tab
  50734. */
  50735. Settings = 4
  50736. }
  50737. /**
  50738. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50739. * what is happening in your scene
  50740. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50741. */
  50742. export class DebugLayer {
  50743. /**
  50744. * Define the url to get the inspector script from.
  50745. * By default it uses the babylonjs CDN.
  50746. * @ignoreNaming
  50747. */
  50748. static InspectorURL: string;
  50749. private _scene;
  50750. private BJSINSPECTOR;
  50751. private _onPropertyChangedObservable?;
  50752. /**
  50753. * Observable triggered when a property is changed through the inspector.
  50754. */
  50755. get onPropertyChangedObservable(): any;
  50756. /**
  50757. * Instantiates a new debug layer.
  50758. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50759. * what is happening in your scene
  50760. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50761. * @param scene Defines the scene to inspect
  50762. */
  50763. constructor(scene: Scene);
  50764. /** Creates the inspector window. */
  50765. private _createInspector;
  50766. /**
  50767. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50768. * @param entity defines the entity to select
  50769. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50770. */
  50771. select(entity: any, lineContainerTitles?: string | string[]): void;
  50772. /** Get the inspector from bundle or global */
  50773. private _getGlobalInspector;
  50774. /**
  50775. * Get if the inspector is visible or not.
  50776. * @returns true if visible otherwise, false
  50777. */
  50778. isVisible(): boolean;
  50779. /**
  50780. * Hide the inspector and close its window.
  50781. */
  50782. hide(): void;
  50783. /**
  50784. * Update the scene in the inspector
  50785. */
  50786. setAsActiveScene(): void;
  50787. /**
  50788. * Launch the debugLayer.
  50789. * @param config Define the configuration of the inspector
  50790. * @return a promise fulfilled when the debug layer is visible
  50791. */
  50792. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50793. }
  50794. }
  50795. declare module BABYLON {
  50796. /**
  50797. * Class containing static functions to help procedurally build meshes
  50798. */
  50799. export class BoxBuilder {
  50800. /**
  50801. * Creates a box mesh
  50802. * * The parameter `size` sets the size (float) of each box side (default 1)
  50803. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50804. * * 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)
  50805. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50807. * * 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
  50808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50809. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50810. * @param name defines the name of the mesh
  50811. * @param options defines the options used to create the mesh
  50812. * @param scene defines the hosting scene
  50813. * @returns the box mesh
  50814. */
  50815. static CreateBox(name: string, options: {
  50816. size?: number;
  50817. width?: number;
  50818. height?: number;
  50819. depth?: number;
  50820. faceUV?: Vector4[];
  50821. faceColors?: Color4[];
  50822. sideOrientation?: number;
  50823. frontUVs?: Vector4;
  50824. backUVs?: Vector4;
  50825. wrap?: boolean;
  50826. topBaseAt?: number;
  50827. bottomBaseAt?: number;
  50828. updatable?: boolean;
  50829. }, scene?: Nullable<Scene>): Mesh;
  50830. }
  50831. }
  50832. declare module BABYLON.Debug {
  50833. /**
  50834. * Used to show the physics impostor around the specific mesh
  50835. */
  50836. export class PhysicsViewer {
  50837. /** @hidden */
  50838. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50839. /** @hidden */
  50840. protected _meshes: Array<Nullable<AbstractMesh>>;
  50841. /** @hidden */
  50842. protected _scene: Nullable<Scene>;
  50843. /** @hidden */
  50844. protected _numMeshes: number;
  50845. /** @hidden */
  50846. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50847. private _renderFunction;
  50848. private _utilityLayer;
  50849. private _debugBoxMesh;
  50850. private _debugSphereMesh;
  50851. private _debugCylinderMesh;
  50852. private _debugMaterial;
  50853. private _debugMeshMeshes;
  50854. /**
  50855. * Creates a new PhysicsViewer
  50856. * @param scene defines the hosting scene
  50857. */
  50858. constructor(scene: Scene);
  50859. /** @hidden */
  50860. protected _updateDebugMeshes(): void;
  50861. /**
  50862. * Renders a specified physic impostor
  50863. * @param impostor defines the impostor to render
  50864. * @param targetMesh defines the mesh represented by the impostor
  50865. * @returns the new debug mesh used to render the impostor
  50866. */
  50867. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50868. /**
  50869. * Hides a specified physic impostor
  50870. * @param impostor defines the impostor to hide
  50871. */
  50872. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50873. private _getDebugMaterial;
  50874. private _getDebugBoxMesh;
  50875. private _getDebugSphereMesh;
  50876. private _getDebugCylinderMesh;
  50877. private _getDebugMeshMesh;
  50878. private _getDebugMesh;
  50879. /** Releases all resources */
  50880. dispose(): void;
  50881. }
  50882. }
  50883. declare module BABYLON {
  50884. /**
  50885. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50886. * in order to better appreciate the issue one might have.
  50887. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50888. */
  50889. export class RayHelper {
  50890. /**
  50891. * Defines the ray we are currently tryin to visualize.
  50892. */
  50893. ray: Nullable<Ray>;
  50894. private _renderPoints;
  50895. private _renderLine;
  50896. private _renderFunction;
  50897. private _scene;
  50898. private _onAfterRenderObserver;
  50899. private _onAfterStepObserver;
  50900. private _attachedToMesh;
  50901. private _meshSpaceDirection;
  50902. private _meshSpaceOrigin;
  50903. /**
  50904. * Helper function to create a colored helper in a scene in one line.
  50905. * @param ray Defines the ray we are currently tryin to visualize
  50906. * @param scene Defines the scene the ray is used in
  50907. * @param color Defines the color we want to see the ray in
  50908. * @returns The newly created ray helper.
  50909. */
  50910. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50911. /**
  50912. * Instantiate a new ray helper.
  50913. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50914. * in order to better appreciate the issue one might have.
  50915. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50916. * @param ray Defines the ray we are currently tryin to visualize
  50917. */
  50918. constructor(ray: Ray);
  50919. /**
  50920. * Shows the ray we are willing to debug.
  50921. * @param scene Defines the scene the ray needs to be rendered in
  50922. * @param color Defines the color the ray needs to be rendered in
  50923. */
  50924. show(scene: Scene, color?: Color3): void;
  50925. /**
  50926. * Hides the ray we are debugging.
  50927. */
  50928. hide(): void;
  50929. private _render;
  50930. /**
  50931. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50932. * @param mesh Defines the mesh we want the helper attached to
  50933. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50934. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50935. * @param length Defines the length of the ray
  50936. */
  50937. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50938. /**
  50939. * Detach the ray helper from the mesh it has previously been attached to.
  50940. */
  50941. detachFromMesh(): void;
  50942. private _updateToMesh;
  50943. /**
  50944. * Dispose the helper and release its associated resources.
  50945. */
  50946. dispose(): void;
  50947. }
  50948. }
  50949. declare module BABYLON {
  50950. /**
  50951. * Defines the options associated with the creation of a SkeletonViewer.
  50952. */
  50953. export interface ISkeletonViewerOptions {
  50954. /** Should the system pause animations before building the Viewer? */
  50955. pauseAnimations: boolean;
  50956. /** Should the system return the skeleton to rest before building? */
  50957. returnToRest: boolean;
  50958. /** public Display Mode of the Viewer */
  50959. displayMode: number;
  50960. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50961. displayOptions: ISkeletonViewerDisplayOptions;
  50962. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50963. computeBonesUsingShaders: boolean;
  50964. }
  50965. /**
  50966. * Defines how to display the various bone meshes for the viewer.
  50967. */
  50968. export interface ISkeletonViewerDisplayOptions {
  50969. /** How far down to start tapering the bone spurs */
  50970. midStep?: number;
  50971. /** How big is the midStep? */
  50972. midStepFactor?: number;
  50973. /** Base for the Sphere Size */
  50974. sphereBaseSize?: number;
  50975. /** The ratio of the sphere to the longest bone in units */
  50976. sphereScaleUnit?: number;
  50977. /** Ratio for the Sphere Size */
  50978. sphereFactor?: number;
  50979. }
  50980. }
  50981. declare module BABYLON {
  50982. /**
  50983. * Class containing static functions to help procedurally build meshes
  50984. */
  50985. export class RibbonBuilder {
  50986. /**
  50987. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50988. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50989. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50990. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50991. * * 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
  50992. * * 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
  50993. * * 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
  50994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50995. * * 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
  50996. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50997. * * 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
  50998. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50999. * * 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
  51000. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51002. * @param name defines the name of the mesh
  51003. * @param options defines the options used to create the mesh
  51004. * @param scene defines the hosting scene
  51005. * @returns the ribbon mesh
  51006. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51007. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51008. */
  51009. static CreateRibbon(name: string, options: {
  51010. pathArray: Vector3[][];
  51011. closeArray?: boolean;
  51012. closePath?: boolean;
  51013. offset?: number;
  51014. updatable?: boolean;
  51015. sideOrientation?: number;
  51016. frontUVs?: Vector4;
  51017. backUVs?: Vector4;
  51018. instance?: Mesh;
  51019. invertUV?: boolean;
  51020. uvs?: Vector2[];
  51021. colors?: Color4[];
  51022. }, scene?: Nullable<Scene>): Mesh;
  51023. }
  51024. }
  51025. declare module BABYLON {
  51026. /**
  51027. * Class containing static functions to help procedurally build meshes
  51028. */
  51029. export class ShapeBuilder {
  51030. /**
  51031. * 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.
  51032. * * 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.
  51033. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51034. * * 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.
  51035. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51036. * * 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
  51037. * * 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
  51038. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51040. * * 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
  51041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51043. * @param name defines the name of the mesh
  51044. * @param options defines the options used to create the mesh
  51045. * @param scene defines the hosting scene
  51046. * @returns the extruded shape mesh
  51047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51049. */
  51050. static ExtrudeShape(name: string, options: {
  51051. shape: Vector3[];
  51052. path: Vector3[];
  51053. scale?: number;
  51054. rotation?: number;
  51055. cap?: number;
  51056. updatable?: boolean;
  51057. sideOrientation?: number;
  51058. frontUVs?: Vector4;
  51059. backUVs?: Vector4;
  51060. instance?: Mesh;
  51061. invertUV?: boolean;
  51062. }, scene?: Nullable<Scene>): Mesh;
  51063. /**
  51064. * Creates an custom extruded shape mesh.
  51065. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51066. * * 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.
  51067. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51068. * * 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
  51069. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51070. * * 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
  51071. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51072. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51073. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51074. * * 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
  51075. * * 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
  51076. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51078. * * 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
  51079. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51081. * @param name defines the name of the mesh
  51082. * @param options defines the options used to create the mesh
  51083. * @param scene defines the hosting scene
  51084. * @returns the custom extruded shape mesh
  51085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51088. */
  51089. static ExtrudeShapeCustom(name: string, options: {
  51090. shape: Vector3[];
  51091. path: Vector3[];
  51092. scaleFunction?: any;
  51093. rotationFunction?: any;
  51094. ribbonCloseArray?: boolean;
  51095. ribbonClosePath?: boolean;
  51096. cap?: number;
  51097. updatable?: boolean;
  51098. sideOrientation?: number;
  51099. frontUVs?: Vector4;
  51100. backUVs?: Vector4;
  51101. instance?: Mesh;
  51102. invertUV?: boolean;
  51103. }, scene?: Nullable<Scene>): Mesh;
  51104. private static _ExtrudeShapeGeneric;
  51105. }
  51106. }
  51107. declare module BABYLON.Debug {
  51108. /**
  51109. * Class used to render a debug view of a given skeleton
  51110. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51111. */
  51112. export class SkeletonViewer {
  51113. /** defines the skeleton to render */
  51114. skeleton: Skeleton;
  51115. /** defines the mesh attached to the skeleton */
  51116. mesh: AbstractMesh;
  51117. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51118. autoUpdateBonesMatrices: boolean;
  51119. /** defines the rendering group id to use with the viewer */
  51120. renderingGroupId: number;
  51121. /** is the options for the viewer */
  51122. options: Partial<ISkeletonViewerOptions>;
  51123. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51124. static readonly DISPLAY_LINES: number;
  51125. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51126. static readonly DISPLAY_SPHERES: number;
  51127. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51128. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51129. /** If SkeletonViewer scene scope. */
  51130. private _scene;
  51131. /** Gets or sets the color used to render the skeleton */
  51132. color: Color3;
  51133. /** Array of the points of the skeleton fo the line view. */
  51134. private _debugLines;
  51135. /** The SkeletonViewers Mesh. */
  51136. private _debugMesh;
  51137. /** If SkeletonViewer is enabled. */
  51138. private _isEnabled;
  51139. /** If SkeletonViewer is ready. */
  51140. private _ready;
  51141. /** SkeletonViewer render observable. */
  51142. private _obs;
  51143. /** The Utility Layer to render the gizmos in. */
  51144. private _utilityLayer;
  51145. private _boneIndices;
  51146. /** Gets the Scene. */
  51147. get scene(): Scene;
  51148. /** Gets the utilityLayer. */
  51149. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51150. /** Checks Ready Status. */
  51151. get isReady(): Boolean;
  51152. /** Sets Ready Status. */
  51153. set ready(value: boolean);
  51154. /** Gets the debugMesh */
  51155. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51156. /** Sets the debugMesh */
  51157. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51158. /** Gets the material */
  51159. get material(): StandardMaterial;
  51160. /** Sets the material */
  51161. set material(value: StandardMaterial);
  51162. /** Gets the material */
  51163. get displayMode(): number;
  51164. /** Sets the material */
  51165. set displayMode(value: number);
  51166. /**
  51167. * Creates a new SkeletonViewer
  51168. * @param skeleton defines the skeleton to render
  51169. * @param mesh defines the mesh attached to the skeleton
  51170. * @param scene defines the hosting scene
  51171. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51172. * @param renderingGroupId defines the rendering group id to use with the viewer
  51173. * @param options All of the extra constructor options for the SkeletonViewer
  51174. */
  51175. constructor(
  51176. /** defines the skeleton to render */
  51177. skeleton: Skeleton,
  51178. /** defines the mesh attached to the skeleton */
  51179. mesh: AbstractMesh,
  51180. /** The Scene scope*/
  51181. scene: Scene,
  51182. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51183. autoUpdateBonesMatrices?: boolean,
  51184. /** defines the rendering group id to use with the viewer */
  51185. renderingGroupId?: number,
  51186. /** is the options for the viewer */
  51187. options?: Partial<ISkeletonViewerOptions>);
  51188. /** The Dynamic bindings for the update functions */
  51189. private _bindObs;
  51190. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51191. update(): void;
  51192. /** Gets or sets a boolean indicating if the viewer is enabled */
  51193. set isEnabled(value: boolean);
  51194. get isEnabled(): boolean;
  51195. private _getBonePosition;
  51196. private _getLinesForBonesWithLength;
  51197. private _getLinesForBonesNoLength;
  51198. /** function to revert the mesh and scene back to the initial state. */
  51199. private _revert;
  51200. /** function to build and bind sphere joint points and spur bone representations. */
  51201. private _buildSpheresAndSpurs;
  51202. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51203. private _displayLinesUpdate;
  51204. /** Changes the displayMode of the skeleton viewer
  51205. * @param mode The displayMode numerical value
  51206. */
  51207. changeDisplayMode(mode: number): void;
  51208. /** Changes the displayMode of the skeleton viewer
  51209. * @param option String of the option name
  51210. * @param value The numerical option value
  51211. */
  51212. changeDisplayOptions(option: string, value: number): void;
  51213. /** Release associated resources */
  51214. dispose(): void;
  51215. }
  51216. }
  51217. declare module BABYLON {
  51218. /**
  51219. * Enum for Device Types
  51220. */
  51221. export enum DeviceType {
  51222. /** Generic */
  51223. Generic = 0,
  51224. /** Keyboard */
  51225. Keyboard = 1,
  51226. /** Mouse */
  51227. Mouse = 2,
  51228. /** Touch Pointers */
  51229. Touch = 3,
  51230. /** PS4 Dual Shock */
  51231. DualShock = 4,
  51232. /** Xbox */
  51233. Xbox = 5,
  51234. /** Switch Controller */
  51235. Switch = 6
  51236. }
  51237. /**
  51238. * Enum for All Pointers (Touch/Mouse)
  51239. */
  51240. export enum PointerInput {
  51241. /** Horizontal Axis */
  51242. Horizontal = 0,
  51243. /** Vertical Axis */
  51244. Vertical = 1,
  51245. /** Left Click or Touch */
  51246. LeftClick = 2,
  51247. /** Middle Click */
  51248. MiddleClick = 3,
  51249. /** Right Click */
  51250. RightClick = 4,
  51251. /** Browser Back */
  51252. BrowserBack = 5,
  51253. /** Browser Forward */
  51254. BrowserForward = 6
  51255. }
  51256. /**
  51257. * Enum for Dual Shock Gamepad
  51258. */
  51259. export enum DualShockInput {
  51260. /** Cross */
  51261. Cross = 0,
  51262. /** Circle */
  51263. Circle = 1,
  51264. /** Square */
  51265. Square = 2,
  51266. /** Triangle */
  51267. Triangle = 3,
  51268. /** L1 */
  51269. L1 = 4,
  51270. /** R1 */
  51271. R1 = 5,
  51272. /** L2 */
  51273. L2 = 6,
  51274. /** R2 */
  51275. R2 = 7,
  51276. /** Share */
  51277. Share = 8,
  51278. /** Options */
  51279. Options = 9,
  51280. /** L3 */
  51281. L3 = 10,
  51282. /** R3 */
  51283. R3 = 11,
  51284. /** DPadUp */
  51285. DPadUp = 12,
  51286. /** DPadDown */
  51287. DPadDown = 13,
  51288. /** DPadLeft */
  51289. DPadLeft = 14,
  51290. /** DRight */
  51291. DPadRight = 15,
  51292. /** Home */
  51293. Home = 16,
  51294. /** TouchPad */
  51295. TouchPad = 17,
  51296. /** LStickXAxis */
  51297. LStickXAxis = 18,
  51298. /** LStickYAxis */
  51299. LStickYAxis = 19,
  51300. /** RStickXAxis */
  51301. RStickXAxis = 20,
  51302. /** RStickYAxis */
  51303. RStickYAxis = 21
  51304. }
  51305. /**
  51306. * Enum for Xbox Gamepad
  51307. */
  51308. export enum XboxInput {
  51309. /** A */
  51310. A = 0,
  51311. /** B */
  51312. B = 1,
  51313. /** X */
  51314. X = 2,
  51315. /** Y */
  51316. Y = 3,
  51317. /** LB */
  51318. LB = 4,
  51319. /** RB */
  51320. RB = 5,
  51321. /** LT */
  51322. LT = 6,
  51323. /** RT */
  51324. RT = 7,
  51325. /** Back */
  51326. Back = 8,
  51327. /** Start */
  51328. Start = 9,
  51329. /** LS */
  51330. LS = 10,
  51331. /** RS */
  51332. RS = 11,
  51333. /** DPadUp */
  51334. DPadUp = 12,
  51335. /** DPadDown */
  51336. DPadDown = 13,
  51337. /** DPadLeft */
  51338. DPadLeft = 14,
  51339. /** DRight */
  51340. DPadRight = 15,
  51341. /** Home */
  51342. Home = 16,
  51343. /** LStickXAxis */
  51344. LStickXAxis = 17,
  51345. /** LStickYAxis */
  51346. LStickYAxis = 18,
  51347. /** RStickXAxis */
  51348. RStickXAxis = 19,
  51349. /** RStickYAxis */
  51350. RStickYAxis = 20
  51351. }
  51352. /**
  51353. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51354. */
  51355. export enum SwitchInput {
  51356. /** B */
  51357. B = 0,
  51358. /** A */
  51359. A = 1,
  51360. /** Y */
  51361. Y = 2,
  51362. /** X */
  51363. X = 3,
  51364. /** L */
  51365. L = 4,
  51366. /** R */
  51367. R = 5,
  51368. /** ZL */
  51369. ZL = 6,
  51370. /** ZR */
  51371. ZR = 7,
  51372. /** Minus */
  51373. Minus = 8,
  51374. /** Plus */
  51375. Plus = 9,
  51376. /** LS */
  51377. LS = 10,
  51378. /** RS */
  51379. RS = 11,
  51380. /** DPadUp */
  51381. DPadUp = 12,
  51382. /** DPadDown */
  51383. DPadDown = 13,
  51384. /** DPadLeft */
  51385. DPadLeft = 14,
  51386. /** DRight */
  51387. DPadRight = 15,
  51388. /** Home */
  51389. Home = 16,
  51390. /** Capture */
  51391. Capture = 17,
  51392. /** LStickXAxis */
  51393. LStickXAxis = 18,
  51394. /** LStickYAxis */
  51395. LStickYAxis = 19,
  51396. /** RStickXAxis */
  51397. RStickXAxis = 20,
  51398. /** RStickYAxis */
  51399. RStickYAxis = 21
  51400. }
  51401. }
  51402. declare module BABYLON {
  51403. /**
  51404. * This class will take all inputs from Keyboard, Pointer, and
  51405. * any Gamepads and provide a polling system that all devices
  51406. * will use. This class assumes that there will only be one
  51407. * pointer device and one keyboard.
  51408. */
  51409. export class DeviceInputSystem implements IDisposable {
  51410. /**
  51411. * Callback to be triggered when a device is connected
  51412. */
  51413. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51414. /**
  51415. * Callback to be triggered when a device is disconnected
  51416. */
  51417. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51418. /**
  51419. * Callback to be triggered when event driven input is updated
  51420. */
  51421. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51422. private _inputs;
  51423. private _gamepads;
  51424. private _keyboardActive;
  51425. private _pointerActive;
  51426. private _elementToAttachTo;
  51427. private _keyboardDownEvent;
  51428. private _keyboardUpEvent;
  51429. private _pointerMoveEvent;
  51430. private _pointerDownEvent;
  51431. private _pointerUpEvent;
  51432. private _gamepadConnectedEvent;
  51433. private _gamepadDisconnectedEvent;
  51434. private static _MAX_KEYCODES;
  51435. private static _MAX_POINTER_INPUTS;
  51436. private constructor();
  51437. /**
  51438. * Creates a new DeviceInputSystem instance
  51439. * @param engine Engine to pull input element from
  51440. * @returns The new instance
  51441. */
  51442. static Create(engine: Engine): DeviceInputSystem;
  51443. /**
  51444. * Checks for current device input value, given an id and input index
  51445. * @param deviceName Id of connected device
  51446. * @param inputIndex Index of device input
  51447. * @returns Current value of input
  51448. */
  51449. /**
  51450. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51451. * @param deviceType Enum specifiying device type
  51452. * @param deviceSlot "Slot" or index that device is referenced in
  51453. * @param inputIndex Id of input to be checked
  51454. * @returns Current value of input
  51455. */
  51456. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51457. /**
  51458. * Dispose of all the eventlisteners
  51459. */
  51460. dispose(): void;
  51461. /**
  51462. * Add device and inputs to device array
  51463. * @param deviceType Enum specifiying device type
  51464. * @param deviceSlot "Slot" or index that device is referenced in
  51465. * @param numberOfInputs Number of input entries to create for given device
  51466. */
  51467. private _registerDevice;
  51468. /**
  51469. * Given a specific device name, remove that device from the device map
  51470. * @param deviceType Enum specifiying device type
  51471. * @param deviceSlot "Slot" or index that device is referenced in
  51472. */
  51473. private _unregisterDevice;
  51474. /**
  51475. * Handle all actions that come from keyboard interaction
  51476. */
  51477. private _handleKeyActions;
  51478. /**
  51479. * Handle all actions that come from pointer interaction
  51480. */
  51481. private _handlePointerActions;
  51482. /**
  51483. * Handle all actions that come from gamepad interaction
  51484. */
  51485. private _handleGamepadActions;
  51486. /**
  51487. * Update all non-event based devices with each frame
  51488. * @param deviceType Enum specifiying device type
  51489. * @param deviceSlot "Slot" or index that device is referenced in
  51490. * @param inputIndex Id of input to be checked
  51491. */
  51492. private _updateDevice;
  51493. /**
  51494. * Gets DeviceType from the device name
  51495. * @param deviceName Name of Device from DeviceInputSystem
  51496. * @returns DeviceType enum value
  51497. */
  51498. private _getGamepadDeviceType;
  51499. }
  51500. }
  51501. declare module BABYLON {
  51502. /**
  51503. * Type to handle enforcement of inputs
  51504. */
  51505. 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;
  51506. }
  51507. declare module BABYLON {
  51508. /**
  51509. * Class that handles all input for a specific device
  51510. */
  51511. export class DeviceSource<T extends DeviceType> {
  51512. /** Type of device */
  51513. readonly deviceType: DeviceType;
  51514. /** "Slot" or index that device is referenced in */
  51515. readonly deviceSlot: number;
  51516. /**
  51517. * Observable to handle device input changes per device
  51518. */
  51519. readonly onInputChangedObservable: Observable<{
  51520. inputIndex: DeviceInput<T>;
  51521. previousState: Nullable<number>;
  51522. currentState: Nullable<number>;
  51523. }>;
  51524. private readonly _deviceInputSystem;
  51525. /**
  51526. * Default Constructor
  51527. * @param deviceInputSystem Reference to DeviceInputSystem
  51528. * @param deviceType Type of device
  51529. * @param deviceSlot "Slot" or index that device is referenced in
  51530. */
  51531. constructor(deviceInputSystem: DeviceInputSystem,
  51532. /** Type of device */
  51533. deviceType: DeviceType,
  51534. /** "Slot" or index that device is referenced in */
  51535. deviceSlot?: number);
  51536. /**
  51537. * Get input for specific input
  51538. * @param inputIndex index of specific input on device
  51539. * @returns Input value from DeviceInputSystem
  51540. */
  51541. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51542. }
  51543. /**
  51544. * Class to keep track of devices
  51545. */
  51546. export class DeviceSourceManager implements IDisposable {
  51547. /**
  51548. * Observable to be triggered when before a device is connected
  51549. */
  51550. readonly onBeforeDeviceConnectedObservable: Observable<{
  51551. deviceType: DeviceType;
  51552. deviceSlot: number;
  51553. }>;
  51554. /**
  51555. * Observable to be triggered when before a device is disconnected
  51556. */
  51557. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51558. deviceType: DeviceType;
  51559. deviceSlot: number;
  51560. }>;
  51561. /**
  51562. * Observable to be triggered when after a device is connected
  51563. */
  51564. readonly onAfterDeviceConnectedObservable: Observable<{
  51565. deviceType: DeviceType;
  51566. deviceSlot: number;
  51567. }>;
  51568. /**
  51569. * Observable to be triggered when after a device is disconnected
  51570. */
  51571. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51572. deviceType: DeviceType;
  51573. deviceSlot: number;
  51574. }>;
  51575. private readonly _devices;
  51576. private readonly _firstDevice;
  51577. private readonly _deviceInputSystem;
  51578. /**
  51579. * Default Constructor
  51580. * @param engine engine to pull input element from
  51581. */
  51582. constructor(engine: Engine);
  51583. /**
  51584. * Gets a DeviceSource, given a type and slot
  51585. * @param deviceType Enum specifying device type
  51586. * @param deviceSlot "Slot" or index that device is referenced in
  51587. * @returns DeviceSource object
  51588. */
  51589. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51590. /**
  51591. * Gets an array of DeviceSource objects for a given device type
  51592. * @param deviceType Enum specifying device type
  51593. * @returns Array of DeviceSource objects
  51594. */
  51595. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51596. /**
  51597. * Dispose of DeviceInputSystem and other parts
  51598. */
  51599. dispose(): void;
  51600. /**
  51601. * Function to add device name to device list
  51602. * @param deviceType Enum specifying device type
  51603. * @param deviceSlot "Slot" or index that device is referenced in
  51604. */
  51605. private _addDevice;
  51606. /**
  51607. * Function to remove device name to device list
  51608. * @param deviceType Enum specifying device type
  51609. * @param deviceSlot "Slot" or index that device is referenced in
  51610. */
  51611. private _removeDevice;
  51612. /**
  51613. * Updates array storing first connected device of each type
  51614. * @param type Type of Device
  51615. */
  51616. private _updateFirstDevices;
  51617. }
  51618. }
  51619. declare module BABYLON {
  51620. /**
  51621. * Options to create the null engine
  51622. */
  51623. export class NullEngineOptions {
  51624. /**
  51625. * Render width (Default: 512)
  51626. */
  51627. renderWidth: number;
  51628. /**
  51629. * Render height (Default: 256)
  51630. */
  51631. renderHeight: number;
  51632. /**
  51633. * Texture size (Default: 512)
  51634. */
  51635. textureSize: number;
  51636. /**
  51637. * If delta time between frames should be constant
  51638. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51639. */
  51640. deterministicLockstep: boolean;
  51641. /**
  51642. * Maximum about of steps between frames (Default: 4)
  51643. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51644. */
  51645. lockstepMaxSteps: number;
  51646. /**
  51647. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51648. */
  51649. useHighPrecisionMatrix?: boolean;
  51650. }
  51651. /**
  51652. * The null engine class provides support for headless version of babylon.js.
  51653. * This can be used in server side scenario or for testing purposes
  51654. */
  51655. export class NullEngine extends Engine {
  51656. private _options;
  51657. /**
  51658. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51659. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51660. * @returns true if engine is in deterministic lock step mode
  51661. */
  51662. isDeterministicLockStep(): boolean;
  51663. /**
  51664. * Gets the max steps when engine is running in deterministic lock step
  51665. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51666. * @returns the max steps
  51667. */
  51668. getLockstepMaxSteps(): number;
  51669. /**
  51670. * Gets the current hardware scaling level.
  51671. * By default the hardware scaling level is computed from the window device ratio.
  51672. * 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.
  51673. * @returns a number indicating the current hardware scaling level
  51674. */
  51675. getHardwareScalingLevel(): number;
  51676. constructor(options?: NullEngineOptions);
  51677. /**
  51678. * Creates a vertex buffer
  51679. * @param vertices the data for the vertex buffer
  51680. * @returns the new WebGL static buffer
  51681. */
  51682. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51683. /**
  51684. * Creates a new index buffer
  51685. * @param indices defines the content of the index buffer
  51686. * @param updatable defines if the index buffer must be updatable
  51687. * @returns a new webGL buffer
  51688. */
  51689. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51690. /**
  51691. * Clear the current render buffer or the current render target (if any is set up)
  51692. * @param color defines the color to use
  51693. * @param backBuffer defines if the back buffer must be cleared
  51694. * @param depth defines if the depth buffer must be cleared
  51695. * @param stencil defines if the stencil buffer must be cleared
  51696. */
  51697. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51698. /**
  51699. * Gets the current render width
  51700. * @param useScreen defines if screen size must be used (or the current render target if any)
  51701. * @returns a number defining the current render width
  51702. */
  51703. getRenderWidth(useScreen?: boolean): number;
  51704. /**
  51705. * Gets the current render height
  51706. * @param useScreen defines if screen size must be used (or the current render target if any)
  51707. * @returns a number defining the current render height
  51708. */
  51709. getRenderHeight(useScreen?: boolean): number;
  51710. /**
  51711. * Set the WebGL's viewport
  51712. * @param viewport defines the viewport element to be used
  51713. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51714. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51715. */
  51716. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51717. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51718. /**
  51719. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51720. * @param pipelineContext defines the pipeline context to use
  51721. * @param uniformsNames defines the list of uniform names
  51722. * @returns an array of webGL uniform locations
  51723. */
  51724. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51725. /**
  51726. * Gets the lsit of active attributes for a given webGL program
  51727. * @param pipelineContext defines the pipeline context to use
  51728. * @param attributesNames defines the list of attribute names to get
  51729. * @returns an array of indices indicating the offset of each attribute
  51730. */
  51731. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51732. /**
  51733. * Binds an effect to the webGL context
  51734. * @param effect defines the effect to bind
  51735. */
  51736. bindSamplers(effect: Effect): void;
  51737. /**
  51738. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51739. * @param effect defines the effect to activate
  51740. */
  51741. enableEffect(effect: Effect): void;
  51742. /**
  51743. * Set various states to the webGL context
  51744. * @param culling defines backface culling state
  51745. * @param zOffset defines the value to apply to zOffset (0 by default)
  51746. * @param force defines if states must be applied even if cache is up to date
  51747. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51748. */
  51749. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51750. /**
  51751. * Set the value of an uniform to an array of int32
  51752. * @param uniform defines the webGL uniform location where to store the value
  51753. * @param array defines the array of int32 to store
  51754. */
  51755. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51756. /**
  51757. * Set the value of an uniform to an array of int32 (stored as vec2)
  51758. * @param uniform defines the webGL uniform location where to store the value
  51759. * @param array defines the array of int32 to store
  51760. */
  51761. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51762. /**
  51763. * Set the value of an uniform to an array of int32 (stored as vec3)
  51764. * @param uniform defines the webGL uniform location where to store the value
  51765. * @param array defines the array of int32 to store
  51766. */
  51767. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51768. /**
  51769. * Set the value of an uniform to an array of int32 (stored as vec4)
  51770. * @param uniform defines the webGL uniform location where to store the value
  51771. * @param array defines the array of int32 to store
  51772. */
  51773. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51774. /**
  51775. * Set the value of an uniform to an array of float32
  51776. * @param uniform defines the webGL uniform location where to store the value
  51777. * @param array defines the array of float32 to store
  51778. */
  51779. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51780. /**
  51781. * Set the value of an uniform to an array of float32 (stored as vec2)
  51782. * @param uniform defines the webGL uniform location where to store the value
  51783. * @param array defines the array of float32 to store
  51784. */
  51785. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51786. /**
  51787. * Set the value of an uniform to an array of float32 (stored as vec3)
  51788. * @param uniform defines the webGL uniform location where to store the value
  51789. * @param array defines the array of float32 to store
  51790. */
  51791. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51792. /**
  51793. * Set the value of an uniform to an array of float32 (stored as vec4)
  51794. * @param uniform defines the webGL uniform location where to store the value
  51795. * @param array defines the array of float32 to store
  51796. */
  51797. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51798. /**
  51799. * Set the value of an uniform to an array of number
  51800. * @param uniform defines the webGL uniform location where to store the value
  51801. * @param array defines the array of number to store
  51802. */
  51803. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51804. /**
  51805. * Set the value of an uniform to an array of number (stored as vec2)
  51806. * @param uniform defines the webGL uniform location where to store the value
  51807. * @param array defines the array of number to store
  51808. */
  51809. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51810. /**
  51811. * Set the value of an uniform to an array of number (stored as vec3)
  51812. * @param uniform defines the webGL uniform location where to store the value
  51813. * @param array defines the array of number to store
  51814. */
  51815. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51816. /**
  51817. * Set the value of an uniform to an array of number (stored as vec4)
  51818. * @param uniform defines the webGL uniform location where to store the value
  51819. * @param array defines the array of number to store
  51820. */
  51821. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51822. /**
  51823. * Set the value of an uniform to an array of float32 (stored as matrices)
  51824. * @param uniform defines the webGL uniform location where to store the value
  51825. * @param matrices defines the array of float32 to store
  51826. */
  51827. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51828. /**
  51829. * Set the value of an uniform to a matrix (3x3)
  51830. * @param uniform defines the webGL uniform location where to store the value
  51831. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51832. */
  51833. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51834. /**
  51835. * Set the value of an uniform to a matrix (2x2)
  51836. * @param uniform defines the webGL uniform location where to store the value
  51837. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51838. */
  51839. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51840. /**
  51841. * Set the value of an uniform to a number (float)
  51842. * @param uniform defines the webGL uniform location where to store the value
  51843. * @param value defines the float number to store
  51844. */
  51845. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51846. /**
  51847. * Set the value of an uniform to a vec2
  51848. * @param uniform defines the webGL uniform location where to store the value
  51849. * @param x defines the 1st component of the value
  51850. * @param y defines the 2nd component of the value
  51851. */
  51852. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51853. /**
  51854. * Set the value of an uniform to a vec3
  51855. * @param uniform defines the webGL uniform location where to store the value
  51856. * @param x defines the 1st component of the value
  51857. * @param y defines the 2nd component of the value
  51858. * @param z defines the 3rd component of the value
  51859. */
  51860. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51861. /**
  51862. * Set the value of an uniform to a boolean
  51863. * @param uniform defines the webGL uniform location where to store the value
  51864. * @param bool defines the boolean to store
  51865. */
  51866. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51867. /**
  51868. * Set the value of an uniform to a vec4
  51869. * @param uniform defines the webGL uniform location where to store the value
  51870. * @param x defines the 1st component of the value
  51871. * @param y defines the 2nd component of the value
  51872. * @param z defines the 3rd component of the value
  51873. * @param w defines the 4th component of the value
  51874. */
  51875. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51876. /**
  51877. * Sets the current alpha mode
  51878. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51879. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51880. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51881. */
  51882. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51883. /**
  51884. * Bind webGl buffers directly to the webGL context
  51885. * @param vertexBuffers defines the vertex buffer to bind
  51886. * @param indexBuffer defines the index buffer to bind
  51887. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51888. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51889. * @param effect defines the effect associated with the vertex buffer
  51890. */
  51891. bindBuffers(vertexBuffers: {
  51892. [key: string]: VertexBuffer;
  51893. }, indexBuffer: DataBuffer, effect: Effect): void;
  51894. /**
  51895. * Force the entire cache to be cleared
  51896. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51897. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51898. */
  51899. wipeCaches(bruteForce?: boolean): void;
  51900. /**
  51901. * Send a draw order
  51902. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51903. * @param indexStart defines the starting index
  51904. * @param indexCount defines the number of index to draw
  51905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51906. */
  51907. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51908. /**
  51909. * Draw a list of indexed primitives
  51910. * @param fillMode defines the primitive to use
  51911. * @param indexStart defines the starting index
  51912. * @param indexCount defines the number of index to draw
  51913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51914. */
  51915. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51916. /**
  51917. * Draw a list of unindexed primitives
  51918. * @param fillMode defines the primitive to use
  51919. * @param verticesStart defines the index of first vertex to draw
  51920. * @param verticesCount defines the count of vertices to draw
  51921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51922. */
  51923. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51924. /** @hidden */
  51925. _createTexture(): WebGLTexture;
  51926. /** @hidden */
  51927. _releaseTexture(texture: InternalTexture): void;
  51928. /**
  51929. * Usually called from Texture.ts.
  51930. * Passed information to create a WebGLTexture
  51931. * @param urlArg defines a value which contains one of the following:
  51932. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51933. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51934. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51935. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51936. * @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)
  51937. * @param scene needed for loading to the correct scene
  51938. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51939. * @param onLoad optional callback to be called upon successful completion
  51940. * @param onError optional callback to be called upon failure
  51941. * @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
  51942. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51943. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51944. * @param forcedExtension defines the extension to use to pick the right loader
  51945. * @param mimeType defines an optional mime type
  51946. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51947. */
  51948. 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;
  51949. /**
  51950. * Creates a new render target texture
  51951. * @param size defines the size of the texture
  51952. * @param options defines the options used to create the texture
  51953. * @returns a new render target texture stored in an InternalTexture
  51954. */
  51955. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51956. /**
  51957. * Update the sampling mode of a given texture
  51958. * @param samplingMode defines the required sampling mode
  51959. * @param texture defines the texture to update
  51960. */
  51961. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51962. /**
  51963. * Binds the frame buffer to the specified texture.
  51964. * @param texture The texture to render to or null for the default canvas
  51965. * @param faceIndex The face of the texture to render to in case of cube texture
  51966. * @param requiredWidth The width of the target to render to
  51967. * @param requiredHeight The height of the target to render to
  51968. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51969. * @param lodLevel defines le lod level to bind to the frame buffer
  51970. */
  51971. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51972. /**
  51973. * Unbind the current render target texture from the webGL context
  51974. * @param texture defines the render target texture to unbind
  51975. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51976. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51977. */
  51978. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51979. /**
  51980. * Creates a dynamic vertex buffer
  51981. * @param vertices the data for the dynamic vertex buffer
  51982. * @returns the new WebGL dynamic buffer
  51983. */
  51984. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51985. /**
  51986. * Update the content of a dynamic texture
  51987. * @param texture defines the texture to update
  51988. * @param canvas defines the canvas containing the source
  51989. * @param invertY defines if data must be stored with Y axis inverted
  51990. * @param premulAlpha defines if alpha is stored as premultiplied
  51991. * @param format defines the format of the data
  51992. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51993. */
  51994. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51995. /**
  51996. * Gets a boolean indicating if all created effects are ready
  51997. * @returns true if all effects are ready
  51998. */
  51999. areAllEffectsReady(): boolean;
  52000. /**
  52001. * @hidden
  52002. * Get the current error code of the webGL context
  52003. * @returns the error code
  52004. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52005. */
  52006. getError(): number;
  52007. /** @hidden */
  52008. _getUnpackAlignement(): number;
  52009. /** @hidden */
  52010. _unpackFlipY(value: boolean): void;
  52011. /**
  52012. * Update a dynamic index buffer
  52013. * @param indexBuffer defines the target index buffer
  52014. * @param indices defines the data to update
  52015. * @param offset defines the offset in the target index buffer where update should start
  52016. */
  52017. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52018. /**
  52019. * Updates a dynamic vertex buffer.
  52020. * @param vertexBuffer the vertex buffer to update
  52021. * @param vertices the data used to update the vertex buffer
  52022. * @param byteOffset the byte offset of the data (optional)
  52023. * @param byteLength the byte length of the data (optional)
  52024. */
  52025. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52026. /** @hidden */
  52027. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52028. /** @hidden */
  52029. _bindTexture(channel: number, texture: InternalTexture): void;
  52030. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52031. /**
  52032. * 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
  52033. */
  52034. releaseEffects(): void;
  52035. displayLoadingUI(): void;
  52036. hideLoadingUI(): void;
  52037. /** @hidden */
  52038. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52039. /** @hidden */
  52040. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52041. /** @hidden */
  52042. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52043. /** @hidden */
  52044. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52045. }
  52046. }
  52047. declare module BABYLON {
  52048. /**
  52049. * @hidden
  52050. **/
  52051. export class _TimeToken {
  52052. _startTimeQuery: Nullable<WebGLQuery>;
  52053. _endTimeQuery: Nullable<WebGLQuery>;
  52054. _timeElapsedQuery: Nullable<WebGLQuery>;
  52055. _timeElapsedQueryEnded: boolean;
  52056. }
  52057. }
  52058. declare module BABYLON {
  52059. /** @hidden */
  52060. export class _OcclusionDataStorage {
  52061. /** @hidden */
  52062. occlusionInternalRetryCounter: number;
  52063. /** @hidden */
  52064. isOcclusionQueryInProgress: boolean;
  52065. /** @hidden */
  52066. isOccluded: boolean;
  52067. /** @hidden */
  52068. occlusionRetryCount: number;
  52069. /** @hidden */
  52070. occlusionType: number;
  52071. /** @hidden */
  52072. occlusionQueryAlgorithmType: number;
  52073. }
  52074. interface Engine {
  52075. /**
  52076. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52077. * @return the new query
  52078. */
  52079. createQuery(): WebGLQuery;
  52080. /**
  52081. * Delete and release a webGL query
  52082. * @param query defines the query to delete
  52083. * @return the current engine
  52084. */
  52085. deleteQuery(query: WebGLQuery): Engine;
  52086. /**
  52087. * Check if a given query has resolved and got its value
  52088. * @param query defines the query to check
  52089. * @returns true if the query got its value
  52090. */
  52091. isQueryResultAvailable(query: WebGLQuery): boolean;
  52092. /**
  52093. * Gets the value of a given query
  52094. * @param query defines the query to check
  52095. * @returns the value of the query
  52096. */
  52097. getQueryResult(query: WebGLQuery): number;
  52098. /**
  52099. * Initiates an occlusion query
  52100. * @param algorithmType defines the algorithm to use
  52101. * @param query defines the query to use
  52102. * @returns the current engine
  52103. * @see https://doc.babylonjs.com/features/occlusionquery
  52104. */
  52105. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52106. /**
  52107. * Ends an occlusion query
  52108. * @see https://doc.babylonjs.com/features/occlusionquery
  52109. * @param algorithmType defines the algorithm to use
  52110. * @returns the current engine
  52111. */
  52112. endOcclusionQuery(algorithmType: number): Engine;
  52113. /**
  52114. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52115. * Please note that only one query can be issued at a time
  52116. * @returns a time token used to track the time span
  52117. */
  52118. startTimeQuery(): Nullable<_TimeToken>;
  52119. /**
  52120. * Ends a time query
  52121. * @param token defines the token used to measure the time span
  52122. * @returns the time spent (in ns)
  52123. */
  52124. endTimeQuery(token: _TimeToken): int;
  52125. /** @hidden */
  52126. _currentNonTimestampToken: Nullable<_TimeToken>;
  52127. /** @hidden */
  52128. _createTimeQuery(): WebGLQuery;
  52129. /** @hidden */
  52130. _deleteTimeQuery(query: WebGLQuery): void;
  52131. /** @hidden */
  52132. _getGlAlgorithmType(algorithmType: number): number;
  52133. /** @hidden */
  52134. _getTimeQueryResult(query: WebGLQuery): any;
  52135. /** @hidden */
  52136. _getTimeQueryAvailability(query: WebGLQuery): any;
  52137. }
  52138. interface AbstractMesh {
  52139. /**
  52140. * Backing filed
  52141. * @hidden
  52142. */
  52143. __occlusionDataStorage: _OcclusionDataStorage;
  52144. /**
  52145. * Access property
  52146. * @hidden
  52147. */
  52148. _occlusionDataStorage: _OcclusionDataStorage;
  52149. /**
  52150. * 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.
  52151. * The default value is -1 which means don't break the query and wait till the result
  52152. * @see https://doc.babylonjs.com/features/occlusionquery
  52153. */
  52154. occlusionRetryCount: number;
  52155. /**
  52156. * 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:
  52157. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52158. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52159. * * 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.
  52160. * @see https://doc.babylonjs.com/features/occlusionquery
  52161. */
  52162. occlusionType: number;
  52163. /**
  52164. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52165. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52166. * * 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.
  52167. * @see https://doc.babylonjs.com/features/occlusionquery
  52168. */
  52169. occlusionQueryAlgorithmType: number;
  52170. /**
  52171. * 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
  52172. * @see https://doc.babylonjs.com/features/occlusionquery
  52173. */
  52174. isOccluded: boolean;
  52175. /**
  52176. * Flag to check the progress status of the query
  52177. * @see https://doc.babylonjs.com/features/occlusionquery
  52178. */
  52179. isOcclusionQueryInProgress: boolean;
  52180. }
  52181. }
  52182. declare module BABYLON {
  52183. /** @hidden */
  52184. export var _forceTransformFeedbackToBundle: boolean;
  52185. interface Engine {
  52186. /**
  52187. * Creates a webGL transform feedback object
  52188. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52189. * @returns the webGL transform feedback object
  52190. */
  52191. createTransformFeedback(): WebGLTransformFeedback;
  52192. /**
  52193. * Delete a webGL transform feedback object
  52194. * @param value defines the webGL transform feedback object to delete
  52195. */
  52196. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52197. /**
  52198. * Bind a webGL transform feedback object to the webgl context
  52199. * @param value defines the webGL transform feedback object to bind
  52200. */
  52201. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52202. /**
  52203. * Begins a transform feedback operation
  52204. * @param usePoints defines if points or triangles must be used
  52205. */
  52206. beginTransformFeedback(usePoints: boolean): void;
  52207. /**
  52208. * Ends a transform feedback operation
  52209. */
  52210. endTransformFeedback(): void;
  52211. /**
  52212. * Specify the varyings to use with transform feedback
  52213. * @param program defines the associated webGL program
  52214. * @param value defines the list of strings representing the varying names
  52215. */
  52216. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52217. /**
  52218. * Bind a webGL buffer for a transform feedback operation
  52219. * @param value defines the webGL buffer to bind
  52220. */
  52221. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52222. }
  52223. }
  52224. declare module BABYLON {
  52225. /**
  52226. * Class used to define an additional view for the engine
  52227. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52228. */
  52229. export class EngineView {
  52230. /** Defines the canvas where to render the view */
  52231. target: HTMLCanvasElement;
  52232. /** Defines an optional camera used to render the view (will use active camera else) */
  52233. camera?: Camera;
  52234. }
  52235. interface Engine {
  52236. /**
  52237. * Gets or sets the HTML element to use for attaching events
  52238. */
  52239. inputElement: Nullable<HTMLElement>;
  52240. /**
  52241. * Gets the current engine view
  52242. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52243. */
  52244. activeView: Nullable<EngineView>;
  52245. /** Gets or sets the list of views */
  52246. views: EngineView[];
  52247. /**
  52248. * Register a new child canvas
  52249. * @param canvas defines the canvas to register
  52250. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52251. * @returns the associated view
  52252. */
  52253. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52254. /**
  52255. * Remove a registered child canvas
  52256. * @param canvas defines the canvas to remove
  52257. * @returns the current engine
  52258. */
  52259. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52260. }
  52261. }
  52262. declare module BABYLON {
  52263. interface Engine {
  52264. /** @hidden */
  52265. _excludedCompressedTextures: string[];
  52266. /** @hidden */
  52267. _textureFormatInUse: string;
  52268. /**
  52269. * Gets the list of texture formats supported
  52270. */
  52271. readonly texturesSupported: Array<string>;
  52272. /**
  52273. * Gets the texture format in use
  52274. */
  52275. readonly textureFormatInUse: Nullable<string>;
  52276. /**
  52277. * Set the compressed texture extensions or file names to skip.
  52278. *
  52279. * @param skippedFiles defines the list of those texture files you want to skip
  52280. * Example: [".dds", ".env", "myfile.png"]
  52281. */
  52282. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52283. /**
  52284. * Set the compressed texture format to use, based on the formats you have, and the formats
  52285. * supported by the hardware / browser.
  52286. *
  52287. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52288. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52289. * to API arguments needed to compressed textures. This puts the burden on the container
  52290. * generator to house the arcane code for determining these for current & future formats.
  52291. *
  52292. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52293. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52294. *
  52295. * Note: The result of this call is not taken into account when a texture is base64.
  52296. *
  52297. * @param formatsAvailable defines the list of those format families you have created
  52298. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52299. *
  52300. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52301. * @returns The extension selected.
  52302. */
  52303. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52304. }
  52305. }
  52306. declare module BABYLON {
  52307. /**
  52308. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52309. */
  52310. export interface CubeMapInfo {
  52311. /**
  52312. * The pixel array for the front face.
  52313. * This is stored in format, left to right, up to down format.
  52314. */
  52315. front: Nullable<ArrayBufferView>;
  52316. /**
  52317. * The pixel array for the back face.
  52318. * This is stored in format, left to right, up to down format.
  52319. */
  52320. back: Nullable<ArrayBufferView>;
  52321. /**
  52322. * The pixel array for the left face.
  52323. * This is stored in format, left to right, up to down format.
  52324. */
  52325. left: Nullable<ArrayBufferView>;
  52326. /**
  52327. * The pixel array for the right face.
  52328. * This is stored in format, left to right, up to down format.
  52329. */
  52330. right: Nullable<ArrayBufferView>;
  52331. /**
  52332. * The pixel array for the up face.
  52333. * This is stored in format, left to right, up to down format.
  52334. */
  52335. up: Nullable<ArrayBufferView>;
  52336. /**
  52337. * The pixel array for the down face.
  52338. * This is stored in format, left to right, up to down format.
  52339. */
  52340. down: Nullable<ArrayBufferView>;
  52341. /**
  52342. * The size of the cubemap stored.
  52343. *
  52344. * Each faces will be size * size pixels.
  52345. */
  52346. size: number;
  52347. /**
  52348. * The format of the texture.
  52349. *
  52350. * RGBA, RGB.
  52351. */
  52352. format: number;
  52353. /**
  52354. * The type of the texture data.
  52355. *
  52356. * UNSIGNED_INT, FLOAT.
  52357. */
  52358. type: number;
  52359. /**
  52360. * Specifies whether the texture is in gamma space.
  52361. */
  52362. gammaSpace: boolean;
  52363. }
  52364. /**
  52365. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52366. */
  52367. export class PanoramaToCubeMapTools {
  52368. private static FACE_LEFT;
  52369. private static FACE_RIGHT;
  52370. private static FACE_FRONT;
  52371. private static FACE_BACK;
  52372. private static FACE_DOWN;
  52373. private static FACE_UP;
  52374. /**
  52375. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52376. *
  52377. * @param float32Array The source data.
  52378. * @param inputWidth The width of the input panorama.
  52379. * @param inputHeight The height of the input panorama.
  52380. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52381. * @return The cubemap data
  52382. */
  52383. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52384. private static CreateCubemapTexture;
  52385. private static CalcProjectionSpherical;
  52386. }
  52387. }
  52388. declare module BABYLON {
  52389. /**
  52390. * Helper class dealing with the extraction of spherical polynomial dataArray
  52391. * from a cube map.
  52392. */
  52393. export class CubeMapToSphericalPolynomialTools {
  52394. private static FileFaces;
  52395. /**
  52396. * Converts a texture to the according Spherical Polynomial data.
  52397. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52398. *
  52399. * @param texture The texture to extract the information from.
  52400. * @return The Spherical Polynomial data.
  52401. */
  52402. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52403. /**
  52404. * Converts a cubemap to the according Spherical Polynomial data.
  52405. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52406. *
  52407. * @param cubeInfo The Cube map to extract the information from.
  52408. * @return The Spherical Polynomial data.
  52409. */
  52410. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52411. }
  52412. }
  52413. declare module BABYLON {
  52414. interface BaseTexture {
  52415. /**
  52416. * Get the polynomial representation of the texture data.
  52417. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52418. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52419. */
  52420. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52421. }
  52422. }
  52423. declare module BABYLON {
  52424. /** @hidden */
  52425. export var rgbdEncodePixelShader: {
  52426. name: string;
  52427. shader: string;
  52428. };
  52429. }
  52430. declare module BABYLON {
  52431. /** @hidden */
  52432. export var rgbdDecodePixelShader: {
  52433. name: string;
  52434. shader: string;
  52435. };
  52436. }
  52437. declare module BABYLON {
  52438. /**
  52439. * Raw texture data and descriptor sufficient for WebGL texture upload
  52440. */
  52441. export interface EnvironmentTextureInfo {
  52442. /**
  52443. * Version of the environment map
  52444. */
  52445. version: number;
  52446. /**
  52447. * Width of image
  52448. */
  52449. width: number;
  52450. /**
  52451. * Irradiance information stored in the file.
  52452. */
  52453. irradiance: any;
  52454. /**
  52455. * Specular information stored in the file.
  52456. */
  52457. specular: any;
  52458. }
  52459. /**
  52460. * Defines One Image in the file. It requires only the position in the file
  52461. * as well as the length.
  52462. */
  52463. interface BufferImageData {
  52464. /**
  52465. * Length of the image data.
  52466. */
  52467. length: number;
  52468. /**
  52469. * Position of the data from the null terminator delimiting the end of the JSON.
  52470. */
  52471. position: number;
  52472. }
  52473. /**
  52474. * Defines the specular data enclosed in the file.
  52475. * This corresponds to the version 1 of the data.
  52476. */
  52477. export interface EnvironmentTextureSpecularInfoV1 {
  52478. /**
  52479. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52480. */
  52481. specularDataPosition?: number;
  52482. /**
  52483. * This contains all the images data needed to reconstruct the cubemap.
  52484. */
  52485. mipmaps: Array<BufferImageData>;
  52486. /**
  52487. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52488. */
  52489. lodGenerationScale: number;
  52490. }
  52491. /**
  52492. * Sets of helpers addressing the serialization and deserialization of environment texture
  52493. * stored in a BabylonJS env file.
  52494. * Those files are usually stored as .env files.
  52495. */
  52496. export class EnvironmentTextureTools {
  52497. /**
  52498. * Magic number identifying the env file.
  52499. */
  52500. private static _MagicBytes;
  52501. /**
  52502. * Gets the environment info from an env file.
  52503. * @param data The array buffer containing the .env bytes.
  52504. * @returns the environment file info (the json header) if successfully parsed.
  52505. */
  52506. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52507. /**
  52508. * Creates an environment texture from a loaded cube texture.
  52509. * @param texture defines the cube texture to convert in env file
  52510. * @return a promise containing the environment data if succesfull.
  52511. */
  52512. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52513. /**
  52514. * Creates a JSON representation of the spherical data.
  52515. * @param texture defines the texture containing the polynomials
  52516. * @return the JSON representation of the spherical info
  52517. */
  52518. private static _CreateEnvTextureIrradiance;
  52519. /**
  52520. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52521. * @param data the image data
  52522. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52523. * @return the views described by info providing access to the underlying buffer
  52524. */
  52525. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52526. /**
  52527. * Uploads the texture info contained in the env file to the GPU.
  52528. * @param texture defines the internal texture to upload to
  52529. * @param data defines the data to load
  52530. * @param info defines the texture info retrieved through the GetEnvInfo method
  52531. * @returns a promise
  52532. */
  52533. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52534. private static _OnImageReadyAsync;
  52535. /**
  52536. * Uploads the levels of image data to the GPU.
  52537. * @param texture defines the internal texture to upload to
  52538. * @param imageData defines the array buffer views of image data [mipmap][face]
  52539. * @returns a promise
  52540. */
  52541. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52542. /**
  52543. * Uploads spherical polynomials information to the texture.
  52544. * @param texture defines the texture we are trying to upload the information to
  52545. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52546. */
  52547. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52548. /** @hidden */
  52549. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52550. }
  52551. }
  52552. declare module BABYLON {
  52553. /**
  52554. * Class used to inline functions in shader code
  52555. */
  52556. export class ShaderCodeInliner {
  52557. private static readonly _RegexpFindFunctionNameAndType;
  52558. private _sourceCode;
  52559. private _functionDescr;
  52560. private _numMaxIterations;
  52561. /** Gets or sets the token used to mark the functions to inline */
  52562. inlineToken: string;
  52563. /** Gets or sets the debug mode */
  52564. debug: boolean;
  52565. /** Gets the code after the inlining process */
  52566. get code(): string;
  52567. /**
  52568. * Initializes the inliner
  52569. * @param sourceCode shader code source to inline
  52570. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52571. */
  52572. constructor(sourceCode: string, numMaxIterations?: number);
  52573. /**
  52574. * Start the processing of the shader code
  52575. */
  52576. processCode(): void;
  52577. private _collectFunctions;
  52578. private _processInlining;
  52579. private _extractBetweenMarkers;
  52580. private _skipWhitespaces;
  52581. private _removeComments;
  52582. private _replaceFunctionCallsByCode;
  52583. private _findBackward;
  52584. private _escapeRegExp;
  52585. private _replaceNames;
  52586. }
  52587. }
  52588. declare module BABYLON {
  52589. /**
  52590. * Container for accessors for natively-stored mesh data buffers.
  52591. */
  52592. class NativeDataBuffer extends DataBuffer {
  52593. /**
  52594. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52595. */
  52596. nativeIndexBuffer?: any;
  52597. /**
  52598. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52599. */
  52600. nativeVertexBuffer?: any;
  52601. }
  52602. /** @hidden */
  52603. class NativeTexture extends InternalTexture {
  52604. getInternalTexture(): InternalTexture;
  52605. getViewCount(): number;
  52606. }
  52607. /** @hidden */
  52608. export class NativeEngine extends Engine {
  52609. private readonly _native;
  52610. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52611. private readonly INVALID_HANDLE;
  52612. private _boundBuffersVertexArray;
  52613. getHardwareScalingLevel(): number;
  52614. constructor();
  52615. dispose(): void;
  52616. /**
  52617. * Can be used to override the current requestAnimationFrame requester.
  52618. * @hidden
  52619. */
  52620. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52621. /**
  52622. * Override default engine behavior.
  52623. * @param color
  52624. * @param backBuffer
  52625. * @param depth
  52626. * @param stencil
  52627. */
  52628. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52629. /**
  52630. * Gets host document
  52631. * @returns the host document object
  52632. */
  52633. getHostDocument(): Nullable<Document>;
  52634. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52635. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52636. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52637. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52638. [key: string]: VertexBuffer;
  52639. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52640. bindBuffers(vertexBuffers: {
  52641. [key: string]: VertexBuffer;
  52642. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52643. recordVertexArrayObject(vertexBuffers: {
  52644. [key: string]: VertexBuffer;
  52645. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52646. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52647. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52648. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52649. /**
  52650. * Draw a list of indexed primitives
  52651. * @param fillMode defines the primitive to use
  52652. * @param indexStart defines the starting index
  52653. * @param indexCount defines the number of index to draw
  52654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52655. */
  52656. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52657. /**
  52658. * Draw a list of unindexed primitives
  52659. * @param fillMode defines the primitive to use
  52660. * @param verticesStart defines the index of first vertex to draw
  52661. * @param verticesCount defines the count of vertices to draw
  52662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52663. */
  52664. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52665. createPipelineContext(): IPipelineContext;
  52666. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52667. /** @hidden */
  52668. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52669. /** @hidden */
  52670. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52671. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52672. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52673. protected _setProgram(program: WebGLProgram): void;
  52674. _releaseEffect(effect: Effect): void;
  52675. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52676. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52677. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52678. bindSamplers(effect: Effect): void;
  52679. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52680. getRenderWidth(useScreen?: boolean): number;
  52681. getRenderHeight(useScreen?: boolean): number;
  52682. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52683. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52684. /**
  52685. * Set the z offset to apply to current rendering
  52686. * @param value defines the offset to apply
  52687. */
  52688. setZOffset(value: number): void;
  52689. /**
  52690. * Gets the current value of the zOffset
  52691. * @returns the current zOffset state
  52692. */
  52693. getZOffset(): number;
  52694. /**
  52695. * Enable or disable depth buffering
  52696. * @param enable defines the state to set
  52697. */
  52698. setDepthBuffer(enable: boolean): void;
  52699. /**
  52700. * Gets a boolean indicating if depth writing is enabled
  52701. * @returns the current depth writing state
  52702. */
  52703. getDepthWrite(): boolean;
  52704. /**
  52705. * Enable or disable depth writing
  52706. * @param enable defines the state to set
  52707. */
  52708. setDepthWrite(enable: boolean): void;
  52709. /**
  52710. * Enable or disable color writing
  52711. * @param enable defines the state to set
  52712. */
  52713. setColorWrite(enable: boolean): void;
  52714. /**
  52715. * Gets a boolean indicating if color writing is enabled
  52716. * @returns the current color writing state
  52717. */
  52718. getColorWrite(): boolean;
  52719. /**
  52720. * Sets alpha constants used by some alpha blending modes
  52721. * @param r defines the red component
  52722. * @param g defines the green component
  52723. * @param b defines the blue component
  52724. * @param a defines the alpha component
  52725. */
  52726. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52727. /**
  52728. * Sets the current alpha mode
  52729. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52730. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52731. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52732. */
  52733. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52734. /**
  52735. * Gets the current alpha mode
  52736. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52737. * @returns the current alpha mode
  52738. */
  52739. getAlphaMode(): number;
  52740. setInt(uniform: WebGLUniformLocation, int: number): void;
  52741. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52742. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52743. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52744. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52745. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52746. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52747. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52748. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52749. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52750. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52751. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52752. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52753. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52754. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52755. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52756. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52757. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52758. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52759. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52760. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52761. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52762. wipeCaches(bruteForce?: boolean): void;
  52763. _createTexture(): WebGLTexture;
  52764. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52765. /**
  52766. * Usually called from Texture.ts.
  52767. * Passed information to create a WebGLTexture
  52768. * @param url defines a value which contains one of the following:
  52769. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52770. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52771. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52772. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52773. * @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)
  52774. * @param scene needed for loading to the correct scene
  52775. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52776. * @param onLoad optional callback to be called upon successful completion
  52777. * @param onError optional callback to be called upon failure
  52778. * @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
  52779. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52780. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52781. * @param forcedExtension defines the extension to use to pick the right loader
  52782. * @param mimeType defines an optional mime type
  52783. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52784. */
  52785. 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;
  52786. /**
  52787. * Creates a cube texture
  52788. * @param rootUrl defines the url where the files to load is located
  52789. * @param scene defines the current scene
  52790. * @param files defines the list of files to load (1 per face)
  52791. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52792. * @param onLoad defines an optional callback raised when the texture is loaded
  52793. * @param onError defines an optional callback raised if there is an issue to load the texture
  52794. * @param format defines the format of the data
  52795. * @param forcedExtension defines the extension to use to pick the right loader
  52796. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52797. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52798. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52799. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52800. * @returns the cube texture as an InternalTexture
  52801. */
  52802. 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;
  52803. private _getSamplingFilter;
  52804. private static _GetNativeTextureFormat;
  52805. createRenderTargetTexture(size: number | {
  52806. width: number;
  52807. height: number;
  52808. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52809. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52810. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52811. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52812. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52813. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52814. /**
  52815. * Updates a dynamic vertex buffer.
  52816. * @param vertexBuffer the vertex buffer to update
  52817. * @param data the data used to update the vertex buffer
  52818. * @param byteOffset the byte offset of the data (optional)
  52819. * @param byteLength the byte length of the data (optional)
  52820. */
  52821. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52822. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52823. private _updateAnisotropicLevel;
  52824. private _getAddressMode;
  52825. /** @hidden */
  52826. _bindTexture(channel: number, texture: InternalTexture): void;
  52827. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52828. releaseEffects(): void;
  52829. /** @hidden */
  52830. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52831. /** @hidden */
  52832. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52833. /** @hidden */
  52834. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52835. /** @hidden */
  52836. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52837. }
  52838. }
  52839. declare module BABYLON {
  52840. /**
  52841. * Gather the list of clipboard event types as constants.
  52842. */
  52843. export class ClipboardEventTypes {
  52844. /**
  52845. * The clipboard event is fired when a copy command is active (pressed).
  52846. */
  52847. static readonly COPY: number;
  52848. /**
  52849. * The clipboard event is fired when a cut command is active (pressed).
  52850. */
  52851. static readonly CUT: number;
  52852. /**
  52853. * The clipboard event is fired when a paste command is active (pressed).
  52854. */
  52855. static readonly PASTE: number;
  52856. }
  52857. /**
  52858. * This class is used to store clipboard related info for the onClipboardObservable event.
  52859. */
  52860. export class ClipboardInfo {
  52861. /**
  52862. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52863. */
  52864. type: number;
  52865. /**
  52866. * Defines the related dom event
  52867. */
  52868. event: ClipboardEvent;
  52869. /**
  52870. *Creates an instance of ClipboardInfo.
  52871. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52872. * @param event Defines the related dom event
  52873. */
  52874. constructor(
  52875. /**
  52876. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52877. */
  52878. type: number,
  52879. /**
  52880. * Defines the related dom event
  52881. */
  52882. event: ClipboardEvent);
  52883. /**
  52884. * Get the clipboard event's type from the keycode.
  52885. * @param keyCode Defines the keyCode for the current keyboard event.
  52886. * @return {number}
  52887. */
  52888. static GetTypeFromCharacter(keyCode: number): number;
  52889. }
  52890. }
  52891. declare module BABYLON {
  52892. /**
  52893. * Google Daydream controller
  52894. */
  52895. export class DaydreamController extends WebVRController {
  52896. /**
  52897. * Base Url for the controller model.
  52898. */
  52899. static MODEL_BASE_URL: string;
  52900. /**
  52901. * File name for the controller model.
  52902. */
  52903. static MODEL_FILENAME: string;
  52904. /**
  52905. * Gamepad Id prefix used to identify Daydream Controller.
  52906. */
  52907. static readonly GAMEPAD_ID_PREFIX: string;
  52908. /**
  52909. * Creates a new DaydreamController from a gamepad
  52910. * @param vrGamepad the gamepad that the controller should be created from
  52911. */
  52912. constructor(vrGamepad: any);
  52913. /**
  52914. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52915. * @param scene scene in which to add meshes
  52916. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52917. */
  52918. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52919. /**
  52920. * Called once for each button that changed state since the last frame
  52921. * @param buttonIdx Which button index changed
  52922. * @param state New state of the button
  52923. * @param changes Which properties on the state changed since last frame
  52924. */
  52925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52926. }
  52927. }
  52928. declare module BABYLON {
  52929. /**
  52930. * Gear VR Controller
  52931. */
  52932. export class GearVRController extends WebVRController {
  52933. /**
  52934. * Base Url for the controller model.
  52935. */
  52936. static MODEL_BASE_URL: string;
  52937. /**
  52938. * File name for the controller model.
  52939. */
  52940. static MODEL_FILENAME: string;
  52941. /**
  52942. * Gamepad Id prefix used to identify this controller.
  52943. */
  52944. static readonly GAMEPAD_ID_PREFIX: string;
  52945. private readonly _buttonIndexToObservableNameMap;
  52946. /**
  52947. * Creates a new GearVRController from a gamepad
  52948. * @param vrGamepad the gamepad that the controller should be created from
  52949. */
  52950. constructor(vrGamepad: any);
  52951. /**
  52952. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52953. * @param scene scene in which to add meshes
  52954. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52955. */
  52956. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52957. /**
  52958. * Called once for each button that changed state since the last frame
  52959. * @param buttonIdx Which button index changed
  52960. * @param state New state of the button
  52961. * @param changes Which properties on the state changed since last frame
  52962. */
  52963. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52964. }
  52965. }
  52966. declare module BABYLON {
  52967. /**
  52968. * Generic Controller
  52969. */
  52970. export class GenericController extends WebVRController {
  52971. /**
  52972. * Base Url for the controller model.
  52973. */
  52974. static readonly MODEL_BASE_URL: string;
  52975. /**
  52976. * File name for the controller model.
  52977. */
  52978. static readonly MODEL_FILENAME: string;
  52979. /**
  52980. * Creates a new GenericController from a gamepad
  52981. * @param vrGamepad the gamepad that the controller should be created from
  52982. */
  52983. constructor(vrGamepad: any);
  52984. /**
  52985. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52986. * @param scene scene in which to add meshes
  52987. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52988. */
  52989. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52990. /**
  52991. * Called once for each button that changed state since the last frame
  52992. * @param buttonIdx Which button index changed
  52993. * @param state New state of the button
  52994. * @param changes Which properties on the state changed since last frame
  52995. */
  52996. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52997. }
  52998. }
  52999. declare module BABYLON {
  53000. /**
  53001. * Oculus Touch Controller
  53002. */
  53003. export class OculusTouchController extends WebVRController {
  53004. /**
  53005. * Base Url for the controller model.
  53006. */
  53007. static MODEL_BASE_URL: string;
  53008. /**
  53009. * File name for the left controller model.
  53010. */
  53011. static MODEL_LEFT_FILENAME: string;
  53012. /**
  53013. * File name for the right controller model.
  53014. */
  53015. static MODEL_RIGHT_FILENAME: string;
  53016. /**
  53017. * Base Url for the Quest controller model.
  53018. */
  53019. static QUEST_MODEL_BASE_URL: string;
  53020. /**
  53021. * @hidden
  53022. * If the controllers are running on a device that needs the updated Quest controller models
  53023. */
  53024. static _IsQuest: boolean;
  53025. /**
  53026. * Fired when the secondary trigger on this controller is modified
  53027. */
  53028. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53029. /**
  53030. * Fired when the thumb rest on this controller is modified
  53031. */
  53032. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53033. /**
  53034. * Creates a new OculusTouchController from a gamepad
  53035. * @param vrGamepad the gamepad that the controller should be created from
  53036. */
  53037. constructor(vrGamepad: any);
  53038. /**
  53039. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53040. * @param scene scene in which to add meshes
  53041. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53042. */
  53043. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53044. /**
  53045. * Fired when the A button on this controller is modified
  53046. */
  53047. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53048. /**
  53049. * Fired when the B button on this controller is modified
  53050. */
  53051. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53052. /**
  53053. * Fired when the X button on this controller is modified
  53054. */
  53055. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53056. /**
  53057. * Fired when the Y button on this controller is modified
  53058. */
  53059. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53060. /**
  53061. * Called once for each button that changed state since the last frame
  53062. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53063. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53064. * 2) secondary trigger (same)
  53065. * 3) A (right) X (left), touch, pressed = value
  53066. * 4) B / Y
  53067. * 5) thumb rest
  53068. * @param buttonIdx Which button index changed
  53069. * @param state New state of the button
  53070. * @param changes Which properties on the state changed since last frame
  53071. */
  53072. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53073. }
  53074. }
  53075. declare module BABYLON {
  53076. /**
  53077. * Vive Controller
  53078. */
  53079. export class ViveController extends WebVRController {
  53080. /**
  53081. * Base Url for the controller model.
  53082. */
  53083. static MODEL_BASE_URL: string;
  53084. /**
  53085. * File name for the controller model.
  53086. */
  53087. static MODEL_FILENAME: string;
  53088. /**
  53089. * Creates a new ViveController from a gamepad
  53090. * @param vrGamepad the gamepad that the controller should be created from
  53091. */
  53092. constructor(vrGamepad: any);
  53093. /**
  53094. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53095. * @param scene scene in which to add meshes
  53096. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53097. */
  53098. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53099. /**
  53100. * Fired when the left button on this controller is modified
  53101. */
  53102. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53103. /**
  53104. * Fired when the right button on this controller is modified
  53105. */
  53106. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53107. /**
  53108. * Fired when the menu button on this controller is modified
  53109. */
  53110. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53111. /**
  53112. * Called once for each button that changed state since the last frame
  53113. * Vive mapping:
  53114. * 0: touchpad
  53115. * 1: trigger
  53116. * 2: left AND right buttons
  53117. * 3: menu button
  53118. * @param buttonIdx Which button index changed
  53119. * @param state New state of the button
  53120. * @param changes Which properties on the state changed since last frame
  53121. */
  53122. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53123. }
  53124. }
  53125. declare module BABYLON {
  53126. /**
  53127. * Defines the WindowsMotionController object that the state of the windows motion controller
  53128. */
  53129. export class WindowsMotionController extends WebVRController {
  53130. /**
  53131. * The base url used to load the left and right controller models
  53132. */
  53133. static MODEL_BASE_URL: string;
  53134. /**
  53135. * The name of the left controller model file
  53136. */
  53137. static MODEL_LEFT_FILENAME: string;
  53138. /**
  53139. * The name of the right controller model file
  53140. */
  53141. static MODEL_RIGHT_FILENAME: string;
  53142. /**
  53143. * The controller name prefix for this controller type
  53144. */
  53145. static readonly GAMEPAD_ID_PREFIX: string;
  53146. /**
  53147. * The controller id pattern for this controller type
  53148. */
  53149. private static readonly GAMEPAD_ID_PATTERN;
  53150. private _loadedMeshInfo;
  53151. protected readonly _mapping: {
  53152. buttons: string[];
  53153. buttonMeshNames: {
  53154. trigger: string;
  53155. menu: string;
  53156. grip: string;
  53157. thumbstick: string;
  53158. trackpad: string;
  53159. };
  53160. buttonObservableNames: {
  53161. trigger: string;
  53162. menu: string;
  53163. grip: string;
  53164. thumbstick: string;
  53165. trackpad: string;
  53166. };
  53167. axisMeshNames: string[];
  53168. pointingPoseMeshName: string;
  53169. };
  53170. /**
  53171. * Fired when the trackpad on this controller is clicked
  53172. */
  53173. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53174. /**
  53175. * Fired when the trackpad on this controller is modified
  53176. */
  53177. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53178. /**
  53179. * The current x and y values of this controller's trackpad
  53180. */
  53181. trackpad: StickValues;
  53182. /**
  53183. * Creates a new WindowsMotionController from a gamepad
  53184. * @param vrGamepad the gamepad that the controller should be created from
  53185. */
  53186. constructor(vrGamepad: any);
  53187. /**
  53188. * Fired when the trigger on this controller is modified
  53189. */
  53190. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53191. /**
  53192. * Fired when the menu button on this controller is modified
  53193. */
  53194. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53195. /**
  53196. * Fired when the grip button on this controller is modified
  53197. */
  53198. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53199. /**
  53200. * Fired when the thumbstick button on this controller is modified
  53201. */
  53202. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53203. /**
  53204. * Fired when the touchpad button on this controller is modified
  53205. */
  53206. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53207. /**
  53208. * Fired when the touchpad values on this controller are modified
  53209. */
  53210. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53211. protected _updateTrackpad(): void;
  53212. /**
  53213. * Called once per frame by the engine.
  53214. */
  53215. update(): void;
  53216. /**
  53217. * Called once for each button that changed state since the last frame
  53218. * @param buttonIdx Which button index changed
  53219. * @param state New state of the button
  53220. * @param changes Which properties on the state changed since last frame
  53221. */
  53222. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53223. /**
  53224. * Moves the buttons on the controller mesh based on their current state
  53225. * @param buttonName the name of the button to move
  53226. * @param buttonValue the value of the button which determines the buttons new position
  53227. */
  53228. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53229. /**
  53230. * Moves the axis on the controller mesh based on its current state
  53231. * @param axis the index of the axis
  53232. * @param axisValue the value of the axis which determines the meshes new position
  53233. * @hidden
  53234. */
  53235. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53236. /**
  53237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53238. * @param scene scene in which to add meshes
  53239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53240. */
  53241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53242. /**
  53243. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53244. * can be transformed by button presses and axes values, based on this._mapping.
  53245. *
  53246. * @param scene scene in which the meshes exist
  53247. * @param meshes list of meshes that make up the controller model to process
  53248. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53249. */
  53250. private processModel;
  53251. private createMeshInfo;
  53252. /**
  53253. * Gets the ray of the controller in the direction the controller is pointing
  53254. * @param length the length the resulting ray should be
  53255. * @returns a ray in the direction the controller is pointing
  53256. */
  53257. getForwardRay(length?: number): Ray;
  53258. /**
  53259. * Disposes of the controller
  53260. */
  53261. dispose(): void;
  53262. }
  53263. /**
  53264. * This class represents a new windows motion controller in XR.
  53265. */
  53266. export class XRWindowsMotionController extends WindowsMotionController {
  53267. /**
  53268. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53269. */
  53270. protected readonly _mapping: {
  53271. buttons: string[];
  53272. buttonMeshNames: {
  53273. trigger: string;
  53274. menu: string;
  53275. grip: string;
  53276. thumbstick: string;
  53277. trackpad: string;
  53278. };
  53279. buttonObservableNames: {
  53280. trigger: string;
  53281. menu: string;
  53282. grip: string;
  53283. thumbstick: string;
  53284. trackpad: string;
  53285. };
  53286. axisMeshNames: string[];
  53287. pointingPoseMeshName: string;
  53288. };
  53289. /**
  53290. * Construct a new XR-Based windows motion controller
  53291. *
  53292. * @param gamepadInfo the gamepad object from the browser
  53293. */
  53294. constructor(gamepadInfo: any);
  53295. /**
  53296. * holds the thumbstick values (X,Y)
  53297. */
  53298. thumbstickValues: StickValues;
  53299. /**
  53300. * Fired when the thumbstick on this controller is clicked
  53301. */
  53302. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53303. /**
  53304. * Fired when the thumbstick on this controller is modified
  53305. */
  53306. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53307. /**
  53308. * Fired when the touchpad button on this controller is modified
  53309. */
  53310. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53311. /**
  53312. * Fired when the touchpad values on this controller are modified
  53313. */
  53314. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53315. /**
  53316. * Fired when the thumbstick button on this controller is modified
  53317. * here to prevent breaking changes
  53318. */
  53319. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53320. /**
  53321. * updating the thumbstick(!) and not the trackpad.
  53322. * This is named this way due to the difference between WebVR and XR and to avoid
  53323. * changing the parent class.
  53324. */
  53325. protected _updateTrackpad(): void;
  53326. /**
  53327. * Disposes the class with joy
  53328. */
  53329. dispose(): void;
  53330. }
  53331. }
  53332. declare module BABYLON {
  53333. /**
  53334. * Class containing static functions to help procedurally build meshes
  53335. */
  53336. export class PolyhedronBuilder {
  53337. /**
  53338. * Creates a polyhedron mesh
  53339. * * 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
  53340. * * The parameter `size` (positive float, default 1) sets the polygon size
  53341. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53342. * * 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`
  53343. * * 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
  53344. * * 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)`)
  53345. * * 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
  53346. * * 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
  53347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53348. * * 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
  53349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53350. * @param name defines the name of the mesh
  53351. * @param options defines the options used to create the mesh
  53352. * @param scene defines the hosting scene
  53353. * @returns the polyhedron mesh
  53354. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53355. */
  53356. static CreatePolyhedron(name: string, options: {
  53357. type?: number;
  53358. size?: number;
  53359. sizeX?: number;
  53360. sizeY?: number;
  53361. sizeZ?: number;
  53362. custom?: any;
  53363. faceUV?: Vector4[];
  53364. faceColors?: Color4[];
  53365. flat?: boolean;
  53366. updatable?: boolean;
  53367. sideOrientation?: number;
  53368. frontUVs?: Vector4;
  53369. backUVs?: Vector4;
  53370. }, scene?: Nullable<Scene>): Mesh;
  53371. }
  53372. }
  53373. declare module BABYLON {
  53374. /**
  53375. * Gizmo that enables scaling a mesh along 3 axis
  53376. */
  53377. export class ScaleGizmo extends Gizmo {
  53378. /**
  53379. * Internal gizmo used for interactions on the x axis
  53380. */
  53381. xGizmo: AxisScaleGizmo;
  53382. /**
  53383. * Internal gizmo used for interactions on the y axis
  53384. */
  53385. yGizmo: AxisScaleGizmo;
  53386. /**
  53387. * Internal gizmo used for interactions on the z axis
  53388. */
  53389. zGizmo: AxisScaleGizmo;
  53390. /**
  53391. * Internal gizmo used to scale all axis equally
  53392. */
  53393. uniformScaleGizmo: AxisScaleGizmo;
  53394. private _meshAttached;
  53395. private _nodeAttached;
  53396. private _snapDistance;
  53397. private _uniformScalingMesh;
  53398. private _octahedron;
  53399. private _sensitivity;
  53400. /** Fires an event when any of it's sub gizmos are dragged */
  53401. onDragStartObservable: Observable<unknown>;
  53402. /** Fires an event when any of it's sub gizmos are released from dragging */
  53403. onDragEndObservable: Observable<unknown>;
  53404. get attachedMesh(): Nullable<AbstractMesh>;
  53405. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53406. get attachedNode(): Nullable<Node>;
  53407. set attachedNode(node: Nullable<Node>);
  53408. /**
  53409. * Creates a ScaleGizmo
  53410. * @param gizmoLayer The utility layer the gizmo will be added to
  53411. * @param thickness display gizmo axis thickness
  53412. */
  53413. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53414. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53415. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53416. /**
  53417. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53418. */
  53419. set snapDistance(value: number);
  53420. get snapDistance(): number;
  53421. /**
  53422. * Ratio for the scale of the gizmo (Default: 1)
  53423. */
  53424. set scaleRatio(value: number);
  53425. get scaleRatio(): number;
  53426. /**
  53427. * Sensitivity factor for dragging (Default: 1)
  53428. */
  53429. set sensitivity(value: number);
  53430. get sensitivity(): number;
  53431. /**
  53432. * Disposes of the gizmo
  53433. */
  53434. dispose(): void;
  53435. }
  53436. }
  53437. declare module BABYLON {
  53438. /**
  53439. * Single axis scale gizmo
  53440. */
  53441. export class AxisScaleGizmo extends Gizmo {
  53442. /**
  53443. * Drag behavior responsible for the gizmos dragging interactions
  53444. */
  53445. dragBehavior: PointerDragBehavior;
  53446. private _pointerObserver;
  53447. /**
  53448. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53449. */
  53450. snapDistance: number;
  53451. /**
  53452. * Event that fires each time the gizmo snaps to a new location.
  53453. * * snapDistance is the the change in distance
  53454. */
  53455. onSnapObservable: Observable<{
  53456. snapDistance: number;
  53457. }>;
  53458. /**
  53459. * If the scaling operation should be done on all axis (default: false)
  53460. */
  53461. uniformScaling: boolean;
  53462. /**
  53463. * Custom sensitivity value for the drag strength
  53464. */
  53465. sensitivity: number;
  53466. private _isEnabled;
  53467. private _parent;
  53468. private _arrow;
  53469. private _coloredMaterial;
  53470. private _hoverMaterial;
  53471. /**
  53472. * Creates an AxisScaleGizmo
  53473. * @param gizmoLayer The utility layer the gizmo will be added to
  53474. * @param dragAxis The axis which the gizmo will be able to scale on
  53475. * @param color The color of the gizmo
  53476. * @param thickness display gizmo axis thickness
  53477. */
  53478. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53479. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53480. /**
  53481. * If the gizmo is enabled
  53482. */
  53483. set isEnabled(value: boolean);
  53484. get isEnabled(): boolean;
  53485. /**
  53486. * Disposes of the gizmo
  53487. */
  53488. dispose(): void;
  53489. /**
  53490. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53491. * @param mesh The mesh to replace the default mesh of the gizmo
  53492. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53493. */
  53494. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53495. }
  53496. }
  53497. declare module BABYLON {
  53498. /**
  53499. * Bounding box gizmo
  53500. */
  53501. export class BoundingBoxGizmo extends Gizmo {
  53502. private _lineBoundingBox;
  53503. private _rotateSpheresParent;
  53504. private _scaleBoxesParent;
  53505. private _boundingDimensions;
  53506. private _renderObserver;
  53507. private _pointerObserver;
  53508. private _scaleDragSpeed;
  53509. private _tmpQuaternion;
  53510. private _tmpVector;
  53511. private _tmpRotationMatrix;
  53512. /**
  53513. * 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)
  53514. */
  53515. ignoreChildren: boolean;
  53516. /**
  53517. * 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)
  53518. */
  53519. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53520. /**
  53521. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53522. */
  53523. rotationSphereSize: number;
  53524. /**
  53525. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53526. */
  53527. scaleBoxSize: number;
  53528. /**
  53529. * 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)
  53530. */
  53531. fixedDragMeshScreenSize: boolean;
  53532. /**
  53533. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53534. */
  53535. fixedDragMeshScreenSizeDistanceFactor: number;
  53536. /**
  53537. * Fired when a rotation sphere or scale box is dragged
  53538. */
  53539. onDragStartObservable: Observable<{}>;
  53540. /**
  53541. * Fired when a scale box is dragged
  53542. */
  53543. onScaleBoxDragObservable: Observable<{}>;
  53544. /**
  53545. * Fired when a scale box drag is ended
  53546. */
  53547. onScaleBoxDragEndObservable: Observable<{}>;
  53548. /**
  53549. * Fired when a rotation sphere is dragged
  53550. */
  53551. onRotationSphereDragObservable: Observable<{}>;
  53552. /**
  53553. * Fired when a rotation sphere drag is ended
  53554. */
  53555. onRotationSphereDragEndObservable: Observable<{}>;
  53556. /**
  53557. * 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)
  53558. */
  53559. scalePivot: Nullable<Vector3>;
  53560. /**
  53561. * Mesh used as a pivot to rotate the attached node
  53562. */
  53563. private _anchorMesh;
  53564. private _existingMeshScale;
  53565. private _dragMesh;
  53566. private pointerDragBehavior;
  53567. private coloredMaterial;
  53568. private hoverColoredMaterial;
  53569. /**
  53570. * Sets the color of the bounding box gizmo
  53571. * @param color the color to set
  53572. */
  53573. setColor(color: Color3): void;
  53574. /**
  53575. * Creates an BoundingBoxGizmo
  53576. * @param gizmoLayer The utility layer the gizmo will be added to
  53577. * @param color The color of the gizmo
  53578. */
  53579. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53580. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53581. private _selectNode;
  53582. /**
  53583. * Updates the bounding box information for the Gizmo
  53584. */
  53585. updateBoundingBox(): void;
  53586. private _updateRotationSpheres;
  53587. private _updateScaleBoxes;
  53588. /**
  53589. * Enables rotation on the specified axis and disables rotation on the others
  53590. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53591. */
  53592. setEnabledRotationAxis(axis: string): void;
  53593. /**
  53594. * Enables/disables scaling
  53595. * @param enable if scaling should be enabled
  53596. * @param homogeneousScaling defines if scaling should only be homogeneous
  53597. */
  53598. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53599. private _updateDummy;
  53600. /**
  53601. * Enables a pointer drag behavior on the bounding box of the gizmo
  53602. */
  53603. enableDragBehavior(): void;
  53604. /**
  53605. * Disposes of the gizmo
  53606. */
  53607. dispose(): void;
  53608. /**
  53609. * 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)
  53610. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53611. * @returns the bounding box mesh with the passed in mesh as a child
  53612. */
  53613. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53614. /**
  53615. * CustomMeshes are not supported by this gizmo
  53616. * @param mesh The mesh to replace the default mesh of the gizmo
  53617. */
  53618. setCustomMesh(mesh: Mesh): void;
  53619. }
  53620. }
  53621. declare module BABYLON {
  53622. /**
  53623. * Single plane rotation gizmo
  53624. */
  53625. export class PlaneRotationGizmo extends Gizmo {
  53626. /**
  53627. * Drag behavior responsible for the gizmos dragging interactions
  53628. */
  53629. dragBehavior: PointerDragBehavior;
  53630. private _pointerObserver;
  53631. /**
  53632. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53633. */
  53634. snapDistance: number;
  53635. /**
  53636. * Event that fires each time the gizmo snaps to a new location.
  53637. * * snapDistance is the the change in distance
  53638. */
  53639. onSnapObservable: Observable<{
  53640. snapDistance: number;
  53641. }>;
  53642. private _isEnabled;
  53643. private _parent;
  53644. /**
  53645. * Creates a PlaneRotationGizmo
  53646. * @param gizmoLayer The utility layer the gizmo will be added to
  53647. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53648. * @param color The color of the gizmo
  53649. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53650. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53651. * @param thickness display gizmo axis thickness
  53652. */
  53653. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53654. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53655. /**
  53656. * If the gizmo is enabled
  53657. */
  53658. set isEnabled(value: boolean);
  53659. get isEnabled(): boolean;
  53660. /**
  53661. * Disposes of the gizmo
  53662. */
  53663. dispose(): void;
  53664. }
  53665. }
  53666. declare module BABYLON {
  53667. /**
  53668. * Gizmo that enables rotating a mesh along 3 axis
  53669. */
  53670. export class RotationGizmo extends Gizmo {
  53671. /**
  53672. * Internal gizmo used for interactions on the x axis
  53673. */
  53674. xGizmo: PlaneRotationGizmo;
  53675. /**
  53676. * Internal gizmo used for interactions on the y axis
  53677. */
  53678. yGizmo: PlaneRotationGizmo;
  53679. /**
  53680. * Internal gizmo used for interactions on the z axis
  53681. */
  53682. zGizmo: PlaneRotationGizmo;
  53683. /** Fires an event when any of it's sub gizmos are dragged */
  53684. onDragStartObservable: Observable<unknown>;
  53685. /** Fires an event when any of it's sub gizmos are released from dragging */
  53686. onDragEndObservable: Observable<unknown>;
  53687. private _meshAttached;
  53688. private _nodeAttached;
  53689. get attachedMesh(): Nullable<AbstractMesh>;
  53690. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53691. get attachedNode(): Nullable<Node>;
  53692. set attachedNode(node: Nullable<Node>);
  53693. /**
  53694. * Creates a RotationGizmo
  53695. * @param gizmoLayer The utility layer the gizmo will be added to
  53696. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53697. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53698. * @param thickness display gizmo axis thickness
  53699. */
  53700. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53701. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53702. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53703. /**
  53704. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53705. */
  53706. set snapDistance(value: number);
  53707. get snapDistance(): number;
  53708. /**
  53709. * Ratio for the scale of the gizmo (Default: 1)
  53710. */
  53711. set scaleRatio(value: number);
  53712. get scaleRatio(): number;
  53713. /**
  53714. * Disposes of the gizmo
  53715. */
  53716. dispose(): void;
  53717. /**
  53718. * CustomMeshes are not supported by this gizmo
  53719. * @param mesh The mesh to replace the default mesh of the gizmo
  53720. */
  53721. setCustomMesh(mesh: Mesh): void;
  53722. }
  53723. }
  53724. declare module BABYLON {
  53725. /**
  53726. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53727. */
  53728. export class GizmoManager implements IDisposable {
  53729. private scene;
  53730. /**
  53731. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53732. */
  53733. gizmos: {
  53734. positionGizmo: Nullable<PositionGizmo>;
  53735. rotationGizmo: Nullable<RotationGizmo>;
  53736. scaleGizmo: Nullable<ScaleGizmo>;
  53737. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53738. };
  53739. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53740. clearGizmoOnEmptyPointerEvent: boolean;
  53741. /** Fires an event when the manager is attached to a mesh */
  53742. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53743. /** Fires an event when the manager is attached to a node */
  53744. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53745. private _gizmosEnabled;
  53746. private _pointerObserver;
  53747. private _attachedMesh;
  53748. private _attachedNode;
  53749. private _boundingBoxColor;
  53750. private _defaultUtilityLayer;
  53751. private _defaultKeepDepthUtilityLayer;
  53752. private _thickness;
  53753. /**
  53754. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53755. */
  53756. boundingBoxDragBehavior: SixDofDragBehavior;
  53757. /**
  53758. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53759. */
  53760. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53761. /**
  53762. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53763. */
  53764. attachableNodes: Nullable<Array<Node>>;
  53765. /**
  53766. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53767. */
  53768. usePointerToAttachGizmos: boolean;
  53769. /**
  53770. * Utility layer that the bounding box gizmo belongs to
  53771. */
  53772. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53773. /**
  53774. * Utility layer that all gizmos besides bounding box belong to
  53775. */
  53776. get utilityLayer(): UtilityLayerRenderer;
  53777. /**
  53778. * Instatiates a gizmo manager
  53779. * @param scene the scene to overlay the gizmos on top of
  53780. * @param thickness display gizmo axis thickness
  53781. */
  53782. constructor(scene: Scene, thickness?: number);
  53783. /**
  53784. * Attaches a set of gizmos to the specified mesh
  53785. * @param mesh The mesh the gizmo's should be attached to
  53786. */
  53787. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53788. /**
  53789. * Attaches a set of gizmos to the specified node
  53790. * @param node The node the gizmo's should be attached to
  53791. */
  53792. attachToNode(node: Nullable<Node>): void;
  53793. /**
  53794. * If the position gizmo is enabled
  53795. */
  53796. set positionGizmoEnabled(value: boolean);
  53797. get positionGizmoEnabled(): boolean;
  53798. /**
  53799. * If the rotation gizmo is enabled
  53800. */
  53801. set rotationGizmoEnabled(value: boolean);
  53802. get rotationGizmoEnabled(): boolean;
  53803. /**
  53804. * If the scale gizmo is enabled
  53805. */
  53806. set scaleGizmoEnabled(value: boolean);
  53807. get scaleGizmoEnabled(): boolean;
  53808. /**
  53809. * If the boundingBox gizmo is enabled
  53810. */
  53811. set boundingBoxGizmoEnabled(value: boolean);
  53812. get boundingBoxGizmoEnabled(): boolean;
  53813. /**
  53814. * Disposes of the gizmo manager
  53815. */
  53816. dispose(): void;
  53817. }
  53818. }
  53819. declare module BABYLON {
  53820. /**
  53821. * A directional light is defined by a direction (what a surprise!).
  53822. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53823. * 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.
  53824. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53825. */
  53826. export class DirectionalLight extends ShadowLight {
  53827. private _shadowFrustumSize;
  53828. /**
  53829. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53830. */
  53831. get shadowFrustumSize(): number;
  53832. /**
  53833. * Specifies a fix frustum size for the shadow generation.
  53834. */
  53835. set shadowFrustumSize(value: number);
  53836. private _shadowOrthoScale;
  53837. /**
  53838. * Gets the shadow projection scale against the optimal computed one.
  53839. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53840. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53841. */
  53842. get shadowOrthoScale(): number;
  53843. /**
  53844. * Sets the shadow projection scale against the optimal computed one.
  53845. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53846. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53847. */
  53848. set shadowOrthoScale(value: number);
  53849. /**
  53850. * Automatically compute the projection matrix to best fit (including all the casters)
  53851. * on each frame.
  53852. */
  53853. autoUpdateExtends: boolean;
  53854. /**
  53855. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53856. * on each frame. autoUpdateExtends must be set to true for this to work
  53857. */
  53858. autoCalcShadowZBounds: boolean;
  53859. private _orthoLeft;
  53860. private _orthoRight;
  53861. private _orthoTop;
  53862. private _orthoBottom;
  53863. /**
  53864. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53865. * The directional light is emitted from everywhere in the given direction.
  53866. * It can cast shadows.
  53867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53868. * @param name The friendly name of the light
  53869. * @param direction The direction of the light
  53870. * @param scene The scene the light belongs to
  53871. */
  53872. constructor(name: string, direction: Vector3, scene: Scene);
  53873. /**
  53874. * Returns the string "DirectionalLight".
  53875. * @return The class name
  53876. */
  53877. getClassName(): string;
  53878. /**
  53879. * Returns the integer 1.
  53880. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53881. */
  53882. getTypeID(): number;
  53883. /**
  53884. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53885. * Returns the DirectionalLight Shadow projection matrix.
  53886. */
  53887. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53888. /**
  53889. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53890. * Returns the DirectionalLight Shadow projection matrix.
  53891. */
  53892. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53893. /**
  53894. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53895. * Returns the DirectionalLight Shadow projection matrix.
  53896. */
  53897. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53898. protected _buildUniformLayout(): void;
  53899. /**
  53900. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53901. * @param effect The effect to update
  53902. * @param lightIndex The index of the light in the effect to update
  53903. * @returns The directional light
  53904. */
  53905. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53906. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53907. /**
  53908. * Gets the minZ used for shadow according to both the scene and the light.
  53909. *
  53910. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53911. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53912. * @param activeCamera The camera we are returning the min for
  53913. * @returns the depth min z
  53914. */
  53915. getDepthMinZ(activeCamera: Camera): number;
  53916. /**
  53917. * Gets the maxZ used for shadow according to both the scene and the light.
  53918. *
  53919. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53920. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53921. * @param activeCamera The camera we are returning the max for
  53922. * @returns the depth max z
  53923. */
  53924. getDepthMaxZ(activeCamera: Camera): number;
  53925. /**
  53926. * Prepares the list of defines specific to the light type.
  53927. * @param defines the list of defines
  53928. * @param lightIndex defines the index of the light for the effect
  53929. */
  53930. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53931. }
  53932. }
  53933. declare module BABYLON {
  53934. /**
  53935. * Class containing static functions to help procedurally build meshes
  53936. */
  53937. export class HemisphereBuilder {
  53938. /**
  53939. * Creates a hemisphere mesh
  53940. * @param name defines the name of the mesh
  53941. * @param options defines the options used to create the mesh
  53942. * @param scene defines the hosting scene
  53943. * @returns the hemisphere mesh
  53944. */
  53945. static CreateHemisphere(name: string, options: {
  53946. segments?: number;
  53947. diameter?: number;
  53948. sideOrientation?: number;
  53949. }, scene: any): Mesh;
  53950. }
  53951. }
  53952. declare module BABYLON {
  53953. /**
  53954. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53955. * These values define a cone of light starting from the position, emitting toward the direction.
  53956. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53957. * and the exponent defines the speed of the decay of the light with distance (reach).
  53958. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53959. */
  53960. export class SpotLight extends ShadowLight {
  53961. private _angle;
  53962. private _innerAngle;
  53963. private _cosHalfAngle;
  53964. private _lightAngleScale;
  53965. private _lightAngleOffset;
  53966. /**
  53967. * Gets the cone angle of the spot light in Radians.
  53968. */
  53969. get angle(): number;
  53970. /**
  53971. * Sets the cone angle of the spot light in Radians.
  53972. */
  53973. set angle(value: number);
  53974. /**
  53975. * Only used in gltf falloff mode, this defines the angle where
  53976. * the directional falloff will start before cutting at angle which could be seen
  53977. * as outer angle.
  53978. */
  53979. get innerAngle(): number;
  53980. /**
  53981. * Only used in gltf falloff mode, this defines the angle where
  53982. * the directional falloff will start before cutting at angle which could be seen
  53983. * as outer angle.
  53984. */
  53985. set innerAngle(value: number);
  53986. private _shadowAngleScale;
  53987. /**
  53988. * Allows scaling the angle of the light for shadow generation only.
  53989. */
  53990. get shadowAngleScale(): number;
  53991. /**
  53992. * Allows scaling the angle of the light for shadow generation only.
  53993. */
  53994. set shadowAngleScale(value: number);
  53995. /**
  53996. * The light decay speed with the distance from the emission spot.
  53997. */
  53998. exponent: number;
  53999. private _projectionTextureMatrix;
  54000. /**
  54001. * Allows reading the projecton texture
  54002. */
  54003. get projectionTextureMatrix(): Matrix;
  54004. protected _projectionTextureLightNear: number;
  54005. /**
  54006. * Gets the near clip of the Spotlight for texture projection.
  54007. */
  54008. get projectionTextureLightNear(): number;
  54009. /**
  54010. * Sets the near clip of the Spotlight for texture projection.
  54011. */
  54012. set projectionTextureLightNear(value: number);
  54013. protected _projectionTextureLightFar: number;
  54014. /**
  54015. * Gets the far clip of the Spotlight for texture projection.
  54016. */
  54017. get projectionTextureLightFar(): number;
  54018. /**
  54019. * Sets the far clip of the Spotlight for texture projection.
  54020. */
  54021. set projectionTextureLightFar(value: number);
  54022. protected _projectionTextureUpDirection: Vector3;
  54023. /**
  54024. * Gets the Up vector of the Spotlight for texture projection.
  54025. */
  54026. get projectionTextureUpDirection(): Vector3;
  54027. /**
  54028. * Sets the Up vector of the Spotlight for texture projection.
  54029. */
  54030. set projectionTextureUpDirection(value: Vector3);
  54031. private _projectionTexture;
  54032. /**
  54033. * Gets the projection texture of the light.
  54034. */
  54035. get projectionTexture(): Nullable<BaseTexture>;
  54036. /**
  54037. * Sets the projection texture of the light.
  54038. */
  54039. set projectionTexture(value: Nullable<BaseTexture>);
  54040. private _projectionTextureViewLightDirty;
  54041. private _projectionTextureProjectionLightDirty;
  54042. private _projectionTextureDirty;
  54043. private _projectionTextureViewTargetVector;
  54044. private _projectionTextureViewLightMatrix;
  54045. private _projectionTextureProjectionLightMatrix;
  54046. private _projectionTextureScalingMatrix;
  54047. /**
  54048. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54049. * It can cast shadows.
  54050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54051. * @param name The light friendly name
  54052. * @param position The position of the spot light in the scene
  54053. * @param direction The direction of the light in the scene
  54054. * @param angle The cone angle of the light in Radians
  54055. * @param exponent The light decay speed with the distance from the emission spot
  54056. * @param scene The scene the lights belongs to
  54057. */
  54058. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54059. /**
  54060. * Returns the string "SpotLight".
  54061. * @returns the class name
  54062. */
  54063. getClassName(): string;
  54064. /**
  54065. * Returns the integer 2.
  54066. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54067. */
  54068. getTypeID(): number;
  54069. /**
  54070. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54071. */
  54072. protected _setDirection(value: Vector3): void;
  54073. /**
  54074. * Overrides the position setter to recompute the projection texture view light Matrix.
  54075. */
  54076. protected _setPosition(value: Vector3): void;
  54077. /**
  54078. * 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.
  54079. * Returns the SpotLight.
  54080. */
  54081. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54082. protected _computeProjectionTextureViewLightMatrix(): void;
  54083. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54084. /**
  54085. * Main function for light texture projection matrix computing.
  54086. */
  54087. protected _computeProjectionTextureMatrix(): void;
  54088. protected _buildUniformLayout(): void;
  54089. private _computeAngleValues;
  54090. /**
  54091. * Sets the passed Effect "effect" with the Light textures.
  54092. * @param effect The effect to update
  54093. * @param lightIndex The index of the light in the effect to update
  54094. * @returns The light
  54095. */
  54096. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54097. /**
  54098. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54099. * @param effect The effect to update
  54100. * @param lightIndex The index of the light in the effect to update
  54101. * @returns The spot light
  54102. */
  54103. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54104. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54105. /**
  54106. * Disposes the light and the associated resources.
  54107. */
  54108. dispose(): void;
  54109. /**
  54110. * Prepares the list of defines specific to the light type.
  54111. * @param defines the list of defines
  54112. * @param lightIndex defines the index of the light for the effect
  54113. */
  54114. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /**
  54119. * Gizmo that enables viewing a light
  54120. */
  54121. export class LightGizmo extends Gizmo {
  54122. private _lightMesh;
  54123. private _material;
  54124. private _cachedPosition;
  54125. private _cachedForward;
  54126. private _attachedMeshParent;
  54127. /**
  54128. * Creates a LightGizmo
  54129. * @param gizmoLayer The utility layer the gizmo will be added to
  54130. */
  54131. constructor(gizmoLayer?: UtilityLayerRenderer);
  54132. private _light;
  54133. /**
  54134. * The light that the gizmo is attached to
  54135. */
  54136. set light(light: Nullable<Light>);
  54137. get light(): Nullable<Light>;
  54138. /**
  54139. * Gets the material used to render the light gizmo
  54140. */
  54141. get material(): StandardMaterial;
  54142. /**
  54143. * @hidden
  54144. * Updates the gizmo to match the attached mesh's position/rotation
  54145. */
  54146. protected _update(): void;
  54147. private static _Scale;
  54148. /**
  54149. * Creates the lines for a light mesh
  54150. */
  54151. private static _CreateLightLines;
  54152. /**
  54153. * Disposes of the light gizmo
  54154. */
  54155. dispose(): void;
  54156. private static _CreateHemisphericLightMesh;
  54157. private static _CreatePointLightMesh;
  54158. private static _CreateSpotLightMesh;
  54159. private static _CreateDirectionalLightMesh;
  54160. }
  54161. }
  54162. declare module BABYLON {
  54163. /**
  54164. * Gizmo that enables viewing a camera
  54165. */
  54166. export class CameraGizmo extends Gizmo {
  54167. private _cameraMesh;
  54168. private _cameraLinesMesh;
  54169. private _material;
  54170. /**
  54171. * Creates a CameraGizmo
  54172. * @param gizmoLayer The utility layer the gizmo will be added to
  54173. */
  54174. constructor(gizmoLayer?: UtilityLayerRenderer);
  54175. private _camera;
  54176. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54177. get displayFrustum(): boolean;
  54178. set displayFrustum(value: boolean);
  54179. /**
  54180. * The camera that the gizmo is attached to
  54181. */
  54182. set camera(camera: Nullable<Camera>);
  54183. get camera(): Nullable<Camera>;
  54184. /**
  54185. * Gets the material used to render the camera gizmo
  54186. */
  54187. get material(): StandardMaterial;
  54188. /**
  54189. * @hidden
  54190. * Updates the gizmo to match the attached mesh's position/rotation
  54191. */
  54192. protected _update(): void;
  54193. private static _Scale;
  54194. private _invProjection;
  54195. /**
  54196. * Disposes of the camera gizmo
  54197. */
  54198. dispose(): void;
  54199. private static _CreateCameraMesh;
  54200. private static _CreateCameraFrustum;
  54201. }
  54202. }
  54203. declare module BABYLON {
  54204. /** @hidden */
  54205. export var backgroundFragmentDeclaration: {
  54206. name: string;
  54207. shader: string;
  54208. };
  54209. }
  54210. declare module BABYLON {
  54211. /** @hidden */
  54212. export var backgroundUboDeclaration: {
  54213. name: string;
  54214. shader: string;
  54215. };
  54216. }
  54217. declare module BABYLON {
  54218. /** @hidden */
  54219. export var backgroundPixelShader: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module BABYLON {
  54225. /** @hidden */
  54226. export var backgroundVertexDeclaration: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module BABYLON {
  54232. /** @hidden */
  54233. export var backgroundVertexShader: {
  54234. name: string;
  54235. shader: string;
  54236. };
  54237. }
  54238. declare module BABYLON {
  54239. /**
  54240. * Background material used to create an efficient environement around your scene.
  54241. */
  54242. export class BackgroundMaterial extends PushMaterial {
  54243. /**
  54244. * Standard reflectance value at parallel view angle.
  54245. */
  54246. static StandardReflectance0: number;
  54247. /**
  54248. * Standard reflectance value at grazing angle.
  54249. */
  54250. static StandardReflectance90: number;
  54251. protected _primaryColor: Color3;
  54252. /**
  54253. * Key light Color (multiply against the environement texture)
  54254. */
  54255. primaryColor: Color3;
  54256. protected __perceptualColor: Nullable<Color3>;
  54257. /**
  54258. * Experimental Internal Use Only.
  54259. *
  54260. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54261. * This acts as a helper to set the primary color to a more "human friendly" value.
  54262. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54263. * output color as close as possible from the chosen value.
  54264. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54265. * part of lighting setup.)
  54266. */
  54267. get _perceptualColor(): Nullable<Color3>;
  54268. set _perceptualColor(value: Nullable<Color3>);
  54269. protected _primaryColorShadowLevel: float;
  54270. /**
  54271. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54272. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54273. */
  54274. get primaryColorShadowLevel(): float;
  54275. set primaryColorShadowLevel(value: float);
  54276. protected _primaryColorHighlightLevel: float;
  54277. /**
  54278. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54279. * The primary color is used at the level chosen to define what the white area would look.
  54280. */
  54281. get primaryColorHighlightLevel(): float;
  54282. set primaryColorHighlightLevel(value: float);
  54283. protected _reflectionTexture: Nullable<BaseTexture>;
  54284. /**
  54285. * Reflection Texture used in the material.
  54286. * Should be author in a specific way for the best result (refer to the documentation).
  54287. */
  54288. reflectionTexture: Nullable<BaseTexture>;
  54289. protected _reflectionBlur: float;
  54290. /**
  54291. * Reflection Texture level of blur.
  54292. *
  54293. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54294. * texture twice.
  54295. */
  54296. reflectionBlur: float;
  54297. protected _diffuseTexture: Nullable<BaseTexture>;
  54298. /**
  54299. * Diffuse Texture used in the material.
  54300. * Should be author in a specific way for the best result (refer to the documentation).
  54301. */
  54302. diffuseTexture: Nullable<BaseTexture>;
  54303. protected _shadowLights: Nullable<IShadowLight[]>;
  54304. /**
  54305. * Specify the list of lights casting shadow on the material.
  54306. * All scene shadow lights will be included if null.
  54307. */
  54308. shadowLights: Nullable<IShadowLight[]>;
  54309. protected _shadowLevel: float;
  54310. /**
  54311. * Helps adjusting the shadow to a softer level if required.
  54312. * 0 means black shadows and 1 means no shadows.
  54313. */
  54314. shadowLevel: float;
  54315. protected _sceneCenter: Vector3;
  54316. /**
  54317. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54318. * It is usually zero but might be interesting to modify according to your setup.
  54319. */
  54320. sceneCenter: Vector3;
  54321. protected _opacityFresnel: boolean;
  54322. /**
  54323. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54324. * This helps ensuring a nice transition when the camera goes under the ground.
  54325. */
  54326. opacityFresnel: boolean;
  54327. protected _reflectionFresnel: boolean;
  54328. /**
  54329. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54330. * This helps adding a mirror texture on the ground.
  54331. */
  54332. reflectionFresnel: boolean;
  54333. protected _reflectionFalloffDistance: number;
  54334. /**
  54335. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54336. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54337. */
  54338. reflectionFalloffDistance: number;
  54339. protected _reflectionAmount: number;
  54340. /**
  54341. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54342. */
  54343. reflectionAmount: number;
  54344. protected _reflectionReflectance0: number;
  54345. /**
  54346. * This specifies the weight of the reflection at grazing angle.
  54347. */
  54348. reflectionReflectance0: number;
  54349. protected _reflectionReflectance90: number;
  54350. /**
  54351. * This specifies the weight of the reflection at a perpendicular point of view.
  54352. */
  54353. reflectionReflectance90: number;
  54354. /**
  54355. * Sets the reflection reflectance fresnel values according to the default standard
  54356. * empirically know to work well :-)
  54357. */
  54358. set reflectionStandardFresnelWeight(value: number);
  54359. protected _useRGBColor: boolean;
  54360. /**
  54361. * Helps to directly use the maps channels instead of their level.
  54362. */
  54363. useRGBColor: boolean;
  54364. protected _enableNoise: boolean;
  54365. /**
  54366. * This helps reducing the banding effect that could occur on the background.
  54367. */
  54368. enableNoise: boolean;
  54369. /**
  54370. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54371. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54372. * Recommended to be keep at 1.0 except for special cases.
  54373. */
  54374. get fovMultiplier(): number;
  54375. set fovMultiplier(value: number);
  54376. private _fovMultiplier;
  54377. /**
  54378. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54379. */
  54380. useEquirectangularFOV: boolean;
  54381. private _maxSimultaneousLights;
  54382. /**
  54383. * Number of Simultaneous lights allowed on the material.
  54384. */
  54385. maxSimultaneousLights: int;
  54386. private _shadowOnly;
  54387. /**
  54388. * Make the material only render shadows
  54389. */
  54390. shadowOnly: boolean;
  54391. /**
  54392. * Default configuration related to image processing available in the Background Material.
  54393. */
  54394. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54395. /**
  54396. * Keep track of the image processing observer to allow dispose and replace.
  54397. */
  54398. private _imageProcessingObserver;
  54399. /**
  54400. * Attaches a new image processing configuration to the PBR Material.
  54401. * @param configuration (if null the scene configuration will be use)
  54402. */
  54403. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54404. /**
  54405. * Gets the image processing configuration used either in this material.
  54406. */
  54407. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54408. /**
  54409. * Sets the Default image processing configuration used either in the this material.
  54410. *
  54411. * If sets to null, the scene one is in use.
  54412. */
  54413. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54414. /**
  54415. * Gets wether the color curves effect is enabled.
  54416. */
  54417. get cameraColorCurvesEnabled(): boolean;
  54418. /**
  54419. * Sets wether the color curves effect is enabled.
  54420. */
  54421. set cameraColorCurvesEnabled(value: boolean);
  54422. /**
  54423. * Gets wether the color grading effect is enabled.
  54424. */
  54425. get cameraColorGradingEnabled(): boolean;
  54426. /**
  54427. * Gets wether the color grading effect is enabled.
  54428. */
  54429. set cameraColorGradingEnabled(value: boolean);
  54430. /**
  54431. * Gets wether tonemapping is enabled or not.
  54432. */
  54433. get cameraToneMappingEnabled(): boolean;
  54434. /**
  54435. * Sets wether tonemapping is enabled or not
  54436. */
  54437. set cameraToneMappingEnabled(value: boolean);
  54438. /**
  54439. * The camera exposure used on this material.
  54440. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54441. * This corresponds to a photographic exposure.
  54442. */
  54443. get cameraExposure(): float;
  54444. /**
  54445. * The camera exposure used on this material.
  54446. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54447. * This corresponds to a photographic exposure.
  54448. */
  54449. set cameraExposure(value: float);
  54450. /**
  54451. * Gets The camera contrast used on this material.
  54452. */
  54453. get cameraContrast(): float;
  54454. /**
  54455. * Sets The camera contrast used on this material.
  54456. */
  54457. set cameraContrast(value: float);
  54458. /**
  54459. * Gets the Color Grading 2D Lookup Texture.
  54460. */
  54461. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54462. /**
  54463. * Sets the Color Grading 2D Lookup Texture.
  54464. */
  54465. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54466. /**
  54467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54469. * 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;
  54470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54471. */
  54472. get cameraColorCurves(): Nullable<ColorCurves>;
  54473. /**
  54474. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54475. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54476. * 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;
  54477. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54478. */
  54479. set cameraColorCurves(value: Nullable<ColorCurves>);
  54480. /**
  54481. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54482. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54483. */
  54484. switchToBGR: boolean;
  54485. private _renderTargets;
  54486. private _reflectionControls;
  54487. private _white;
  54488. private _primaryShadowColor;
  54489. private _primaryHighlightColor;
  54490. /**
  54491. * Instantiates a Background Material in the given scene
  54492. * @param name The friendly name of the material
  54493. * @param scene The scene to add the material to
  54494. */
  54495. constructor(name: string, scene: Scene);
  54496. /**
  54497. * Gets a boolean indicating that current material needs to register RTT
  54498. */
  54499. get hasRenderTargetTextures(): boolean;
  54500. /**
  54501. * The entire material has been created in order to prevent overdraw.
  54502. * @returns false
  54503. */
  54504. needAlphaTesting(): boolean;
  54505. /**
  54506. * The entire material has been created in order to prevent overdraw.
  54507. * @returns true if blending is enable
  54508. */
  54509. needAlphaBlending(): boolean;
  54510. /**
  54511. * Checks wether the material is ready to be rendered for a given mesh.
  54512. * @param mesh The mesh to render
  54513. * @param subMesh The submesh to check against
  54514. * @param useInstances Specify wether or not the material is used with instances
  54515. * @returns true if all the dependencies are ready (Textures, Effects...)
  54516. */
  54517. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54518. /**
  54519. * Compute the primary color according to the chosen perceptual color.
  54520. */
  54521. private _computePrimaryColorFromPerceptualColor;
  54522. /**
  54523. * Compute the highlights and shadow colors according to their chosen levels.
  54524. */
  54525. private _computePrimaryColors;
  54526. /**
  54527. * Build the uniform buffer used in the material.
  54528. */
  54529. buildUniformLayout(): void;
  54530. /**
  54531. * Unbind the material.
  54532. */
  54533. unbind(): void;
  54534. /**
  54535. * Bind only the world matrix to the material.
  54536. * @param world The world matrix to bind.
  54537. */
  54538. bindOnlyWorldMatrix(world: Matrix): void;
  54539. /**
  54540. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54541. * @param world The world matrix to bind.
  54542. * @param subMesh The submesh to bind for.
  54543. */
  54544. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54545. /**
  54546. * Checks to see if a texture is used in the material.
  54547. * @param texture - Base texture to use.
  54548. * @returns - Boolean specifying if a texture is used in the material.
  54549. */
  54550. hasTexture(texture: BaseTexture): boolean;
  54551. /**
  54552. * Dispose the material.
  54553. * @param forceDisposeEffect Force disposal of the associated effect.
  54554. * @param forceDisposeTextures Force disposal of the associated textures.
  54555. */
  54556. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54557. /**
  54558. * Clones the material.
  54559. * @param name The cloned name.
  54560. * @returns The cloned material.
  54561. */
  54562. clone(name: string): BackgroundMaterial;
  54563. /**
  54564. * Serializes the current material to its JSON representation.
  54565. * @returns The JSON representation.
  54566. */
  54567. serialize(): any;
  54568. /**
  54569. * Gets the class name of the material
  54570. * @returns "BackgroundMaterial"
  54571. */
  54572. getClassName(): string;
  54573. /**
  54574. * Parse a JSON input to create back a background material.
  54575. * @param source The JSON data to parse
  54576. * @param scene The scene to create the parsed material in
  54577. * @param rootUrl The root url of the assets the material depends upon
  54578. * @returns the instantiated BackgroundMaterial.
  54579. */
  54580. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54581. }
  54582. }
  54583. declare module BABYLON {
  54584. /**
  54585. * Represents the different options available during the creation of
  54586. * a Environment helper.
  54587. *
  54588. * This can control the default ground, skybox and image processing setup of your scene.
  54589. */
  54590. export interface IEnvironmentHelperOptions {
  54591. /**
  54592. * Specifies whether or not to create a ground.
  54593. * True by default.
  54594. */
  54595. createGround: boolean;
  54596. /**
  54597. * Specifies the ground size.
  54598. * 15 by default.
  54599. */
  54600. groundSize: number;
  54601. /**
  54602. * The texture used on the ground for the main color.
  54603. * Comes from the BabylonJS CDN by default.
  54604. *
  54605. * Remarks: Can be either a texture or a url.
  54606. */
  54607. groundTexture: string | BaseTexture;
  54608. /**
  54609. * The color mixed in the ground texture by default.
  54610. * BabylonJS clearColor by default.
  54611. */
  54612. groundColor: Color3;
  54613. /**
  54614. * Specifies the ground opacity.
  54615. * 1 by default.
  54616. */
  54617. groundOpacity: number;
  54618. /**
  54619. * Enables the ground to receive shadows.
  54620. * True by default.
  54621. */
  54622. enableGroundShadow: boolean;
  54623. /**
  54624. * Helps preventing the shadow to be fully black on the ground.
  54625. * 0.5 by default.
  54626. */
  54627. groundShadowLevel: number;
  54628. /**
  54629. * Creates a mirror texture attach to the ground.
  54630. * false by default.
  54631. */
  54632. enableGroundMirror: boolean;
  54633. /**
  54634. * Specifies the ground mirror size ratio.
  54635. * 0.3 by default as the default kernel is 64.
  54636. */
  54637. groundMirrorSizeRatio: number;
  54638. /**
  54639. * Specifies the ground mirror blur kernel size.
  54640. * 64 by default.
  54641. */
  54642. groundMirrorBlurKernel: number;
  54643. /**
  54644. * Specifies the ground mirror visibility amount.
  54645. * 1 by default
  54646. */
  54647. groundMirrorAmount: number;
  54648. /**
  54649. * Specifies the ground mirror reflectance weight.
  54650. * This uses the standard weight of the background material to setup the fresnel effect
  54651. * of the mirror.
  54652. * 1 by default.
  54653. */
  54654. groundMirrorFresnelWeight: number;
  54655. /**
  54656. * Specifies the ground mirror Falloff distance.
  54657. * This can helps reducing the size of the reflection.
  54658. * 0 by Default.
  54659. */
  54660. groundMirrorFallOffDistance: number;
  54661. /**
  54662. * Specifies the ground mirror texture type.
  54663. * Unsigned Int by Default.
  54664. */
  54665. groundMirrorTextureType: number;
  54666. /**
  54667. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54668. * the shown objects.
  54669. */
  54670. groundYBias: number;
  54671. /**
  54672. * Specifies whether or not to create a skybox.
  54673. * True by default.
  54674. */
  54675. createSkybox: boolean;
  54676. /**
  54677. * Specifies the skybox size.
  54678. * 20 by default.
  54679. */
  54680. skyboxSize: number;
  54681. /**
  54682. * The texture used on the skybox for the main color.
  54683. * Comes from the BabylonJS CDN by default.
  54684. *
  54685. * Remarks: Can be either a texture or a url.
  54686. */
  54687. skyboxTexture: string | BaseTexture;
  54688. /**
  54689. * The color mixed in the skybox texture by default.
  54690. * BabylonJS clearColor by default.
  54691. */
  54692. skyboxColor: Color3;
  54693. /**
  54694. * The background rotation around the Y axis of the scene.
  54695. * This helps aligning the key lights of your scene with the background.
  54696. * 0 by default.
  54697. */
  54698. backgroundYRotation: number;
  54699. /**
  54700. * Compute automatically the size of the elements to best fit with the scene.
  54701. */
  54702. sizeAuto: boolean;
  54703. /**
  54704. * Default position of the rootMesh if autoSize is not true.
  54705. */
  54706. rootPosition: Vector3;
  54707. /**
  54708. * Sets up the image processing in the scene.
  54709. * true by default.
  54710. */
  54711. setupImageProcessing: boolean;
  54712. /**
  54713. * The texture used as your environment texture in the scene.
  54714. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54715. *
  54716. * Remarks: Can be either a texture or a url.
  54717. */
  54718. environmentTexture: string | BaseTexture;
  54719. /**
  54720. * The value of the exposure to apply to the scene.
  54721. * 0.6 by default if setupImageProcessing is true.
  54722. */
  54723. cameraExposure: number;
  54724. /**
  54725. * The value of the contrast to apply to the scene.
  54726. * 1.6 by default if setupImageProcessing is true.
  54727. */
  54728. cameraContrast: number;
  54729. /**
  54730. * Specifies whether or not tonemapping should be enabled in the scene.
  54731. * true by default if setupImageProcessing is true.
  54732. */
  54733. toneMappingEnabled: boolean;
  54734. }
  54735. /**
  54736. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54737. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54738. * It also helps with the default setup of your imageProcessing configuration.
  54739. */
  54740. export class EnvironmentHelper {
  54741. /**
  54742. * Default ground texture URL.
  54743. */
  54744. private static _groundTextureCDNUrl;
  54745. /**
  54746. * Default skybox texture URL.
  54747. */
  54748. private static _skyboxTextureCDNUrl;
  54749. /**
  54750. * Default environment texture URL.
  54751. */
  54752. private static _environmentTextureCDNUrl;
  54753. /**
  54754. * Creates the default options for the helper.
  54755. */
  54756. private static _getDefaultOptions;
  54757. private _rootMesh;
  54758. /**
  54759. * Gets the root mesh created by the helper.
  54760. */
  54761. get rootMesh(): Mesh;
  54762. private _skybox;
  54763. /**
  54764. * Gets the skybox created by the helper.
  54765. */
  54766. get skybox(): Nullable<Mesh>;
  54767. private _skyboxTexture;
  54768. /**
  54769. * Gets the skybox texture created by the helper.
  54770. */
  54771. get skyboxTexture(): Nullable<BaseTexture>;
  54772. private _skyboxMaterial;
  54773. /**
  54774. * Gets the skybox material created by the helper.
  54775. */
  54776. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54777. private _ground;
  54778. /**
  54779. * Gets the ground mesh created by the helper.
  54780. */
  54781. get ground(): Nullable<Mesh>;
  54782. private _groundTexture;
  54783. /**
  54784. * Gets the ground texture created by the helper.
  54785. */
  54786. get groundTexture(): Nullable<BaseTexture>;
  54787. private _groundMirror;
  54788. /**
  54789. * Gets the ground mirror created by the helper.
  54790. */
  54791. get groundMirror(): Nullable<MirrorTexture>;
  54792. /**
  54793. * Gets the ground mirror render list to helps pushing the meshes
  54794. * you wish in the ground reflection.
  54795. */
  54796. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54797. private _groundMaterial;
  54798. /**
  54799. * Gets the ground material created by the helper.
  54800. */
  54801. get groundMaterial(): Nullable<BackgroundMaterial>;
  54802. /**
  54803. * Stores the creation options.
  54804. */
  54805. private readonly _scene;
  54806. private _options;
  54807. /**
  54808. * This observable will be notified with any error during the creation of the environment,
  54809. * mainly texture creation errors.
  54810. */
  54811. onErrorObservable: Observable<{
  54812. message?: string;
  54813. exception?: any;
  54814. }>;
  54815. /**
  54816. * constructor
  54817. * @param options Defines the options we want to customize the helper
  54818. * @param scene The scene to add the material to
  54819. */
  54820. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54821. /**
  54822. * Updates the background according to the new options
  54823. * @param options
  54824. */
  54825. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54826. /**
  54827. * Sets the primary color of all the available elements.
  54828. * @param color the main color to affect to the ground and the background
  54829. */
  54830. setMainColor(color: Color3): void;
  54831. /**
  54832. * Setup the image processing according to the specified options.
  54833. */
  54834. private _setupImageProcessing;
  54835. /**
  54836. * Setup the environment texture according to the specified options.
  54837. */
  54838. private _setupEnvironmentTexture;
  54839. /**
  54840. * Setup the background according to the specified options.
  54841. */
  54842. private _setupBackground;
  54843. /**
  54844. * Get the scene sizes according to the setup.
  54845. */
  54846. private _getSceneSize;
  54847. /**
  54848. * Setup the ground according to the specified options.
  54849. */
  54850. private _setupGround;
  54851. /**
  54852. * Setup the ground material according to the specified options.
  54853. */
  54854. private _setupGroundMaterial;
  54855. /**
  54856. * Setup the ground diffuse texture according to the specified options.
  54857. */
  54858. private _setupGroundDiffuseTexture;
  54859. /**
  54860. * Setup the ground mirror texture according to the specified options.
  54861. */
  54862. private _setupGroundMirrorTexture;
  54863. /**
  54864. * Setup the ground to receive the mirror texture.
  54865. */
  54866. private _setupMirrorInGroundMaterial;
  54867. /**
  54868. * Setup the skybox according to the specified options.
  54869. */
  54870. private _setupSkybox;
  54871. /**
  54872. * Setup the skybox material according to the specified options.
  54873. */
  54874. private _setupSkyboxMaterial;
  54875. /**
  54876. * Setup the skybox reflection texture according to the specified options.
  54877. */
  54878. private _setupSkyboxReflectionTexture;
  54879. private _errorHandler;
  54880. /**
  54881. * Dispose all the elements created by the Helper.
  54882. */
  54883. dispose(): void;
  54884. }
  54885. }
  54886. declare module BABYLON {
  54887. /**
  54888. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  54889. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  54890. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54891. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54892. */
  54893. export abstract class TextureDome<T extends Texture> extends TransformNode {
  54894. protected onError: Nullable<(message?: string, exception?: any) => void>;
  54895. /**
  54896. * Define the source as a Monoscopic panoramic 360/180.
  54897. */
  54898. static readonly MODE_MONOSCOPIC: number;
  54899. /**
  54900. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  54901. */
  54902. static readonly MODE_TOPBOTTOM: number;
  54903. /**
  54904. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  54905. */
  54906. static readonly MODE_SIDEBYSIDE: number;
  54907. private _halfDome;
  54908. protected _useDirectMapping: boolean;
  54909. /**
  54910. * The texture being displayed on the sphere
  54911. */
  54912. protected _texture: T;
  54913. /**
  54914. * Gets the texture being displayed on the sphere
  54915. */
  54916. get texture(): T;
  54917. /**
  54918. * Sets the texture being displayed on the sphere
  54919. */
  54920. set texture(newTexture: T);
  54921. /**
  54922. * The skybox material
  54923. */
  54924. protected _material: BackgroundMaterial;
  54925. /**
  54926. * The surface used for the dome
  54927. */
  54928. protected _mesh: Mesh;
  54929. /**
  54930. * Gets the mesh used for the dome.
  54931. */
  54932. get mesh(): Mesh;
  54933. /**
  54934. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  54935. */
  54936. private _halfDomeMask;
  54937. /**
  54938. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54939. * Also see the options.resolution property.
  54940. */
  54941. get fovMultiplier(): number;
  54942. set fovMultiplier(value: number);
  54943. protected _textureMode: number;
  54944. /**
  54945. * Gets or set the current texture mode for the texture. It can be:
  54946. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54947. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54948. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54949. */
  54950. get textureMode(): number;
  54951. /**
  54952. * Sets the current texture mode for the texture. It can be:
  54953. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54954. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54955. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54956. */
  54957. set textureMode(value: number);
  54958. /**
  54959. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  54960. */
  54961. get halfDome(): boolean;
  54962. /**
  54963. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54964. */
  54965. set halfDome(enabled: boolean);
  54966. /**
  54967. * Oberserver used in Stereoscopic VR Mode.
  54968. */
  54969. private _onBeforeCameraRenderObserver;
  54970. /**
  54971. * Observable raised when an error occured while loading the 360 image
  54972. */
  54973. onLoadErrorObservable: Observable<string>;
  54974. /**
  54975. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  54976. * @param name Element's name, child elements will append suffixes for their own names.
  54977. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  54978. * @param options An object containing optional or exposed sub element properties
  54979. */
  54980. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  54981. resolution?: number;
  54982. clickToPlay?: boolean;
  54983. autoPlay?: boolean;
  54984. loop?: boolean;
  54985. size?: number;
  54986. poster?: string;
  54987. faceForward?: boolean;
  54988. useDirectMapping?: boolean;
  54989. halfDomeMode?: boolean;
  54990. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54991. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  54992. protected _changeTextureMode(value: number): void;
  54993. /**
  54994. * Releases resources associated with this node.
  54995. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54996. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54997. */
  54998. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54999. }
  55000. }
  55001. declare module BABYLON {
  55002. /**
  55003. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55004. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55005. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55006. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55007. */
  55008. export class PhotoDome extends TextureDome<Texture> {
  55009. /**
  55010. * Define the image as a Monoscopic panoramic 360 image.
  55011. */
  55012. static readonly MODE_MONOSCOPIC: number;
  55013. /**
  55014. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55015. */
  55016. static readonly MODE_TOPBOTTOM: number;
  55017. /**
  55018. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55019. */
  55020. static readonly MODE_SIDEBYSIDE: number;
  55021. /**
  55022. * Gets or sets the texture being displayed on the sphere
  55023. */
  55024. get photoTexture(): Texture;
  55025. /**
  55026. * sets the texture being displayed on the sphere
  55027. */
  55028. set photoTexture(value: Texture);
  55029. /**
  55030. * Gets the current video mode for the video. It can be:
  55031. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55032. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55033. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55034. */
  55035. get imageMode(): number;
  55036. /**
  55037. * Sets the current video mode for the video. It can be:
  55038. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55039. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55040. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55041. */
  55042. set imageMode(value: number);
  55043. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55044. }
  55045. }
  55046. declare module BABYLON {
  55047. /**
  55048. * Class used to host RGBD texture specific utilities
  55049. */
  55050. export class RGBDTextureTools {
  55051. /**
  55052. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55053. * @param texture the texture to expand.
  55054. */
  55055. static ExpandRGBDTexture(texture: Texture): void;
  55056. }
  55057. }
  55058. declare module BABYLON {
  55059. /**
  55060. * Class used to host texture specific utilities
  55061. */
  55062. export class BRDFTextureTools {
  55063. /**
  55064. * Prevents texture cache collision
  55065. */
  55066. private static _instanceNumber;
  55067. /**
  55068. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55069. * @param scene defines the hosting scene
  55070. * @returns the environment BRDF texture
  55071. */
  55072. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55073. private static _environmentBRDFBase64Texture;
  55074. }
  55075. }
  55076. declare module BABYLON {
  55077. /**
  55078. * @hidden
  55079. */
  55080. export interface IMaterialClearCoatDefines {
  55081. CLEARCOAT: boolean;
  55082. CLEARCOAT_DEFAULTIOR: boolean;
  55083. CLEARCOAT_TEXTURE: boolean;
  55084. CLEARCOAT_TEXTUREDIRECTUV: number;
  55085. CLEARCOAT_BUMP: boolean;
  55086. CLEARCOAT_BUMPDIRECTUV: number;
  55087. CLEARCOAT_TINT: boolean;
  55088. CLEARCOAT_TINT_TEXTURE: boolean;
  55089. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55090. /** @hidden */
  55091. _areTexturesDirty: boolean;
  55092. }
  55093. /**
  55094. * Define the code related to the clear coat parameters of the pbr material.
  55095. */
  55096. export class PBRClearCoatConfiguration {
  55097. /**
  55098. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55099. * The default fits with a polyurethane material.
  55100. */
  55101. private static readonly _DefaultIndexOfRefraction;
  55102. private _isEnabled;
  55103. /**
  55104. * Defines if the clear coat is enabled in the material.
  55105. */
  55106. isEnabled: boolean;
  55107. /**
  55108. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55109. */
  55110. intensity: number;
  55111. /**
  55112. * Defines the clear coat layer roughness.
  55113. */
  55114. roughness: number;
  55115. private _indexOfRefraction;
  55116. /**
  55117. * Defines the index of refraction of the clear coat.
  55118. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55119. * The default fits with a polyurethane material.
  55120. * Changing the default value is more performance intensive.
  55121. */
  55122. indexOfRefraction: number;
  55123. private _texture;
  55124. /**
  55125. * Stores the clear coat values in a texture.
  55126. */
  55127. texture: Nullable<BaseTexture>;
  55128. private _bumpTexture;
  55129. /**
  55130. * Define the clear coat specific bump texture.
  55131. */
  55132. bumpTexture: Nullable<BaseTexture>;
  55133. private _isTintEnabled;
  55134. /**
  55135. * Defines if the clear coat tint is enabled in the material.
  55136. */
  55137. isTintEnabled: boolean;
  55138. /**
  55139. * Defines the clear coat tint of the material.
  55140. * This is only use if tint is enabled
  55141. */
  55142. tintColor: Color3;
  55143. /**
  55144. * Defines the distance at which the tint color should be found in the
  55145. * clear coat media.
  55146. * This is only use if tint is enabled
  55147. */
  55148. tintColorAtDistance: number;
  55149. /**
  55150. * Defines the clear coat layer thickness.
  55151. * This is only use if tint is enabled
  55152. */
  55153. tintThickness: number;
  55154. private _tintTexture;
  55155. /**
  55156. * Stores the clear tint values in a texture.
  55157. * rgb is tint
  55158. * a is a thickness factor
  55159. */
  55160. tintTexture: Nullable<BaseTexture>;
  55161. /** @hidden */
  55162. private _internalMarkAllSubMeshesAsTexturesDirty;
  55163. /** @hidden */
  55164. _markAllSubMeshesAsTexturesDirty(): void;
  55165. /**
  55166. * Instantiate a new istance of clear coat configuration.
  55167. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55168. */
  55169. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55170. /**
  55171. * Gets wehter the submesh is ready to be used or not.
  55172. * @param defines the list of "defines" to update.
  55173. * @param scene defines the scene the material belongs to.
  55174. * @param engine defines the engine the material belongs to.
  55175. * @param disableBumpMap defines wether the material disables bump or not.
  55176. * @returns - boolean indicating that the submesh is ready or not.
  55177. */
  55178. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55179. /**
  55180. * Checks to see if a texture is used in the material.
  55181. * @param defines the list of "defines" to update.
  55182. * @param scene defines the scene to the material belongs to.
  55183. */
  55184. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55185. /**
  55186. * Binds the material data.
  55187. * @param uniformBuffer defines the Uniform buffer to fill in.
  55188. * @param scene defines the scene the material belongs to.
  55189. * @param engine defines the engine the material belongs to.
  55190. * @param disableBumpMap defines wether the material disables bump or not.
  55191. * @param isFrozen defines wether the material is frozen or not.
  55192. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55193. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55194. */
  55195. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55196. /**
  55197. * Checks to see if a texture is used in the material.
  55198. * @param texture - Base texture to use.
  55199. * @returns - Boolean specifying if a texture is used in the material.
  55200. */
  55201. hasTexture(texture: BaseTexture): boolean;
  55202. /**
  55203. * Returns an array of the actively used textures.
  55204. * @param activeTextures Array of BaseTextures
  55205. */
  55206. getActiveTextures(activeTextures: BaseTexture[]): void;
  55207. /**
  55208. * Returns the animatable textures.
  55209. * @param animatables Array of animatable textures.
  55210. */
  55211. getAnimatables(animatables: IAnimatable[]): void;
  55212. /**
  55213. * Disposes the resources of the material.
  55214. * @param forceDisposeTextures - Forces the disposal of all textures.
  55215. */
  55216. dispose(forceDisposeTextures?: boolean): void;
  55217. /**
  55218. * Get the current class name of the texture useful for serialization or dynamic coding.
  55219. * @returns "PBRClearCoatConfiguration"
  55220. */
  55221. getClassName(): string;
  55222. /**
  55223. * Add fallbacks to the effect fallbacks list.
  55224. * @param defines defines the Base texture to use.
  55225. * @param fallbacks defines the current fallback list.
  55226. * @param currentRank defines the current fallback rank.
  55227. * @returns the new fallback rank.
  55228. */
  55229. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55230. /**
  55231. * Add the required uniforms to the current list.
  55232. * @param uniforms defines the current uniform list.
  55233. */
  55234. static AddUniforms(uniforms: string[]): void;
  55235. /**
  55236. * Add the required samplers to the current list.
  55237. * @param samplers defines the current sampler list.
  55238. */
  55239. static AddSamplers(samplers: string[]): void;
  55240. /**
  55241. * Add the required uniforms to the current buffer.
  55242. * @param uniformBuffer defines the current uniform buffer.
  55243. */
  55244. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55245. /**
  55246. * Makes a duplicate of the current configuration into another one.
  55247. * @param clearCoatConfiguration define the config where to copy the info
  55248. */
  55249. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55250. /**
  55251. * Serializes this clear coat configuration.
  55252. * @returns - An object with the serialized config.
  55253. */
  55254. serialize(): any;
  55255. /**
  55256. * Parses a anisotropy Configuration from a serialized object.
  55257. * @param source - Serialized object.
  55258. * @param scene Defines the scene we are parsing for
  55259. * @param rootUrl Defines the rootUrl to load from
  55260. */
  55261. parse(source: any, scene: Scene, rootUrl: string): void;
  55262. }
  55263. }
  55264. declare module BABYLON {
  55265. /**
  55266. * @hidden
  55267. */
  55268. export interface IMaterialAnisotropicDefines {
  55269. ANISOTROPIC: boolean;
  55270. ANISOTROPIC_TEXTURE: boolean;
  55271. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55272. MAINUV1: boolean;
  55273. _areTexturesDirty: boolean;
  55274. _needUVs: boolean;
  55275. }
  55276. /**
  55277. * Define the code related to the anisotropic parameters of the pbr material.
  55278. */
  55279. export class PBRAnisotropicConfiguration {
  55280. private _isEnabled;
  55281. /**
  55282. * Defines if the anisotropy is enabled in the material.
  55283. */
  55284. isEnabled: boolean;
  55285. /**
  55286. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55287. */
  55288. intensity: number;
  55289. /**
  55290. * Defines if the effect is along the tangents, bitangents or in between.
  55291. * By default, the effect is "strectching" the highlights along the tangents.
  55292. */
  55293. direction: Vector2;
  55294. private _texture;
  55295. /**
  55296. * Stores the anisotropy values in a texture.
  55297. * rg is direction (like normal from -1 to 1)
  55298. * b is a intensity
  55299. */
  55300. texture: Nullable<BaseTexture>;
  55301. /** @hidden */
  55302. private _internalMarkAllSubMeshesAsTexturesDirty;
  55303. /** @hidden */
  55304. _markAllSubMeshesAsTexturesDirty(): void;
  55305. /**
  55306. * Instantiate a new istance of anisotropy configuration.
  55307. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55308. */
  55309. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55310. /**
  55311. * Specifies that the submesh is ready to be used.
  55312. * @param defines the list of "defines" to update.
  55313. * @param scene defines the scene the material belongs to.
  55314. * @returns - boolean indicating that the submesh is ready or not.
  55315. */
  55316. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55317. /**
  55318. * Checks to see if a texture is used in the material.
  55319. * @param defines the list of "defines" to update.
  55320. * @param mesh the mesh we are preparing the defines for.
  55321. * @param scene defines the scene the material belongs to.
  55322. */
  55323. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55324. /**
  55325. * Binds the material data.
  55326. * @param uniformBuffer defines the Uniform buffer to fill in.
  55327. * @param scene defines the scene the material belongs to.
  55328. * @param isFrozen defines wether the material is frozen or not.
  55329. */
  55330. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55331. /**
  55332. * Checks to see if a texture is used in the material.
  55333. * @param texture - Base texture to use.
  55334. * @returns - Boolean specifying if a texture is used in the material.
  55335. */
  55336. hasTexture(texture: BaseTexture): boolean;
  55337. /**
  55338. * Returns an array of the actively used textures.
  55339. * @param activeTextures Array of BaseTextures
  55340. */
  55341. getActiveTextures(activeTextures: BaseTexture[]): void;
  55342. /**
  55343. * Returns the animatable textures.
  55344. * @param animatables Array of animatable textures.
  55345. */
  55346. getAnimatables(animatables: IAnimatable[]): void;
  55347. /**
  55348. * Disposes the resources of the material.
  55349. * @param forceDisposeTextures - Forces the disposal of all textures.
  55350. */
  55351. dispose(forceDisposeTextures?: boolean): void;
  55352. /**
  55353. * Get the current class name of the texture useful for serialization or dynamic coding.
  55354. * @returns "PBRAnisotropicConfiguration"
  55355. */
  55356. getClassName(): string;
  55357. /**
  55358. * Add fallbacks to the effect fallbacks list.
  55359. * @param defines defines the Base texture to use.
  55360. * @param fallbacks defines the current fallback list.
  55361. * @param currentRank defines the current fallback rank.
  55362. * @returns the new fallback rank.
  55363. */
  55364. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55365. /**
  55366. * Add the required uniforms to the current list.
  55367. * @param uniforms defines the current uniform list.
  55368. */
  55369. static AddUniforms(uniforms: string[]): void;
  55370. /**
  55371. * Add the required uniforms to the current buffer.
  55372. * @param uniformBuffer defines the current uniform buffer.
  55373. */
  55374. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55375. /**
  55376. * Add the required samplers to the current list.
  55377. * @param samplers defines the current sampler list.
  55378. */
  55379. static AddSamplers(samplers: string[]): void;
  55380. /**
  55381. * Makes a duplicate of the current configuration into another one.
  55382. * @param anisotropicConfiguration define the config where to copy the info
  55383. */
  55384. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55385. /**
  55386. * Serializes this anisotropy configuration.
  55387. * @returns - An object with the serialized config.
  55388. */
  55389. serialize(): any;
  55390. /**
  55391. * Parses a anisotropy Configuration from a serialized object.
  55392. * @param source - Serialized object.
  55393. * @param scene Defines the scene we are parsing for
  55394. * @param rootUrl Defines the rootUrl to load from
  55395. */
  55396. parse(source: any, scene: Scene, rootUrl: string): void;
  55397. }
  55398. }
  55399. declare module BABYLON {
  55400. /**
  55401. * @hidden
  55402. */
  55403. export interface IMaterialBRDFDefines {
  55404. BRDF_V_HEIGHT_CORRELATED: boolean;
  55405. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55406. SPHERICAL_HARMONICS: boolean;
  55407. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55408. /** @hidden */
  55409. _areMiscDirty: boolean;
  55410. }
  55411. /**
  55412. * Define the code related to the BRDF parameters of the pbr material.
  55413. */
  55414. export class PBRBRDFConfiguration {
  55415. /**
  55416. * Default value used for the energy conservation.
  55417. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55418. */
  55419. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55420. /**
  55421. * Default value used for the Smith Visibility Height Correlated mode.
  55422. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55423. */
  55424. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55425. /**
  55426. * Default value used for the IBL diffuse part.
  55427. * This can help switching back to the polynomials mode globally which is a tiny bit
  55428. * less GPU intensive at the drawback of a lower quality.
  55429. */
  55430. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55431. /**
  55432. * Default value used for activating energy conservation for the specular workflow.
  55433. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55434. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55435. */
  55436. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55437. private _useEnergyConservation;
  55438. /**
  55439. * Defines if the material uses energy conservation.
  55440. */
  55441. useEnergyConservation: boolean;
  55442. private _useSmithVisibilityHeightCorrelated;
  55443. /**
  55444. * LEGACY Mode set to false
  55445. * Defines if the material uses height smith correlated visibility term.
  55446. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55447. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55448. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55449. * Not relying on height correlated will also disable energy conservation.
  55450. */
  55451. useSmithVisibilityHeightCorrelated: boolean;
  55452. private _useSphericalHarmonics;
  55453. /**
  55454. * LEGACY Mode set to false
  55455. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55456. * diffuse part of the IBL.
  55457. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55458. * to the ground truth.
  55459. */
  55460. useSphericalHarmonics: boolean;
  55461. private _useSpecularGlossinessInputEnergyConservation;
  55462. /**
  55463. * Defines if the material uses energy conservation, when the specular workflow is active.
  55464. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55465. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55466. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55467. */
  55468. useSpecularGlossinessInputEnergyConservation: boolean;
  55469. /** @hidden */
  55470. private _internalMarkAllSubMeshesAsMiscDirty;
  55471. /** @hidden */
  55472. _markAllSubMeshesAsMiscDirty(): void;
  55473. /**
  55474. * Instantiate a new istance of clear coat configuration.
  55475. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55476. */
  55477. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55478. /**
  55479. * Checks to see if a texture is used in the material.
  55480. * @param defines the list of "defines" to update.
  55481. */
  55482. prepareDefines(defines: IMaterialBRDFDefines): void;
  55483. /**
  55484. * Get the current class name of the texture useful for serialization or dynamic coding.
  55485. * @returns "PBRClearCoatConfiguration"
  55486. */
  55487. getClassName(): string;
  55488. /**
  55489. * Makes a duplicate of the current configuration into another one.
  55490. * @param brdfConfiguration define the config where to copy the info
  55491. */
  55492. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55493. /**
  55494. * Serializes this BRDF configuration.
  55495. * @returns - An object with the serialized config.
  55496. */
  55497. serialize(): any;
  55498. /**
  55499. * Parses a anisotropy Configuration from a serialized object.
  55500. * @param source - Serialized object.
  55501. * @param scene Defines the scene we are parsing for
  55502. * @param rootUrl Defines the rootUrl to load from
  55503. */
  55504. parse(source: any, scene: Scene, rootUrl: string): void;
  55505. }
  55506. }
  55507. declare module BABYLON {
  55508. /**
  55509. * @hidden
  55510. */
  55511. export interface IMaterialSheenDefines {
  55512. SHEEN: boolean;
  55513. SHEEN_TEXTURE: boolean;
  55514. SHEEN_TEXTUREDIRECTUV: number;
  55515. SHEEN_LINKWITHALBEDO: boolean;
  55516. SHEEN_ROUGHNESS: boolean;
  55517. SHEEN_ALBEDOSCALING: boolean;
  55518. /** @hidden */
  55519. _areTexturesDirty: boolean;
  55520. }
  55521. /**
  55522. * Define the code related to the Sheen parameters of the pbr material.
  55523. */
  55524. export class PBRSheenConfiguration {
  55525. private _isEnabled;
  55526. /**
  55527. * Defines if the material uses sheen.
  55528. */
  55529. isEnabled: boolean;
  55530. private _linkSheenWithAlbedo;
  55531. /**
  55532. * Defines if the sheen is linked to the sheen color.
  55533. */
  55534. linkSheenWithAlbedo: boolean;
  55535. /**
  55536. * Defines the sheen intensity.
  55537. */
  55538. intensity: number;
  55539. /**
  55540. * Defines the sheen color.
  55541. */
  55542. color: Color3;
  55543. private _texture;
  55544. /**
  55545. * Stores the sheen tint values in a texture.
  55546. * rgb is tint
  55547. * a is a intensity or roughness if roughness has been defined
  55548. */
  55549. texture: Nullable<BaseTexture>;
  55550. private _roughness;
  55551. /**
  55552. * Defines the sheen roughness.
  55553. * It is not taken into account if linkSheenWithAlbedo is true.
  55554. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55555. */
  55556. roughness: Nullable<number>;
  55557. private _albedoScaling;
  55558. /**
  55559. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55560. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55561. * making it easier to setup and tweak the effect
  55562. */
  55563. albedoScaling: boolean;
  55564. /** @hidden */
  55565. private _internalMarkAllSubMeshesAsTexturesDirty;
  55566. /** @hidden */
  55567. _markAllSubMeshesAsTexturesDirty(): void;
  55568. /**
  55569. * Instantiate a new istance of clear coat configuration.
  55570. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55571. */
  55572. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55573. /**
  55574. * Specifies that the submesh is ready to be used.
  55575. * @param defines the list of "defines" to update.
  55576. * @param scene defines the scene the material belongs to.
  55577. * @returns - boolean indicating that the submesh is ready or not.
  55578. */
  55579. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55580. /**
  55581. * Checks to see if a texture is used in the material.
  55582. * @param defines the list of "defines" to update.
  55583. * @param scene defines the scene the material belongs to.
  55584. */
  55585. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55586. /**
  55587. * Binds the material data.
  55588. * @param uniformBuffer defines the Uniform buffer to fill in.
  55589. * @param scene defines the scene the material belongs to.
  55590. * @param isFrozen defines wether the material is frozen or not.
  55591. */
  55592. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55593. /**
  55594. * Checks to see if a texture is used in the material.
  55595. * @param texture - Base texture to use.
  55596. * @returns - Boolean specifying if a texture is used in the material.
  55597. */
  55598. hasTexture(texture: BaseTexture): boolean;
  55599. /**
  55600. * Returns an array of the actively used textures.
  55601. * @param activeTextures Array of BaseTextures
  55602. */
  55603. getActiveTextures(activeTextures: BaseTexture[]): void;
  55604. /**
  55605. * Returns the animatable textures.
  55606. * @param animatables Array of animatable textures.
  55607. */
  55608. getAnimatables(animatables: IAnimatable[]): void;
  55609. /**
  55610. * Disposes the resources of the material.
  55611. * @param forceDisposeTextures - Forces the disposal of all textures.
  55612. */
  55613. dispose(forceDisposeTextures?: boolean): void;
  55614. /**
  55615. * Get the current class name of the texture useful for serialization or dynamic coding.
  55616. * @returns "PBRSheenConfiguration"
  55617. */
  55618. getClassName(): string;
  55619. /**
  55620. * Add fallbacks to the effect fallbacks list.
  55621. * @param defines defines the Base texture to use.
  55622. * @param fallbacks defines the current fallback list.
  55623. * @param currentRank defines the current fallback rank.
  55624. * @returns the new fallback rank.
  55625. */
  55626. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55627. /**
  55628. * Add the required uniforms to the current list.
  55629. * @param uniforms defines the current uniform list.
  55630. */
  55631. static AddUniforms(uniforms: string[]): void;
  55632. /**
  55633. * Add the required uniforms to the current buffer.
  55634. * @param uniformBuffer defines the current uniform buffer.
  55635. */
  55636. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55637. /**
  55638. * Add the required samplers to the current list.
  55639. * @param samplers defines the current sampler list.
  55640. */
  55641. static AddSamplers(samplers: string[]): void;
  55642. /**
  55643. * Makes a duplicate of the current configuration into another one.
  55644. * @param sheenConfiguration define the config where to copy the info
  55645. */
  55646. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55647. /**
  55648. * Serializes this BRDF configuration.
  55649. * @returns - An object with the serialized config.
  55650. */
  55651. serialize(): any;
  55652. /**
  55653. * Parses a anisotropy Configuration from a serialized object.
  55654. * @param source - Serialized object.
  55655. * @param scene Defines the scene we are parsing for
  55656. * @param rootUrl Defines the rootUrl to load from
  55657. */
  55658. parse(source: any, scene: Scene, rootUrl: string): void;
  55659. }
  55660. }
  55661. declare module BABYLON {
  55662. /**
  55663. * @hidden
  55664. */
  55665. export interface IMaterialSubSurfaceDefines {
  55666. SUBSURFACE: boolean;
  55667. SS_REFRACTION: boolean;
  55668. SS_TRANSLUCENCY: boolean;
  55669. SS_SCATTERING: boolean;
  55670. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55671. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55672. SS_REFRACTIONMAP_3D: boolean;
  55673. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55674. SS_LODINREFRACTIONALPHA: boolean;
  55675. SS_GAMMAREFRACTION: boolean;
  55676. SS_RGBDREFRACTION: boolean;
  55677. SS_LINEARSPECULARREFRACTION: boolean;
  55678. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55679. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55680. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55681. /** @hidden */
  55682. _areTexturesDirty: boolean;
  55683. }
  55684. /**
  55685. * Define the code related to the sub surface parameters of the pbr material.
  55686. */
  55687. export class PBRSubSurfaceConfiguration {
  55688. private _isRefractionEnabled;
  55689. /**
  55690. * Defines if the refraction is enabled in the material.
  55691. */
  55692. isRefractionEnabled: boolean;
  55693. private _isTranslucencyEnabled;
  55694. /**
  55695. * Defines if the translucency is enabled in the material.
  55696. */
  55697. isTranslucencyEnabled: boolean;
  55698. private _isScatteringEnabled;
  55699. /**
  55700. * Defines if the sub surface scattering is enabled in the material.
  55701. */
  55702. isScatteringEnabled: boolean;
  55703. private _scatteringDiffusionProfileIndex;
  55704. /**
  55705. * Diffusion profile for subsurface scattering.
  55706. * Useful for better scattering in the skins or foliages.
  55707. */
  55708. get scatteringDiffusionProfile(): Nullable<Color3>;
  55709. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55710. /**
  55711. * Defines the refraction intensity of the material.
  55712. * The refraction when enabled replaces the Diffuse part of the material.
  55713. * The intensity helps transitionning between diffuse and refraction.
  55714. */
  55715. refractionIntensity: number;
  55716. /**
  55717. * Defines the translucency intensity of the material.
  55718. * When translucency has been enabled, this defines how much of the "translucency"
  55719. * is addded to the diffuse part of the material.
  55720. */
  55721. translucencyIntensity: number;
  55722. /**
  55723. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55724. */
  55725. useAlbedoToTintRefraction: boolean;
  55726. private _thicknessTexture;
  55727. /**
  55728. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55729. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55730. * 0 would mean minimumThickness
  55731. * 1 would mean maximumThickness
  55732. * The other channels might be use as a mask to vary the different effects intensity.
  55733. */
  55734. thicknessTexture: Nullable<BaseTexture>;
  55735. private _refractionTexture;
  55736. /**
  55737. * Defines the texture to use for refraction.
  55738. */
  55739. refractionTexture: Nullable<BaseTexture>;
  55740. private _indexOfRefraction;
  55741. /**
  55742. * Index of refraction of the material base layer.
  55743. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55744. *
  55745. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55746. *
  55747. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55748. */
  55749. indexOfRefraction: number;
  55750. private _volumeIndexOfRefraction;
  55751. /**
  55752. * Index of refraction of the material's volume.
  55753. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55754. *
  55755. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55756. * the volume will use the same IOR as the surface.
  55757. */
  55758. get volumeIndexOfRefraction(): number;
  55759. set volumeIndexOfRefraction(value: number);
  55760. private _invertRefractionY;
  55761. /**
  55762. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55763. */
  55764. invertRefractionY: boolean;
  55765. private _linkRefractionWithTransparency;
  55766. /**
  55767. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55768. * Materials half opaque for instance using refraction could benefit from this control.
  55769. */
  55770. linkRefractionWithTransparency: boolean;
  55771. /**
  55772. * Defines the minimum thickness stored in the thickness map.
  55773. * If no thickness map is defined, this value will be used to simulate thickness.
  55774. */
  55775. minimumThickness: number;
  55776. /**
  55777. * Defines the maximum thickness stored in the thickness map.
  55778. */
  55779. maximumThickness: number;
  55780. /**
  55781. * Defines the volume tint of the material.
  55782. * This is used for both translucency and scattering.
  55783. */
  55784. tintColor: Color3;
  55785. /**
  55786. * Defines the distance at which the tint color should be found in the media.
  55787. * This is used for refraction only.
  55788. */
  55789. tintColorAtDistance: number;
  55790. /**
  55791. * Defines how far each channel transmit through the media.
  55792. * It is defined as a color to simplify it selection.
  55793. */
  55794. diffusionDistance: Color3;
  55795. private _useMaskFromThicknessTexture;
  55796. /**
  55797. * Stores the intensity of the different subsurface effects in the thickness texture.
  55798. * * the green channel is the translucency intensity.
  55799. * * the blue channel is the scattering intensity.
  55800. * * the alpha channel is the refraction intensity.
  55801. */
  55802. useMaskFromThicknessTexture: boolean;
  55803. private _scene;
  55804. /** @hidden */
  55805. private _internalMarkAllSubMeshesAsTexturesDirty;
  55806. private _internalMarkScenePrePassDirty;
  55807. /** @hidden */
  55808. _markAllSubMeshesAsTexturesDirty(): void;
  55809. /** @hidden */
  55810. _markScenePrePassDirty(): void;
  55811. /**
  55812. * Instantiate a new istance of sub surface configuration.
  55813. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55814. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55815. * @param scene The scene
  55816. */
  55817. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55818. /**
  55819. * Gets wehter the submesh is ready to be used or not.
  55820. * @param defines the list of "defines" to update.
  55821. * @param scene defines the scene the material belongs to.
  55822. * @returns - boolean indicating that the submesh is ready or not.
  55823. */
  55824. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55825. /**
  55826. * Checks to see if a texture is used in the material.
  55827. * @param defines the list of "defines" to update.
  55828. * @param scene defines the scene to the material belongs to.
  55829. */
  55830. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55831. /**
  55832. * Binds the material data.
  55833. * @param uniformBuffer defines the Uniform buffer to fill in.
  55834. * @param scene defines the scene the material belongs to.
  55835. * @param engine defines the engine the material belongs to.
  55836. * @param isFrozen defines whether the material is frozen or not.
  55837. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55838. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55839. */
  55840. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55841. /**
  55842. * Unbinds the material from the mesh.
  55843. * @param activeEffect defines the effect that should be unbound from.
  55844. * @returns true if unbound, otherwise false
  55845. */
  55846. unbind(activeEffect: Effect): boolean;
  55847. /**
  55848. * Returns the texture used for refraction or null if none is used.
  55849. * @param scene defines the scene the material belongs to.
  55850. * @returns - Refraction texture if present. If no refraction texture and refraction
  55851. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55852. */
  55853. private _getRefractionTexture;
  55854. /**
  55855. * Returns true if alpha blending should be disabled.
  55856. */
  55857. get disableAlphaBlending(): boolean;
  55858. /**
  55859. * Fills the list of render target textures.
  55860. * @param renderTargets the list of render targets to update
  55861. */
  55862. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55863. /**
  55864. * Checks to see if a texture is used in the material.
  55865. * @param texture - Base texture to use.
  55866. * @returns - Boolean specifying if a texture is used in the material.
  55867. */
  55868. hasTexture(texture: BaseTexture): boolean;
  55869. /**
  55870. * Gets a boolean indicating that current material needs to register RTT
  55871. * @returns true if this uses a render target otherwise false.
  55872. */
  55873. hasRenderTargetTextures(): boolean;
  55874. /**
  55875. * Returns an array of the actively used textures.
  55876. * @param activeTextures Array of BaseTextures
  55877. */
  55878. getActiveTextures(activeTextures: BaseTexture[]): void;
  55879. /**
  55880. * Returns the animatable textures.
  55881. * @param animatables Array of animatable textures.
  55882. */
  55883. getAnimatables(animatables: IAnimatable[]): void;
  55884. /**
  55885. * Disposes the resources of the material.
  55886. * @param forceDisposeTextures - Forces the disposal of all textures.
  55887. */
  55888. dispose(forceDisposeTextures?: boolean): void;
  55889. /**
  55890. * Get the current class name of the texture useful for serialization or dynamic coding.
  55891. * @returns "PBRSubSurfaceConfiguration"
  55892. */
  55893. getClassName(): string;
  55894. /**
  55895. * Add fallbacks to the effect fallbacks list.
  55896. * @param defines defines the Base texture to use.
  55897. * @param fallbacks defines the current fallback list.
  55898. * @param currentRank defines the current fallback rank.
  55899. * @returns the new fallback rank.
  55900. */
  55901. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55902. /**
  55903. * Add the required uniforms to the current list.
  55904. * @param uniforms defines the current uniform list.
  55905. */
  55906. static AddUniforms(uniforms: string[]): void;
  55907. /**
  55908. * Add the required samplers to the current list.
  55909. * @param samplers defines the current sampler list.
  55910. */
  55911. static AddSamplers(samplers: string[]): void;
  55912. /**
  55913. * Add the required uniforms to the current buffer.
  55914. * @param uniformBuffer defines the current uniform buffer.
  55915. */
  55916. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55917. /**
  55918. * Makes a duplicate of the current configuration into another one.
  55919. * @param configuration define the config where to copy the info
  55920. */
  55921. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55922. /**
  55923. * Serializes this Sub Surface configuration.
  55924. * @returns - An object with the serialized config.
  55925. */
  55926. serialize(): any;
  55927. /**
  55928. * Parses a anisotropy Configuration from a serialized object.
  55929. * @param source - Serialized object.
  55930. * @param scene Defines the scene we are parsing for
  55931. * @param rootUrl Defines the rootUrl to load from
  55932. */
  55933. parse(source: any, scene: Scene, rootUrl: string): void;
  55934. }
  55935. }
  55936. declare module BABYLON {
  55937. /** @hidden */
  55938. export var pbrFragmentDeclaration: {
  55939. name: string;
  55940. shader: string;
  55941. };
  55942. }
  55943. declare module BABYLON {
  55944. /** @hidden */
  55945. export var pbrUboDeclaration: {
  55946. name: string;
  55947. shader: string;
  55948. };
  55949. }
  55950. declare module BABYLON {
  55951. /** @hidden */
  55952. export var pbrFragmentExtraDeclaration: {
  55953. name: string;
  55954. shader: string;
  55955. };
  55956. }
  55957. declare module BABYLON {
  55958. /** @hidden */
  55959. export var pbrFragmentSamplersDeclaration: {
  55960. name: string;
  55961. shader: string;
  55962. };
  55963. }
  55964. declare module BABYLON {
  55965. /** @hidden */
  55966. export var importanceSampling: {
  55967. name: string;
  55968. shader: string;
  55969. };
  55970. }
  55971. declare module BABYLON {
  55972. /** @hidden */
  55973. export var pbrHelperFunctions: {
  55974. name: string;
  55975. shader: string;
  55976. };
  55977. }
  55978. declare module BABYLON {
  55979. /** @hidden */
  55980. export var harmonicsFunctions: {
  55981. name: string;
  55982. shader: string;
  55983. };
  55984. }
  55985. declare module BABYLON {
  55986. /** @hidden */
  55987. export var pbrDirectLightingSetupFunctions: {
  55988. name: string;
  55989. shader: string;
  55990. };
  55991. }
  55992. declare module BABYLON {
  55993. /** @hidden */
  55994. export var pbrDirectLightingFalloffFunctions: {
  55995. name: string;
  55996. shader: string;
  55997. };
  55998. }
  55999. declare module BABYLON {
  56000. /** @hidden */
  56001. export var pbrBRDFFunctions: {
  56002. name: string;
  56003. shader: string;
  56004. };
  56005. }
  56006. declare module BABYLON {
  56007. /** @hidden */
  56008. export var hdrFilteringFunctions: {
  56009. name: string;
  56010. shader: string;
  56011. };
  56012. }
  56013. declare module BABYLON {
  56014. /** @hidden */
  56015. export var pbrDirectLightingFunctions: {
  56016. name: string;
  56017. shader: string;
  56018. };
  56019. }
  56020. declare module BABYLON {
  56021. /** @hidden */
  56022. export var pbrIBLFunctions: {
  56023. name: string;
  56024. shader: string;
  56025. };
  56026. }
  56027. declare module BABYLON {
  56028. /** @hidden */
  56029. export var pbrBlockAlbedoOpacity: {
  56030. name: string;
  56031. shader: string;
  56032. };
  56033. }
  56034. declare module BABYLON {
  56035. /** @hidden */
  56036. export var pbrBlockReflectivity: {
  56037. name: string;
  56038. shader: string;
  56039. };
  56040. }
  56041. declare module BABYLON {
  56042. /** @hidden */
  56043. export var pbrBlockAmbientOcclusion: {
  56044. name: string;
  56045. shader: string;
  56046. };
  56047. }
  56048. declare module BABYLON {
  56049. /** @hidden */
  56050. export var pbrBlockAlphaFresnel: {
  56051. name: string;
  56052. shader: string;
  56053. };
  56054. }
  56055. declare module BABYLON {
  56056. /** @hidden */
  56057. export var pbrBlockAnisotropic: {
  56058. name: string;
  56059. shader: string;
  56060. };
  56061. }
  56062. declare module BABYLON {
  56063. /** @hidden */
  56064. export var pbrBlockReflection: {
  56065. name: string;
  56066. shader: string;
  56067. };
  56068. }
  56069. declare module BABYLON {
  56070. /** @hidden */
  56071. export var pbrBlockSheen: {
  56072. name: string;
  56073. shader: string;
  56074. };
  56075. }
  56076. declare module BABYLON {
  56077. /** @hidden */
  56078. export var pbrBlockClearcoat: {
  56079. name: string;
  56080. shader: string;
  56081. };
  56082. }
  56083. declare module BABYLON {
  56084. /** @hidden */
  56085. export var pbrBlockSubSurface: {
  56086. name: string;
  56087. shader: string;
  56088. };
  56089. }
  56090. declare module BABYLON {
  56091. /** @hidden */
  56092. export var pbrBlockNormalGeometric: {
  56093. name: string;
  56094. shader: string;
  56095. };
  56096. }
  56097. declare module BABYLON {
  56098. /** @hidden */
  56099. export var pbrBlockNormalFinal: {
  56100. name: string;
  56101. shader: string;
  56102. };
  56103. }
  56104. declare module BABYLON {
  56105. /** @hidden */
  56106. export var pbrBlockLightmapInit: {
  56107. name: string;
  56108. shader: string;
  56109. };
  56110. }
  56111. declare module BABYLON {
  56112. /** @hidden */
  56113. export var pbrBlockGeometryInfo: {
  56114. name: string;
  56115. shader: string;
  56116. };
  56117. }
  56118. declare module BABYLON {
  56119. /** @hidden */
  56120. export var pbrBlockReflectance0: {
  56121. name: string;
  56122. shader: string;
  56123. };
  56124. }
  56125. declare module BABYLON {
  56126. /** @hidden */
  56127. export var pbrBlockReflectance: {
  56128. name: string;
  56129. shader: string;
  56130. };
  56131. }
  56132. declare module BABYLON {
  56133. /** @hidden */
  56134. export var pbrBlockDirectLighting: {
  56135. name: string;
  56136. shader: string;
  56137. };
  56138. }
  56139. declare module BABYLON {
  56140. /** @hidden */
  56141. export var pbrBlockFinalLitComponents: {
  56142. name: string;
  56143. shader: string;
  56144. };
  56145. }
  56146. declare module BABYLON {
  56147. /** @hidden */
  56148. export var pbrBlockFinalUnlitComponents: {
  56149. name: string;
  56150. shader: string;
  56151. };
  56152. }
  56153. declare module BABYLON {
  56154. /** @hidden */
  56155. export var pbrBlockFinalColorComposition: {
  56156. name: string;
  56157. shader: string;
  56158. };
  56159. }
  56160. declare module BABYLON {
  56161. /** @hidden */
  56162. export var pbrBlockImageProcessing: {
  56163. name: string;
  56164. shader: string;
  56165. };
  56166. }
  56167. declare module BABYLON {
  56168. /** @hidden */
  56169. export var pbrDebug: {
  56170. name: string;
  56171. shader: string;
  56172. };
  56173. }
  56174. declare module BABYLON {
  56175. /** @hidden */
  56176. export var pbrPixelShader: {
  56177. name: string;
  56178. shader: string;
  56179. };
  56180. }
  56181. declare module BABYLON {
  56182. /** @hidden */
  56183. export var pbrVertexDeclaration: {
  56184. name: string;
  56185. shader: string;
  56186. };
  56187. }
  56188. declare module BABYLON {
  56189. /** @hidden */
  56190. export var pbrVertexShader: {
  56191. name: string;
  56192. shader: string;
  56193. };
  56194. }
  56195. declare module BABYLON {
  56196. /**
  56197. * Manages the defines for the PBR Material.
  56198. * @hidden
  56199. */
  56200. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56201. PBR: boolean;
  56202. NUM_SAMPLES: string;
  56203. REALTIME_FILTERING: boolean;
  56204. MAINUV1: boolean;
  56205. MAINUV2: boolean;
  56206. UV1: boolean;
  56207. UV2: boolean;
  56208. ALBEDO: boolean;
  56209. GAMMAALBEDO: boolean;
  56210. ALBEDODIRECTUV: number;
  56211. VERTEXCOLOR: boolean;
  56212. DETAIL: boolean;
  56213. DETAILDIRECTUV: number;
  56214. DETAIL_NORMALBLENDMETHOD: number;
  56215. AMBIENT: boolean;
  56216. AMBIENTDIRECTUV: number;
  56217. AMBIENTINGRAYSCALE: boolean;
  56218. OPACITY: boolean;
  56219. VERTEXALPHA: boolean;
  56220. OPACITYDIRECTUV: number;
  56221. OPACITYRGB: boolean;
  56222. ALPHATEST: boolean;
  56223. DEPTHPREPASS: boolean;
  56224. ALPHABLEND: boolean;
  56225. ALPHAFROMALBEDO: boolean;
  56226. ALPHATESTVALUE: string;
  56227. SPECULAROVERALPHA: boolean;
  56228. RADIANCEOVERALPHA: boolean;
  56229. ALPHAFRESNEL: boolean;
  56230. LINEARALPHAFRESNEL: boolean;
  56231. PREMULTIPLYALPHA: boolean;
  56232. EMISSIVE: boolean;
  56233. EMISSIVEDIRECTUV: number;
  56234. REFLECTIVITY: boolean;
  56235. REFLECTIVITYDIRECTUV: number;
  56236. SPECULARTERM: boolean;
  56237. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56238. MICROSURFACEAUTOMATIC: boolean;
  56239. LODBASEDMICROSFURACE: boolean;
  56240. MICROSURFACEMAP: boolean;
  56241. MICROSURFACEMAPDIRECTUV: number;
  56242. METALLICWORKFLOW: boolean;
  56243. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56244. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56245. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56246. AOSTOREINMETALMAPRED: boolean;
  56247. METALLIC_REFLECTANCE: boolean;
  56248. METALLIC_REFLECTANCEDIRECTUV: number;
  56249. ENVIRONMENTBRDF: boolean;
  56250. ENVIRONMENTBRDF_RGBD: boolean;
  56251. NORMAL: boolean;
  56252. TANGENT: boolean;
  56253. BUMP: boolean;
  56254. BUMPDIRECTUV: number;
  56255. OBJECTSPACE_NORMALMAP: boolean;
  56256. PARALLAX: boolean;
  56257. PARALLAXOCCLUSION: boolean;
  56258. NORMALXYSCALE: boolean;
  56259. LIGHTMAP: boolean;
  56260. LIGHTMAPDIRECTUV: number;
  56261. USELIGHTMAPASSHADOWMAP: boolean;
  56262. GAMMALIGHTMAP: boolean;
  56263. RGBDLIGHTMAP: boolean;
  56264. REFLECTION: boolean;
  56265. REFLECTIONMAP_3D: boolean;
  56266. REFLECTIONMAP_SPHERICAL: boolean;
  56267. REFLECTIONMAP_PLANAR: boolean;
  56268. REFLECTIONMAP_CUBIC: boolean;
  56269. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56270. REFLECTIONMAP_PROJECTION: boolean;
  56271. REFLECTIONMAP_SKYBOX: boolean;
  56272. REFLECTIONMAP_EXPLICIT: boolean;
  56273. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56274. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56275. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56276. INVERTCUBICMAP: boolean;
  56277. USESPHERICALFROMREFLECTIONMAP: boolean;
  56278. USEIRRADIANCEMAP: boolean;
  56279. SPHERICAL_HARMONICS: boolean;
  56280. USESPHERICALINVERTEX: boolean;
  56281. REFLECTIONMAP_OPPOSITEZ: boolean;
  56282. LODINREFLECTIONALPHA: boolean;
  56283. GAMMAREFLECTION: boolean;
  56284. RGBDREFLECTION: boolean;
  56285. LINEARSPECULARREFLECTION: boolean;
  56286. RADIANCEOCCLUSION: boolean;
  56287. HORIZONOCCLUSION: boolean;
  56288. INSTANCES: boolean;
  56289. THIN_INSTANCES: boolean;
  56290. PREPASS: boolean;
  56291. SCENE_MRT_COUNT: number;
  56292. NUM_BONE_INFLUENCERS: number;
  56293. BonesPerMesh: number;
  56294. BONETEXTURE: boolean;
  56295. NONUNIFORMSCALING: boolean;
  56296. MORPHTARGETS: boolean;
  56297. MORPHTARGETS_NORMAL: boolean;
  56298. MORPHTARGETS_TANGENT: boolean;
  56299. MORPHTARGETS_UV: boolean;
  56300. NUM_MORPH_INFLUENCERS: number;
  56301. IMAGEPROCESSING: boolean;
  56302. VIGNETTE: boolean;
  56303. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56304. VIGNETTEBLENDMODEOPAQUE: boolean;
  56305. TONEMAPPING: boolean;
  56306. TONEMAPPING_ACES: boolean;
  56307. CONTRAST: boolean;
  56308. COLORCURVES: boolean;
  56309. COLORGRADING: boolean;
  56310. COLORGRADING3D: boolean;
  56311. SAMPLER3DGREENDEPTH: boolean;
  56312. SAMPLER3DBGRMAP: boolean;
  56313. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56314. EXPOSURE: boolean;
  56315. MULTIVIEW: boolean;
  56316. USEPHYSICALLIGHTFALLOFF: boolean;
  56317. USEGLTFLIGHTFALLOFF: boolean;
  56318. TWOSIDEDLIGHTING: boolean;
  56319. SHADOWFLOAT: boolean;
  56320. CLIPPLANE: boolean;
  56321. CLIPPLANE2: boolean;
  56322. CLIPPLANE3: boolean;
  56323. CLIPPLANE4: boolean;
  56324. CLIPPLANE5: boolean;
  56325. CLIPPLANE6: boolean;
  56326. POINTSIZE: boolean;
  56327. FOG: boolean;
  56328. LOGARITHMICDEPTH: boolean;
  56329. FORCENORMALFORWARD: boolean;
  56330. SPECULARAA: boolean;
  56331. CLEARCOAT: boolean;
  56332. CLEARCOAT_DEFAULTIOR: boolean;
  56333. CLEARCOAT_TEXTURE: boolean;
  56334. CLEARCOAT_TEXTUREDIRECTUV: number;
  56335. CLEARCOAT_BUMP: boolean;
  56336. CLEARCOAT_BUMPDIRECTUV: number;
  56337. CLEARCOAT_TINT: boolean;
  56338. CLEARCOAT_TINT_TEXTURE: boolean;
  56339. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56340. ANISOTROPIC: boolean;
  56341. ANISOTROPIC_TEXTURE: boolean;
  56342. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56343. BRDF_V_HEIGHT_CORRELATED: boolean;
  56344. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56345. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56346. SHEEN: boolean;
  56347. SHEEN_TEXTURE: boolean;
  56348. SHEEN_TEXTUREDIRECTUV: number;
  56349. SHEEN_LINKWITHALBEDO: boolean;
  56350. SHEEN_ROUGHNESS: boolean;
  56351. SHEEN_ALBEDOSCALING: boolean;
  56352. SUBSURFACE: boolean;
  56353. SS_REFRACTION: boolean;
  56354. SS_TRANSLUCENCY: boolean;
  56355. SS_SCATTERING: boolean;
  56356. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56357. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56358. SS_REFRACTIONMAP_3D: boolean;
  56359. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56360. SS_LODINREFRACTIONALPHA: boolean;
  56361. SS_GAMMAREFRACTION: boolean;
  56362. SS_RGBDREFRACTION: boolean;
  56363. SS_LINEARSPECULARREFRACTION: boolean;
  56364. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56365. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56366. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56367. UNLIT: boolean;
  56368. DEBUGMODE: number;
  56369. /**
  56370. * Initializes the PBR Material defines.
  56371. */
  56372. constructor();
  56373. /**
  56374. * Resets the PBR Material defines.
  56375. */
  56376. reset(): void;
  56377. }
  56378. /**
  56379. * The Physically based material base class of BJS.
  56380. *
  56381. * This offers the main features of a standard PBR material.
  56382. * For more information, please refer to the documentation :
  56383. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56384. */
  56385. export abstract class PBRBaseMaterial extends PushMaterial {
  56386. /**
  56387. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56388. */
  56389. static readonly PBRMATERIAL_OPAQUE: number;
  56390. /**
  56391. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56392. */
  56393. static readonly PBRMATERIAL_ALPHATEST: number;
  56394. /**
  56395. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56396. */
  56397. static readonly PBRMATERIAL_ALPHABLEND: number;
  56398. /**
  56399. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56400. * They are also discarded below the alpha cutoff threshold to improve performances.
  56401. */
  56402. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56403. /**
  56404. * Defines the default value of how much AO map is occluding the analytical lights
  56405. * (point spot...).
  56406. */
  56407. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56408. /**
  56409. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56410. */
  56411. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56412. /**
  56413. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56414. * to enhance interoperability with other engines.
  56415. */
  56416. static readonly LIGHTFALLOFF_GLTF: number;
  56417. /**
  56418. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56419. * to enhance interoperability with other materials.
  56420. */
  56421. static readonly LIGHTFALLOFF_STANDARD: number;
  56422. /**
  56423. * Intensity of the direct lights e.g. the four lights available in your scene.
  56424. * This impacts both the direct diffuse and specular highlights.
  56425. */
  56426. protected _directIntensity: number;
  56427. /**
  56428. * Intensity of the emissive part of the material.
  56429. * This helps controlling the emissive effect without modifying the emissive color.
  56430. */
  56431. protected _emissiveIntensity: number;
  56432. /**
  56433. * Intensity of the environment e.g. how much the environment will light the object
  56434. * either through harmonics for rough material or through the refelction for shiny ones.
  56435. */
  56436. protected _environmentIntensity: number;
  56437. /**
  56438. * This is a special control allowing the reduction of the specular highlights coming from the
  56439. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56440. */
  56441. protected _specularIntensity: number;
  56442. /**
  56443. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56444. */
  56445. private _lightingInfos;
  56446. /**
  56447. * Debug Control allowing disabling the bump map on this material.
  56448. */
  56449. protected _disableBumpMap: boolean;
  56450. /**
  56451. * AKA Diffuse Texture in standard nomenclature.
  56452. */
  56453. protected _albedoTexture: Nullable<BaseTexture>;
  56454. /**
  56455. * AKA Occlusion Texture in other nomenclature.
  56456. */
  56457. protected _ambientTexture: Nullable<BaseTexture>;
  56458. /**
  56459. * AKA Occlusion Texture Intensity in other nomenclature.
  56460. */
  56461. protected _ambientTextureStrength: number;
  56462. /**
  56463. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56464. * 1 means it completely occludes it
  56465. * 0 mean it has no impact
  56466. */
  56467. protected _ambientTextureImpactOnAnalyticalLights: number;
  56468. /**
  56469. * Stores the alpha values in a texture.
  56470. */
  56471. protected _opacityTexture: Nullable<BaseTexture>;
  56472. /**
  56473. * Stores the reflection values in a texture.
  56474. */
  56475. protected _reflectionTexture: Nullable<BaseTexture>;
  56476. /**
  56477. * Stores the emissive values in a texture.
  56478. */
  56479. protected _emissiveTexture: Nullable<BaseTexture>;
  56480. /**
  56481. * AKA Specular texture in other nomenclature.
  56482. */
  56483. protected _reflectivityTexture: Nullable<BaseTexture>;
  56484. /**
  56485. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56486. */
  56487. protected _metallicTexture: Nullable<BaseTexture>;
  56488. /**
  56489. * Specifies the metallic scalar of the metallic/roughness workflow.
  56490. * Can also be used to scale the metalness values of the metallic texture.
  56491. */
  56492. protected _metallic: Nullable<number>;
  56493. /**
  56494. * Specifies the roughness scalar of the metallic/roughness workflow.
  56495. * Can also be used to scale the roughness values of the metallic texture.
  56496. */
  56497. protected _roughness: Nullable<number>;
  56498. /**
  56499. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56500. * By default the indexOfrefraction is used to compute F0;
  56501. *
  56502. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56503. *
  56504. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56505. * F90 = metallicReflectanceColor;
  56506. */
  56507. protected _metallicF0Factor: number;
  56508. /**
  56509. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56510. * By default the F90 is always 1;
  56511. *
  56512. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56513. *
  56514. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56515. * F90 = metallicReflectanceColor;
  56516. */
  56517. protected _metallicReflectanceColor: Color3;
  56518. /**
  56519. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56520. * This is multiply against the scalar values defined in the material.
  56521. */
  56522. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56523. /**
  56524. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56525. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56526. */
  56527. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56528. /**
  56529. * Stores surface normal data used to displace a mesh in a texture.
  56530. */
  56531. protected _bumpTexture: Nullable<BaseTexture>;
  56532. /**
  56533. * Stores the pre-calculated light information of a mesh in a texture.
  56534. */
  56535. protected _lightmapTexture: Nullable<BaseTexture>;
  56536. /**
  56537. * The color of a material in ambient lighting.
  56538. */
  56539. protected _ambientColor: Color3;
  56540. /**
  56541. * AKA Diffuse Color in other nomenclature.
  56542. */
  56543. protected _albedoColor: Color3;
  56544. /**
  56545. * AKA Specular Color in other nomenclature.
  56546. */
  56547. protected _reflectivityColor: Color3;
  56548. /**
  56549. * The color applied when light is reflected from a material.
  56550. */
  56551. protected _reflectionColor: Color3;
  56552. /**
  56553. * The color applied when light is emitted from a material.
  56554. */
  56555. protected _emissiveColor: Color3;
  56556. /**
  56557. * AKA Glossiness in other nomenclature.
  56558. */
  56559. protected _microSurface: number;
  56560. /**
  56561. * Specifies that the material will use the light map as a show map.
  56562. */
  56563. protected _useLightmapAsShadowmap: boolean;
  56564. /**
  56565. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56566. * makes the reflect vector face the model (under horizon).
  56567. */
  56568. protected _useHorizonOcclusion: boolean;
  56569. /**
  56570. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56571. * too much the area relying on ambient texture to define their ambient occlusion.
  56572. */
  56573. protected _useRadianceOcclusion: boolean;
  56574. /**
  56575. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56576. */
  56577. protected _useAlphaFromAlbedoTexture: boolean;
  56578. /**
  56579. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56580. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56581. */
  56582. protected _useSpecularOverAlpha: boolean;
  56583. /**
  56584. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56585. */
  56586. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56587. /**
  56588. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56589. */
  56590. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56591. /**
  56592. * Specifies if the metallic texture contains the roughness information in its green channel.
  56593. */
  56594. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56595. /**
  56596. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56597. */
  56598. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56599. /**
  56600. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56601. */
  56602. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56603. /**
  56604. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56605. */
  56606. protected _useAmbientInGrayScale: boolean;
  56607. /**
  56608. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56609. * The material will try to infer what glossiness each pixel should be.
  56610. */
  56611. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56612. /**
  56613. * Defines the falloff type used in this material.
  56614. * It by default is Physical.
  56615. */
  56616. protected _lightFalloff: number;
  56617. /**
  56618. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56619. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56620. */
  56621. protected _useRadianceOverAlpha: boolean;
  56622. /**
  56623. * Allows using an object space normal map (instead of tangent space).
  56624. */
  56625. protected _useObjectSpaceNormalMap: boolean;
  56626. /**
  56627. * Allows using the bump map in parallax mode.
  56628. */
  56629. protected _useParallax: boolean;
  56630. /**
  56631. * Allows using the bump map in parallax occlusion mode.
  56632. */
  56633. protected _useParallaxOcclusion: boolean;
  56634. /**
  56635. * Controls the scale bias of the parallax mode.
  56636. */
  56637. protected _parallaxScaleBias: number;
  56638. /**
  56639. * If sets to true, disables all the lights affecting the material.
  56640. */
  56641. protected _disableLighting: boolean;
  56642. /**
  56643. * Number of Simultaneous lights allowed on the material.
  56644. */
  56645. protected _maxSimultaneousLights: number;
  56646. /**
  56647. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56648. */
  56649. protected _invertNormalMapX: boolean;
  56650. /**
  56651. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56652. */
  56653. protected _invertNormalMapY: boolean;
  56654. /**
  56655. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56656. */
  56657. protected _twoSidedLighting: boolean;
  56658. /**
  56659. * Defines the alpha limits in alpha test mode.
  56660. */
  56661. protected _alphaCutOff: number;
  56662. /**
  56663. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56664. */
  56665. protected _forceAlphaTest: boolean;
  56666. /**
  56667. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56668. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56669. */
  56670. protected _useAlphaFresnel: boolean;
  56671. /**
  56672. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56673. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56674. */
  56675. protected _useLinearAlphaFresnel: boolean;
  56676. /**
  56677. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56678. * from cos thetav and roughness:
  56679. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56680. */
  56681. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56682. /**
  56683. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56684. */
  56685. protected _forceIrradianceInFragment: boolean;
  56686. private _realTimeFiltering;
  56687. /**
  56688. * Enables realtime filtering on the texture.
  56689. */
  56690. get realTimeFiltering(): boolean;
  56691. set realTimeFiltering(b: boolean);
  56692. private _realTimeFilteringQuality;
  56693. /**
  56694. * Quality switch for realtime filtering
  56695. */
  56696. get realTimeFilteringQuality(): number;
  56697. set realTimeFilteringQuality(n: number);
  56698. /**
  56699. * Can this material render to several textures at once
  56700. */
  56701. get canRenderToMRT(): boolean;
  56702. /**
  56703. * Force normal to face away from face.
  56704. */
  56705. protected _forceNormalForward: boolean;
  56706. /**
  56707. * Enables specular anti aliasing in the PBR shader.
  56708. * It will both interacts on the Geometry for analytical and IBL lighting.
  56709. * It also prefilter the roughness map based on the bump values.
  56710. */
  56711. protected _enableSpecularAntiAliasing: boolean;
  56712. /**
  56713. * Default configuration related to image processing available in the PBR Material.
  56714. */
  56715. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56716. /**
  56717. * Keep track of the image processing observer to allow dispose and replace.
  56718. */
  56719. private _imageProcessingObserver;
  56720. /**
  56721. * Attaches a new image processing configuration to the PBR Material.
  56722. * @param configuration
  56723. */
  56724. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56725. /**
  56726. * Stores the available render targets.
  56727. */
  56728. private _renderTargets;
  56729. /**
  56730. * Sets the global ambient color for the material used in lighting calculations.
  56731. */
  56732. private _globalAmbientColor;
  56733. /**
  56734. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56735. */
  56736. private _useLogarithmicDepth;
  56737. /**
  56738. * If set to true, no lighting calculations will be applied.
  56739. */
  56740. private _unlit;
  56741. private _debugMode;
  56742. /**
  56743. * @hidden
  56744. * This is reserved for the inspector.
  56745. * Defines the material debug mode.
  56746. * It helps seeing only some components of the material while troubleshooting.
  56747. */
  56748. debugMode: number;
  56749. /**
  56750. * @hidden
  56751. * This is reserved for the inspector.
  56752. * Specify from where on screen the debug mode should start.
  56753. * The value goes from -1 (full screen) to 1 (not visible)
  56754. * It helps with side by side comparison against the final render
  56755. * This defaults to -1
  56756. */
  56757. private debugLimit;
  56758. /**
  56759. * @hidden
  56760. * This is reserved for the inspector.
  56761. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56762. * You can use the factor to better multiply the final value.
  56763. */
  56764. private debugFactor;
  56765. /**
  56766. * Defines the clear coat layer parameters for the material.
  56767. */
  56768. readonly clearCoat: PBRClearCoatConfiguration;
  56769. /**
  56770. * Defines the anisotropic parameters for the material.
  56771. */
  56772. readonly anisotropy: PBRAnisotropicConfiguration;
  56773. /**
  56774. * Defines the BRDF parameters for the material.
  56775. */
  56776. readonly brdf: PBRBRDFConfiguration;
  56777. /**
  56778. * Defines the Sheen parameters for the material.
  56779. */
  56780. readonly sheen: PBRSheenConfiguration;
  56781. /**
  56782. * Defines the SubSurface parameters for the material.
  56783. */
  56784. readonly subSurface: PBRSubSurfaceConfiguration;
  56785. /**
  56786. * Defines the detail map parameters for the material.
  56787. */
  56788. readonly detailMap: DetailMapConfiguration;
  56789. protected _rebuildInParallel: boolean;
  56790. /**
  56791. * Instantiates a new PBRMaterial instance.
  56792. *
  56793. * @param name The material name
  56794. * @param scene The scene the material will be use in.
  56795. */
  56796. constructor(name: string, scene: Scene);
  56797. /**
  56798. * Gets a boolean indicating that current material needs to register RTT
  56799. */
  56800. get hasRenderTargetTextures(): boolean;
  56801. /**
  56802. * Gets the name of the material class.
  56803. */
  56804. getClassName(): string;
  56805. /**
  56806. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56807. */
  56808. get useLogarithmicDepth(): boolean;
  56809. /**
  56810. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56811. */
  56812. set useLogarithmicDepth(value: boolean);
  56813. /**
  56814. * Returns true if alpha blending should be disabled.
  56815. */
  56816. protected get _disableAlphaBlending(): boolean;
  56817. /**
  56818. * Specifies whether or not this material should be rendered in alpha blend mode.
  56819. */
  56820. needAlphaBlending(): boolean;
  56821. /**
  56822. * Specifies whether or not this material should be rendered in alpha test mode.
  56823. */
  56824. needAlphaTesting(): boolean;
  56825. /**
  56826. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56827. */
  56828. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56829. /**
  56830. * Gets the texture used for the alpha test.
  56831. */
  56832. getAlphaTestTexture(): Nullable<BaseTexture>;
  56833. /**
  56834. * Specifies that the submesh is ready to be used.
  56835. * @param mesh - BJS mesh.
  56836. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56837. * @param useInstances - Specifies that instances should be used.
  56838. * @returns - boolean indicating that the submesh is ready or not.
  56839. */
  56840. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56841. /**
  56842. * Specifies if the material uses metallic roughness workflow.
  56843. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56844. */
  56845. isMetallicWorkflow(): boolean;
  56846. private _prepareEffect;
  56847. private _prepareDefines;
  56848. /**
  56849. * Force shader compilation
  56850. */
  56851. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56852. /**
  56853. * Initializes the uniform buffer layout for the shader.
  56854. */
  56855. buildUniformLayout(): void;
  56856. /**
  56857. * Unbinds the material from the mesh
  56858. */
  56859. unbind(): void;
  56860. /**
  56861. * Binds the submesh data.
  56862. * @param world - The world matrix.
  56863. * @param mesh - The BJS mesh.
  56864. * @param subMesh - A submesh of the BJS mesh.
  56865. */
  56866. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56867. /**
  56868. * Returns the animatable textures.
  56869. * @returns - Array of animatable textures.
  56870. */
  56871. getAnimatables(): IAnimatable[];
  56872. /**
  56873. * Returns the texture used for reflections.
  56874. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56875. */
  56876. private _getReflectionTexture;
  56877. /**
  56878. * Returns an array of the actively used textures.
  56879. * @returns - Array of BaseTextures
  56880. */
  56881. getActiveTextures(): BaseTexture[];
  56882. /**
  56883. * Checks to see if a texture is used in the material.
  56884. * @param texture - Base texture to use.
  56885. * @returns - Boolean specifying if a texture is used in the material.
  56886. */
  56887. hasTexture(texture: BaseTexture): boolean;
  56888. /**
  56889. * Sets the required values to the prepass renderer.
  56890. * @param prePassRenderer defines the prepass renderer to setup
  56891. */
  56892. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56893. /**
  56894. * Disposes the resources of the material.
  56895. * @param forceDisposeEffect - Forces the disposal of effects.
  56896. * @param forceDisposeTextures - Forces the disposal of all textures.
  56897. */
  56898. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56899. }
  56900. }
  56901. declare module BABYLON {
  56902. /**
  56903. * The Physically based material of BJS.
  56904. *
  56905. * This offers the main features of a standard PBR material.
  56906. * For more information, please refer to the documentation :
  56907. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56908. */
  56909. export class PBRMaterial extends PBRBaseMaterial {
  56910. /**
  56911. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56912. */
  56913. static readonly PBRMATERIAL_OPAQUE: number;
  56914. /**
  56915. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56916. */
  56917. static readonly PBRMATERIAL_ALPHATEST: number;
  56918. /**
  56919. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56920. */
  56921. static readonly PBRMATERIAL_ALPHABLEND: number;
  56922. /**
  56923. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56924. * They are also discarded below the alpha cutoff threshold to improve performances.
  56925. */
  56926. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56927. /**
  56928. * Defines the default value of how much AO map is occluding the analytical lights
  56929. * (point spot...).
  56930. */
  56931. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56932. /**
  56933. * Intensity of the direct lights e.g. the four lights available in your scene.
  56934. * This impacts both the direct diffuse and specular highlights.
  56935. */
  56936. directIntensity: number;
  56937. /**
  56938. * Intensity of the emissive part of the material.
  56939. * This helps controlling the emissive effect without modifying the emissive color.
  56940. */
  56941. emissiveIntensity: number;
  56942. /**
  56943. * Intensity of the environment e.g. how much the environment will light the object
  56944. * either through harmonics for rough material or through the refelction for shiny ones.
  56945. */
  56946. environmentIntensity: number;
  56947. /**
  56948. * This is a special control allowing the reduction of the specular highlights coming from the
  56949. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56950. */
  56951. specularIntensity: number;
  56952. /**
  56953. * Debug Control allowing disabling the bump map on this material.
  56954. */
  56955. disableBumpMap: boolean;
  56956. /**
  56957. * AKA Diffuse Texture in standard nomenclature.
  56958. */
  56959. albedoTexture: BaseTexture;
  56960. /**
  56961. * AKA Occlusion Texture in other nomenclature.
  56962. */
  56963. ambientTexture: BaseTexture;
  56964. /**
  56965. * AKA Occlusion Texture Intensity in other nomenclature.
  56966. */
  56967. ambientTextureStrength: number;
  56968. /**
  56969. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56970. * 1 means it completely occludes it
  56971. * 0 mean it has no impact
  56972. */
  56973. ambientTextureImpactOnAnalyticalLights: number;
  56974. /**
  56975. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56976. */
  56977. opacityTexture: BaseTexture;
  56978. /**
  56979. * Stores the reflection values in a texture.
  56980. */
  56981. reflectionTexture: Nullable<BaseTexture>;
  56982. /**
  56983. * Stores the emissive values in a texture.
  56984. */
  56985. emissiveTexture: BaseTexture;
  56986. /**
  56987. * AKA Specular texture in other nomenclature.
  56988. */
  56989. reflectivityTexture: BaseTexture;
  56990. /**
  56991. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56992. */
  56993. metallicTexture: BaseTexture;
  56994. /**
  56995. * Specifies the metallic scalar of the metallic/roughness workflow.
  56996. * Can also be used to scale the metalness values of the metallic texture.
  56997. */
  56998. metallic: Nullable<number>;
  56999. /**
  57000. * Specifies the roughness scalar of the metallic/roughness workflow.
  57001. * Can also be used to scale the roughness values of the metallic texture.
  57002. */
  57003. roughness: Nullable<number>;
  57004. /**
  57005. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57006. * By default the indexOfrefraction is used to compute F0;
  57007. *
  57008. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57009. *
  57010. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57011. * F90 = metallicReflectanceColor;
  57012. */
  57013. metallicF0Factor: number;
  57014. /**
  57015. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57016. * By default the F90 is always 1;
  57017. *
  57018. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57019. *
  57020. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57021. * F90 = metallicReflectanceColor;
  57022. */
  57023. metallicReflectanceColor: Color3;
  57024. /**
  57025. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57026. * This is multiply against the scalar values defined in the material.
  57027. */
  57028. metallicReflectanceTexture: Nullable<BaseTexture>;
  57029. /**
  57030. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57031. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57032. */
  57033. microSurfaceTexture: BaseTexture;
  57034. /**
  57035. * Stores surface normal data used to displace a mesh in a texture.
  57036. */
  57037. bumpTexture: BaseTexture;
  57038. /**
  57039. * Stores the pre-calculated light information of a mesh in a texture.
  57040. */
  57041. lightmapTexture: BaseTexture;
  57042. /**
  57043. * Stores the refracted light information in a texture.
  57044. */
  57045. get refractionTexture(): Nullable<BaseTexture>;
  57046. set refractionTexture(value: Nullable<BaseTexture>);
  57047. /**
  57048. * The color of a material in ambient lighting.
  57049. */
  57050. ambientColor: Color3;
  57051. /**
  57052. * AKA Diffuse Color in other nomenclature.
  57053. */
  57054. albedoColor: Color3;
  57055. /**
  57056. * AKA Specular Color in other nomenclature.
  57057. */
  57058. reflectivityColor: Color3;
  57059. /**
  57060. * The color reflected from the material.
  57061. */
  57062. reflectionColor: Color3;
  57063. /**
  57064. * The color emitted from the material.
  57065. */
  57066. emissiveColor: Color3;
  57067. /**
  57068. * AKA Glossiness in other nomenclature.
  57069. */
  57070. microSurface: number;
  57071. /**
  57072. * Index of refraction of the material base layer.
  57073. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57074. *
  57075. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57076. *
  57077. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57078. */
  57079. get indexOfRefraction(): number;
  57080. set indexOfRefraction(value: number);
  57081. /**
  57082. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57083. */
  57084. get invertRefractionY(): boolean;
  57085. set invertRefractionY(value: boolean);
  57086. /**
  57087. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57088. * Materials half opaque for instance using refraction could benefit from this control.
  57089. */
  57090. get linkRefractionWithTransparency(): boolean;
  57091. set linkRefractionWithTransparency(value: boolean);
  57092. /**
  57093. * If true, the light map contains occlusion information instead of lighting info.
  57094. */
  57095. useLightmapAsShadowmap: boolean;
  57096. /**
  57097. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57098. */
  57099. useAlphaFromAlbedoTexture: boolean;
  57100. /**
  57101. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57102. */
  57103. forceAlphaTest: boolean;
  57104. /**
  57105. * Defines the alpha limits in alpha test mode.
  57106. */
  57107. alphaCutOff: number;
  57108. /**
  57109. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57110. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57111. */
  57112. useSpecularOverAlpha: boolean;
  57113. /**
  57114. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57115. */
  57116. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57117. /**
  57118. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57119. */
  57120. useRoughnessFromMetallicTextureAlpha: boolean;
  57121. /**
  57122. * Specifies if the metallic texture contains the roughness information in its green channel.
  57123. */
  57124. useRoughnessFromMetallicTextureGreen: boolean;
  57125. /**
  57126. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57127. */
  57128. useMetallnessFromMetallicTextureBlue: boolean;
  57129. /**
  57130. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57131. */
  57132. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57133. /**
  57134. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57135. */
  57136. useAmbientInGrayScale: boolean;
  57137. /**
  57138. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57139. * The material will try to infer what glossiness each pixel should be.
  57140. */
  57141. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57142. /**
  57143. * BJS is using an harcoded light falloff based on a manually sets up range.
  57144. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57145. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57146. */
  57147. get usePhysicalLightFalloff(): boolean;
  57148. /**
  57149. * BJS is using an harcoded light falloff based on a manually sets up range.
  57150. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57151. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57152. */
  57153. set usePhysicalLightFalloff(value: boolean);
  57154. /**
  57155. * In order to support the falloff compatibility with gltf, a special mode has been added
  57156. * to reproduce the gltf light falloff.
  57157. */
  57158. get useGLTFLightFalloff(): boolean;
  57159. /**
  57160. * In order to support the falloff compatibility with gltf, a special mode has been added
  57161. * to reproduce the gltf light falloff.
  57162. */
  57163. set useGLTFLightFalloff(value: boolean);
  57164. /**
  57165. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57166. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57167. */
  57168. useRadianceOverAlpha: boolean;
  57169. /**
  57170. * Allows using an object space normal map (instead of tangent space).
  57171. */
  57172. useObjectSpaceNormalMap: boolean;
  57173. /**
  57174. * Allows using the bump map in parallax mode.
  57175. */
  57176. useParallax: boolean;
  57177. /**
  57178. * Allows using the bump map in parallax occlusion mode.
  57179. */
  57180. useParallaxOcclusion: boolean;
  57181. /**
  57182. * Controls the scale bias of the parallax mode.
  57183. */
  57184. parallaxScaleBias: number;
  57185. /**
  57186. * If sets to true, disables all the lights affecting the material.
  57187. */
  57188. disableLighting: boolean;
  57189. /**
  57190. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57191. */
  57192. forceIrradianceInFragment: boolean;
  57193. /**
  57194. * Number of Simultaneous lights allowed on the material.
  57195. */
  57196. maxSimultaneousLights: number;
  57197. /**
  57198. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57199. */
  57200. invertNormalMapX: boolean;
  57201. /**
  57202. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57203. */
  57204. invertNormalMapY: boolean;
  57205. /**
  57206. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57207. */
  57208. twoSidedLighting: boolean;
  57209. /**
  57210. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57211. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57212. */
  57213. useAlphaFresnel: boolean;
  57214. /**
  57215. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57216. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57217. */
  57218. useLinearAlphaFresnel: boolean;
  57219. /**
  57220. * Let user defines the brdf lookup texture used for IBL.
  57221. * A default 8bit version is embedded but you could point at :
  57222. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57223. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57224. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57225. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57226. */
  57227. environmentBRDFTexture: Nullable<BaseTexture>;
  57228. /**
  57229. * Force normal to face away from face.
  57230. */
  57231. forceNormalForward: boolean;
  57232. /**
  57233. * Enables specular anti aliasing in the PBR shader.
  57234. * It will both interacts on the Geometry for analytical and IBL lighting.
  57235. * It also prefilter the roughness map based on the bump values.
  57236. */
  57237. enableSpecularAntiAliasing: boolean;
  57238. /**
  57239. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57240. * makes the reflect vector face the model (under horizon).
  57241. */
  57242. useHorizonOcclusion: boolean;
  57243. /**
  57244. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57245. * too much the area relying on ambient texture to define their ambient occlusion.
  57246. */
  57247. useRadianceOcclusion: boolean;
  57248. /**
  57249. * If set to true, no lighting calculations will be applied.
  57250. */
  57251. unlit: boolean;
  57252. /**
  57253. * Gets the image processing configuration used either in this material.
  57254. */
  57255. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57256. /**
  57257. * Sets the Default image processing configuration used either in the this material.
  57258. *
  57259. * If sets to null, the scene one is in use.
  57260. */
  57261. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57262. /**
  57263. * Gets wether the color curves effect is enabled.
  57264. */
  57265. get cameraColorCurvesEnabled(): boolean;
  57266. /**
  57267. * Sets wether the color curves effect is enabled.
  57268. */
  57269. set cameraColorCurvesEnabled(value: boolean);
  57270. /**
  57271. * Gets wether the color grading effect is enabled.
  57272. */
  57273. get cameraColorGradingEnabled(): boolean;
  57274. /**
  57275. * Gets wether the color grading effect is enabled.
  57276. */
  57277. set cameraColorGradingEnabled(value: boolean);
  57278. /**
  57279. * Gets wether tonemapping is enabled or not.
  57280. */
  57281. get cameraToneMappingEnabled(): boolean;
  57282. /**
  57283. * Sets wether tonemapping is enabled or not
  57284. */
  57285. set cameraToneMappingEnabled(value: boolean);
  57286. /**
  57287. * The camera exposure used on this material.
  57288. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57289. * This corresponds to a photographic exposure.
  57290. */
  57291. get cameraExposure(): number;
  57292. /**
  57293. * The camera exposure used on this material.
  57294. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57295. * This corresponds to a photographic exposure.
  57296. */
  57297. set cameraExposure(value: number);
  57298. /**
  57299. * Gets The camera contrast used on this material.
  57300. */
  57301. get cameraContrast(): number;
  57302. /**
  57303. * Sets The camera contrast used on this material.
  57304. */
  57305. set cameraContrast(value: number);
  57306. /**
  57307. * Gets the Color Grading 2D Lookup Texture.
  57308. */
  57309. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57310. /**
  57311. * Sets the Color Grading 2D Lookup Texture.
  57312. */
  57313. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57314. /**
  57315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57317. * 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;
  57318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57319. */
  57320. get cameraColorCurves(): Nullable<ColorCurves>;
  57321. /**
  57322. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57323. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57324. * 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;
  57325. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57326. */
  57327. set cameraColorCurves(value: Nullable<ColorCurves>);
  57328. /**
  57329. * Instantiates a new PBRMaterial instance.
  57330. *
  57331. * @param name The material name
  57332. * @param scene The scene the material will be use in.
  57333. */
  57334. constructor(name: string, scene: Scene);
  57335. /**
  57336. * Returns the name of this material class.
  57337. */
  57338. getClassName(): string;
  57339. /**
  57340. * Makes a duplicate of the current material.
  57341. * @param name - name to use for the new material.
  57342. */
  57343. clone(name: string): PBRMaterial;
  57344. /**
  57345. * Serializes this PBR Material.
  57346. * @returns - An object with the serialized material.
  57347. */
  57348. serialize(): any;
  57349. /**
  57350. * Parses a PBR Material from a serialized object.
  57351. * @param source - Serialized object.
  57352. * @param scene - BJS scene instance.
  57353. * @param rootUrl - url for the scene object
  57354. * @returns - PBRMaterial
  57355. */
  57356. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57357. }
  57358. }
  57359. declare module BABYLON {
  57360. /**
  57361. * Direct draw surface info
  57362. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57363. */
  57364. export interface DDSInfo {
  57365. /**
  57366. * Width of the texture
  57367. */
  57368. width: number;
  57369. /**
  57370. * Width of the texture
  57371. */
  57372. height: number;
  57373. /**
  57374. * Number of Mipmaps for the texture
  57375. * @see https://en.wikipedia.org/wiki/Mipmap
  57376. */
  57377. mipmapCount: number;
  57378. /**
  57379. * If the textures format is a known fourCC format
  57380. * @see https://www.fourcc.org/
  57381. */
  57382. isFourCC: boolean;
  57383. /**
  57384. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57385. */
  57386. isRGB: boolean;
  57387. /**
  57388. * If the texture is a lumincance format
  57389. */
  57390. isLuminance: boolean;
  57391. /**
  57392. * If this is a cube texture
  57393. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57394. */
  57395. isCube: boolean;
  57396. /**
  57397. * If the texture is a compressed format eg. FOURCC_DXT1
  57398. */
  57399. isCompressed: boolean;
  57400. /**
  57401. * The dxgiFormat of the texture
  57402. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57403. */
  57404. dxgiFormat: number;
  57405. /**
  57406. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57407. */
  57408. textureType: number;
  57409. /**
  57410. * Sphericle polynomial created for the dds texture
  57411. */
  57412. sphericalPolynomial?: SphericalPolynomial;
  57413. }
  57414. /**
  57415. * Class used to provide DDS decompression tools
  57416. */
  57417. export class DDSTools {
  57418. /**
  57419. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57420. */
  57421. static StoreLODInAlphaChannel: boolean;
  57422. /**
  57423. * Gets DDS information from an array buffer
  57424. * @param data defines the array buffer view to read data from
  57425. * @returns the DDS information
  57426. */
  57427. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57428. private static _FloatView;
  57429. private static _Int32View;
  57430. private static _ToHalfFloat;
  57431. private static _FromHalfFloat;
  57432. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57433. private static _GetHalfFloatRGBAArrayBuffer;
  57434. private static _GetFloatRGBAArrayBuffer;
  57435. private static _GetFloatAsUIntRGBAArrayBuffer;
  57436. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57437. private static _GetRGBAArrayBuffer;
  57438. private static _ExtractLongWordOrder;
  57439. private static _GetRGBArrayBuffer;
  57440. private static _GetLuminanceArrayBuffer;
  57441. /**
  57442. * Uploads DDS Levels to a Babylon Texture
  57443. * @hidden
  57444. */
  57445. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57446. }
  57447. interface ThinEngine {
  57448. /**
  57449. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57450. * @param rootUrl defines the url where the file to load is located
  57451. * @param scene defines the current scene
  57452. * @param lodScale defines scale to apply to the mip map selection
  57453. * @param lodOffset defines offset to apply to the mip map selection
  57454. * @param onLoad defines an optional callback raised when the texture is loaded
  57455. * @param onError defines an optional callback raised if there is an issue to load the texture
  57456. * @param format defines the format of the data
  57457. * @param forcedExtension defines the extension to use to pick the right loader
  57458. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57459. * @returns the cube texture as an InternalTexture
  57460. */
  57461. 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;
  57462. }
  57463. }
  57464. declare module BABYLON {
  57465. /**
  57466. * Implementation of the DDS Texture Loader.
  57467. * @hidden
  57468. */
  57469. export class _DDSTextureLoader implements IInternalTextureLoader {
  57470. /**
  57471. * Defines wether the loader supports cascade loading the different faces.
  57472. */
  57473. readonly supportCascades: boolean;
  57474. /**
  57475. * This returns if the loader support the current file information.
  57476. * @param extension defines the file extension of the file being loaded
  57477. * @returns true if the loader can load the specified file
  57478. */
  57479. canLoad(extension: string): boolean;
  57480. /**
  57481. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57482. * @param data contains the texture data
  57483. * @param texture defines the BabylonJS internal texture
  57484. * @param createPolynomials will be true if polynomials have been requested
  57485. * @param onLoad defines the callback to trigger once the texture is ready
  57486. * @param onError defines the callback to trigger in case of error
  57487. */
  57488. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57489. /**
  57490. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57491. * @param data contains the texture data
  57492. * @param texture defines the BabylonJS internal texture
  57493. * @param callback defines the method to call once ready to upload
  57494. */
  57495. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57496. }
  57497. }
  57498. declare module BABYLON {
  57499. /**
  57500. * Implementation of the ENV Texture Loader.
  57501. * @hidden
  57502. */
  57503. export class _ENVTextureLoader implements IInternalTextureLoader {
  57504. /**
  57505. * Defines wether the loader supports cascade loading the different faces.
  57506. */
  57507. readonly supportCascades: boolean;
  57508. /**
  57509. * This returns if the loader support the current file information.
  57510. * @param extension defines the file extension of the file being loaded
  57511. * @returns true if the loader can load the specified file
  57512. */
  57513. canLoad(extension: string): boolean;
  57514. /**
  57515. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57516. * @param data contains the texture data
  57517. * @param texture defines the BabylonJS internal texture
  57518. * @param createPolynomials will be true if polynomials have been requested
  57519. * @param onLoad defines the callback to trigger once the texture is ready
  57520. * @param onError defines the callback to trigger in case of error
  57521. */
  57522. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57523. /**
  57524. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57525. * @param data contains the texture data
  57526. * @param texture defines the BabylonJS internal texture
  57527. * @param callback defines the method to call once ready to upload
  57528. */
  57529. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57530. }
  57531. }
  57532. declare module BABYLON {
  57533. /**
  57534. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57535. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57536. */
  57537. export class KhronosTextureContainer {
  57538. /** contents of the KTX container file */
  57539. data: ArrayBufferView;
  57540. private static HEADER_LEN;
  57541. private static COMPRESSED_2D;
  57542. private static COMPRESSED_3D;
  57543. private static TEX_2D;
  57544. private static TEX_3D;
  57545. /**
  57546. * Gets the openGL type
  57547. */
  57548. glType: number;
  57549. /**
  57550. * Gets the openGL type size
  57551. */
  57552. glTypeSize: number;
  57553. /**
  57554. * Gets the openGL format
  57555. */
  57556. glFormat: number;
  57557. /**
  57558. * Gets the openGL internal format
  57559. */
  57560. glInternalFormat: number;
  57561. /**
  57562. * Gets the base internal format
  57563. */
  57564. glBaseInternalFormat: number;
  57565. /**
  57566. * Gets image width in pixel
  57567. */
  57568. pixelWidth: number;
  57569. /**
  57570. * Gets image height in pixel
  57571. */
  57572. pixelHeight: number;
  57573. /**
  57574. * Gets image depth in pixels
  57575. */
  57576. pixelDepth: number;
  57577. /**
  57578. * Gets the number of array elements
  57579. */
  57580. numberOfArrayElements: number;
  57581. /**
  57582. * Gets the number of faces
  57583. */
  57584. numberOfFaces: number;
  57585. /**
  57586. * Gets the number of mipmap levels
  57587. */
  57588. numberOfMipmapLevels: number;
  57589. /**
  57590. * Gets the bytes of key value data
  57591. */
  57592. bytesOfKeyValueData: number;
  57593. /**
  57594. * Gets the load type
  57595. */
  57596. loadType: number;
  57597. /**
  57598. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57599. */
  57600. isInvalid: boolean;
  57601. /**
  57602. * Creates a new KhronosTextureContainer
  57603. * @param data contents of the KTX container file
  57604. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57605. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57606. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57607. */
  57608. constructor(
  57609. /** contents of the KTX container file */
  57610. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57611. /**
  57612. * Uploads KTX content to a Babylon Texture.
  57613. * It is assumed that the texture has already been created & is currently bound
  57614. * @hidden
  57615. */
  57616. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57617. private _upload2DCompressedLevels;
  57618. /**
  57619. * Checks if the given data starts with a KTX file identifier.
  57620. * @param data the data to check
  57621. * @returns true if the data is a KTX file or false otherwise
  57622. */
  57623. static IsValid(data: ArrayBufferView): boolean;
  57624. }
  57625. }
  57626. declare module BABYLON {
  57627. /**
  57628. * Class for loading KTX2 files
  57629. * !!! Experimental Extension Subject to Changes !!!
  57630. * @hidden
  57631. */
  57632. export class KhronosTextureContainer2 {
  57633. private static _ModulePromise;
  57634. private static _TranscodeFormat;
  57635. constructor(engine: ThinEngine);
  57636. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57637. private _determineTranscodeFormat;
  57638. /**
  57639. * Checks if the given data starts with a KTX2 file identifier.
  57640. * @param data the data to check
  57641. * @returns true if the data is a KTX2 file or false otherwise
  57642. */
  57643. static IsValid(data: ArrayBufferView): boolean;
  57644. }
  57645. }
  57646. declare module BABYLON {
  57647. /**
  57648. * Implementation of the KTX Texture Loader.
  57649. * @hidden
  57650. */
  57651. export class _KTXTextureLoader implements IInternalTextureLoader {
  57652. /**
  57653. * Defines wether the loader supports cascade loading the different faces.
  57654. */
  57655. readonly supportCascades: boolean;
  57656. /**
  57657. * This returns if the loader support the current file information.
  57658. * @param extension defines the file extension of the file being loaded
  57659. * @param mimeType defines the optional mime type of the file being loaded
  57660. * @returns true if the loader can load the specified file
  57661. */
  57662. canLoad(extension: string, mimeType?: string): boolean;
  57663. /**
  57664. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57665. * @param data contains the texture data
  57666. * @param texture defines the BabylonJS internal texture
  57667. * @param createPolynomials will be true if polynomials have been requested
  57668. * @param onLoad defines the callback to trigger once the texture is ready
  57669. * @param onError defines the callback to trigger in case of error
  57670. */
  57671. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57672. /**
  57673. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57674. * @param data contains the texture data
  57675. * @param texture defines the BabylonJS internal texture
  57676. * @param callback defines the method to call once ready to upload
  57677. */
  57678. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57679. }
  57680. }
  57681. declare module BABYLON {
  57682. /** @hidden */
  57683. export var _forceSceneHelpersToBundle: boolean;
  57684. interface Scene {
  57685. /**
  57686. * Creates a default light for the scene.
  57687. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57688. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57689. */
  57690. createDefaultLight(replace?: boolean): void;
  57691. /**
  57692. * Creates a default camera for the scene.
  57693. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57694. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57695. * @param replace has default false, when true replaces the active camera in the scene
  57696. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57697. */
  57698. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57699. /**
  57700. * Creates a default camera and a default light.
  57701. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57702. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57703. * @param replace has the default false, when true replaces the active camera/light in the scene
  57704. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57705. */
  57706. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57707. /**
  57708. * Creates a new sky box
  57709. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57710. * @param environmentTexture defines the texture to use as environment texture
  57711. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57712. * @param scale defines the overall scale of the skybox
  57713. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57714. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57715. * @returns a new mesh holding the sky box
  57716. */
  57717. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57718. /**
  57719. * Creates a new environment
  57720. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57721. * @param options defines the options you can use to configure the environment
  57722. * @returns the new EnvironmentHelper
  57723. */
  57724. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57725. /**
  57726. * Creates a new VREXperienceHelper
  57727. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57728. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57729. * @returns a new VREXperienceHelper
  57730. */
  57731. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57732. /**
  57733. * Creates a new WebXRDefaultExperience
  57734. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57735. * @param options experience options
  57736. * @returns a promise for a new WebXRDefaultExperience
  57737. */
  57738. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57739. }
  57740. }
  57741. declare module BABYLON {
  57742. /**
  57743. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57744. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57745. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57746. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57747. */
  57748. export class VideoDome extends TextureDome<VideoTexture> {
  57749. /**
  57750. * Define the video source as a Monoscopic panoramic 360 video.
  57751. */
  57752. static readonly MODE_MONOSCOPIC: number;
  57753. /**
  57754. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57755. */
  57756. static readonly MODE_TOPBOTTOM: number;
  57757. /**
  57758. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57759. */
  57760. static readonly MODE_SIDEBYSIDE: number;
  57761. /**
  57762. * Get the video texture associated with this video dome
  57763. */
  57764. get videoTexture(): VideoTexture;
  57765. /**
  57766. * Get the video mode of this dome
  57767. */
  57768. get videoMode(): number;
  57769. /**
  57770. * Set the video mode of this dome.
  57771. * @see textureMode
  57772. */
  57773. set videoMode(value: number);
  57774. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  57775. }
  57776. }
  57777. declare module BABYLON {
  57778. /**
  57779. * This class can be used to get instrumentation data from a Babylon engine
  57780. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57781. */
  57782. export class EngineInstrumentation implements IDisposable {
  57783. /**
  57784. * Define the instrumented engine.
  57785. */
  57786. engine: Engine;
  57787. private _captureGPUFrameTime;
  57788. private _gpuFrameTimeToken;
  57789. private _gpuFrameTime;
  57790. private _captureShaderCompilationTime;
  57791. private _shaderCompilationTime;
  57792. private _onBeginFrameObserver;
  57793. private _onEndFrameObserver;
  57794. private _onBeforeShaderCompilationObserver;
  57795. private _onAfterShaderCompilationObserver;
  57796. /**
  57797. * Gets the perf counter used for GPU frame time
  57798. */
  57799. get gpuFrameTimeCounter(): PerfCounter;
  57800. /**
  57801. * Gets the GPU frame time capture status
  57802. */
  57803. get captureGPUFrameTime(): boolean;
  57804. /**
  57805. * Enable or disable the GPU frame time capture
  57806. */
  57807. set captureGPUFrameTime(value: boolean);
  57808. /**
  57809. * Gets the perf counter used for shader compilation time
  57810. */
  57811. get shaderCompilationTimeCounter(): PerfCounter;
  57812. /**
  57813. * Gets the shader compilation time capture status
  57814. */
  57815. get captureShaderCompilationTime(): boolean;
  57816. /**
  57817. * Enable or disable the shader compilation time capture
  57818. */
  57819. set captureShaderCompilationTime(value: boolean);
  57820. /**
  57821. * Instantiates a new engine instrumentation.
  57822. * This class can be used to get instrumentation data from a Babylon engine
  57823. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57824. * @param engine Defines the engine to instrument
  57825. */
  57826. constructor(
  57827. /**
  57828. * Define the instrumented engine.
  57829. */
  57830. engine: Engine);
  57831. /**
  57832. * Dispose and release associated resources.
  57833. */
  57834. dispose(): void;
  57835. }
  57836. }
  57837. declare module BABYLON {
  57838. /**
  57839. * This class can be used to get instrumentation data from a Babylon engine
  57840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57841. */
  57842. export class SceneInstrumentation implements IDisposable {
  57843. /**
  57844. * Defines the scene to instrument
  57845. */
  57846. scene: Scene;
  57847. private _captureActiveMeshesEvaluationTime;
  57848. private _activeMeshesEvaluationTime;
  57849. private _captureRenderTargetsRenderTime;
  57850. private _renderTargetsRenderTime;
  57851. private _captureFrameTime;
  57852. private _frameTime;
  57853. private _captureRenderTime;
  57854. private _renderTime;
  57855. private _captureInterFrameTime;
  57856. private _interFrameTime;
  57857. private _captureParticlesRenderTime;
  57858. private _particlesRenderTime;
  57859. private _captureSpritesRenderTime;
  57860. private _spritesRenderTime;
  57861. private _capturePhysicsTime;
  57862. private _physicsTime;
  57863. private _captureAnimationsTime;
  57864. private _animationsTime;
  57865. private _captureCameraRenderTime;
  57866. private _cameraRenderTime;
  57867. private _onBeforeActiveMeshesEvaluationObserver;
  57868. private _onAfterActiveMeshesEvaluationObserver;
  57869. private _onBeforeRenderTargetsRenderObserver;
  57870. private _onAfterRenderTargetsRenderObserver;
  57871. private _onAfterRenderObserver;
  57872. private _onBeforeDrawPhaseObserver;
  57873. private _onAfterDrawPhaseObserver;
  57874. private _onBeforeAnimationsObserver;
  57875. private _onBeforeParticlesRenderingObserver;
  57876. private _onAfterParticlesRenderingObserver;
  57877. private _onBeforeSpritesRenderingObserver;
  57878. private _onAfterSpritesRenderingObserver;
  57879. private _onBeforePhysicsObserver;
  57880. private _onAfterPhysicsObserver;
  57881. private _onAfterAnimationsObserver;
  57882. private _onBeforeCameraRenderObserver;
  57883. private _onAfterCameraRenderObserver;
  57884. /**
  57885. * Gets the perf counter used for active meshes evaluation time
  57886. */
  57887. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57888. /**
  57889. * Gets the active meshes evaluation time capture status
  57890. */
  57891. get captureActiveMeshesEvaluationTime(): boolean;
  57892. /**
  57893. * Enable or disable the active meshes evaluation time capture
  57894. */
  57895. set captureActiveMeshesEvaluationTime(value: boolean);
  57896. /**
  57897. * Gets the perf counter used for render targets render time
  57898. */
  57899. get renderTargetsRenderTimeCounter(): PerfCounter;
  57900. /**
  57901. * Gets the render targets render time capture status
  57902. */
  57903. get captureRenderTargetsRenderTime(): boolean;
  57904. /**
  57905. * Enable or disable the render targets render time capture
  57906. */
  57907. set captureRenderTargetsRenderTime(value: boolean);
  57908. /**
  57909. * Gets the perf counter used for particles render time
  57910. */
  57911. get particlesRenderTimeCounter(): PerfCounter;
  57912. /**
  57913. * Gets the particles render time capture status
  57914. */
  57915. get captureParticlesRenderTime(): boolean;
  57916. /**
  57917. * Enable or disable the particles render time capture
  57918. */
  57919. set captureParticlesRenderTime(value: boolean);
  57920. /**
  57921. * Gets the perf counter used for sprites render time
  57922. */
  57923. get spritesRenderTimeCounter(): PerfCounter;
  57924. /**
  57925. * Gets the sprites render time capture status
  57926. */
  57927. get captureSpritesRenderTime(): boolean;
  57928. /**
  57929. * Enable or disable the sprites render time capture
  57930. */
  57931. set captureSpritesRenderTime(value: boolean);
  57932. /**
  57933. * Gets the perf counter used for physics time
  57934. */
  57935. get physicsTimeCounter(): PerfCounter;
  57936. /**
  57937. * Gets the physics time capture status
  57938. */
  57939. get capturePhysicsTime(): boolean;
  57940. /**
  57941. * Enable or disable the physics time capture
  57942. */
  57943. set capturePhysicsTime(value: boolean);
  57944. /**
  57945. * Gets the perf counter used for animations time
  57946. */
  57947. get animationsTimeCounter(): PerfCounter;
  57948. /**
  57949. * Gets the animations time capture status
  57950. */
  57951. get captureAnimationsTime(): boolean;
  57952. /**
  57953. * Enable or disable the animations time capture
  57954. */
  57955. set captureAnimationsTime(value: boolean);
  57956. /**
  57957. * Gets the perf counter used for frame time capture
  57958. */
  57959. get frameTimeCounter(): PerfCounter;
  57960. /**
  57961. * Gets the frame time capture status
  57962. */
  57963. get captureFrameTime(): boolean;
  57964. /**
  57965. * Enable or disable the frame time capture
  57966. */
  57967. set captureFrameTime(value: boolean);
  57968. /**
  57969. * Gets the perf counter used for inter-frames time capture
  57970. */
  57971. get interFrameTimeCounter(): PerfCounter;
  57972. /**
  57973. * Gets the inter-frames time capture status
  57974. */
  57975. get captureInterFrameTime(): boolean;
  57976. /**
  57977. * Enable or disable the inter-frames time capture
  57978. */
  57979. set captureInterFrameTime(value: boolean);
  57980. /**
  57981. * Gets the perf counter used for render time capture
  57982. */
  57983. get renderTimeCounter(): PerfCounter;
  57984. /**
  57985. * Gets the render time capture status
  57986. */
  57987. get captureRenderTime(): boolean;
  57988. /**
  57989. * Enable or disable the render time capture
  57990. */
  57991. set captureRenderTime(value: boolean);
  57992. /**
  57993. * Gets the perf counter used for camera render time capture
  57994. */
  57995. get cameraRenderTimeCounter(): PerfCounter;
  57996. /**
  57997. * Gets the camera render time capture status
  57998. */
  57999. get captureCameraRenderTime(): boolean;
  58000. /**
  58001. * Enable or disable the camera render time capture
  58002. */
  58003. set captureCameraRenderTime(value: boolean);
  58004. /**
  58005. * Gets the perf counter used for draw calls
  58006. */
  58007. get drawCallsCounter(): PerfCounter;
  58008. /**
  58009. * Instantiates a new scene instrumentation.
  58010. * This class can be used to get instrumentation data from a Babylon engine
  58011. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58012. * @param scene Defines the scene to instrument
  58013. */
  58014. constructor(
  58015. /**
  58016. * Defines the scene to instrument
  58017. */
  58018. scene: Scene);
  58019. /**
  58020. * Dispose and release associated resources.
  58021. */
  58022. dispose(): void;
  58023. }
  58024. }
  58025. declare module BABYLON {
  58026. /** @hidden */
  58027. export var glowMapGenerationPixelShader: {
  58028. name: string;
  58029. shader: string;
  58030. };
  58031. }
  58032. declare module BABYLON {
  58033. /** @hidden */
  58034. export var glowMapGenerationVertexShader: {
  58035. name: string;
  58036. shader: string;
  58037. };
  58038. }
  58039. declare module BABYLON {
  58040. /**
  58041. * Effect layer options. This helps customizing the behaviour
  58042. * of the effect layer.
  58043. */
  58044. export interface IEffectLayerOptions {
  58045. /**
  58046. * Multiplication factor apply to the canvas size to compute the render target size
  58047. * used to generated the objects (the smaller the faster).
  58048. */
  58049. mainTextureRatio: number;
  58050. /**
  58051. * Enforces a fixed size texture to ensure effect stability across devices.
  58052. */
  58053. mainTextureFixedSize?: number;
  58054. /**
  58055. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58056. */
  58057. alphaBlendingMode: number;
  58058. /**
  58059. * The camera attached to the layer.
  58060. */
  58061. camera: Nullable<Camera>;
  58062. /**
  58063. * The rendering group to draw the layer in.
  58064. */
  58065. renderingGroupId: number;
  58066. }
  58067. /**
  58068. * The effect layer Helps adding post process effect blended with the main pass.
  58069. *
  58070. * This can be for instance use to generate glow or higlight effects on the scene.
  58071. *
  58072. * The effect layer class can not be used directly and is intented to inherited from to be
  58073. * customized per effects.
  58074. */
  58075. export abstract class EffectLayer {
  58076. private _vertexBuffers;
  58077. private _indexBuffer;
  58078. private _cachedDefines;
  58079. private _effectLayerMapGenerationEffect;
  58080. private _effectLayerOptions;
  58081. private _mergeEffect;
  58082. protected _scene: Scene;
  58083. protected _engine: Engine;
  58084. protected _maxSize: number;
  58085. protected _mainTextureDesiredSize: ISize;
  58086. protected _mainTexture: RenderTargetTexture;
  58087. protected _shouldRender: boolean;
  58088. protected _postProcesses: PostProcess[];
  58089. protected _textures: BaseTexture[];
  58090. protected _emissiveTextureAndColor: {
  58091. texture: Nullable<BaseTexture>;
  58092. color: Color4;
  58093. };
  58094. /**
  58095. * The name of the layer
  58096. */
  58097. name: string;
  58098. /**
  58099. * The clear color of the texture used to generate the glow map.
  58100. */
  58101. neutralColor: Color4;
  58102. /**
  58103. * Specifies whether the highlight layer is enabled or not.
  58104. */
  58105. isEnabled: boolean;
  58106. /**
  58107. * Gets the camera attached to the layer.
  58108. */
  58109. get camera(): Nullable<Camera>;
  58110. /**
  58111. * Gets the rendering group id the layer should render in.
  58112. */
  58113. get renderingGroupId(): number;
  58114. set renderingGroupId(renderingGroupId: number);
  58115. /**
  58116. * An event triggered when the effect layer has been disposed.
  58117. */
  58118. onDisposeObservable: Observable<EffectLayer>;
  58119. /**
  58120. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58121. */
  58122. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58123. /**
  58124. * An event triggered when the generated texture is being merged in the scene.
  58125. */
  58126. onBeforeComposeObservable: Observable<EffectLayer>;
  58127. /**
  58128. * An event triggered when the mesh is rendered into the effect render target.
  58129. */
  58130. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58131. /**
  58132. * An event triggered after the mesh has been rendered into the effect render target.
  58133. */
  58134. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58135. /**
  58136. * An event triggered when the generated texture has been merged in the scene.
  58137. */
  58138. onAfterComposeObservable: Observable<EffectLayer>;
  58139. /**
  58140. * An event triggered when the efffect layer changes its size.
  58141. */
  58142. onSizeChangedObservable: Observable<EffectLayer>;
  58143. /** @hidden */
  58144. static _SceneComponentInitialization: (scene: Scene) => void;
  58145. /**
  58146. * Instantiates a new effect Layer and references it in the scene.
  58147. * @param name The name of the layer
  58148. * @param scene The scene to use the layer in
  58149. */
  58150. constructor(
  58151. /** The Friendly of the effect in the scene */
  58152. name: string, scene: Scene);
  58153. /**
  58154. * Get the effect name of the layer.
  58155. * @return The effect name
  58156. */
  58157. abstract getEffectName(): string;
  58158. /**
  58159. * Checks for the readiness of the element composing the layer.
  58160. * @param subMesh the mesh to check for
  58161. * @param useInstances specify whether or not to use instances to render the mesh
  58162. * @return true if ready otherwise, false
  58163. */
  58164. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58165. /**
  58166. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58167. * @returns true if the effect requires stencil during the main canvas render pass.
  58168. */
  58169. abstract needStencil(): boolean;
  58170. /**
  58171. * Create the merge effect. This is the shader use to blit the information back
  58172. * to the main canvas at the end of the scene rendering.
  58173. * @returns The effect containing the shader used to merge the effect on the main canvas
  58174. */
  58175. protected abstract _createMergeEffect(): Effect;
  58176. /**
  58177. * Creates the render target textures and post processes used in the effect layer.
  58178. */
  58179. protected abstract _createTextureAndPostProcesses(): void;
  58180. /**
  58181. * Implementation specific of rendering the generating effect on the main canvas.
  58182. * @param effect The effect used to render through
  58183. */
  58184. protected abstract _internalRender(effect: Effect): void;
  58185. /**
  58186. * Sets the required values for both the emissive texture and and the main color.
  58187. */
  58188. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58189. /**
  58190. * Free any resources and references associated to a mesh.
  58191. * Internal use
  58192. * @param mesh The mesh to free.
  58193. */
  58194. abstract _disposeMesh(mesh: Mesh): void;
  58195. /**
  58196. * Serializes this layer (Glow or Highlight for example)
  58197. * @returns a serialized layer object
  58198. */
  58199. abstract serialize?(): any;
  58200. /**
  58201. * Initializes the effect layer with the required options.
  58202. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58203. */
  58204. protected _init(options: Partial<IEffectLayerOptions>): void;
  58205. /**
  58206. * Generates the index buffer of the full screen quad blending to the main canvas.
  58207. */
  58208. private _generateIndexBuffer;
  58209. /**
  58210. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58211. */
  58212. private _generateVertexBuffer;
  58213. /**
  58214. * Sets the main texture desired size which is the closest power of two
  58215. * of the engine canvas size.
  58216. */
  58217. private _setMainTextureSize;
  58218. /**
  58219. * Creates the main texture for the effect layer.
  58220. */
  58221. protected _createMainTexture(): void;
  58222. /**
  58223. * Adds specific effects defines.
  58224. * @param defines The defines to add specifics to.
  58225. */
  58226. protected _addCustomEffectDefines(defines: string[]): void;
  58227. /**
  58228. * Checks for the readiness of the element composing the layer.
  58229. * @param subMesh the mesh to check for
  58230. * @param useInstances specify whether or not to use instances to render the mesh
  58231. * @param emissiveTexture the associated emissive texture used to generate the glow
  58232. * @return true if ready otherwise, false
  58233. */
  58234. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58235. /**
  58236. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58237. */
  58238. render(): void;
  58239. /**
  58240. * Determine if a given mesh will be used in the current effect.
  58241. * @param mesh mesh to test
  58242. * @returns true if the mesh will be used
  58243. */
  58244. hasMesh(mesh: AbstractMesh): boolean;
  58245. /**
  58246. * Returns true if the layer contains information to display, otherwise false.
  58247. * @returns true if the glow layer should be rendered
  58248. */
  58249. shouldRender(): boolean;
  58250. /**
  58251. * Returns true if the mesh should render, otherwise false.
  58252. * @param mesh The mesh to render
  58253. * @returns true if it should render otherwise false
  58254. */
  58255. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58256. /**
  58257. * Returns true if the mesh can be rendered, otherwise false.
  58258. * @param mesh The mesh to render
  58259. * @param material The material used on the mesh
  58260. * @returns true if it can be rendered otherwise false
  58261. */
  58262. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58263. /**
  58264. * Returns true if the mesh should render, otherwise false.
  58265. * @param mesh The mesh to render
  58266. * @returns true if it should render otherwise false
  58267. */
  58268. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58269. /**
  58270. * Renders the submesh passed in parameter to the generation map.
  58271. */
  58272. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58273. /**
  58274. * Defines whether the current material of the mesh should be use to render the effect.
  58275. * @param mesh defines the current mesh to render
  58276. */
  58277. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58278. /**
  58279. * Rebuild the required buffers.
  58280. * @hidden Internal use only.
  58281. */
  58282. _rebuild(): void;
  58283. /**
  58284. * Dispose only the render target textures and post process.
  58285. */
  58286. private _disposeTextureAndPostProcesses;
  58287. /**
  58288. * Dispose the highlight layer and free resources.
  58289. */
  58290. dispose(): void;
  58291. /**
  58292. * Gets the class name of the effect layer
  58293. * @returns the string with the class name of the effect layer
  58294. */
  58295. getClassName(): string;
  58296. /**
  58297. * Creates an effect layer from parsed effect layer data
  58298. * @param parsedEffectLayer defines effect layer data
  58299. * @param scene defines the current scene
  58300. * @param rootUrl defines the root URL containing the effect layer information
  58301. * @returns a parsed effect Layer
  58302. */
  58303. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58304. }
  58305. }
  58306. declare module BABYLON {
  58307. interface AbstractScene {
  58308. /**
  58309. * The list of effect layers (highlights/glow) added to the scene
  58310. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58311. * @see https://doc.babylonjs.com/how_to/glow_layer
  58312. */
  58313. effectLayers: Array<EffectLayer>;
  58314. /**
  58315. * Removes the given effect layer from this scene.
  58316. * @param toRemove defines the effect layer to remove
  58317. * @returns the index of the removed effect layer
  58318. */
  58319. removeEffectLayer(toRemove: EffectLayer): number;
  58320. /**
  58321. * Adds the given effect layer to this scene
  58322. * @param newEffectLayer defines the effect layer to add
  58323. */
  58324. addEffectLayer(newEffectLayer: EffectLayer): void;
  58325. }
  58326. /**
  58327. * Defines the layer scene component responsible to manage any effect layers
  58328. * in a given scene.
  58329. */
  58330. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58331. /**
  58332. * The component name helpfull to identify the component in the list of scene components.
  58333. */
  58334. readonly name: string;
  58335. /**
  58336. * The scene the component belongs to.
  58337. */
  58338. scene: Scene;
  58339. private _engine;
  58340. private _renderEffects;
  58341. private _needStencil;
  58342. private _previousStencilState;
  58343. /**
  58344. * Creates a new instance of the component for the given scene
  58345. * @param scene Defines the scene to register the component in
  58346. */
  58347. constructor(scene: Scene);
  58348. /**
  58349. * Registers the component in a given scene
  58350. */
  58351. register(): void;
  58352. /**
  58353. * Rebuilds the elements related to this component in case of
  58354. * context lost for instance.
  58355. */
  58356. rebuild(): void;
  58357. /**
  58358. * Serializes the component data to the specified json object
  58359. * @param serializationObject The object to serialize to
  58360. */
  58361. serialize(serializationObject: any): void;
  58362. /**
  58363. * Adds all the elements from the container to the scene
  58364. * @param container the container holding the elements
  58365. */
  58366. addFromContainer(container: AbstractScene): void;
  58367. /**
  58368. * Removes all the elements in the container from the scene
  58369. * @param container contains the elements to remove
  58370. * @param dispose if the removed element should be disposed (default: false)
  58371. */
  58372. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58373. /**
  58374. * Disposes the component and the associated ressources.
  58375. */
  58376. dispose(): void;
  58377. private _isReadyForMesh;
  58378. private _renderMainTexture;
  58379. private _setStencil;
  58380. private _setStencilBack;
  58381. private _draw;
  58382. private _drawCamera;
  58383. private _drawRenderingGroup;
  58384. }
  58385. }
  58386. declare module BABYLON {
  58387. /** @hidden */
  58388. export var glowMapMergePixelShader: {
  58389. name: string;
  58390. shader: string;
  58391. };
  58392. }
  58393. declare module BABYLON {
  58394. /** @hidden */
  58395. export var glowMapMergeVertexShader: {
  58396. name: string;
  58397. shader: string;
  58398. };
  58399. }
  58400. declare module BABYLON {
  58401. interface AbstractScene {
  58402. /**
  58403. * Return a the first highlight layer of the scene with a given name.
  58404. * @param name The name of the highlight layer to look for.
  58405. * @return The highlight layer if found otherwise null.
  58406. */
  58407. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58408. }
  58409. /**
  58410. * Glow layer options. This helps customizing the behaviour
  58411. * of the glow layer.
  58412. */
  58413. export interface IGlowLayerOptions {
  58414. /**
  58415. * Multiplication factor apply to the canvas size to compute the render target size
  58416. * used to generated the glowing objects (the smaller the faster).
  58417. */
  58418. mainTextureRatio: number;
  58419. /**
  58420. * Enforces a fixed size texture to ensure resize independant blur.
  58421. */
  58422. mainTextureFixedSize?: number;
  58423. /**
  58424. * How big is the kernel of the blur texture.
  58425. */
  58426. blurKernelSize: number;
  58427. /**
  58428. * The camera attached to the layer.
  58429. */
  58430. camera: Nullable<Camera>;
  58431. /**
  58432. * Enable MSAA by chosing the number of samples.
  58433. */
  58434. mainTextureSamples?: number;
  58435. /**
  58436. * The rendering group to draw the layer in.
  58437. */
  58438. renderingGroupId: number;
  58439. }
  58440. /**
  58441. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58442. *
  58443. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58444. *
  58445. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58446. */
  58447. export class GlowLayer extends EffectLayer {
  58448. /**
  58449. * Effect Name of the layer.
  58450. */
  58451. static readonly EffectName: string;
  58452. /**
  58453. * The default blur kernel size used for the glow.
  58454. */
  58455. static DefaultBlurKernelSize: number;
  58456. /**
  58457. * The default texture size ratio used for the glow.
  58458. */
  58459. static DefaultTextureRatio: number;
  58460. /**
  58461. * Sets the kernel size of the blur.
  58462. */
  58463. set blurKernelSize(value: number);
  58464. /**
  58465. * Gets the kernel size of the blur.
  58466. */
  58467. get blurKernelSize(): number;
  58468. /**
  58469. * Sets the glow intensity.
  58470. */
  58471. set intensity(value: number);
  58472. /**
  58473. * Gets the glow intensity.
  58474. */
  58475. get intensity(): number;
  58476. private _options;
  58477. private _intensity;
  58478. private _horizontalBlurPostprocess1;
  58479. private _verticalBlurPostprocess1;
  58480. private _horizontalBlurPostprocess2;
  58481. private _verticalBlurPostprocess2;
  58482. private _blurTexture1;
  58483. private _blurTexture2;
  58484. private _postProcesses1;
  58485. private _postProcesses2;
  58486. private _includedOnlyMeshes;
  58487. private _excludedMeshes;
  58488. private _meshesUsingTheirOwnMaterials;
  58489. /**
  58490. * Callback used to let the user override the color selection on a per mesh basis
  58491. */
  58492. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58493. /**
  58494. * Callback used to let the user override the texture selection on a per mesh basis
  58495. */
  58496. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58497. /**
  58498. * Instantiates a new glow Layer and references it to the scene.
  58499. * @param name The name of the layer
  58500. * @param scene The scene to use the layer in
  58501. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58502. */
  58503. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58504. /**
  58505. * Get the effect name of the layer.
  58506. * @return The effect name
  58507. */
  58508. getEffectName(): string;
  58509. /**
  58510. * Create the merge effect. This is the shader use to blit the information back
  58511. * to the main canvas at the end of the scene rendering.
  58512. */
  58513. protected _createMergeEffect(): Effect;
  58514. /**
  58515. * Creates the render target textures and post processes used in the glow layer.
  58516. */
  58517. protected _createTextureAndPostProcesses(): void;
  58518. /**
  58519. * Checks for the readiness of the element composing the layer.
  58520. * @param subMesh the mesh to check for
  58521. * @param useInstances specify wether or not to use instances to render the mesh
  58522. * @param emissiveTexture the associated emissive texture used to generate the glow
  58523. * @return true if ready otherwise, false
  58524. */
  58525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58526. /**
  58527. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58528. */
  58529. needStencil(): boolean;
  58530. /**
  58531. * Returns true if the mesh can be rendered, otherwise false.
  58532. * @param mesh The mesh to render
  58533. * @param material The material used on the mesh
  58534. * @returns true if it can be rendered otherwise false
  58535. */
  58536. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58537. /**
  58538. * Implementation specific of rendering the generating effect on the main canvas.
  58539. * @param effect The effect used to render through
  58540. */
  58541. protected _internalRender(effect: Effect): void;
  58542. /**
  58543. * Sets the required values for both the emissive texture and and the main color.
  58544. */
  58545. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58546. /**
  58547. * Returns true if the mesh should render, otherwise false.
  58548. * @param mesh The mesh to render
  58549. * @returns true if it should render otherwise false
  58550. */
  58551. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58552. /**
  58553. * Adds specific effects defines.
  58554. * @param defines The defines to add specifics to.
  58555. */
  58556. protected _addCustomEffectDefines(defines: string[]): void;
  58557. /**
  58558. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58559. * @param mesh The mesh to exclude from the glow layer
  58560. */
  58561. addExcludedMesh(mesh: Mesh): void;
  58562. /**
  58563. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58564. * @param mesh The mesh to remove
  58565. */
  58566. removeExcludedMesh(mesh: Mesh): void;
  58567. /**
  58568. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58569. * @param mesh The mesh to include in the glow layer
  58570. */
  58571. addIncludedOnlyMesh(mesh: Mesh): void;
  58572. /**
  58573. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58574. * @param mesh The mesh to remove
  58575. */
  58576. removeIncludedOnlyMesh(mesh: Mesh): void;
  58577. /**
  58578. * Determine if a given mesh will be used in the glow layer
  58579. * @param mesh The mesh to test
  58580. * @returns true if the mesh will be highlighted by the current glow layer
  58581. */
  58582. hasMesh(mesh: AbstractMesh): boolean;
  58583. /**
  58584. * Defines whether the current material of the mesh should be use to render the effect.
  58585. * @param mesh defines the current mesh to render
  58586. */
  58587. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58588. /**
  58589. * Add a mesh to be rendered through its own material and not with emissive only.
  58590. * @param mesh The mesh for which we need to use its material
  58591. */
  58592. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58593. /**
  58594. * Remove a mesh from being rendered through its own material and not with emissive only.
  58595. * @param mesh The mesh for which we need to not use its material
  58596. */
  58597. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58598. /**
  58599. * Free any resources and references associated to a mesh.
  58600. * Internal use
  58601. * @param mesh The mesh to free.
  58602. * @hidden
  58603. */
  58604. _disposeMesh(mesh: Mesh): void;
  58605. /**
  58606. * Gets the class name of the effect layer
  58607. * @returns the string with the class name of the effect layer
  58608. */
  58609. getClassName(): string;
  58610. /**
  58611. * Serializes this glow layer
  58612. * @returns a serialized glow layer object
  58613. */
  58614. serialize(): any;
  58615. /**
  58616. * Creates a Glow Layer from parsed glow layer data
  58617. * @param parsedGlowLayer defines glow layer data
  58618. * @param scene defines the current scene
  58619. * @param rootUrl defines the root URL containing the glow layer information
  58620. * @returns a parsed Glow Layer
  58621. */
  58622. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58623. }
  58624. }
  58625. declare module BABYLON {
  58626. /** @hidden */
  58627. export var glowBlurPostProcessPixelShader: {
  58628. name: string;
  58629. shader: string;
  58630. };
  58631. }
  58632. declare module BABYLON {
  58633. interface AbstractScene {
  58634. /**
  58635. * Return a the first highlight layer of the scene with a given name.
  58636. * @param name The name of the highlight layer to look for.
  58637. * @return The highlight layer if found otherwise null.
  58638. */
  58639. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58640. }
  58641. /**
  58642. * Highlight layer options. This helps customizing the behaviour
  58643. * of the highlight layer.
  58644. */
  58645. export interface IHighlightLayerOptions {
  58646. /**
  58647. * Multiplication factor apply to the canvas size to compute the render target size
  58648. * used to generated the glowing objects (the smaller the faster).
  58649. */
  58650. mainTextureRatio: number;
  58651. /**
  58652. * Enforces a fixed size texture to ensure resize independant blur.
  58653. */
  58654. mainTextureFixedSize?: number;
  58655. /**
  58656. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58657. * of the picture to blur (the smaller the faster).
  58658. */
  58659. blurTextureSizeRatio: number;
  58660. /**
  58661. * How big in texel of the blur texture is the vertical blur.
  58662. */
  58663. blurVerticalSize: number;
  58664. /**
  58665. * How big in texel of the blur texture is the horizontal blur.
  58666. */
  58667. blurHorizontalSize: number;
  58668. /**
  58669. * Alpha blending mode used to apply the blur. Default is combine.
  58670. */
  58671. alphaBlendingMode: number;
  58672. /**
  58673. * The camera attached to the layer.
  58674. */
  58675. camera: Nullable<Camera>;
  58676. /**
  58677. * Should we display highlight as a solid stroke?
  58678. */
  58679. isStroke?: boolean;
  58680. /**
  58681. * The rendering group to draw the layer in.
  58682. */
  58683. renderingGroupId: number;
  58684. }
  58685. /**
  58686. * The highlight layer Helps adding a glow effect around a mesh.
  58687. *
  58688. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58689. * glowy meshes to your scene.
  58690. *
  58691. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58692. */
  58693. export class HighlightLayer extends EffectLayer {
  58694. name: string;
  58695. /**
  58696. * Effect Name of the highlight layer.
  58697. */
  58698. static readonly EffectName: string;
  58699. /**
  58700. * The neutral color used during the preparation of the glow effect.
  58701. * This is black by default as the blend operation is a blend operation.
  58702. */
  58703. static NeutralColor: Color4;
  58704. /**
  58705. * Stencil value used for glowing meshes.
  58706. */
  58707. static GlowingMeshStencilReference: number;
  58708. /**
  58709. * Stencil value used for the other meshes in the scene.
  58710. */
  58711. static NormalMeshStencilReference: number;
  58712. /**
  58713. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58714. */
  58715. innerGlow: boolean;
  58716. /**
  58717. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58718. */
  58719. outerGlow: boolean;
  58720. /**
  58721. * Specifies the horizontal size of the blur.
  58722. */
  58723. set blurHorizontalSize(value: number);
  58724. /**
  58725. * Specifies the vertical size of the blur.
  58726. */
  58727. set blurVerticalSize(value: number);
  58728. /**
  58729. * Gets the horizontal size of the blur.
  58730. */
  58731. get blurHorizontalSize(): number;
  58732. /**
  58733. * Gets the vertical size of the blur.
  58734. */
  58735. get blurVerticalSize(): number;
  58736. /**
  58737. * An event triggered when the highlight layer is being blurred.
  58738. */
  58739. onBeforeBlurObservable: Observable<HighlightLayer>;
  58740. /**
  58741. * An event triggered when the highlight layer has been blurred.
  58742. */
  58743. onAfterBlurObservable: Observable<HighlightLayer>;
  58744. private _instanceGlowingMeshStencilReference;
  58745. private _options;
  58746. private _downSamplePostprocess;
  58747. private _horizontalBlurPostprocess;
  58748. private _verticalBlurPostprocess;
  58749. private _blurTexture;
  58750. private _meshes;
  58751. private _excludedMeshes;
  58752. /**
  58753. * Instantiates a new highlight Layer and references it to the scene..
  58754. * @param name The name of the layer
  58755. * @param scene The scene to use the layer in
  58756. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58757. */
  58758. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58759. /**
  58760. * Get the effect name of the layer.
  58761. * @return The effect name
  58762. */
  58763. getEffectName(): string;
  58764. /**
  58765. * Create the merge effect. This is the shader use to blit the information back
  58766. * to the main canvas at the end of the scene rendering.
  58767. */
  58768. protected _createMergeEffect(): Effect;
  58769. /**
  58770. * Creates the render target textures and post processes used in the highlight layer.
  58771. */
  58772. protected _createTextureAndPostProcesses(): void;
  58773. /**
  58774. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58775. */
  58776. needStencil(): boolean;
  58777. /**
  58778. * Checks for the readiness of the element composing the layer.
  58779. * @param subMesh the mesh to check for
  58780. * @param useInstances specify wether or not to use instances to render the mesh
  58781. * @param emissiveTexture the associated emissive texture used to generate the glow
  58782. * @return true if ready otherwise, false
  58783. */
  58784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58785. /**
  58786. * Implementation specific of rendering the generating effect on the main canvas.
  58787. * @param effect The effect used to render through
  58788. */
  58789. protected _internalRender(effect: Effect): void;
  58790. /**
  58791. * Returns true if the layer contains information to display, otherwise false.
  58792. */
  58793. shouldRender(): boolean;
  58794. /**
  58795. * Returns true if the mesh should render, otherwise false.
  58796. * @param mesh The mesh to render
  58797. * @returns true if it should render otherwise false
  58798. */
  58799. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58800. /**
  58801. * Returns true if the mesh can be rendered, otherwise false.
  58802. * @param mesh The mesh to render
  58803. * @param material The material used on the mesh
  58804. * @returns true if it can be rendered otherwise false
  58805. */
  58806. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58807. /**
  58808. * Adds specific effects defines.
  58809. * @param defines The defines to add specifics to.
  58810. */
  58811. protected _addCustomEffectDefines(defines: string[]): void;
  58812. /**
  58813. * Sets the required values for both the emissive texture and and the main color.
  58814. */
  58815. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58816. /**
  58817. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58818. * @param mesh The mesh to exclude from the highlight layer
  58819. */
  58820. addExcludedMesh(mesh: Mesh): void;
  58821. /**
  58822. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58823. * @param mesh The mesh to highlight
  58824. */
  58825. removeExcludedMesh(mesh: Mesh): void;
  58826. /**
  58827. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58828. * @param mesh mesh to test
  58829. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58830. */
  58831. hasMesh(mesh: AbstractMesh): boolean;
  58832. /**
  58833. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58834. * @param mesh The mesh to highlight
  58835. * @param color The color of the highlight
  58836. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58837. */
  58838. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58839. /**
  58840. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58841. * @param mesh The mesh to highlight
  58842. */
  58843. removeMesh(mesh: Mesh): void;
  58844. /**
  58845. * Remove all the meshes currently referenced in the highlight layer
  58846. */
  58847. removeAllMeshes(): void;
  58848. /**
  58849. * Force the stencil to the normal expected value for none glowing parts
  58850. */
  58851. private _defaultStencilReference;
  58852. /**
  58853. * Free any resources and references associated to a mesh.
  58854. * Internal use
  58855. * @param mesh The mesh to free.
  58856. * @hidden
  58857. */
  58858. _disposeMesh(mesh: Mesh): void;
  58859. /**
  58860. * Dispose the highlight layer and free resources.
  58861. */
  58862. dispose(): void;
  58863. /**
  58864. * Gets the class name of the effect layer
  58865. * @returns the string with the class name of the effect layer
  58866. */
  58867. getClassName(): string;
  58868. /**
  58869. * Serializes this Highlight layer
  58870. * @returns a serialized Highlight layer object
  58871. */
  58872. serialize(): any;
  58873. /**
  58874. * Creates a Highlight layer from parsed Highlight layer data
  58875. * @param parsedHightlightLayer defines the Highlight layer data
  58876. * @param scene defines the current scene
  58877. * @param rootUrl defines the root URL containing the Highlight layer information
  58878. * @returns a parsed Highlight layer
  58879. */
  58880. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58881. }
  58882. }
  58883. declare module BABYLON {
  58884. interface AbstractScene {
  58885. /**
  58886. * The list of layers (background and foreground) of the scene
  58887. */
  58888. layers: Array<Layer>;
  58889. }
  58890. /**
  58891. * Defines the layer scene component responsible to manage any layers
  58892. * in a given scene.
  58893. */
  58894. export class LayerSceneComponent implements ISceneComponent {
  58895. /**
  58896. * The component name helpfull to identify the component in the list of scene components.
  58897. */
  58898. readonly name: string;
  58899. /**
  58900. * The scene the component belongs to.
  58901. */
  58902. scene: Scene;
  58903. private _engine;
  58904. /**
  58905. * Creates a new instance of the component for the given scene
  58906. * @param scene Defines the scene to register the component in
  58907. */
  58908. constructor(scene: Scene);
  58909. /**
  58910. * Registers the component in a given scene
  58911. */
  58912. register(): void;
  58913. /**
  58914. * Rebuilds the elements related to this component in case of
  58915. * context lost for instance.
  58916. */
  58917. rebuild(): void;
  58918. /**
  58919. * Disposes the component and the associated ressources.
  58920. */
  58921. dispose(): void;
  58922. private _draw;
  58923. private _drawCameraPredicate;
  58924. private _drawCameraBackground;
  58925. private _drawCameraForeground;
  58926. private _drawRenderTargetPredicate;
  58927. private _drawRenderTargetBackground;
  58928. private _drawRenderTargetForeground;
  58929. /**
  58930. * Adds all the elements from the container to the scene
  58931. * @param container the container holding the elements
  58932. */
  58933. addFromContainer(container: AbstractScene): void;
  58934. /**
  58935. * Removes all the elements in the container from the scene
  58936. * @param container contains the elements to remove
  58937. * @param dispose if the removed element should be disposed (default: false)
  58938. */
  58939. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58940. }
  58941. }
  58942. declare module BABYLON {
  58943. /** @hidden */
  58944. export var layerPixelShader: {
  58945. name: string;
  58946. shader: string;
  58947. };
  58948. }
  58949. declare module BABYLON {
  58950. /** @hidden */
  58951. export var layerVertexShader: {
  58952. name: string;
  58953. shader: string;
  58954. };
  58955. }
  58956. declare module BABYLON {
  58957. /**
  58958. * This represents a full screen 2d layer.
  58959. * This can be useful to display a picture in the background of your scene for instance.
  58960. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58961. */
  58962. export class Layer {
  58963. /**
  58964. * Define the name of the layer.
  58965. */
  58966. name: string;
  58967. /**
  58968. * Define the texture the layer should display.
  58969. */
  58970. texture: Nullable<Texture>;
  58971. /**
  58972. * Is the layer in background or foreground.
  58973. */
  58974. isBackground: boolean;
  58975. /**
  58976. * Define the color of the layer (instead of texture).
  58977. */
  58978. color: Color4;
  58979. /**
  58980. * Define the scale of the layer in order to zoom in out of the texture.
  58981. */
  58982. scale: Vector2;
  58983. /**
  58984. * Define an offset for the layer in order to shift the texture.
  58985. */
  58986. offset: Vector2;
  58987. /**
  58988. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58989. */
  58990. alphaBlendingMode: number;
  58991. /**
  58992. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58993. * Alpha test will not mix with the background color in case of transparency.
  58994. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58995. */
  58996. alphaTest: boolean;
  58997. /**
  58998. * Define a mask to restrict the layer to only some of the scene cameras.
  58999. */
  59000. layerMask: number;
  59001. /**
  59002. * Define the list of render target the layer is visible into.
  59003. */
  59004. renderTargetTextures: RenderTargetTexture[];
  59005. /**
  59006. * Define if the layer is only used in renderTarget or if it also
  59007. * renders in the main frame buffer of the canvas.
  59008. */
  59009. renderOnlyInRenderTargetTextures: boolean;
  59010. private _scene;
  59011. private _vertexBuffers;
  59012. private _indexBuffer;
  59013. private _effect;
  59014. private _previousDefines;
  59015. /**
  59016. * An event triggered when the layer is disposed.
  59017. */
  59018. onDisposeObservable: Observable<Layer>;
  59019. private _onDisposeObserver;
  59020. /**
  59021. * Back compatibility with callback before the onDisposeObservable existed.
  59022. * The set callback will be triggered when the layer has been disposed.
  59023. */
  59024. set onDispose(callback: () => void);
  59025. /**
  59026. * An event triggered before rendering the scene
  59027. */
  59028. onBeforeRenderObservable: Observable<Layer>;
  59029. private _onBeforeRenderObserver;
  59030. /**
  59031. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59032. * The set callback will be triggered just before rendering the layer.
  59033. */
  59034. set onBeforeRender(callback: () => void);
  59035. /**
  59036. * An event triggered after rendering the scene
  59037. */
  59038. onAfterRenderObservable: Observable<Layer>;
  59039. private _onAfterRenderObserver;
  59040. /**
  59041. * Back compatibility with callback before the onAfterRenderObservable existed.
  59042. * The set callback will be triggered just after rendering the layer.
  59043. */
  59044. set onAfterRender(callback: () => void);
  59045. /**
  59046. * Instantiates a new layer.
  59047. * This represents a full screen 2d layer.
  59048. * This can be useful to display a picture in the background of your scene for instance.
  59049. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59050. * @param name Define the name of the layer in the scene
  59051. * @param imgUrl Define the url of the texture to display in the layer
  59052. * @param scene Define the scene the layer belongs to
  59053. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59054. * @param color Defines a color for the layer
  59055. */
  59056. constructor(
  59057. /**
  59058. * Define the name of the layer.
  59059. */
  59060. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59061. private _createIndexBuffer;
  59062. /** @hidden */
  59063. _rebuild(): void;
  59064. /**
  59065. * Renders the layer in the scene.
  59066. */
  59067. render(): void;
  59068. /**
  59069. * Disposes and releases the associated ressources.
  59070. */
  59071. dispose(): void;
  59072. }
  59073. }
  59074. declare module BABYLON {
  59075. /** @hidden */
  59076. export var lensFlarePixelShader: {
  59077. name: string;
  59078. shader: string;
  59079. };
  59080. }
  59081. declare module BABYLON {
  59082. /** @hidden */
  59083. export var lensFlareVertexShader: {
  59084. name: string;
  59085. shader: string;
  59086. };
  59087. }
  59088. declare module BABYLON {
  59089. /**
  59090. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59091. * It is usually composed of several `lensFlare`.
  59092. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59093. */
  59094. export class LensFlareSystem {
  59095. /**
  59096. * Define the name of the lens flare system
  59097. */
  59098. name: string;
  59099. /**
  59100. * List of lens flares used in this system.
  59101. */
  59102. lensFlares: LensFlare[];
  59103. /**
  59104. * Define a limit from the border the lens flare can be visible.
  59105. */
  59106. borderLimit: number;
  59107. /**
  59108. * Define a viewport border we do not want to see the lens flare in.
  59109. */
  59110. viewportBorder: number;
  59111. /**
  59112. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59113. */
  59114. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59115. /**
  59116. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59117. */
  59118. layerMask: number;
  59119. /**
  59120. * Define the id of the lens flare system in the scene.
  59121. * (equal to name by default)
  59122. */
  59123. id: string;
  59124. private _scene;
  59125. private _emitter;
  59126. private _vertexBuffers;
  59127. private _indexBuffer;
  59128. private _effect;
  59129. private _positionX;
  59130. private _positionY;
  59131. private _isEnabled;
  59132. /** @hidden */
  59133. static _SceneComponentInitialization: (scene: Scene) => void;
  59134. /**
  59135. * Instantiates a lens flare system.
  59136. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59137. * It is usually composed of several `lensFlare`.
  59138. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59139. * @param name Define the name of the lens flare system in the scene
  59140. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59141. * @param scene Define the scene the lens flare system belongs to
  59142. */
  59143. constructor(
  59144. /**
  59145. * Define the name of the lens flare system
  59146. */
  59147. name: string, emitter: any, scene: Scene);
  59148. /**
  59149. * Define if the lens flare system is enabled.
  59150. */
  59151. get isEnabled(): boolean;
  59152. set isEnabled(value: boolean);
  59153. /**
  59154. * Get the scene the effects belongs to.
  59155. * @returns the scene holding the lens flare system
  59156. */
  59157. getScene(): Scene;
  59158. /**
  59159. * Get the emitter of the lens flare system.
  59160. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59161. * @returns the emitter of the lens flare system
  59162. */
  59163. getEmitter(): any;
  59164. /**
  59165. * Set the emitter of the lens flare system.
  59166. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59167. * @param newEmitter Define the new emitter of the system
  59168. */
  59169. setEmitter(newEmitter: any): void;
  59170. /**
  59171. * Get the lens flare system emitter position.
  59172. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59173. * @returns the position
  59174. */
  59175. getEmitterPosition(): Vector3;
  59176. /**
  59177. * @hidden
  59178. */
  59179. computeEffectivePosition(globalViewport: Viewport): boolean;
  59180. /** @hidden */
  59181. _isVisible(): boolean;
  59182. /**
  59183. * @hidden
  59184. */
  59185. render(): boolean;
  59186. /**
  59187. * Dispose and release the lens flare with its associated resources.
  59188. */
  59189. dispose(): void;
  59190. /**
  59191. * Parse a lens flare system from a JSON repressentation
  59192. * @param parsedLensFlareSystem Define the JSON to parse
  59193. * @param scene Define the scene the parsed system should be instantiated in
  59194. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59195. * @returns the parsed system
  59196. */
  59197. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59198. /**
  59199. * Serialize the current Lens Flare System into a JSON representation.
  59200. * @returns the serialized JSON
  59201. */
  59202. serialize(): any;
  59203. }
  59204. }
  59205. declare module BABYLON {
  59206. /**
  59207. * This represents one of the lens effect in a `lensFlareSystem`.
  59208. * It controls one of the indiviual texture used in the effect.
  59209. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59210. */
  59211. export class LensFlare {
  59212. /**
  59213. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59214. */
  59215. size: number;
  59216. /**
  59217. * 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.
  59218. */
  59219. position: number;
  59220. /**
  59221. * Define the lens color.
  59222. */
  59223. color: Color3;
  59224. /**
  59225. * Define the lens texture.
  59226. */
  59227. texture: Nullable<Texture>;
  59228. /**
  59229. * Define the alpha mode to render this particular lens.
  59230. */
  59231. alphaMode: number;
  59232. private _system;
  59233. /**
  59234. * Creates a new Lens Flare.
  59235. * This represents one of the lens effect in a `lensFlareSystem`.
  59236. * It controls one of the indiviual texture used in the effect.
  59237. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59238. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59239. * @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.
  59240. * @param color Define the lens color
  59241. * @param imgUrl Define the lens texture url
  59242. * @param system Define the `lensFlareSystem` this flare is part of
  59243. * @returns The newly created Lens Flare
  59244. */
  59245. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59246. /**
  59247. * Instantiates a new Lens Flare.
  59248. * This represents one of the lens effect in a `lensFlareSystem`.
  59249. * It controls one of the indiviual texture used in the effect.
  59250. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59251. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59252. * @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.
  59253. * @param color Define the lens color
  59254. * @param imgUrl Define the lens texture url
  59255. * @param system Define the `lensFlareSystem` this flare is part of
  59256. */
  59257. constructor(
  59258. /**
  59259. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59260. */
  59261. size: number,
  59262. /**
  59263. * 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.
  59264. */
  59265. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59266. /**
  59267. * Dispose and release the lens flare with its associated resources.
  59268. */
  59269. dispose(): void;
  59270. }
  59271. }
  59272. declare module BABYLON {
  59273. interface AbstractScene {
  59274. /**
  59275. * The list of lens flare system added to the scene
  59276. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59277. */
  59278. lensFlareSystems: Array<LensFlareSystem>;
  59279. /**
  59280. * Removes the given lens flare system from this scene.
  59281. * @param toRemove The lens flare system to remove
  59282. * @returns The index of the removed lens flare system
  59283. */
  59284. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59285. /**
  59286. * Adds the given lens flare system to this scene
  59287. * @param newLensFlareSystem The lens flare system to add
  59288. */
  59289. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59290. /**
  59291. * Gets a lens flare system using its name
  59292. * @param name defines the name to look for
  59293. * @returns the lens flare system or null if not found
  59294. */
  59295. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59296. /**
  59297. * Gets a lens flare system using its id
  59298. * @param id defines the id to look for
  59299. * @returns the lens flare system or null if not found
  59300. */
  59301. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59302. }
  59303. /**
  59304. * Defines the lens flare scene component responsible to manage any lens flares
  59305. * in a given scene.
  59306. */
  59307. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59308. /**
  59309. * The component name helpfull to identify the component in the list of scene components.
  59310. */
  59311. readonly name: string;
  59312. /**
  59313. * The scene the component belongs to.
  59314. */
  59315. scene: Scene;
  59316. /**
  59317. * Creates a new instance of the component for the given scene
  59318. * @param scene Defines the scene to register the component in
  59319. */
  59320. constructor(scene: Scene);
  59321. /**
  59322. * Registers the component in a given scene
  59323. */
  59324. register(): void;
  59325. /**
  59326. * Rebuilds the elements related to this component in case of
  59327. * context lost for instance.
  59328. */
  59329. rebuild(): void;
  59330. /**
  59331. * Adds all the elements from the container to the scene
  59332. * @param container the container holding the elements
  59333. */
  59334. addFromContainer(container: AbstractScene): void;
  59335. /**
  59336. * Removes all the elements in the container from the scene
  59337. * @param container contains the elements to remove
  59338. * @param dispose if the removed element should be disposed (default: false)
  59339. */
  59340. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59341. /**
  59342. * Serializes the component data to the specified json object
  59343. * @param serializationObject The object to serialize to
  59344. */
  59345. serialize(serializationObject: any): void;
  59346. /**
  59347. * Disposes the component and the associated ressources.
  59348. */
  59349. dispose(): void;
  59350. private _draw;
  59351. }
  59352. }
  59353. declare module BABYLON {
  59354. /** @hidden */
  59355. export var depthPixelShader: {
  59356. name: string;
  59357. shader: string;
  59358. };
  59359. }
  59360. declare module BABYLON {
  59361. /** @hidden */
  59362. export var depthVertexShader: {
  59363. name: string;
  59364. shader: string;
  59365. };
  59366. }
  59367. declare module BABYLON {
  59368. /**
  59369. * This represents a depth renderer in Babylon.
  59370. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59371. */
  59372. export class DepthRenderer {
  59373. private _scene;
  59374. private _depthMap;
  59375. private _effect;
  59376. private readonly _storeNonLinearDepth;
  59377. private readonly _clearColor;
  59378. /** Get if the depth renderer is using packed depth or not */
  59379. readonly isPacked: boolean;
  59380. private _cachedDefines;
  59381. private _camera;
  59382. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59383. enabled: boolean;
  59384. /**
  59385. * Specifiess that the depth renderer will only be used within
  59386. * the camera it is created for.
  59387. * This can help forcing its rendering during the camera processing.
  59388. */
  59389. useOnlyInActiveCamera: boolean;
  59390. /** @hidden */
  59391. static _SceneComponentInitialization: (scene: Scene) => void;
  59392. /**
  59393. * Instantiates a depth renderer
  59394. * @param scene The scene the renderer belongs to
  59395. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59396. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59397. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59398. */
  59399. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59400. /**
  59401. * Creates the depth rendering effect and checks if the effect is ready.
  59402. * @param subMesh The submesh to be used to render the depth map of
  59403. * @param useInstances If multiple world instances should be used
  59404. * @returns if the depth renderer is ready to render the depth map
  59405. */
  59406. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59407. /**
  59408. * Gets the texture which the depth map will be written to.
  59409. * @returns The depth map texture
  59410. */
  59411. getDepthMap(): RenderTargetTexture;
  59412. /**
  59413. * Disposes of the depth renderer.
  59414. */
  59415. dispose(): void;
  59416. }
  59417. }
  59418. declare module BABYLON {
  59419. /** @hidden */
  59420. export var minmaxReduxPixelShader: {
  59421. name: string;
  59422. shader: string;
  59423. };
  59424. }
  59425. declare module BABYLON {
  59426. /**
  59427. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59428. * and maximum values from all values of the texture.
  59429. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59430. * The source values are read from the red channel of the texture.
  59431. */
  59432. export class MinMaxReducer {
  59433. /**
  59434. * Observable triggered when the computation has been performed
  59435. */
  59436. onAfterReductionPerformed: Observable<{
  59437. min: number;
  59438. max: number;
  59439. }>;
  59440. protected _camera: Camera;
  59441. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59442. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59443. protected _postProcessManager: PostProcessManager;
  59444. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59445. protected _forceFullscreenViewport: boolean;
  59446. /**
  59447. * Creates a min/max reducer
  59448. * @param camera The camera to use for the post processes
  59449. */
  59450. constructor(camera: Camera);
  59451. /**
  59452. * Gets the texture used to read the values from.
  59453. */
  59454. get sourceTexture(): Nullable<RenderTargetTexture>;
  59455. /**
  59456. * Sets the source texture to read the values from.
  59457. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59458. * because in such textures '1' value must not be taken into account to compute the maximum
  59459. * as this value is used to clear the texture.
  59460. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59461. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59462. * @param depthRedux Indicates if the texture is a depth texture or not
  59463. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59464. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59465. */
  59466. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59467. /**
  59468. * Defines the refresh rate of the computation.
  59469. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59470. */
  59471. get refreshRate(): number;
  59472. set refreshRate(value: number);
  59473. protected _activated: boolean;
  59474. /**
  59475. * Gets the activation status of the reducer
  59476. */
  59477. get activated(): boolean;
  59478. /**
  59479. * Activates the reduction computation.
  59480. * When activated, the observers registered in onAfterReductionPerformed are
  59481. * called after the compuation is performed
  59482. */
  59483. activate(): void;
  59484. /**
  59485. * Deactivates the reduction computation.
  59486. */
  59487. deactivate(): void;
  59488. /**
  59489. * Disposes the min/max reducer
  59490. * @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.
  59491. */
  59492. dispose(disposeAll?: boolean): void;
  59493. }
  59494. }
  59495. declare module BABYLON {
  59496. /**
  59497. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59498. */
  59499. export class DepthReducer extends MinMaxReducer {
  59500. private _depthRenderer;
  59501. private _depthRendererId;
  59502. /**
  59503. * Gets the depth renderer used for the computation.
  59504. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59505. */
  59506. get depthRenderer(): Nullable<DepthRenderer>;
  59507. /**
  59508. * Creates a depth reducer
  59509. * @param camera The camera used to render the depth texture
  59510. */
  59511. constructor(camera: Camera);
  59512. /**
  59513. * Sets the depth renderer to use to generate the depth map
  59514. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59515. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59516. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59517. */
  59518. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59519. /** @hidden */
  59520. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59521. /**
  59522. * Activates the reduction computation.
  59523. * When activated, the observers registered in onAfterReductionPerformed are
  59524. * called after the compuation is performed
  59525. */
  59526. activate(): void;
  59527. /**
  59528. * Deactivates the reduction computation.
  59529. */
  59530. deactivate(): void;
  59531. /**
  59532. * Disposes the depth reducer
  59533. * @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.
  59534. */
  59535. dispose(disposeAll?: boolean): void;
  59536. }
  59537. }
  59538. declare module BABYLON {
  59539. /**
  59540. * A CSM implementation allowing casting shadows on large scenes.
  59541. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59542. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59543. */
  59544. export class CascadedShadowGenerator extends ShadowGenerator {
  59545. private static readonly frustumCornersNDCSpace;
  59546. /**
  59547. * Name of the CSM class
  59548. */
  59549. static CLASSNAME: string;
  59550. /**
  59551. * Defines the default number of cascades used by the CSM.
  59552. */
  59553. static readonly DEFAULT_CASCADES_COUNT: number;
  59554. /**
  59555. * Defines the minimum number of cascades used by the CSM.
  59556. */
  59557. static readonly MIN_CASCADES_COUNT: number;
  59558. /**
  59559. * Defines the maximum number of cascades used by the CSM.
  59560. */
  59561. static readonly MAX_CASCADES_COUNT: number;
  59562. protected _validateFilter(filter: number): number;
  59563. /**
  59564. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59565. */
  59566. penumbraDarkness: number;
  59567. private _numCascades;
  59568. /**
  59569. * Gets or set the number of cascades used by the CSM.
  59570. */
  59571. get numCascades(): number;
  59572. set numCascades(value: number);
  59573. /**
  59574. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59575. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59576. */
  59577. stabilizeCascades: boolean;
  59578. private _freezeShadowCastersBoundingInfo;
  59579. private _freezeShadowCastersBoundingInfoObservable;
  59580. /**
  59581. * Enables or disables the shadow casters bounding info computation.
  59582. * If your shadow casters don't move, you can disable this feature.
  59583. * If it is enabled, the bounding box computation is done every frame.
  59584. */
  59585. get freezeShadowCastersBoundingInfo(): boolean;
  59586. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59587. private _scbiMin;
  59588. private _scbiMax;
  59589. protected _computeShadowCastersBoundingInfo(): void;
  59590. protected _shadowCastersBoundingInfo: BoundingInfo;
  59591. /**
  59592. * Gets or sets the shadow casters bounding info.
  59593. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59594. * so that the system won't overwrite the bounds you provide
  59595. */
  59596. get shadowCastersBoundingInfo(): BoundingInfo;
  59597. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59598. protected _breaksAreDirty: boolean;
  59599. protected _minDistance: number;
  59600. protected _maxDistance: number;
  59601. /**
  59602. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59603. *
  59604. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59605. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59606. * @param min minimal distance for the breaks (default to 0.)
  59607. * @param max maximal distance for the breaks (default to 1.)
  59608. */
  59609. setMinMaxDistance(min: number, max: number): void;
  59610. /** Gets the minimal distance used in the cascade break computation */
  59611. get minDistance(): number;
  59612. /** Gets the maximal distance used in the cascade break computation */
  59613. get maxDistance(): number;
  59614. /**
  59615. * Gets the class name of that object
  59616. * @returns "CascadedShadowGenerator"
  59617. */
  59618. getClassName(): string;
  59619. private _cascadeMinExtents;
  59620. private _cascadeMaxExtents;
  59621. /**
  59622. * Gets a cascade minimum extents
  59623. * @param cascadeIndex index of the cascade
  59624. * @returns the minimum cascade extents
  59625. */
  59626. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59627. /**
  59628. * Gets a cascade maximum extents
  59629. * @param cascadeIndex index of the cascade
  59630. * @returns the maximum cascade extents
  59631. */
  59632. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59633. private _cascades;
  59634. private _currentLayer;
  59635. private _viewSpaceFrustumsZ;
  59636. private _viewMatrices;
  59637. private _projectionMatrices;
  59638. private _transformMatrices;
  59639. private _transformMatricesAsArray;
  59640. private _frustumLengths;
  59641. private _lightSizeUVCorrection;
  59642. private _depthCorrection;
  59643. private _frustumCornersWorldSpace;
  59644. private _frustumCenter;
  59645. private _shadowCameraPos;
  59646. private _shadowMaxZ;
  59647. /**
  59648. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59649. * It defaults to camera.maxZ
  59650. */
  59651. get shadowMaxZ(): number;
  59652. /**
  59653. * Sets the shadow max z distance.
  59654. */
  59655. set shadowMaxZ(value: number);
  59656. protected _debug: boolean;
  59657. /**
  59658. * Gets or sets the debug flag.
  59659. * When enabled, the cascades are materialized by different colors on the screen.
  59660. */
  59661. get debug(): boolean;
  59662. set debug(dbg: boolean);
  59663. private _depthClamp;
  59664. /**
  59665. * Gets or sets the depth clamping value.
  59666. *
  59667. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59668. * to account for the shadow casters far away.
  59669. *
  59670. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59671. */
  59672. get depthClamp(): boolean;
  59673. set depthClamp(value: boolean);
  59674. private _cascadeBlendPercentage;
  59675. /**
  59676. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59677. * It defaults to 0.1 (10% blending).
  59678. */
  59679. get cascadeBlendPercentage(): number;
  59680. set cascadeBlendPercentage(value: number);
  59681. private _lambda;
  59682. /**
  59683. * Gets or set the lambda parameter.
  59684. * This parameter is used to split the camera frustum and create the cascades.
  59685. * 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.
  59686. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59687. */
  59688. get lambda(): number;
  59689. set lambda(value: number);
  59690. /**
  59691. * Gets the view matrix corresponding to a given cascade
  59692. * @param cascadeNum cascade to retrieve the view matrix from
  59693. * @returns the cascade view matrix
  59694. */
  59695. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59696. /**
  59697. * Gets the projection matrix corresponding to a given cascade
  59698. * @param cascadeNum cascade to retrieve the projection matrix from
  59699. * @returns the cascade projection matrix
  59700. */
  59701. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59702. /**
  59703. * Gets the transformation matrix corresponding to a given cascade
  59704. * @param cascadeNum cascade to retrieve the transformation matrix from
  59705. * @returns the cascade transformation matrix
  59706. */
  59707. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59708. private _depthRenderer;
  59709. /**
  59710. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59711. *
  59712. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59713. *
  59714. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59715. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59716. * @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
  59717. */
  59718. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59719. private _depthReducer;
  59720. private _autoCalcDepthBounds;
  59721. /**
  59722. * Gets or sets the autoCalcDepthBounds property.
  59723. *
  59724. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59725. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59726. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59727. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59728. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59729. */
  59730. get autoCalcDepthBounds(): boolean;
  59731. set autoCalcDepthBounds(value: boolean);
  59732. /**
  59733. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59734. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59735. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59736. * for setting the refresh rate on the renderer yourself!
  59737. */
  59738. get autoCalcDepthBoundsRefreshRate(): number;
  59739. set autoCalcDepthBoundsRefreshRate(value: number);
  59740. /**
  59741. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59742. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59743. * you change the camera near/far planes!
  59744. */
  59745. splitFrustum(): void;
  59746. private _splitFrustum;
  59747. private _computeMatrices;
  59748. private _computeFrustumInWorldSpace;
  59749. private _computeCascadeFrustum;
  59750. /**
  59751. * Support test.
  59752. */
  59753. static get IsSupported(): boolean;
  59754. /** @hidden */
  59755. static _SceneComponentInitialization: (scene: Scene) => void;
  59756. /**
  59757. * Creates a Cascaded Shadow Generator object.
  59758. * A ShadowGenerator is the required tool to use the shadows.
  59759. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59760. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59761. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59762. * @param light The directional light object generating the shadows.
  59763. * @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.
  59764. */
  59765. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59766. protected _initializeGenerator(): void;
  59767. protected _createTargetRenderTexture(): void;
  59768. protected _initializeShadowMap(): void;
  59769. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59770. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59771. /**
  59772. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59773. * @param defines Defines of the material we want to update
  59774. * @param lightIndex Index of the light in the enabled light list of the material
  59775. */
  59776. prepareDefines(defines: any, lightIndex: number): void;
  59777. /**
  59778. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59779. * defined in the generator but impacting the effect).
  59780. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59781. * @param effect The effect we are binfing the information for
  59782. */
  59783. bindShadowLight(lightIndex: string, effect: Effect): void;
  59784. /**
  59785. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59786. * (eq to view projection * shadow projection matrices)
  59787. * @returns The transform matrix used to create the shadow map
  59788. */
  59789. getTransformMatrix(): Matrix;
  59790. /**
  59791. * Disposes the ShadowGenerator.
  59792. * Returns nothing.
  59793. */
  59794. dispose(): void;
  59795. /**
  59796. * Serializes the shadow generator setup to a json object.
  59797. * @returns The serialized JSON object
  59798. */
  59799. serialize(): any;
  59800. /**
  59801. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59802. * @param parsedShadowGenerator The JSON object to parse
  59803. * @param scene The scene to create the shadow map for
  59804. * @returns The parsed shadow generator
  59805. */
  59806. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59807. }
  59808. }
  59809. declare module BABYLON {
  59810. /**
  59811. * Defines the shadow generator component responsible to manage any shadow generators
  59812. * in a given scene.
  59813. */
  59814. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59815. /**
  59816. * The component name helpfull to identify the component in the list of scene components.
  59817. */
  59818. readonly name: string;
  59819. /**
  59820. * The scene the component belongs to.
  59821. */
  59822. scene: Scene;
  59823. /**
  59824. * Creates a new instance of the component for the given scene
  59825. * @param scene Defines the scene to register the component in
  59826. */
  59827. constructor(scene: Scene);
  59828. /**
  59829. * Registers the component in a given scene
  59830. */
  59831. register(): void;
  59832. /**
  59833. * Rebuilds the elements related to this component in case of
  59834. * context lost for instance.
  59835. */
  59836. rebuild(): void;
  59837. /**
  59838. * Serializes the component data to the specified json object
  59839. * @param serializationObject The object to serialize to
  59840. */
  59841. serialize(serializationObject: any): void;
  59842. /**
  59843. * Adds all the elements from the container to the scene
  59844. * @param container the container holding the elements
  59845. */
  59846. addFromContainer(container: AbstractScene): void;
  59847. /**
  59848. * Removes all the elements in the container from the scene
  59849. * @param container contains the elements to remove
  59850. * @param dispose if the removed element should be disposed (default: false)
  59851. */
  59852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59853. /**
  59854. * Rebuilds the elements related to this component in case of
  59855. * context lost for instance.
  59856. */
  59857. dispose(): void;
  59858. private _gatherRenderTargets;
  59859. }
  59860. }
  59861. declare module BABYLON {
  59862. /**
  59863. * A point light is a light defined by an unique point in world space.
  59864. * The light is emitted in every direction from this point.
  59865. * A good example of a point light is a standard light bulb.
  59866. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59867. */
  59868. export class PointLight extends ShadowLight {
  59869. private _shadowAngle;
  59870. /**
  59871. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59872. * This specifies what angle the shadow will use to be created.
  59873. *
  59874. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59875. */
  59876. get shadowAngle(): number;
  59877. /**
  59878. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59879. * This specifies what angle the shadow will use to be created.
  59880. *
  59881. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59882. */
  59883. set shadowAngle(value: number);
  59884. /**
  59885. * Gets the direction if it has been set.
  59886. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59887. */
  59888. get direction(): Vector3;
  59889. /**
  59890. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59891. */
  59892. set direction(value: Vector3);
  59893. /**
  59894. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59895. * A PointLight emits the light in every direction.
  59896. * It can cast shadows.
  59897. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59898. * ```javascript
  59899. * var pointLight = new PointLight("pl", camera.position, scene);
  59900. * ```
  59901. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59902. * @param name The light friendly name
  59903. * @param position The position of the point light in the scene
  59904. * @param scene The scene the lights belongs to
  59905. */
  59906. constructor(name: string, position: Vector3, scene: Scene);
  59907. /**
  59908. * Returns the string "PointLight"
  59909. * @returns the class name
  59910. */
  59911. getClassName(): string;
  59912. /**
  59913. * Returns the integer 0.
  59914. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59915. */
  59916. getTypeID(): number;
  59917. /**
  59918. * Specifies wether or not the shadowmap should be a cube texture.
  59919. * @returns true if the shadowmap needs to be a cube texture.
  59920. */
  59921. needCube(): boolean;
  59922. /**
  59923. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59924. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59925. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59926. */
  59927. getShadowDirection(faceIndex?: number): Vector3;
  59928. /**
  59929. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59930. * - fov = PI / 2
  59931. * - aspect ratio : 1.0
  59932. * - z-near and far equal to the active camera minZ and maxZ.
  59933. * Returns the PointLight.
  59934. */
  59935. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59936. protected _buildUniformLayout(): void;
  59937. /**
  59938. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59939. * @param effect The effect to update
  59940. * @param lightIndex The index of the light in the effect to update
  59941. * @returns The point light
  59942. */
  59943. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59944. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59945. /**
  59946. * Prepares the list of defines specific to the light type.
  59947. * @param defines the list of defines
  59948. * @param lightIndex defines the index of the light for the effect
  59949. */
  59950. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59951. }
  59952. }
  59953. declare module BABYLON {
  59954. /**
  59955. * Header information of HDR texture files.
  59956. */
  59957. export interface HDRInfo {
  59958. /**
  59959. * The height of the texture in pixels.
  59960. */
  59961. height: number;
  59962. /**
  59963. * The width of the texture in pixels.
  59964. */
  59965. width: number;
  59966. /**
  59967. * The index of the beginning of the data in the binary file.
  59968. */
  59969. dataPosition: number;
  59970. }
  59971. /**
  59972. * This groups tools to convert HDR texture to native colors array.
  59973. */
  59974. export class HDRTools {
  59975. private static Ldexp;
  59976. private static Rgbe2float;
  59977. private static readStringLine;
  59978. /**
  59979. * Reads header information from an RGBE texture stored in a native array.
  59980. * More information on this format are available here:
  59981. * https://en.wikipedia.org/wiki/RGBE_image_format
  59982. *
  59983. * @param uint8array The binary file stored in native array.
  59984. * @return The header information.
  59985. */
  59986. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59987. /**
  59988. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59989. * This RGBE texture needs to store the information as a panorama.
  59990. *
  59991. * More information on this format are available here:
  59992. * https://en.wikipedia.org/wiki/RGBE_image_format
  59993. *
  59994. * @param buffer The binary file stored in an array buffer.
  59995. * @param size The expected size of the extracted cubemap.
  59996. * @return The Cube Map information.
  59997. */
  59998. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59999. /**
  60000. * Returns the pixels data extracted from an RGBE texture.
  60001. * This pixels will be stored left to right up to down in the R G B order in one array.
  60002. *
  60003. * More information on this format are available here:
  60004. * https://en.wikipedia.org/wiki/RGBE_image_format
  60005. *
  60006. * @param uint8array The binary file stored in an array buffer.
  60007. * @param hdrInfo The header information of the file.
  60008. * @return The pixels data in RGB right to left up to down order.
  60009. */
  60010. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60011. private static RGBE_ReadPixels_RLE;
  60012. private static RGBE_ReadPixels_NOT_RLE;
  60013. }
  60014. }
  60015. declare module BABYLON {
  60016. /**
  60017. * Effect Render Options
  60018. */
  60019. export interface IEffectRendererOptions {
  60020. /**
  60021. * Defines the vertices positions.
  60022. */
  60023. positions?: number[];
  60024. /**
  60025. * Defines the indices.
  60026. */
  60027. indices?: number[];
  60028. }
  60029. /**
  60030. * Helper class to render one or more effects.
  60031. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60032. */
  60033. export class EffectRenderer {
  60034. private engine;
  60035. private static _DefaultOptions;
  60036. private _vertexBuffers;
  60037. private _indexBuffer;
  60038. private _fullscreenViewport;
  60039. /**
  60040. * Creates an effect renderer
  60041. * @param engine the engine to use for rendering
  60042. * @param options defines the options of the effect renderer
  60043. */
  60044. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60045. /**
  60046. * Sets the current viewport in normalized coordinates 0-1
  60047. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60048. */
  60049. setViewport(viewport?: Viewport): void;
  60050. /**
  60051. * Binds the embedded attributes buffer to the effect.
  60052. * @param effect Defines the effect to bind the attributes for
  60053. */
  60054. bindBuffers(effect: Effect): void;
  60055. /**
  60056. * Sets the current effect wrapper to use during draw.
  60057. * The effect needs to be ready before calling this api.
  60058. * This also sets the default full screen position attribute.
  60059. * @param effectWrapper Defines the effect to draw with
  60060. */
  60061. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60062. /**
  60063. * Restores engine states
  60064. */
  60065. restoreStates(): void;
  60066. /**
  60067. * Draws a full screen quad.
  60068. */
  60069. draw(): void;
  60070. private isRenderTargetTexture;
  60071. /**
  60072. * renders one or more effects to a specified texture
  60073. * @param effectWrapper the effect to renderer
  60074. * @param outputTexture texture to draw to, if null it will render to the screen.
  60075. */
  60076. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60077. /**
  60078. * Disposes of the effect renderer
  60079. */
  60080. dispose(): void;
  60081. }
  60082. /**
  60083. * Options to create an EffectWrapper
  60084. */
  60085. interface EffectWrapperCreationOptions {
  60086. /**
  60087. * Engine to use to create the effect
  60088. */
  60089. engine: ThinEngine;
  60090. /**
  60091. * Fragment shader for the effect
  60092. */
  60093. fragmentShader: string;
  60094. /**
  60095. * Use the shader store instead of direct source code
  60096. */
  60097. useShaderStore?: boolean;
  60098. /**
  60099. * Vertex shader for the effect
  60100. */
  60101. vertexShader?: string;
  60102. /**
  60103. * Attributes to use in the shader
  60104. */
  60105. attributeNames?: Array<string>;
  60106. /**
  60107. * Uniforms to use in the shader
  60108. */
  60109. uniformNames?: Array<string>;
  60110. /**
  60111. * Texture sampler names to use in the shader
  60112. */
  60113. samplerNames?: Array<string>;
  60114. /**
  60115. * Defines to use in the shader
  60116. */
  60117. defines?: Array<string>;
  60118. /**
  60119. * Callback when effect is compiled
  60120. */
  60121. onCompiled?: Nullable<(effect: Effect) => void>;
  60122. /**
  60123. * The friendly name of the effect displayed in Spector.
  60124. */
  60125. name?: string;
  60126. }
  60127. /**
  60128. * Wraps an effect to be used for rendering
  60129. */
  60130. export class EffectWrapper {
  60131. /**
  60132. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60133. */
  60134. onApplyObservable: Observable<{}>;
  60135. /**
  60136. * The underlying effect
  60137. */
  60138. effect: Effect;
  60139. /**
  60140. * Creates an effect to be renderer
  60141. * @param creationOptions options to create the effect
  60142. */
  60143. constructor(creationOptions: EffectWrapperCreationOptions);
  60144. /**
  60145. * Disposes of the effect wrapper
  60146. */
  60147. dispose(): void;
  60148. }
  60149. }
  60150. declare module BABYLON {
  60151. /** @hidden */
  60152. export var hdrFilteringVertexShader: {
  60153. name: string;
  60154. shader: string;
  60155. };
  60156. }
  60157. declare module BABYLON {
  60158. /** @hidden */
  60159. export var hdrFilteringPixelShader: {
  60160. name: string;
  60161. shader: string;
  60162. };
  60163. }
  60164. declare module BABYLON {
  60165. /**
  60166. * Options for texture filtering
  60167. */
  60168. interface IHDRFilteringOptions {
  60169. /**
  60170. * Scales pixel intensity for the input HDR map.
  60171. */
  60172. hdrScale?: number;
  60173. /**
  60174. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60175. */
  60176. quality?: number;
  60177. }
  60178. /**
  60179. * Filters HDR maps to get correct renderings of PBR reflections
  60180. */
  60181. export class HDRFiltering {
  60182. private _engine;
  60183. private _effectRenderer;
  60184. private _effectWrapper;
  60185. private _lodGenerationOffset;
  60186. private _lodGenerationScale;
  60187. /**
  60188. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60189. * you care about baking speed.
  60190. */
  60191. quality: number;
  60192. /**
  60193. * Scales pixel intensity for the input HDR map.
  60194. */
  60195. hdrScale: number;
  60196. /**
  60197. * Instantiates HDR filter for reflection maps
  60198. *
  60199. * @param engine Thin engine
  60200. * @param options Options
  60201. */
  60202. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60203. private _createRenderTarget;
  60204. private _prefilterInternal;
  60205. private _createEffect;
  60206. /**
  60207. * Get a value indicating if the filter is ready to be used
  60208. * @param texture Texture to filter
  60209. * @returns true if the filter is ready
  60210. */
  60211. isReady(texture: BaseTexture): boolean;
  60212. /**
  60213. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60214. * Prefiltering will be invoked at the end of next rendering pass.
  60215. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60216. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60217. * @param texture Texture to filter
  60218. * @param onFinished Callback when filtering is done
  60219. * @return Promise called when prefiltering is done
  60220. */
  60221. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60222. }
  60223. }
  60224. declare module BABYLON {
  60225. /**
  60226. * This represents a texture coming from an HDR input.
  60227. *
  60228. * The only supported format is currently panorama picture stored in RGBE format.
  60229. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60230. */
  60231. export class HDRCubeTexture extends BaseTexture {
  60232. private static _facesMapping;
  60233. private _generateHarmonics;
  60234. private _noMipmap;
  60235. private _prefilterOnLoad;
  60236. private _textureMatrix;
  60237. private _size;
  60238. private _onLoad;
  60239. private _onError;
  60240. /**
  60241. * The texture URL.
  60242. */
  60243. url: string;
  60244. protected _isBlocking: boolean;
  60245. /**
  60246. * Sets wether or not the texture is blocking during loading.
  60247. */
  60248. set isBlocking(value: boolean);
  60249. /**
  60250. * Gets wether or not the texture is blocking during loading.
  60251. */
  60252. get isBlocking(): boolean;
  60253. protected _rotationY: number;
  60254. /**
  60255. * Sets texture matrix rotation angle around Y axis in radians.
  60256. */
  60257. set rotationY(value: number);
  60258. /**
  60259. * Gets texture matrix rotation angle around Y axis radians.
  60260. */
  60261. get rotationY(): number;
  60262. /**
  60263. * Gets or sets the center of the bounding box associated with the cube texture
  60264. * It must define where the camera used to render the texture was set
  60265. */
  60266. boundingBoxPosition: Vector3;
  60267. private _boundingBoxSize;
  60268. /**
  60269. * Gets or sets the size of the bounding box associated with the cube texture
  60270. * When defined, the cubemap will switch to local mode
  60271. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60272. * @example https://www.babylonjs-playground.com/#RNASML
  60273. */
  60274. set boundingBoxSize(value: Vector3);
  60275. get boundingBoxSize(): Vector3;
  60276. /**
  60277. * Instantiates an HDRTexture from the following parameters.
  60278. *
  60279. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60280. * @param sceneOrEngine The scene or engine the texture will be used in
  60281. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60282. * @param noMipmap Forces to not generate the mipmap if true
  60283. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60284. * @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)
  60285. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60286. */
  60287. 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>);
  60288. /**
  60289. * Get the current class name of the texture useful for serialization or dynamic coding.
  60290. * @returns "HDRCubeTexture"
  60291. */
  60292. getClassName(): string;
  60293. /**
  60294. * Occurs when the file is raw .hdr file.
  60295. */
  60296. private loadTexture;
  60297. clone(): HDRCubeTexture;
  60298. delayLoad(): void;
  60299. /**
  60300. * Get the texture reflection matrix used to rotate/transform the reflection.
  60301. * @returns the reflection matrix
  60302. */
  60303. getReflectionTextureMatrix(): Matrix;
  60304. /**
  60305. * Set the texture reflection matrix used to rotate/transform the reflection.
  60306. * @param value Define the reflection matrix to set
  60307. */
  60308. setReflectionTextureMatrix(value: Matrix): void;
  60309. /**
  60310. * Parses a JSON representation of an HDR Texture in order to create the texture
  60311. * @param parsedTexture Define the JSON representation
  60312. * @param scene Define the scene the texture should be created in
  60313. * @param rootUrl Define the root url in case we need to load relative dependencies
  60314. * @returns the newly created texture after parsing
  60315. */
  60316. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60317. serialize(): any;
  60318. }
  60319. }
  60320. declare module BABYLON {
  60321. /**
  60322. * Class used to control physics engine
  60323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60324. */
  60325. export class PhysicsEngine implements IPhysicsEngine {
  60326. private _physicsPlugin;
  60327. /**
  60328. * Global value used to control the smallest number supported by the simulation
  60329. */
  60330. static Epsilon: number;
  60331. private _impostors;
  60332. private _joints;
  60333. private _subTimeStep;
  60334. /**
  60335. * Gets the gravity vector used by the simulation
  60336. */
  60337. gravity: Vector3;
  60338. /**
  60339. * Factory used to create the default physics plugin.
  60340. * @returns The default physics plugin
  60341. */
  60342. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60343. /**
  60344. * Creates a new Physics Engine
  60345. * @param gravity defines the gravity vector used by the simulation
  60346. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60347. */
  60348. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60349. /**
  60350. * Sets the gravity vector used by the simulation
  60351. * @param gravity defines the gravity vector to use
  60352. */
  60353. setGravity(gravity: Vector3): void;
  60354. /**
  60355. * Set the time step of the physics engine.
  60356. * Default is 1/60.
  60357. * To slow it down, enter 1/600 for example.
  60358. * To speed it up, 1/30
  60359. * @param newTimeStep defines the new timestep to apply to this world.
  60360. */
  60361. setTimeStep(newTimeStep?: number): void;
  60362. /**
  60363. * Get the time step of the physics engine.
  60364. * @returns the current time step
  60365. */
  60366. getTimeStep(): number;
  60367. /**
  60368. * Set the sub time step of the physics engine.
  60369. * Default is 0 meaning there is no sub steps
  60370. * To increase physics resolution precision, set a small value (like 1 ms)
  60371. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60372. */
  60373. setSubTimeStep(subTimeStep?: number): void;
  60374. /**
  60375. * Get the sub time step of the physics engine.
  60376. * @returns the current sub time step
  60377. */
  60378. getSubTimeStep(): number;
  60379. /**
  60380. * Release all resources
  60381. */
  60382. dispose(): void;
  60383. /**
  60384. * Gets the name of the current physics plugin
  60385. * @returns the name of the plugin
  60386. */
  60387. getPhysicsPluginName(): string;
  60388. /**
  60389. * Adding a new impostor for the impostor tracking.
  60390. * This will be done by the impostor itself.
  60391. * @param impostor the impostor to add
  60392. */
  60393. addImpostor(impostor: PhysicsImpostor): void;
  60394. /**
  60395. * Remove an impostor from the engine.
  60396. * This impostor and its mesh will not longer be updated by the physics engine.
  60397. * @param impostor the impostor to remove
  60398. */
  60399. removeImpostor(impostor: PhysicsImpostor): void;
  60400. /**
  60401. * Add a joint to the physics engine
  60402. * @param mainImpostor defines the main impostor to which the joint is added.
  60403. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60404. * @param joint defines the joint that will connect both impostors.
  60405. */
  60406. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60407. /**
  60408. * Removes a joint from the simulation
  60409. * @param mainImpostor defines the impostor used with the joint
  60410. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60411. * @param joint defines the joint to remove
  60412. */
  60413. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60414. /**
  60415. * Called by the scene. No need to call it.
  60416. * @param delta defines the timespam between frames
  60417. */
  60418. _step(delta: number): void;
  60419. /**
  60420. * Gets the current plugin used to run the simulation
  60421. * @returns current plugin
  60422. */
  60423. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60424. /**
  60425. * Gets the list of physic impostors
  60426. * @returns an array of PhysicsImpostor
  60427. */
  60428. getImpostors(): Array<PhysicsImpostor>;
  60429. /**
  60430. * Gets the impostor for a physics enabled object
  60431. * @param object defines the object impersonated by the impostor
  60432. * @returns the PhysicsImpostor or null if not found
  60433. */
  60434. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60435. /**
  60436. * Gets the impostor for a physics body object
  60437. * @param body defines physics body used by the impostor
  60438. * @returns the PhysicsImpostor or null if not found
  60439. */
  60440. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60441. /**
  60442. * Does a raycast in the physics world
  60443. * @param from when should the ray start?
  60444. * @param to when should the ray end?
  60445. * @returns PhysicsRaycastResult
  60446. */
  60447. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60448. }
  60449. }
  60450. declare module BABYLON {
  60451. /** @hidden */
  60452. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60453. private _useDeltaForWorldStep;
  60454. world: any;
  60455. name: string;
  60456. private _physicsMaterials;
  60457. private _fixedTimeStep;
  60458. private _cannonRaycastResult;
  60459. private _raycastResult;
  60460. private _physicsBodysToRemoveAfterStep;
  60461. private _firstFrame;
  60462. BJSCANNON: any;
  60463. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60464. setGravity(gravity: Vector3): void;
  60465. setTimeStep(timeStep: number): void;
  60466. getTimeStep(): number;
  60467. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60468. private _removeMarkedPhysicsBodiesFromWorld;
  60469. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60470. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60471. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60472. private _processChildMeshes;
  60473. removePhysicsBody(impostor: PhysicsImpostor): void;
  60474. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60475. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60476. private _addMaterial;
  60477. private _checkWithEpsilon;
  60478. private _createShape;
  60479. private _createHeightmap;
  60480. private _minus90X;
  60481. private _plus90X;
  60482. private _tmpPosition;
  60483. private _tmpDeltaPosition;
  60484. private _tmpUnityRotation;
  60485. private _updatePhysicsBodyTransformation;
  60486. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60487. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60488. isSupported(): boolean;
  60489. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60490. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60491. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60492. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60493. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60494. getBodyMass(impostor: PhysicsImpostor): number;
  60495. getBodyFriction(impostor: PhysicsImpostor): number;
  60496. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60497. getBodyRestitution(impostor: PhysicsImpostor): number;
  60498. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60499. sleepBody(impostor: PhysicsImpostor): void;
  60500. wakeUpBody(impostor: PhysicsImpostor): void;
  60501. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60502. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60503. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60504. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60505. getRadius(impostor: PhysicsImpostor): number;
  60506. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60507. dispose(): void;
  60508. private _extendNamespace;
  60509. /**
  60510. * Does a raycast in the physics world
  60511. * @param from when should the ray start?
  60512. * @param to when should the ray end?
  60513. * @returns PhysicsRaycastResult
  60514. */
  60515. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60516. }
  60517. }
  60518. declare module BABYLON {
  60519. /** @hidden */
  60520. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60521. private _useDeltaForWorldStep;
  60522. world: any;
  60523. name: string;
  60524. BJSOIMO: any;
  60525. private _raycastResult;
  60526. private _fixedTimeStep;
  60527. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60528. setGravity(gravity: Vector3): void;
  60529. setTimeStep(timeStep: number): void;
  60530. getTimeStep(): number;
  60531. private _tmpImpostorsArray;
  60532. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60533. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60534. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60535. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60536. private _tmpPositionVector;
  60537. removePhysicsBody(impostor: PhysicsImpostor): void;
  60538. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60539. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60540. isSupported(): boolean;
  60541. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60542. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60543. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60544. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60545. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60546. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60547. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60548. getBodyMass(impostor: PhysicsImpostor): number;
  60549. getBodyFriction(impostor: PhysicsImpostor): number;
  60550. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60551. getBodyRestitution(impostor: PhysicsImpostor): number;
  60552. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60553. sleepBody(impostor: PhysicsImpostor): void;
  60554. wakeUpBody(impostor: PhysicsImpostor): void;
  60555. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60556. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60557. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60558. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60559. getRadius(impostor: PhysicsImpostor): number;
  60560. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60561. dispose(): void;
  60562. /**
  60563. * Does a raycast in the physics world
  60564. * @param from when should the ray start?
  60565. * @param to when should the ray end?
  60566. * @returns PhysicsRaycastResult
  60567. */
  60568. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60569. }
  60570. }
  60571. declare module BABYLON {
  60572. /**
  60573. * AmmoJS Physics plugin
  60574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60575. * @see https://github.com/kripken/ammo.js/
  60576. */
  60577. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60578. private _useDeltaForWorldStep;
  60579. /**
  60580. * Reference to the Ammo library
  60581. */
  60582. bjsAMMO: any;
  60583. /**
  60584. * Created ammoJS world which physics bodies are added to
  60585. */
  60586. world: any;
  60587. /**
  60588. * Name of the plugin
  60589. */
  60590. name: string;
  60591. private _timeStep;
  60592. private _fixedTimeStep;
  60593. private _maxSteps;
  60594. private _tmpQuaternion;
  60595. private _tmpAmmoTransform;
  60596. private _tmpAmmoQuaternion;
  60597. private _tmpAmmoConcreteContactResultCallback;
  60598. private _collisionConfiguration;
  60599. private _dispatcher;
  60600. private _overlappingPairCache;
  60601. private _solver;
  60602. private _softBodySolver;
  60603. private _tmpAmmoVectorA;
  60604. private _tmpAmmoVectorB;
  60605. private _tmpAmmoVectorC;
  60606. private _tmpAmmoVectorD;
  60607. private _tmpContactCallbackResult;
  60608. private _tmpAmmoVectorRCA;
  60609. private _tmpAmmoVectorRCB;
  60610. private _raycastResult;
  60611. private static readonly DISABLE_COLLISION_FLAG;
  60612. private static readonly KINEMATIC_FLAG;
  60613. private static readonly DISABLE_DEACTIVATION_FLAG;
  60614. /**
  60615. * Initializes the ammoJS plugin
  60616. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60617. * @param ammoInjection can be used to inject your own ammo reference
  60618. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60619. */
  60620. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60621. /**
  60622. * Sets the gravity of the physics world (m/(s^2))
  60623. * @param gravity Gravity to set
  60624. */
  60625. setGravity(gravity: Vector3): void;
  60626. /**
  60627. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60628. * @param timeStep timestep to use in seconds
  60629. */
  60630. setTimeStep(timeStep: number): void;
  60631. /**
  60632. * 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)
  60633. * @param fixedTimeStep fixedTimeStep to use in seconds
  60634. */
  60635. setFixedTimeStep(fixedTimeStep: number): void;
  60636. /**
  60637. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60638. * @param maxSteps the maximum number of steps by the physics engine per frame
  60639. */
  60640. setMaxSteps(maxSteps: number): void;
  60641. /**
  60642. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60643. * @returns the current timestep in seconds
  60644. */
  60645. getTimeStep(): number;
  60646. /**
  60647. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60648. */
  60649. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60650. private _isImpostorInContact;
  60651. private _isImpostorPairInContact;
  60652. private _stepSimulation;
  60653. /**
  60654. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60655. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60656. * After the step the babylon meshes are set to the position of the physics imposters
  60657. * @param delta amount of time to step forward
  60658. * @param impostors array of imposters to update before/after the step
  60659. */
  60660. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60661. /**
  60662. * Update babylon mesh to match physics world object
  60663. * @param impostor imposter to match
  60664. */
  60665. private _afterSoftStep;
  60666. /**
  60667. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60668. * @param impostor imposter to match
  60669. */
  60670. private _ropeStep;
  60671. /**
  60672. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60673. * @param impostor imposter to match
  60674. */
  60675. private _softbodyOrClothStep;
  60676. private _tmpMatrix;
  60677. /**
  60678. * Applies an impulse on the imposter
  60679. * @param impostor imposter to apply impulse to
  60680. * @param force amount of force to be applied to the imposter
  60681. * @param contactPoint the location to apply the impulse on the imposter
  60682. */
  60683. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60684. /**
  60685. * Applies a force on the imposter
  60686. * @param impostor imposter to apply force
  60687. * @param force amount of force to be applied to the imposter
  60688. * @param contactPoint the location to apply the force on the imposter
  60689. */
  60690. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60691. /**
  60692. * Creates a physics body using the plugin
  60693. * @param impostor the imposter to create the physics body on
  60694. */
  60695. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60696. /**
  60697. * Removes the physics body from the imposter and disposes of the body's memory
  60698. * @param impostor imposter to remove the physics body from
  60699. */
  60700. removePhysicsBody(impostor: PhysicsImpostor): void;
  60701. /**
  60702. * Generates a joint
  60703. * @param impostorJoint the imposter joint to create the joint with
  60704. */
  60705. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60706. /**
  60707. * Removes a joint
  60708. * @param impostorJoint the imposter joint to remove the joint from
  60709. */
  60710. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60711. private _addMeshVerts;
  60712. /**
  60713. * Initialise the soft body vertices to match its object's (mesh) vertices
  60714. * Softbody vertices (nodes) are in world space and to match this
  60715. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60716. * @param impostor to create the softbody for
  60717. */
  60718. private _softVertexData;
  60719. /**
  60720. * Create an impostor's soft body
  60721. * @param impostor to create the softbody for
  60722. */
  60723. private _createSoftbody;
  60724. /**
  60725. * Create cloth for an impostor
  60726. * @param impostor to create the softbody for
  60727. */
  60728. private _createCloth;
  60729. /**
  60730. * Create rope for an impostor
  60731. * @param impostor to create the softbody for
  60732. */
  60733. private _createRope;
  60734. /**
  60735. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60736. * @param impostor to create the custom physics shape for
  60737. */
  60738. private _createCustom;
  60739. private _addHullVerts;
  60740. private _createShape;
  60741. /**
  60742. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60743. * @param impostor imposter containing the physics body and babylon object
  60744. */
  60745. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60746. /**
  60747. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60748. * @param impostor imposter containing the physics body and babylon object
  60749. * @param newPosition new position
  60750. * @param newRotation new rotation
  60751. */
  60752. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60753. /**
  60754. * If this plugin is supported
  60755. * @returns true if its supported
  60756. */
  60757. isSupported(): boolean;
  60758. /**
  60759. * Sets the linear velocity of the physics body
  60760. * @param impostor imposter to set the velocity on
  60761. * @param velocity velocity to set
  60762. */
  60763. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60764. /**
  60765. * Sets the angular velocity of the physics body
  60766. * @param impostor imposter to set the velocity on
  60767. * @param velocity velocity to set
  60768. */
  60769. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60770. /**
  60771. * gets the linear velocity
  60772. * @param impostor imposter to get linear velocity from
  60773. * @returns linear velocity
  60774. */
  60775. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60776. /**
  60777. * gets the angular velocity
  60778. * @param impostor imposter to get angular velocity from
  60779. * @returns angular velocity
  60780. */
  60781. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60782. /**
  60783. * Sets the mass of physics body
  60784. * @param impostor imposter to set the mass on
  60785. * @param mass mass to set
  60786. */
  60787. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60788. /**
  60789. * Gets the mass of the physics body
  60790. * @param impostor imposter to get the mass from
  60791. * @returns mass
  60792. */
  60793. getBodyMass(impostor: PhysicsImpostor): number;
  60794. /**
  60795. * Gets friction of the impostor
  60796. * @param impostor impostor to get friction from
  60797. * @returns friction value
  60798. */
  60799. getBodyFriction(impostor: PhysicsImpostor): number;
  60800. /**
  60801. * Sets friction of the impostor
  60802. * @param impostor impostor to set friction on
  60803. * @param friction friction value
  60804. */
  60805. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60806. /**
  60807. * Gets restitution of the impostor
  60808. * @param impostor impostor to get restitution from
  60809. * @returns restitution value
  60810. */
  60811. getBodyRestitution(impostor: PhysicsImpostor): number;
  60812. /**
  60813. * Sets resitution of the impostor
  60814. * @param impostor impostor to set resitution on
  60815. * @param restitution resitution value
  60816. */
  60817. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60818. /**
  60819. * Gets pressure inside the impostor
  60820. * @param impostor impostor to get pressure from
  60821. * @returns pressure value
  60822. */
  60823. getBodyPressure(impostor: PhysicsImpostor): number;
  60824. /**
  60825. * Sets pressure inside a soft body impostor
  60826. * Cloth and rope must remain 0 pressure
  60827. * @param impostor impostor to set pressure on
  60828. * @param pressure pressure value
  60829. */
  60830. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60831. /**
  60832. * Gets stiffness of the impostor
  60833. * @param impostor impostor to get stiffness from
  60834. * @returns pressure value
  60835. */
  60836. getBodyStiffness(impostor: PhysicsImpostor): number;
  60837. /**
  60838. * Sets stiffness of the impostor
  60839. * @param impostor impostor to set stiffness on
  60840. * @param stiffness stiffness value from 0 to 1
  60841. */
  60842. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60843. /**
  60844. * Gets velocityIterations of the impostor
  60845. * @param impostor impostor to get velocity iterations from
  60846. * @returns velocityIterations value
  60847. */
  60848. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60849. /**
  60850. * Sets velocityIterations of the impostor
  60851. * @param impostor impostor to set velocity iterations on
  60852. * @param velocityIterations velocityIterations value
  60853. */
  60854. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60855. /**
  60856. * Gets positionIterations of the impostor
  60857. * @param impostor impostor to get position iterations from
  60858. * @returns positionIterations value
  60859. */
  60860. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60861. /**
  60862. * Sets positionIterations of the impostor
  60863. * @param impostor impostor to set position on
  60864. * @param positionIterations positionIterations value
  60865. */
  60866. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60867. /**
  60868. * Append an anchor to a cloth object
  60869. * @param impostor is the cloth impostor to add anchor to
  60870. * @param otherImpostor is the rigid impostor to anchor to
  60871. * @param width ratio across width from 0 to 1
  60872. * @param height ratio up height from 0 to 1
  60873. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60874. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60875. */
  60876. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60877. /**
  60878. * Append an hook to a rope object
  60879. * @param impostor is the rope impostor to add hook to
  60880. * @param otherImpostor is the rigid impostor to hook to
  60881. * @param length ratio along the rope from 0 to 1
  60882. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60883. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60884. */
  60885. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60886. /**
  60887. * Sleeps the physics body and stops it from being active
  60888. * @param impostor impostor to sleep
  60889. */
  60890. sleepBody(impostor: PhysicsImpostor): void;
  60891. /**
  60892. * Activates the physics body
  60893. * @param impostor impostor to activate
  60894. */
  60895. wakeUpBody(impostor: PhysicsImpostor): void;
  60896. /**
  60897. * Updates the distance parameters of the joint
  60898. * @param joint joint to update
  60899. * @param maxDistance maximum distance of the joint
  60900. * @param minDistance minimum distance of the joint
  60901. */
  60902. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60903. /**
  60904. * Sets a motor on the joint
  60905. * @param joint joint to set motor on
  60906. * @param speed speed of the motor
  60907. * @param maxForce maximum force of the motor
  60908. * @param motorIndex index of the motor
  60909. */
  60910. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60911. /**
  60912. * Sets the motors limit
  60913. * @param joint joint to set limit on
  60914. * @param upperLimit upper limit
  60915. * @param lowerLimit lower limit
  60916. */
  60917. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60918. /**
  60919. * Syncs the position and rotation of a mesh with the impostor
  60920. * @param mesh mesh to sync
  60921. * @param impostor impostor to update the mesh with
  60922. */
  60923. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60924. /**
  60925. * Gets the radius of the impostor
  60926. * @param impostor impostor to get radius from
  60927. * @returns the radius
  60928. */
  60929. getRadius(impostor: PhysicsImpostor): number;
  60930. /**
  60931. * Gets the box size of the impostor
  60932. * @param impostor impostor to get box size from
  60933. * @param result the resulting box size
  60934. */
  60935. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60936. /**
  60937. * Disposes of the impostor
  60938. */
  60939. dispose(): void;
  60940. /**
  60941. * Does a raycast in the physics world
  60942. * @param from when should the ray start?
  60943. * @param to when should the ray end?
  60944. * @returns PhysicsRaycastResult
  60945. */
  60946. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60947. }
  60948. }
  60949. declare module BABYLON {
  60950. interface AbstractScene {
  60951. /**
  60952. * The list of reflection probes added to the scene
  60953. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60954. */
  60955. reflectionProbes: Array<ReflectionProbe>;
  60956. /**
  60957. * Removes the given reflection probe from this scene.
  60958. * @param toRemove The reflection probe to remove
  60959. * @returns The index of the removed reflection probe
  60960. */
  60961. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60962. /**
  60963. * Adds the given reflection probe to this scene.
  60964. * @param newReflectionProbe The reflection probe to add
  60965. */
  60966. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60967. }
  60968. /**
  60969. * Class used to generate realtime reflection / refraction cube textures
  60970. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60971. */
  60972. export class ReflectionProbe {
  60973. /** defines the name of the probe */
  60974. name: string;
  60975. private _scene;
  60976. private _renderTargetTexture;
  60977. private _projectionMatrix;
  60978. private _viewMatrix;
  60979. private _target;
  60980. private _add;
  60981. private _attachedMesh;
  60982. private _invertYAxis;
  60983. /** Gets or sets probe position (center of the cube map) */
  60984. position: Vector3;
  60985. /**
  60986. * Creates a new reflection probe
  60987. * @param name defines the name of the probe
  60988. * @param size defines the texture resolution (for each face)
  60989. * @param scene defines the hosting scene
  60990. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60991. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60992. */
  60993. constructor(
  60994. /** defines the name of the probe */
  60995. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60996. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60997. get samples(): number;
  60998. set samples(value: number);
  60999. /** Gets or sets the refresh rate to use (on every frame by default) */
  61000. get refreshRate(): number;
  61001. set refreshRate(value: number);
  61002. /**
  61003. * Gets the hosting scene
  61004. * @returns a Scene
  61005. */
  61006. getScene(): Scene;
  61007. /** Gets the internal CubeTexture used to render to */
  61008. get cubeTexture(): RenderTargetTexture;
  61009. /** Gets the list of meshes to render */
  61010. get renderList(): Nullable<AbstractMesh[]>;
  61011. /**
  61012. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61013. * @param mesh defines the mesh to attach to
  61014. */
  61015. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61016. /**
  61017. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61018. * @param renderingGroupId The rendering group id corresponding to its index
  61019. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61020. */
  61021. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61022. /**
  61023. * Clean all associated resources
  61024. */
  61025. dispose(): void;
  61026. /**
  61027. * Converts the reflection probe information to a readable string for debug purpose.
  61028. * @param fullDetails Supports for multiple levels of logging within scene loading
  61029. * @returns the human readable reflection probe info
  61030. */
  61031. toString(fullDetails?: boolean): string;
  61032. /**
  61033. * Get the class name of the relfection probe.
  61034. * @returns "ReflectionProbe"
  61035. */
  61036. getClassName(): string;
  61037. /**
  61038. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61039. * @returns The JSON representation of the texture
  61040. */
  61041. serialize(): any;
  61042. /**
  61043. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61044. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61045. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61046. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61047. * @returns The parsed reflection probe if successful
  61048. */
  61049. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61050. }
  61051. }
  61052. declare module BABYLON {
  61053. /** @hidden */
  61054. export var _BabylonLoaderRegistered: boolean;
  61055. /**
  61056. * Helps setting up some configuration for the babylon file loader.
  61057. */
  61058. export class BabylonFileLoaderConfiguration {
  61059. /**
  61060. * The loader does not allow injecting custom physix engine into the plugins.
  61061. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61062. * So you could set this variable to your engine import to make it work.
  61063. */
  61064. static LoaderInjectedPhysicsEngine: any;
  61065. }
  61066. }
  61067. declare module BABYLON {
  61068. /**
  61069. * The Physically based simple base material of BJS.
  61070. *
  61071. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61072. * It is used as the base class for both the specGloss and metalRough conventions.
  61073. */
  61074. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61075. /**
  61076. * Number of Simultaneous lights allowed on the material.
  61077. */
  61078. maxSimultaneousLights: number;
  61079. /**
  61080. * If sets to true, disables all the lights affecting the material.
  61081. */
  61082. disableLighting: boolean;
  61083. /**
  61084. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61085. */
  61086. environmentTexture: BaseTexture;
  61087. /**
  61088. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61089. */
  61090. invertNormalMapX: boolean;
  61091. /**
  61092. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61093. */
  61094. invertNormalMapY: boolean;
  61095. /**
  61096. * Normal map used in the model.
  61097. */
  61098. normalTexture: BaseTexture;
  61099. /**
  61100. * Emissivie color used to self-illuminate the model.
  61101. */
  61102. emissiveColor: Color3;
  61103. /**
  61104. * Emissivie texture used to self-illuminate the model.
  61105. */
  61106. emissiveTexture: BaseTexture;
  61107. /**
  61108. * Occlusion Channel Strenght.
  61109. */
  61110. occlusionStrength: number;
  61111. /**
  61112. * Occlusion Texture of the material (adding extra occlusion effects).
  61113. */
  61114. occlusionTexture: BaseTexture;
  61115. /**
  61116. * Defines the alpha limits in alpha test mode.
  61117. */
  61118. alphaCutOff: number;
  61119. /**
  61120. * Gets the current double sided mode.
  61121. */
  61122. get doubleSided(): boolean;
  61123. /**
  61124. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61125. */
  61126. set doubleSided(value: boolean);
  61127. /**
  61128. * Stores the pre-calculated light information of a mesh in a texture.
  61129. */
  61130. lightmapTexture: BaseTexture;
  61131. /**
  61132. * If true, the light map contains occlusion information instead of lighting info.
  61133. */
  61134. useLightmapAsShadowmap: boolean;
  61135. /**
  61136. * Instantiates a new PBRMaterial instance.
  61137. *
  61138. * @param name The material name
  61139. * @param scene The scene the material will be use in.
  61140. */
  61141. constructor(name: string, scene: Scene);
  61142. getClassName(): string;
  61143. }
  61144. }
  61145. declare module BABYLON {
  61146. /**
  61147. * The PBR material of BJS following the metal roughness convention.
  61148. *
  61149. * This fits to the PBR convention in the GLTF definition:
  61150. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61151. */
  61152. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61153. /**
  61154. * The base color has two different interpretations depending on the value of metalness.
  61155. * When the material is a metal, the base color is the specific measured reflectance value
  61156. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61157. * of the material.
  61158. */
  61159. baseColor: Color3;
  61160. /**
  61161. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61162. * well as opacity information in the alpha channel.
  61163. */
  61164. baseTexture: BaseTexture;
  61165. /**
  61166. * Specifies the metallic scalar value of the material.
  61167. * Can also be used to scale the metalness values of the metallic texture.
  61168. */
  61169. metallic: number;
  61170. /**
  61171. * Specifies the roughness scalar value of the material.
  61172. * Can also be used to scale the roughness values of the metallic texture.
  61173. */
  61174. roughness: number;
  61175. /**
  61176. * Texture containing both the metallic value in the B channel and the
  61177. * roughness value in the G channel to keep better precision.
  61178. */
  61179. metallicRoughnessTexture: BaseTexture;
  61180. /**
  61181. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61182. *
  61183. * @param name The material name
  61184. * @param scene The scene the material will be use in.
  61185. */
  61186. constructor(name: string, scene: Scene);
  61187. /**
  61188. * Return the currrent class name of the material.
  61189. */
  61190. getClassName(): string;
  61191. /**
  61192. * Makes a duplicate of the current material.
  61193. * @param name - name to use for the new material.
  61194. */
  61195. clone(name: string): PBRMetallicRoughnessMaterial;
  61196. /**
  61197. * Serialize the material to a parsable JSON object.
  61198. */
  61199. serialize(): any;
  61200. /**
  61201. * Parses a JSON object correponding to the serialize function.
  61202. */
  61203. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61204. }
  61205. }
  61206. declare module BABYLON {
  61207. /**
  61208. * The PBR material of BJS following the specular glossiness convention.
  61209. *
  61210. * This fits to the PBR convention in the GLTF definition:
  61211. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61212. */
  61213. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61214. /**
  61215. * Specifies the diffuse color of the material.
  61216. */
  61217. diffuseColor: Color3;
  61218. /**
  61219. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61220. * channel.
  61221. */
  61222. diffuseTexture: BaseTexture;
  61223. /**
  61224. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61225. */
  61226. specularColor: Color3;
  61227. /**
  61228. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61229. */
  61230. glossiness: number;
  61231. /**
  61232. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61233. */
  61234. specularGlossinessTexture: BaseTexture;
  61235. /**
  61236. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61237. *
  61238. * @param name The material name
  61239. * @param scene The scene the material will be use in.
  61240. */
  61241. constructor(name: string, scene: Scene);
  61242. /**
  61243. * Return the currrent class name of the material.
  61244. */
  61245. getClassName(): string;
  61246. /**
  61247. * Makes a duplicate of the current material.
  61248. * @param name - name to use for the new material.
  61249. */
  61250. clone(name: string): PBRSpecularGlossinessMaterial;
  61251. /**
  61252. * Serialize the material to a parsable JSON object.
  61253. */
  61254. serialize(): any;
  61255. /**
  61256. * Parses a JSON object correponding to the serialize function.
  61257. */
  61258. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61259. }
  61260. }
  61261. declare module BABYLON {
  61262. /**
  61263. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61264. * It can help converting any input color in a desired output one. This can then be used to create effects
  61265. * from sepia, black and white to sixties or futuristic rendering...
  61266. *
  61267. * The only supported format is currently 3dl.
  61268. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61269. */
  61270. export class ColorGradingTexture extends BaseTexture {
  61271. /**
  61272. * The texture URL.
  61273. */
  61274. url: string;
  61275. /**
  61276. * Empty line regex stored for GC.
  61277. */
  61278. private static _noneEmptyLineRegex;
  61279. private _textureMatrix;
  61280. private _onLoad;
  61281. /**
  61282. * Instantiates a ColorGradingTexture from the following parameters.
  61283. *
  61284. * @param url The location of the color gradind data (currently only supporting 3dl)
  61285. * @param sceneOrEngine The scene or engine the texture will be used in
  61286. * @param onLoad defines a callback triggered when the texture has been loaded
  61287. */
  61288. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61289. /**
  61290. * Fires the onload event from the constructor if requested.
  61291. */
  61292. private _triggerOnLoad;
  61293. /**
  61294. * Returns the texture matrix used in most of the material.
  61295. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61296. */
  61297. getTextureMatrix(): Matrix;
  61298. /**
  61299. * Occurs when the file being loaded is a .3dl LUT file.
  61300. */
  61301. private load3dlTexture;
  61302. /**
  61303. * Starts the loading process of the texture.
  61304. */
  61305. private loadTexture;
  61306. /**
  61307. * Clones the color gradind texture.
  61308. */
  61309. clone(): ColorGradingTexture;
  61310. /**
  61311. * Called during delayed load for textures.
  61312. */
  61313. delayLoad(): void;
  61314. /**
  61315. * Parses a color grading texture serialized by Babylon.
  61316. * @param parsedTexture The texture information being parsedTexture
  61317. * @param scene The scene to load the texture in
  61318. * @param rootUrl The root url of the data assets to load
  61319. * @return A color gradind texture
  61320. */
  61321. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61322. /**
  61323. * Serializes the LUT texture to json format.
  61324. */
  61325. serialize(): any;
  61326. }
  61327. }
  61328. declare module BABYLON {
  61329. /**
  61330. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61331. */
  61332. export class EquiRectangularCubeTexture extends BaseTexture {
  61333. /** The six faces of the cube. */
  61334. private static _FacesMapping;
  61335. private _noMipmap;
  61336. private _onLoad;
  61337. private _onError;
  61338. /** The size of the cubemap. */
  61339. private _size;
  61340. /** The buffer of the image. */
  61341. private _buffer;
  61342. /** The width of the input image. */
  61343. private _width;
  61344. /** The height of the input image. */
  61345. private _height;
  61346. /** The URL to the image. */
  61347. url: string;
  61348. /**
  61349. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61350. * @param url The location of the image
  61351. * @param scene The scene the texture will be used in
  61352. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61353. * @param noMipmap Forces to not generate the mipmap if true
  61354. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61355. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61356. * @param onLoad — defines a callback called when texture is loaded
  61357. * @param onError — defines a callback called if there is an error
  61358. */
  61359. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61360. /**
  61361. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61362. */
  61363. private loadImage;
  61364. /**
  61365. * Convert the image buffer into a cubemap and create a CubeTexture.
  61366. */
  61367. private loadTexture;
  61368. /**
  61369. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61370. * @param buffer The ArrayBuffer that should be converted.
  61371. * @returns The buffer as Float32Array.
  61372. */
  61373. private getFloat32ArrayFromArrayBuffer;
  61374. /**
  61375. * Get the current class name of the texture useful for serialization or dynamic coding.
  61376. * @returns "EquiRectangularCubeTexture"
  61377. */
  61378. getClassName(): string;
  61379. /**
  61380. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61381. * @returns A clone of the current EquiRectangularCubeTexture.
  61382. */
  61383. clone(): EquiRectangularCubeTexture;
  61384. }
  61385. }
  61386. declare module BABYLON {
  61387. /**
  61388. * Defines the options related to the creation of an HtmlElementTexture
  61389. */
  61390. export interface IHtmlElementTextureOptions {
  61391. /**
  61392. * Defines wether mip maps should be created or not.
  61393. */
  61394. generateMipMaps?: boolean;
  61395. /**
  61396. * Defines the sampling mode of the texture.
  61397. */
  61398. samplingMode?: number;
  61399. /**
  61400. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61401. */
  61402. engine: Nullable<ThinEngine>;
  61403. /**
  61404. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61405. */
  61406. scene: Nullable<Scene>;
  61407. }
  61408. /**
  61409. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61410. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61411. * is automatically managed.
  61412. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61413. * in your application.
  61414. *
  61415. * As the update is not automatic, you need to call them manually.
  61416. */
  61417. export class HtmlElementTexture extends BaseTexture {
  61418. /**
  61419. * The texture URL.
  61420. */
  61421. element: HTMLVideoElement | HTMLCanvasElement;
  61422. private static readonly DefaultOptions;
  61423. private _textureMatrix;
  61424. private _isVideo;
  61425. private _generateMipMaps;
  61426. private _samplingMode;
  61427. /**
  61428. * Instantiates a HtmlElementTexture from the following parameters.
  61429. *
  61430. * @param name Defines the name of the texture
  61431. * @param element Defines the video or canvas the texture is filled with
  61432. * @param options Defines the other none mandatory texture creation options
  61433. */
  61434. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61435. private _createInternalTexture;
  61436. /**
  61437. * Returns the texture matrix used in most of the material.
  61438. */
  61439. getTextureMatrix(): Matrix;
  61440. /**
  61441. * Updates the content of the texture.
  61442. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61443. */
  61444. update(invertY?: Nullable<boolean>): void;
  61445. }
  61446. }
  61447. declare module BABYLON {
  61448. /**
  61449. * Based on jsTGALoader - Javascript loader for TGA file
  61450. * By Vincent Thibault
  61451. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61452. */
  61453. export class TGATools {
  61454. private static _TYPE_INDEXED;
  61455. private static _TYPE_RGB;
  61456. private static _TYPE_GREY;
  61457. private static _TYPE_RLE_INDEXED;
  61458. private static _TYPE_RLE_RGB;
  61459. private static _TYPE_RLE_GREY;
  61460. private static _ORIGIN_MASK;
  61461. private static _ORIGIN_SHIFT;
  61462. private static _ORIGIN_BL;
  61463. private static _ORIGIN_BR;
  61464. private static _ORIGIN_UL;
  61465. private static _ORIGIN_UR;
  61466. /**
  61467. * Gets the header of a TGA file
  61468. * @param data defines the TGA data
  61469. * @returns the header
  61470. */
  61471. static GetTGAHeader(data: Uint8Array): any;
  61472. /**
  61473. * Uploads TGA content to a Babylon Texture
  61474. * @hidden
  61475. */
  61476. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61477. /** @hidden */
  61478. 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;
  61479. /** @hidden */
  61480. 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;
  61481. /** @hidden */
  61482. 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;
  61483. /** @hidden */
  61484. 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;
  61485. /** @hidden */
  61486. 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;
  61487. /** @hidden */
  61488. 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;
  61489. }
  61490. }
  61491. declare module BABYLON {
  61492. /**
  61493. * Implementation of the TGA Texture Loader.
  61494. * @hidden
  61495. */
  61496. export class _TGATextureLoader implements IInternalTextureLoader {
  61497. /**
  61498. * Defines wether the loader supports cascade loading the different faces.
  61499. */
  61500. readonly supportCascades: boolean;
  61501. /**
  61502. * This returns if the loader support the current file information.
  61503. * @param extension defines the file extension of the file being loaded
  61504. * @returns true if the loader can load the specified file
  61505. */
  61506. canLoad(extension: string): boolean;
  61507. /**
  61508. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61509. * @param data contains the texture data
  61510. * @param texture defines the BabylonJS internal texture
  61511. * @param createPolynomials will be true if polynomials have been requested
  61512. * @param onLoad defines the callback to trigger once the texture is ready
  61513. * @param onError defines the callback to trigger in case of error
  61514. */
  61515. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61516. /**
  61517. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61518. * @param data contains the texture data
  61519. * @param texture defines the BabylonJS internal texture
  61520. * @param callback defines the method to call once ready to upload
  61521. */
  61522. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61523. }
  61524. }
  61525. declare module BABYLON {
  61526. /**
  61527. * Info about the .basis files
  61528. */
  61529. class BasisFileInfo {
  61530. /**
  61531. * If the file has alpha
  61532. */
  61533. hasAlpha: boolean;
  61534. /**
  61535. * Info about each image of the basis file
  61536. */
  61537. images: Array<{
  61538. levels: Array<{
  61539. width: number;
  61540. height: number;
  61541. transcodedPixels: ArrayBufferView;
  61542. }>;
  61543. }>;
  61544. }
  61545. /**
  61546. * Result of transcoding a basis file
  61547. */
  61548. class TranscodeResult {
  61549. /**
  61550. * Info about the .basis file
  61551. */
  61552. fileInfo: BasisFileInfo;
  61553. /**
  61554. * Format to use when loading the file
  61555. */
  61556. format: number;
  61557. }
  61558. /**
  61559. * Configuration options for the Basis transcoder
  61560. */
  61561. export class BasisTranscodeConfiguration {
  61562. /**
  61563. * Supported compression formats used to determine the supported output format of the transcoder
  61564. */
  61565. supportedCompressionFormats?: {
  61566. /**
  61567. * etc1 compression format
  61568. */
  61569. etc1?: boolean;
  61570. /**
  61571. * s3tc compression format
  61572. */
  61573. s3tc?: boolean;
  61574. /**
  61575. * pvrtc compression format
  61576. */
  61577. pvrtc?: boolean;
  61578. /**
  61579. * etc2 compression format
  61580. */
  61581. etc2?: boolean;
  61582. };
  61583. /**
  61584. * If mipmap levels should be loaded for transcoded images (Default: true)
  61585. */
  61586. loadMipmapLevels?: boolean;
  61587. /**
  61588. * Index of a single image to load (Default: all images)
  61589. */
  61590. loadSingleImage?: number;
  61591. }
  61592. /**
  61593. * Used to load .Basis files
  61594. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61595. */
  61596. export class BasisTools {
  61597. private static _IgnoreSupportedFormats;
  61598. /**
  61599. * URL to use when loading the basis transcoder
  61600. */
  61601. static JSModuleURL: string;
  61602. /**
  61603. * URL to use when loading the wasm module for the transcoder
  61604. */
  61605. static WasmModuleURL: string;
  61606. /**
  61607. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61608. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61609. * @returns internal format corresponding to the Basis format
  61610. */
  61611. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61612. private static _WorkerPromise;
  61613. private static _Worker;
  61614. private static _actionId;
  61615. private static _CreateWorkerAsync;
  61616. /**
  61617. * Transcodes a loaded image file to compressed pixel data
  61618. * @param data image data to transcode
  61619. * @param config configuration options for the transcoding
  61620. * @returns a promise resulting in the transcoded image
  61621. */
  61622. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61623. /**
  61624. * Loads a texture from the transcode result
  61625. * @param texture texture load to
  61626. * @param transcodeResult the result of transcoding the basis file to load from
  61627. */
  61628. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61629. }
  61630. }
  61631. declare module BABYLON {
  61632. /**
  61633. * Loader for .basis file format
  61634. */
  61635. export class _BasisTextureLoader implements IInternalTextureLoader {
  61636. /**
  61637. * Defines whether the loader supports cascade loading the different faces.
  61638. */
  61639. readonly supportCascades: boolean;
  61640. /**
  61641. * This returns if the loader support the current file information.
  61642. * @param extension defines the file extension of the file being loaded
  61643. * @returns true if the loader can load the specified file
  61644. */
  61645. canLoad(extension: string): boolean;
  61646. /**
  61647. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61648. * @param data contains the texture data
  61649. * @param texture defines the BabylonJS internal texture
  61650. * @param createPolynomials will be true if polynomials have been requested
  61651. * @param onLoad defines the callback to trigger once the texture is ready
  61652. * @param onError defines the callback to trigger in case of error
  61653. */
  61654. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61655. /**
  61656. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61657. * @param data contains the texture data
  61658. * @param texture defines the BabylonJS internal texture
  61659. * @param callback defines the method to call once ready to upload
  61660. */
  61661. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61662. }
  61663. }
  61664. declare module BABYLON {
  61665. /**
  61666. * Defines the basic options interface of a TexturePacker Frame
  61667. */
  61668. export interface ITexturePackerFrame {
  61669. /**
  61670. * The frame ID
  61671. */
  61672. id: number;
  61673. /**
  61674. * The frames Scale
  61675. */
  61676. scale: Vector2;
  61677. /**
  61678. * The Frames offset
  61679. */
  61680. offset: Vector2;
  61681. }
  61682. /**
  61683. * This is a support class for frame Data on texture packer sets.
  61684. */
  61685. export class TexturePackerFrame implements ITexturePackerFrame {
  61686. /**
  61687. * The frame ID
  61688. */
  61689. id: number;
  61690. /**
  61691. * The frames Scale
  61692. */
  61693. scale: Vector2;
  61694. /**
  61695. * The Frames offset
  61696. */
  61697. offset: Vector2;
  61698. /**
  61699. * Initializes a texture package frame.
  61700. * @param id The numerical frame identifier
  61701. * @param scale Scalar Vector2 for UV frame
  61702. * @param offset Vector2 for the frame position in UV units.
  61703. * @returns TexturePackerFrame
  61704. */
  61705. constructor(id: number, scale: Vector2, offset: Vector2);
  61706. }
  61707. }
  61708. declare module BABYLON {
  61709. /**
  61710. * Defines the basic options interface of a TexturePacker
  61711. */
  61712. export interface ITexturePackerOptions {
  61713. /**
  61714. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61715. */
  61716. map?: string[];
  61717. /**
  61718. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61719. */
  61720. uvsIn?: string;
  61721. /**
  61722. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61723. */
  61724. uvsOut?: string;
  61725. /**
  61726. * number representing the layout style. Defaults to LAYOUT_STRIP
  61727. */
  61728. layout?: number;
  61729. /**
  61730. * number of columns if using custom column count layout(2). This defaults to 4.
  61731. */
  61732. colnum?: number;
  61733. /**
  61734. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61735. */
  61736. updateInputMeshes?: boolean;
  61737. /**
  61738. * boolean flag to dispose all the source textures. Defaults to true.
  61739. */
  61740. disposeSources?: boolean;
  61741. /**
  61742. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61743. */
  61744. fillBlanks?: boolean;
  61745. /**
  61746. * string value representing the context fill style color. Defaults to 'black'.
  61747. */
  61748. customFillColor?: string;
  61749. /**
  61750. * Width and Height Value of each Frame in the TexturePacker Sets
  61751. */
  61752. frameSize?: number;
  61753. /**
  61754. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61755. */
  61756. paddingRatio?: number;
  61757. /**
  61758. * Number that declares the fill method for the padding gutter.
  61759. */
  61760. paddingMode?: number;
  61761. /**
  61762. * If in SUBUV_COLOR padding mode what color to use.
  61763. */
  61764. paddingColor?: Color3 | Color4;
  61765. }
  61766. /**
  61767. * Defines the basic interface of a TexturePacker JSON File
  61768. */
  61769. export interface ITexturePackerJSON {
  61770. /**
  61771. * The frame ID
  61772. */
  61773. name: string;
  61774. /**
  61775. * The base64 channel data
  61776. */
  61777. sets: any;
  61778. /**
  61779. * The options of the Packer
  61780. */
  61781. options: ITexturePackerOptions;
  61782. /**
  61783. * The frame data of the Packer
  61784. */
  61785. frames: Array<number>;
  61786. }
  61787. /**
  61788. * This is a support class that generates a series of packed texture sets.
  61789. * @see https://doc.babylonjs.com/babylon101/materials
  61790. */
  61791. export class TexturePacker {
  61792. /** Packer Layout Constant 0 */
  61793. static readonly LAYOUT_STRIP: number;
  61794. /** Packer Layout Constant 1 */
  61795. static readonly LAYOUT_POWER2: number;
  61796. /** Packer Layout Constant 2 */
  61797. static readonly LAYOUT_COLNUM: number;
  61798. /** Packer Layout Constant 0 */
  61799. static readonly SUBUV_WRAP: number;
  61800. /** Packer Layout Constant 1 */
  61801. static readonly SUBUV_EXTEND: number;
  61802. /** Packer Layout Constant 2 */
  61803. static readonly SUBUV_COLOR: number;
  61804. /** The Name of the Texture Package */
  61805. name: string;
  61806. /** The scene scope of the TexturePacker */
  61807. scene: Scene;
  61808. /** The Meshes to target */
  61809. meshes: AbstractMesh[];
  61810. /** Arguments passed with the Constructor */
  61811. options: ITexturePackerOptions;
  61812. /** The promise that is started upon initialization */
  61813. promise: Nullable<Promise<TexturePacker | string>>;
  61814. /** The Container object for the channel sets that are generated */
  61815. sets: object;
  61816. /** The Container array for the frames that are generated */
  61817. frames: TexturePackerFrame[];
  61818. /** The expected number of textures the system is parsing. */
  61819. private _expecting;
  61820. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61821. private _paddingValue;
  61822. /**
  61823. * Initializes a texture package series from an array of meshes or a single mesh.
  61824. * @param name The name of the package
  61825. * @param meshes The target meshes to compose the package from
  61826. * @param options The arguments that texture packer should follow while building.
  61827. * @param scene The scene which the textures are scoped to.
  61828. * @returns TexturePacker
  61829. */
  61830. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61831. /**
  61832. * Starts the package process
  61833. * @param resolve The promises resolution function
  61834. * @returns TexturePacker
  61835. */
  61836. private _createFrames;
  61837. /**
  61838. * Calculates the Size of the Channel Sets
  61839. * @returns Vector2
  61840. */
  61841. private _calculateSize;
  61842. /**
  61843. * Calculates the UV data for the frames.
  61844. * @param baseSize the base frameSize
  61845. * @param padding the base frame padding
  61846. * @param dtSize size of the Dynamic Texture for that channel
  61847. * @param dtUnits is 1/dtSize
  61848. * @param update flag to update the input meshes
  61849. */
  61850. private _calculateMeshUVFrames;
  61851. /**
  61852. * Calculates the frames Offset.
  61853. * @param index of the frame
  61854. * @returns Vector2
  61855. */
  61856. private _getFrameOffset;
  61857. /**
  61858. * Updates a Mesh to the frame data
  61859. * @param mesh that is the target
  61860. * @param frameID or the frame index
  61861. */
  61862. private _updateMeshUV;
  61863. /**
  61864. * Updates a Meshes materials to use the texture packer channels
  61865. * @param m is the mesh to target
  61866. * @param force all channels on the packer to be set.
  61867. */
  61868. private _updateTextureReferences;
  61869. /**
  61870. * Public method to set a Mesh to a frame
  61871. * @param m that is the target
  61872. * @param frameID or the frame index
  61873. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61874. */
  61875. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61876. /**
  61877. * Starts the async promise to compile the texture packer.
  61878. * @returns Promise<void>
  61879. */
  61880. processAsync(): Promise<void>;
  61881. /**
  61882. * Disposes all textures associated with this packer
  61883. */
  61884. dispose(): void;
  61885. /**
  61886. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61887. * @param imageType is the image type to use.
  61888. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61889. */
  61890. download(imageType?: string, quality?: number): void;
  61891. /**
  61892. * Public method to load a texturePacker JSON file.
  61893. * @param data of the JSON file in string format.
  61894. */
  61895. updateFromJSON(data: string): void;
  61896. }
  61897. }
  61898. declare module BABYLON {
  61899. /**
  61900. * 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.
  61901. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61902. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61903. */
  61904. export class CustomProceduralTexture extends ProceduralTexture {
  61905. private _animate;
  61906. private _time;
  61907. private _config;
  61908. private _texturePath;
  61909. /**
  61910. * Instantiates a new Custom Procedural Texture.
  61911. * 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.
  61912. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61913. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61914. * @param name Define the name of the texture
  61915. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61916. * @param size Define the size of the texture to create
  61917. * @param scene Define the scene the texture belongs to
  61918. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61919. * @param generateMipMaps Define if the texture should creates mip maps or not
  61920. */
  61921. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61922. private _loadJson;
  61923. /**
  61924. * Is the texture ready to be used ? (rendered at least once)
  61925. * @returns true if ready, otherwise, false.
  61926. */
  61927. isReady(): boolean;
  61928. /**
  61929. * Render the texture to its associated render target.
  61930. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61931. */
  61932. render(useCameraPostProcess?: boolean): void;
  61933. /**
  61934. * Update the list of dependant textures samplers in the shader.
  61935. */
  61936. updateTextures(): void;
  61937. /**
  61938. * Update the uniform values of the procedural texture in the shader.
  61939. */
  61940. updateShaderUniforms(): void;
  61941. /**
  61942. * Define if the texture animates or not.
  61943. */
  61944. get animate(): boolean;
  61945. set animate(value: boolean);
  61946. }
  61947. }
  61948. declare module BABYLON {
  61949. /** @hidden */
  61950. export var noisePixelShader: {
  61951. name: string;
  61952. shader: string;
  61953. };
  61954. }
  61955. declare module BABYLON {
  61956. /**
  61957. * Class used to generate noise procedural textures
  61958. */
  61959. export class NoiseProceduralTexture extends ProceduralTexture {
  61960. private _time;
  61961. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61962. brightness: number;
  61963. /** Defines the number of octaves to process */
  61964. octaves: number;
  61965. /** Defines the level of persistence (0.8 by default) */
  61966. persistence: number;
  61967. /** Gets or sets animation speed factor (default is 1) */
  61968. animationSpeedFactor: number;
  61969. /**
  61970. * Creates a new NoiseProceduralTexture
  61971. * @param name defines the name fo the texture
  61972. * @param size defines the size of the texture (default is 256)
  61973. * @param scene defines the hosting scene
  61974. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61975. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61976. */
  61977. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61978. private _updateShaderUniforms;
  61979. protected _getDefines(): string;
  61980. /** Generate the current state of the procedural texture */
  61981. render(useCameraPostProcess?: boolean): void;
  61982. /**
  61983. * Serializes this noise procedural texture
  61984. * @returns a serialized noise procedural texture object
  61985. */
  61986. serialize(): any;
  61987. /**
  61988. * Clone the texture.
  61989. * @returns the cloned texture
  61990. */
  61991. clone(): NoiseProceduralTexture;
  61992. /**
  61993. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61994. * @param parsedTexture defines parsed texture data
  61995. * @param scene defines the current scene
  61996. * @param rootUrl defines the root URL containing noise procedural texture information
  61997. * @returns a parsed NoiseProceduralTexture
  61998. */
  61999. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62000. }
  62001. }
  62002. declare module BABYLON {
  62003. /**
  62004. * Raw cube texture where the raw buffers are passed in
  62005. */
  62006. export class RawCubeTexture extends CubeTexture {
  62007. /**
  62008. * Creates a cube texture where the raw buffers are passed in.
  62009. * @param scene defines the scene the texture is attached to
  62010. * @param data defines the array of data to use to create each face
  62011. * @param size defines the size of the textures
  62012. * @param format defines the format of the data
  62013. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62014. * @param generateMipMaps defines if the engine should generate the mip levels
  62015. * @param invertY defines if data must be stored with Y axis inverted
  62016. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62017. * @param compression defines the compression used (null by default)
  62018. */
  62019. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62020. /**
  62021. * Updates the raw cube texture.
  62022. * @param data defines the data to store
  62023. * @param format defines the data format
  62024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62025. * @param invertY defines if data must be stored with Y axis inverted
  62026. * @param compression defines the compression used (null by default)
  62027. * @param level defines which level of the texture to update
  62028. */
  62029. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62030. /**
  62031. * Updates a raw cube texture with RGBD encoded data.
  62032. * @param data defines the array of data [mipmap][face] to use to create each face
  62033. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62034. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62035. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62036. * @returns a promsie that resolves when the operation is complete
  62037. */
  62038. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62039. /**
  62040. * Clones the raw cube texture.
  62041. * @return a new cube texture
  62042. */
  62043. clone(): CubeTexture;
  62044. /** @hidden */
  62045. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62046. }
  62047. }
  62048. declare module BABYLON {
  62049. /**
  62050. * Class used to store 2D array textures containing user data
  62051. */
  62052. export class RawTexture2DArray extends Texture {
  62053. /** Gets or sets the texture format to use */
  62054. format: number;
  62055. /**
  62056. * Create a new RawTexture2DArray
  62057. * @param data defines the data of the texture
  62058. * @param width defines the width of the texture
  62059. * @param height defines the height of the texture
  62060. * @param depth defines the number of layers of the texture
  62061. * @param format defines the texture format to use
  62062. * @param scene defines the hosting scene
  62063. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62064. * @param invertY defines if texture must be stored with Y axis inverted
  62065. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62066. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62067. */
  62068. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62069. /** Gets or sets the texture format to use */
  62070. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62071. /**
  62072. * Update the texture with new data
  62073. * @param data defines the data to store in the texture
  62074. */
  62075. update(data: ArrayBufferView): void;
  62076. }
  62077. }
  62078. declare module BABYLON {
  62079. /**
  62080. * Class used to store 3D textures containing user data
  62081. */
  62082. export class RawTexture3D extends Texture {
  62083. /** Gets or sets the texture format to use */
  62084. format: number;
  62085. /**
  62086. * Create a new RawTexture3D
  62087. * @param data defines the data of the texture
  62088. * @param width defines the width of the texture
  62089. * @param height defines the height of the texture
  62090. * @param depth defines the depth of the texture
  62091. * @param format defines the texture format to use
  62092. * @param scene defines the hosting scene
  62093. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62094. * @param invertY defines if texture must be stored with Y axis inverted
  62095. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62096. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62097. */
  62098. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62099. /** Gets or sets the texture format to use */
  62100. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62101. /**
  62102. * Update the texture with new data
  62103. * @param data defines the data to store in the texture
  62104. */
  62105. update(data: ArrayBufferView): void;
  62106. }
  62107. }
  62108. declare module BABYLON {
  62109. /**
  62110. * Creates a refraction texture used by refraction channel of the standard material.
  62111. * It is like a mirror but to see through a material.
  62112. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62113. */
  62114. export class RefractionTexture extends RenderTargetTexture {
  62115. /**
  62116. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62117. * 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.
  62118. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62119. */
  62120. refractionPlane: Plane;
  62121. /**
  62122. * Define how deep under the surface we should see.
  62123. */
  62124. depth: number;
  62125. /**
  62126. * Creates a refraction texture used by refraction channel of the standard material.
  62127. * It is like a mirror but to see through a material.
  62128. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62129. * @param name Define the texture name
  62130. * @param size Define the size of the underlying texture
  62131. * @param scene Define the scene the refraction belongs to
  62132. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62133. */
  62134. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62135. /**
  62136. * Clone the refraction texture.
  62137. * @returns the cloned texture
  62138. */
  62139. clone(): RefractionTexture;
  62140. /**
  62141. * Serialize the texture to a JSON representation you could use in Parse later on
  62142. * @returns the serialized JSON representation
  62143. */
  62144. serialize(): any;
  62145. }
  62146. }
  62147. declare module BABYLON {
  62148. /**
  62149. * Block used to add support for vertex skinning (bones)
  62150. */
  62151. export class BonesBlock extends NodeMaterialBlock {
  62152. /**
  62153. * Creates a new BonesBlock
  62154. * @param name defines the block name
  62155. */
  62156. constructor(name: string);
  62157. /**
  62158. * Initialize the block and prepare the context for build
  62159. * @param state defines the state that will be used for the build
  62160. */
  62161. initialize(state: NodeMaterialBuildState): void;
  62162. /**
  62163. * Gets the current class name
  62164. * @returns the class name
  62165. */
  62166. getClassName(): string;
  62167. /**
  62168. * Gets the matrix indices input component
  62169. */
  62170. get matricesIndices(): NodeMaterialConnectionPoint;
  62171. /**
  62172. * Gets the matrix weights input component
  62173. */
  62174. get matricesWeights(): NodeMaterialConnectionPoint;
  62175. /**
  62176. * Gets the extra matrix indices input component
  62177. */
  62178. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62179. /**
  62180. * Gets the extra matrix weights input component
  62181. */
  62182. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62183. /**
  62184. * Gets the world input component
  62185. */
  62186. get world(): NodeMaterialConnectionPoint;
  62187. /**
  62188. * Gets the output component
  62189. */
  62190. get output(): NodeMaterialConnectionPoint;
  62191. autoConfigure(material: NodeMaterial): void;
  62192. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62195. protected _buildBlock(state: NodeMaterialBuildState): this;
  62196. }
  62197. }
  62198. declare module BABYLON {
  62199. /**
  62200. * Block used to add support for instances
  62201. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62202. */
  62203. export class InstancesBlock extends NodeMaterialBlock {
  62204. /**
  62205. * Creates a new InstancesBlock
  62206. * @param name defines the block name
  62207. */
  62208. constructor(name: string);
  62209. /**
  62210. * Gets the current class name
  62211. * @returns the class name
  62212. */
  62213. getClassName(): string;
  62214. /**
  62215. * Gets the first world row input component
  62216. */
  62217. get world0(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the second world row input component
  62220. */
  62221. get world1(): NodeMaterialConnectionPoint;
  62222. /**
  62223. * Gets the third world row input component
  62224. */
  62225. get world2(): NodeMaterialConnectionPoint;
  62226. /**
  62227. * Gets the forth world row input component
  62228. */
  62229. get world3(): NodeMaterialConnectionPoint;
  62230. /**
  62231. * Gets the world input component
  62232. */
  62233. get world(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the output component
  62236. */
  62237. get output(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the isntanceID component
  62240. */
  62241. get instanceID(): NodeMaterialConnectionPoint;
  62242. autoConfigure(material: NodeMaterial): void;
  62243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62244. protected _buildBlock(state: NodeMaterialBuildState): this;
  62245. }
  62246. }
  62247. declare module BABYLON {
  62248. /**
  62249. * Block used to add morph targets support to vertex shader
  62250. */
  62251. export class MorphTargetsBlock extends NodeMaterialBlock {
  62252. private _repeatableContentAnchor;
  62253. /**
  62254. * Create a new MorphTargetsBlock
  62255. * @param name defines the block name
  62256. */
  62257. constructor(name: string);
  62258. /**
  62259. * Gets the current class name
  62260. * @returns the class name
  62261. */
  62262. getClassName(): string;
  62263. /**
  62264. * Gets the position input component
  62265. */
  62266. get position(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the normal input component
  62269. */
  62270. get normal(): NodeMaterialConnectionPoint;
  62271. /**
  62272. * Gets the tangent input component
  62273. */
  62274. get tangent(): NodeMaterialConnectionPoint;
  62275. /**
  62276. * Gets the tangent input component
  62277. */
  62278. get uv(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the position output component
  62281. */
  62282. get positionOutput(): NodeMaterialConnectionPoint;
  62283. /**
  62284. * Gets the normal output component
  62285. */
  62286. get normalOutput(): NodeMaterialConnectionPoint;
  62287. /**
  62288. * Gets the tangent output component
  62289. */
  62290. get tangentOutput(): NodeMaterialConnectionPoint;
  62291. /**
  62292. * Gets the tangent output component
  62293. */
  62294. get uvOutput(): NodeMaterialConnectionPoint;
  62295. initialize(state: NodeMaterialBuildState): void;
  62296. autoConfigure(material: NodeMaterial): void;
  62297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62299. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62300. protected _buildBlock(state: NodeMaterialBuildState): this;
  62301. }
  62302. }
  62303. declare module BABYLON {
  62304. /**
  62305. * Block used to get data information from a light
  62306. */
  62307. export class LightInformationBlock extends NodeMaterialBlock {
  62308. private _lightDataUniformName;
  62309. private _lightColorUniformName;
  62310. private _lightTypeDefineName;
  62311. /**
  62312. * Gets or sets the light associated with this block
  62313. */
  62314. light: Nullable<Light>;
  62315. /**
  62316. * Creates a new LightInformationBlock
  62317. * @param name defines the block name
  62318. */
  62319. constructor(name: string);
  62320. /**
  62321. * Gets the current class name
  62322. * @returns the class name
  62323. */
  62324. getClassName(): string;
  62325. /**
  62326. * Gets the world position input component
  62327. */
  62328. get worldPosition(): NodeMaterialConnectionPoint;
  62329. /**
  62330. * Gets the direction output component
  62331. */
  62332. get direction(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the direction output component
  62335. */
  62336. get color(): NodeMaterialConnectionPoint;
  62337. /**
  62338. * Gets the direction output component
  62339. */
  62340. get intensity(): NodeMaterialConnectionPoint;
  62341. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62343. protected _buildBlock(state: NodeMaterialBuildState): this;
  62344. serialize(): any;
  62345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62346. }
  62347. }
  62348. declare module BABYLON {
  62349. /**
  62350. * Block used to add image processing support to fragment shader
  62351. */
  62352. export class ImageProcessingBlock extends NodeMaterialBlock {
  62353. /**
  62354. * Create a new ImageProcessingBlock
  62355. * @param name defines the block name
  62356. */
  62357. constructor(name: string);
  62358. /**
  62359. * Gets the current class name
  62360. * @returns the class name
  62361. */
  62362. getClassName(): string;
  62363. /**
  62364. * Gets the color input component
  62365. */
  62366. get color(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the output component
  62369. */
  62370. get output(): NodeMaterialConnectionPoint;
  62371. /**
  62372. * Initialize the block and prepare the context for build
  62373. * @param state defines the state that will be used for the build
  62374. */
  62375. initialize(state: NodeMaterialBuildState): void;
  62376. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62379. protected _buildBlock(state: NodeMaterialBuildState): this;
  62380. }
  62381. }
  62382. declare module BABYLON {
  62383. /**
  62384. * Block used to pertub normals based on a normal map
  62385. */
  62386. export class PerturbNormalBlock extends NodeMaterialBlock {
  62387. private _tangentSpaceParameterName;
  62388. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62389. invertX: boolean;
  62390. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62391. invertY: boolean;
  62392. /**
  62393. * Create a new PerturbNormalBlock
  62394. * @param name defines the block name
  62395. */
  62396. constructor(name: string);
  62397. /**
  62398. * Gets the current class name
  62399. * @returns the class name
  62400. */
  62401. getClassName(): string;
  62402. /**
  62403. * Gets the world position input component
  62404. */
  62405. get worldPosition(): NodeMaterialConnectionPoint;
  62406. /**
  62407. * Gets the world normal input component
  62408. */
  62409. get worldNormal(): NodeMaterialConnectionPoint;
  62410. /**
  62411. * Gets the world tangent input component
  62412. */
  62413. get worldTangent(): NodeMaterialConnectionPoint;
  62414. /**
  62415. * Gets the uv input component
  62416. */
  62417. get uv(): NodeMaterialConnectionPoint;
  62418. /**
  62419. * Gets the normal map color input component
  62420. */
  62421. get normalMapColor(): NodeMaterialConnectionPoint;
  62422. /**
  62423. * Gets the strength input component
  62424. */
  62425. get strength(): NodeMaterialConnectionPoint;
  62426. /**
  62427. * Gets the output component
  62428. */
  62429. get output(): NodeMaterialConnectionPoint;
  62430. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62431. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62432. autoConfigure(material: NodeMaterial): void;
  62433. protected _buildBlock(state: NodeMaterialBuildState): this;
  62434. protected _dumpPropertiesCode(): string;
  62435. serialize(): any;
  62436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62437. }
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * Block used to discard a pixel if a value is smaller than a cutoff
  62442. */
  62443. export class DiscardBlock extends NodeMaterialBlock {
  62444. /**
  62445. * Create a new DiscardBlock
  62446. * @param name defines the block name
  62447. */
  62448. constructor(name: string);
  62449. /**
  62450. * Gets the current class name
  62451. * @returns the class name
  62452. */
  62453. getClassName(): string;
  62454. /**
  62455. * Gets the color input component
  62456. */
  62457. get value(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the cutoff input component
  62460. */
  62461. get cutoff(): NodeMaterialConnectionPoint;
  62462. protected _buildBlock(state: NodeMaterialBuildState): this;
  62463. }
  62464. }
  62465. declare module BABYLON {
  62466. /**
  62467. * Block used to test if the fragment shader is front facing
  62468. */
  62469. export class FrontFacingBlock extends NodeMaterialBlock {
  62470. /**
  62471. * Creates a new FrontFacingBlock
  62472. * @param name defines the block name
  62473. */
  62474. constructor(name: string);
  62475. /**
  62476. * Gets the current class name
  62477. * @returns the class name
  62478. */
  62479. getClassName(): string;
  62480. /**
  62481. * Gets the output component
  62482. */
  62483. get output(): NodeMaterialConnectionPoint;
  62484. protected _buildBlock(state: NodeMaterialBuildState): this;
  62485. }
  62486. }
  62487. declare module BABYLON {
  62488. /**
  62489. * Block used to get the derivative value on x and y of a given input
  62490. */
  62491. export class DerivativeBlock extends NodeMaterialBlock {
  62492. /**
  62493. * Create a new DerivativeBlock
  62494. * @param name defines the block name
  62495. */
  62496. constructor(name: string);
  62497. /**
  62498. * Gets the current class name
  62499. * @returns the class name
  62500. */
  62501. getClassName(): string;
  62502. /**
  62503. * Gets the input component
  62504. */
  62505. get input(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Gets the derivative output on x
  62508. */
  62509. get dx(): NodeMaterialConnectionPoint;
  62510. /**
  62511. * Gets the derivative output on y
  62512. */
  62513. get dy(): NodeMaterialConnectionPoint;
  62514. protected _buildBlock(state: NodeMaterialBuildState): this;
  62515. }
  62516. }
  62517. declare module BABYLON {
  62518. /**
  62519. * Block used to make gl_FragCoord available
  62520. */
  62521. export class FragCoordBlock extends NodeMaterialBlock {
  62522. /**
  62523. * Creates a new FragCoordBlock
  62524. * @param name defines the block name
  62525. */
  62526. constructor(name: string);
  62527. /**
  62528. * Gets the current class name
  62529. * @returns the class name
  62530. */
  62531. getClassName(): string;
  62532. /**
  62533. * Gets the xy component
  62534. */
  62535. get xy(): NodeMaterialConnectionPoint;
  62536. /**
  62537. * Gets the xyz component
  62538. */
  62539. get xyz(): NodeMaterialConnectionPoint;
  62540. /**
  62541. * Gets the xyzw component
  62542. */
  62543. get xyzw(): NodeMaterialConnectionPoint;
  62544. /**
  62545. * Gets the x component
  62546. */
  62547. get x(): NodeMaterialConnectionPoint;
  62548. /**
  62549. * Gets the y component
  62550. */
  62551. get y(): NodeMaterialConnectionPoint;
  62552. /**
  62553. * Gets the z component
  62554. */
  62555. get z(): NodeMaterialConnectionPoint;
  62556. /**
  62557. * Gets the w component
  62558. */
  62559. get output(): NodeMaterialConnectionPoint;
  62560. protected writeOutputs(state: NodeMaterialBuildState): string;
  62561. protected _buildBlock(state: NodeMaterialBuildState): this;
  62562. }
  62563. }
  62564. declare module BABYLON {
  62565. /**
  62566. * Block used to get the screen sizes
  62567. */
  62568. export class ScreenSizeBlock extends NodeMaterialBlock {
  62569. private _varName;
  62570. private _scene;
  62571. /**
  62572. * Creates a new ScreenSizeBlock
  62573. * @param name defines the block name
  62574. */
  62575. constructor(name: string);
  62576. /**
  62577. * Gets the current class name
  62578. * @returns the class name
  62579. */
  62580. getClassName(): string;
  62581. /**
  62582. * Gets the xy component
  62583. */
  62584. get xy(): NodeMaterialConnectionPoint;
  62585. /**
  62586. * Gets the x component
  62587. */
  62588. get x(): NodeMaterialConnectionPoint;
  62589. /**
  62590. * Gets the y component
  62591. */
  62592. get y(): NodeMaterialConnectionPoint;
  62593. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62594. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62595. protected _buildBlock(state: NodeMaterialBuildState): this;
  62596. }
  62597. }
  62598. declare module BABYLON {
  62599. /**
  62600. * Block used to add support for scene fog
  62601. */
  62602. export class FogBlock extends NodeMaterialBlock {
  62603. private _fogDistanceName;
  62604. private _fogParameters;
  62605. /**
  62606. * Create a new FogBlock
  62607. * @param name defines the block name
  62608. */
  62609. constructor(name: string);
  62610. /**
  62611. * Gets the current class name
  62612. * @returns the class name
  62613. */
  62614. getClassName(): string;
  62615. /**
  62616. * Gets the world position input component
  62617. */
  62618. get worldPosition(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the view input component
  62621. */
  62622. get view(): NodeMaterialConnectionPoint;
  62623. /**
  62624. * Gets the color input component
  62625. */
  62626. get input(): NodeMaterialConnectionPoint;
  62627. /**
  62628. * Gets the fog color input component
  62629. */
  62630. get fogColor(): NodeMaterialConnectionPoint;
  62631. /**
  62632. * Gets the output component
  62633. */
  62634. get output(): NodeMaterialConnectionPoint;
  62635. autoConfigure(material: NodeMaterial): void;
  62636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62638. protected _buildBlock(state: NodeMaterialBuildState): this;
  62639. }
  62640. }
  62641. declare module BABYLON {
  62642. /**
  62643. * Block used to add light in the fragment shader
  62644. */
  62645. export class LightBlock extends NodeMaterialBlock {
  62646. private _lightId;
  62647. /**
  62648. * Gets or sets the light associated with this block
  62649. */
  62650. light: Nullable<Light>;
  62651. /**
  62652. * Create a new LightBlock
  62653. * @param name defines the block name
  62654. */
  62655. constructor(name: string);
  62656. /**
  62657. * Gets the current class name
  62658. * @returns the class name
  62659. */
  62660. getClassName(): string;
  62661. /**
  62662. * Gets the world position input component
  62663. */
  62664. get worldPosition(): NodeMaterialConnectionPoint;
  62665. /**
  62666. * Gets the world normal input component
  62667. */
  62668. get worldNormal(): NodeMaterialConnectionPoint;
  62669. /**
  62670. * Gets the camera (or eye) position component
  62671. */
  62672. get cameraPosition(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the glossiness component
  62675. */
  62676. get glossiness(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Gets the glossinness power component
  62679. */
  62680. get glossPower(): NodeMaterialConnectionPoint;
  62681. /**
  62682. * Gets the diffuse color component
  62683. */
  62684. get diffuseColor(): NodeMaterialConnectionPoint;
  62685. /**
  62686. * Gets the specular color component
  62687. */
  62688. get specularColor(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the diffuse output component
  62691. */
  62692. get diffuseOutput(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the specular output component
  62695. */
  62696. get specularOutput(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the shadow output component
  62699. */
  62700. get shadow(): NodeMaterialConnectionPoint;
  62701. autoConfigure(material: NodeMaterial): void;
  62702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62703. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62705. private _injectVertexCode;
  62706. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62707. serialize(): any;
  62708. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62709. }
  62710. }
  62711. declare module BABYLON {
  62712. /**
  62713. * Block used to read a reflection texture from a sampler
  62714. */
  62715. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62716. /**
  62717. * Create a new ReflectionTextureBlock
  62718. * @param name defines the block name
  62719. */
  62720. constructor(name: string);
  62721. /**
  62722. * Gets the current class name
  62723. * @returns the class name
  62724. */
  62725. getClassName(): string;
  62726. /**
  62727. * Gets the world position input component
  62728. */
  62729. get position(): NodeMaterialConnectionPoint;
  62730. /**
  62731. * Gets the world position input component
  62732. */
  62733. get worldPosition(): NodeMaterialConnectionPoint;
  62734. /**
  62735. * Gets the world normal input component
  62736. */
  62737. get worldNormal(): NodeMaterialConnectionPoint;
  62738. /**
  62739. * Gets the world input component
  62740. */
  62741. get world(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the camera (or eye) position component
  62744. */
  62745. get cameraPosition(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the view input component
  62748. */
  62749. get view(): NodeMaterialConnectionPoint;
  62750. /**
  62751. * Gets the rgb output component
  62752. */
  62753. get rgb(): NodeMaterialConnectionPoint;
  62754. /**
  62755. * Gets the rgba output component
  62756. */
  62757. get rgba(): NodeMaterialConnectionPoint;
  62758. /**
  62759. * Gets the r output component
  62760. */
  62761. get r(): NodeMaterialConnectionPoint;
  62762. /**
  62763. * Gets the g output component
  62764. */
  62765. get g(): NodeMaterialConnectionPoint;
  62766. /**
  62767. * Gets the b output component
  62768. */
  62769. get b(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the a output component
  62772. */
  62773. get a(): NodeMaterialConnectionPoint;
  62774. autoConfigure(material: NodeMaterial): void;
  62775. protected _buildBlock(state: NodeMaterialBuildState): this;
  62776. }
  62777. }
  62778. declare module BABYLON {
  62779. /**
  62780. * Block used to add 2 vectors
  62781. */
  62782. export class AddBlock extends NodeMaterialBlock {
  62783. /**
  62784. * Creates a new AddBlock
  62785. * @param name defines the block name
  62786. */
  62787. constructor(name: string);
  62788. /**
  62789. * Gets the current class name
  62790. * @returns the class name
  62791. */
  62792. getClassName(): string;
  62793. /**
  62794. * Gets the left operand input component
  62795. */
  62796. get left(): NodeMaterialConnectionPoint;
  62797. /**
  62798. * Gets the right operand input component
  62799. */
  62800. get right(): NodeMaterialConnectionPoint;
  62801. /**
  62802. * Gets the output component
  62803. */
  62804. get output(): NodeMaterialConnectionPoint;
  62805. protected _buildBlock(state: NodeMaterialBuildState): this;
  62806. }
  62807. }
  62808. declare module BABYLON {
  62809. /**
  62810. * Block used to scale a vector by a float
  62811. */
  62812. export class ScaleBlock extends NodeMaterialBlock {
  62813. /**
  62814. * Creates a new ScaleBlock
  62815. * @param name defines the block name
  62816. */
  62817. constructor(name: string);
  62818. /**
  62819. * Gets the current class name
  62820. * @returns the class name
  62821. */
  62822. getClassName(): string;
  62823. /**
  62824. * Gets the input component
  62825. */
  62826. get input(): NodeMaterialConnectionPoint;
  62827. /**
  62828. * Gets the factor input component
  62829. */
  62830. get factor(): NodeMaterialConnectionPoint;
  62831. /**
  62832. * Gets the output component
  62833. */
  62834. get output(): NodeMaterialConnectionPoint;
  62835. protected _buildBlock(state: NodeMaterialBuildState): this;
  62836. }
  62837. }
  62838. declare module BABYLON {
  62839. /**
  62840. * Block used to clamp a float
  62841. */
  62842. export class ClampBlock extends NodeMaterialBlock {
  62843. /** Gets or sets the minimum range */
  62844. minimum: number;
  62845. /** Gets or sets the maximum range */
  62846. maximum: number;
  62847. /**
  62848. * Creates a new ClampBlock
  62849. * @param name defines the block name
  62850. */
  62851. constructor(name: string);
  62852. /**
  62853. * Gets the current class name
  62854. * @returns the class name
  62855. */
  62856. getClassName(): string;
  62857. /**
  62858. * Gets the value input component
  62859. */
  62860. get value(): NodeMaterialConnectionPoint;
  62861. /**
  62862. * Gets the output component
  62863. */
  62864. get output(): NodeMaterialConnectionPoint;
  62865. protected _buildBlock(state: NodeMaterialBuildState): this;
  62866. protected _dumpPropertiesCode(): string;
  62867. serialize(): any;
  62868. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62869. }
  62870. }
  62871. declare module BABYLON {
  62872. /**
  62873. * Block used to apply a cross product between 2 vectors
  62874. */
  62875. export class CrossBlock extends NodeMaterialBlock {
  62876. /**
  62877. * Creates a new CrossBlock
  62878. * @param name defines the block name
  62879. */
  62880. constructor(name: string);
  62881. /**
  62882. * Gets the current class name
  62883. * @returns the class name
  62884. */
  62885. getClassName(): string;
  62886. /**
  62887. * Gets the left operand input component
  62888. */
  62889. get left(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the right operand input component
  62892. */
  62893. get right(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the output component
  62896. */
  62897. get output(): NodeMaterialConnectionPoint;
  62898. protected _buildBlock(state: NodeMaterialBuildState): this;
  62899. }
  62900. }
  62901. declare module BABYLON {
  62902. /**
  62903. * Block used to apply a dot product between 2 vectors
  62904. */
  62905. export class DotBlock extends NodeMaterialBlock {
  62906. /**
  62907. * Creates a new DotBlock
  62908. * @param name defines the block name
  62909. */
  62910. constructor(name: string);
  62911. /**
  62912. * Gets the current class name
  62913. * @returns the class name
  62914. */
  62915. getClassName(): string;
  62916. /**
  62917. * Gets the left operand input component
  62918. */
  62919. get left(): NodeMaterialConnectionPoint;
  62920. /**
  62921. * Gets the right operand input component
  62922. */
  62923. get right(): NodeMaterialConnectionPoint;
  62924. /**
  62925. * Gets the output component
  62926. */
  62927. get output(): NodeMaterialConnectionPoint;
  62928. protected _buildBlock(state: NodeMaterialBuildState): this;
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /**
  62933. * Block used to normalize a vector
  62934. */
  62935. export class NormalizeBlock extends NodeMaterialBlock {
  62936. /**
  62937. * Creates a new NormalizeBlock
  62938. * @param name defines the block name
  62939. */
  62940. constructor(name: string);
  62941. /**
  62942. * Gets the current class name
  62943. * @returns the class name
  62944. */
  62945. getClassName(): string;
  62946. /**
  62947. * Gets the input component
  62948. */
  62949. get input(): NodeMaterialConnectionPoint;
  62950. /**
  62951. * Gets the output component
  62952. */
  62953. get output(): NodeMaterialConnectionPoint;
  62954. protected _buildBlock(state: NodeMaterialBuildState): this;
  62955. }
  62956. }
  62957. declare module BABYLON {
  62958. /**
  62959. * Operations supported by the Trigonometry block
  62960. */
  62961. export enum TrigonometryBlockOperations {
  62962. /** Cos */
  62963. Cos = 0,
  62964. /** Sin */
  62965. Sin = 1,
  62966. /** Abs */
  62967. Abs = 2,
  62968. /** Exp */
  62969. Exp = 3,
  62970. /** Exp2 */
  62971. Exp2 = 4,
  62972. /** Round */
  62973. Round = 5,
  62974. /** Floor */
  62975. Floor = 6,
  62976. /** Ceiling */
  62977. Ceiling = 7,
  62978. /** Square root */
  62979. Sqrt = 8,
  62980. /** Log */
  62981. Log = 9,
  62982. /** Tangent */
  62983. Tan = 10,
  62984. /** Arc tangent */
  62985. ArcTan = 11,
  62986. /** Arc cosinus */
  62987. ArcCos = 12,
  62988. /** Arc sinus */
  62989. ArcSin = 13,
  62990. /** Fraction */
  62991. Fract = 14,
  62992. /** Sign */
  62993. Sign = 15,
  62994. /** To radians (from degrees) */
  62995. Radians = 16,
  62996. /** To degrees (from radians) */
  62997. Degrees = 17
  62998. }
  62999. /**
  63000. * Block used to apply trigonometry operation to floats
  63001. */
  63002. export class TrigonometryBlock extends NodeMaterialBlock {
  63003. /**
  63004. * Gets or sets the operation applied by the block
  63005. */
  63006. operation: TrigonometryBlockOperations;
  63007. /**
  63008. * Creates a new TrigonometryBlock
  63009. * @param name defines the block name
  63010. */
  63011. constructor(name: string);
  63012. /**
  63013. * Gets the current class name
  63014. * @returns the class name
  63015. */
  63016. getClassName(): string;
  63017. /**
  63018. * Gets the input component
  63019. */
  63020. get input(): NodeMaterialConnectionPoint;
  63021. /**
  63022. * Gets the output component
  63023. */
  63024. get output(): NodeMaterialConnectionPoint;
  63025. protected _buildBlock(state: NodeMaterialBuildState): this;
  63026. serialize(): any;
  63027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63028. protected _dumpPropertiesCode(): string;
  63029. }
  63030. }
  63031. declare module BABYLON {
  63032. /**
  63033. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63034. */
  63035. export class ColorMergerBlock extends NodeMaterialBlock {
  63036. /**
  63037. * Create a new ColorMergerBlock
  63038. * @param name defines the block name
  63039. */
  63040. constructor(name: string);
  63041. /**
  63042. * Gets the current class name
  63043. * @returns the class name
  63044. */
  63045. getClassName(): string;
  63046. /**
  63047. * Gets the rgb component (input)
  63048. */
  63049. get rgbIn(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the r component (input)
  63052. */
  63053. get r(): NodeMaterialConnectionPoint;
  63054. /**
  63055. * Gets the g component (input)
  63056. */
  63057. get g(): NodeMaterialConnectionPoint;
  63058. /**
  63059. * Gets the b component (input)
  63060. */
  63061. get b(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the a component (input)
  63064. */
  63065. get a(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the rgba component (output)
  63068. */
  63069. get rgba(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the rgb component (output)
  63072. */
  63073. get rgbOut(): NodeMaterialConnectionPoint;
  63074. /**
  63075. * Gets the rgb component (output)
  63076. * @deprecated Please use rgbOut instead.
  63077. */
  63078. get rgb(): NodeMaterialConnectionPoint;
  63079. protected _buildBlock(state: NodeMaterialBuildState): this;
  63080. }
  63081. }
  63082. declare module BABYLON {
  63083. /**
  63084. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63085. */
  63086. export class VectorSplitterBlock extends NodeMaterialBlock {
  63087. /**
  63088. * Create a new VectorSplitterBlock
  63089. * @param name defines the block name
  63090. */
  63091. constructor(name: string);
  63092. /**
  63093. * Gets the current class name
  63094. * @returns the class name
  63095. */
  63096. getClassName(): string;
  63097. /**
  63098. * Gets the xyzw component (input)
  63099. */
  63100. get xyzw(): NodeMaterialConnectionPoint;
  63101. /**
  63102. * Gets the xyz component (input)
  63103. */
  63104. get xyzIn(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the xy component (input)
  63107. */
  63108. get xyIn(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the xyz component (output)
  63111. */
  63112. get xyzOut(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the xy component (output)
  63115. */
  63116. get xyOut(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the x component (output)
  63119. */
  63120. get x(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the y component (output)
  63123. */
  63124. get y(): NodeMaterialConnectionPoint;
  63125. /**
  63126. * Gets the z component (output)
  63127. */
  63128. get z(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the w component (output)
  63131. */
  63132. get w(): NodeMaterialConnectionPoint;
  63133. protected _inputRename(name: string): string;
  63134. protected _outputRename(name: string): string;
  63135. protected _buildBlock(state: NodeMaterialBuildState): this;
  63136. }
  63137. }
  63138. declare module BABYLON {
  63139. /**
  63140. * Block used to lerp between 2 values
  63141. */
  63142. export class LerpBlock extends NodeMaterialBlock {
  63143. /**
  63144. * Creates a new LerpBlock
  63145. * @param name defines the block name
  63146. */
  63147. constructor(name: string);
  63148. /**
  63149. * Gets the current class name
  63150. * @returns the class name
  63151. */
  63152. getClassName(): string;
  63153. /**
  63154. * Gets the left operand input component
  63155. */
  63156. get left(): NodeMaterialConnectionPoint;
  63157. /**
  63158. * Gets the right operand input component
  63159. */
  63160. get right(): NodeMaterialConnectionPoint;
  63161. /**
  63162. * Gets the gradient operand input component
  63163. */
  63164. get gradient(): NodeMaterialConnectionPoint;
  63165. /**
  63166. * Gets the output component
  63167. */
  63168. get output(): NodeMaterialConnectionPoint;
  63169. protected _buildBlock(state: NodeMaterialBuildState): this;
  63170. }
  63171. }
  63172. declare module BABYLON {
  63173. /**
  63174. * Block used to divide 2 vectors
  63175. */
  63176. export class DivideBlock extends NodeMaterialBlock {
  63177. /**
  63178. * Creates a new DivideBlock
  63179. * @param name defines the block name
  63180. */
  63181. constructor(name: string);
  63182. /**
  63183. * Gets the current class name
  63184. * @returns the class name
  63185. */
  63186. getClassName(): string;
  63187. /**
  63188. * Gets the left operand input component
  63189. */
  63190. get left(): NodeMaterialConnectionPoint;
  63191. /**
  63192. * Gets the right operand input component
  63193. */
  63194. get right(): NodeMaterialConnectionPoint;
  63195. /**
  63196. * Gets the output component
  63197. */
  63198. get output(): NodeMaterialConnectionPoint;
  63199. protected _buildBlock(state: NodeMaterialBuildState): this;
  63200. }
  63201. }
  63202. declare module BABYLON {
  63203. /**
  63204. * Block used to subtract 2 vectors
  63205. */
  63206. export class SubtractBlock extends NodeMaterialBlock {
  63207. /**
  63208. * Creates a new SubtractBlock
  63209. * @param name defines the block name
  63210. */
  63211. constructor(name: string);
  63212. /**
  63213. * Gets the current class name
  63214. * @returns the class name
  63215. */
  63216. getClassName(): string;
  63217. /**
  63218. * Gets the left operand input component
  63219. */
  63220. get left(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the right operand input component
  63223. */
  63224. get right(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the output component
  63227. */
  63228. get output(): NodeMaterialConnectionPoint;
  63229. protected _buildBlock(state: NodeMaterialBuildState): this;
  63230. }
  63231. }
  63232. declare module BABYLON {
  63233. /**
  63234. * Block used to step a value
  63235. */
  63236. export class StepBlock extends NodeMaterialBlock {
  63237. /**
  63238. * Creates a new StepBlock
  63239. * @param name defines the block name
  63240. */
  63241. constructor(name: string);
  63242. /**
  63243. * Gets the current class name
  63244. * @returns the class name
  63245. */
  63246. getClassName(): string;
  63247. /**
  63248. * Gets the value operand input component
  63249. */
  63250. get value(): NodeMaterialConnectionPoint;
  63251. /**
  63252. * Gets the edge operand input component
  63253. */
  63254. get edge(): NodeMaterialConnectionPoint;
  63255. /**
  63256. * Gets the output component
  63257. */
  63258. get output(): NodeMaterialConnectionPoint;
  63259. protected _buildBlock(state: NodeMaterialBuildState): this;
  63260. }
  63261. }
  63262. declare module BABYLON {
  63263. /**
  63264. * Block used to get the opposite (1 - x) of a value
  63265. */
  63266. export class OneMinusBlock extends NodeMaterialBlock {
  63267. /**
  63268. * Creates a new OneMinusBlock
  63269. * @param name defines the block name
  63270. */
  63271. constructor(name: string);
  63272. /**
  63273. * Gets the current class name
  63274. * @returns the class name
  63275. */
  63276. getClassName(): string;
  63277. /**
  63278. * Gets the input component
  63279. */
  63280. get input(): NodeMaterialConnectionPoint;
  63281. /**
  63282. * Gets the output component
  63283. */
  63284. get output(): NodeMaterialConnectionPoint;
  63285. protected _buildBlock(state: NodeMaterialBuildState): this;
  63286. }
  63287. }
  63288. declare module BABYLON {
  63289. /**
  63290. * Block used to get the view direction
  63291. */
  63292. export class ViewDirectionBlock extends NodeMaterialBlock {
  63293. /**
  63294. * Creates a new ViewDirectionBlock
  63295. * @param name defines the block name
  63296. */
  63297. constructor(name: string);
  63298. /**
  63299. * Gets the current class name
  63300. * @returns the class name
  63301. */
  63302. getClassName(): string;
  63303. /**
  63304. * Gets the world position component
  63305. */
  63306. get worldPosition(): NodeMaterialConnectionPoint;
  63307. /**
  63308. * Gets the camera position component
  63309. */
  63310. get cameraPosition(): NodeMaterialConnectionPoint;
  63311. /**
  63312. * Gets the output component
  63313. */
  63314. get output(): NodeMaterialConnectionPoint;
  63315. autoConfigure(material: NodeMaterial): void;
  63316. protected _buildBlock(state: NodeMaterialBuildState): this;
  63317. }
  63318. }
  63319. declare module BABYLON {
  63320. /**
  63321. * Block used to compute fresnel value
  63322. */
  63323. export class FresnelBlock extends NodeMaterialBlock {
  63324. /**
  63325. * Create a new FresnelBlock
  63326. * @param name defines the block name
  63327. */
  63328. constructor(name: string);
  63329. /**
  63330. * Gets the current class name
  63331. * @returns the class name
  63332. */
  63333. getClassName(): string;
  63334. /**
  63335. * Gets the world normal input component
  63336. */
  63337. get worldNormal(): NodeMaterialConnectionPoint;
  63338. /**
  63339. * Gets the view direction input component
  63340. */
  63341. get viewDirection(): NodeMaterialConnectionPoint;
  63342. /**
  63343. * Gets the bias input component
  63344. */
  63345. get bias(): NodeMaterialConnectionPoint;
  63346. /**
  63347. * Gets the camera (or eye) position component
  63348. */
  63349. get power(): NodeMaterialConnectionPoint;
  63350. /**
  63351. * Gets the fresnel output component
  63352. */
  63353. get fresnel(): NodeMaterialConnectionPoint;
  63354. autoConfigure(material: NodeMaterial): void;
  63355. protected _buildBlock(state: NodeMaterialBuildState): this;
  63356. }
  63357. }
  63358. declare module BABYLON {
  63359. /**
  63360. * Block used to get the max of 2 values
  63361. */
  63362. export class MaxBlock extends NodeMaterialBlock {
  63363. /**
  63364. * Creates a new MaxBlock
  63365. * @param name defines the block name
  63366. */
  63367. constructor(name: string);
  63368. /**
  63369. * Gets the current class name
  63370. * @returns the class name
  63371. */
  63372. getClassName(): string;
  63373. /**
  63374. * Gets the left operand input component
  63375. */
  63376. get left(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the right operand input component
  63379. */
  63380. get right(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the output component
  63383. */
  63384. get output(): NodeMaterialConnectionPoint;
  63385. protected _buildBlock(state: NodeMaterialBuildState): this;
  63386. }
  63387. }
  63388. declare module BABYLON {
  63389. /**
  63390. * Block used to get the min of 2 values
  63391. */
  63392. export class MinBlock extends NodeMaterialBlock {
  63393. /**
  63394. * Creates a new MinBlock
  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 left operand input component
  63405. */
  63406. get left(): NodeMaterialConnectionPoint;
  63407. /**
  63408. * Gets the right operand input component
  63409. */
  63410. get right(): NodeMaterialConnectionPoint;
  63411. /**
  63412. * Gets the output component
  63413. */
  63414. get output(): NodeMaterialConnectionPoint;
  63415. protected _buildBlock(state: NodeMaterialBuildState): this;
  63416. }
  63417. }
  63418. declare module BABYLON {
  63419. /**
  63420. * Block used to get the distance between 2 values
  63421. */
  63422. export class DistanceBlock extends NodeMaterialBlock {
  63423. /**
  63424. * Creates a new DistanceBlock
  63425. * @param name defines the block name
  63426. */
  63427. constructor(name: string);
  63428. /**
  63429. * Gets the current class name
  63430. * @returns the class name
  63431. */
  63432. getClassName(): string;
  63433. /**
  63434. * Gets the left operand input component
  63435. */
  63436. get left(): NodeMaterialConnectionPoint;
  63437. /**
  63438. * Gets the right operand input component
  63439. */
  63440. get right(): NodeMaterialConnectionPoint;
  63441. /**
  63442. * Gets the output component
  63443. */
  63444. get output(): NodeMaterialConnectionPoint;
  63445. protected _buildBlock(state: NodeMaterialBuildState): this;
  63446. }
  63447. }
  63448. declare module BABYLON {
  63449. /**
  63450. * Block used to get the length of a vector
  63451. */
  63452. export class LengthBlock extends NodeMaterialBlock {
  63453. /**
  63454. * Creates a new LengthBlock
  63455. * @param name defines the block name
  63456. */
  63457. constructor(name: string);
  63458. /**
  63459. * Gets the current class name
  63460. * @returns the class name
  63461. */
  63462. getClassName(): string;
  63463. /**
  63464. * Gets the value input component
  63465. */
  63466. get value(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the output component
  63469. */
  63470. get output(): NodeMaterialConnectionPoint;
  63471. protected _buildBlock(state: NodeMaterialBuildState): this;
  63472. }
  63473. }
  63474. declare module BABYLON {
  63475. /**
  63476. * Block used to get negative version of a value (i.e. x * -1)
  63477. */
  63478. export class NegateBlock extends NodeMaterialBlock {
  63479. /**
  63480. * Creates a new NegateBlock
  63481. * @param name defines the block name
  63482. */
  63483. constructor(name: string);
  63484. /**
  63485. * Gets the current class name
  63486. * @returns the class name
  63487. */
  63488. getClassName(): string;
  63489. /**
  63490. * Gets the value input component
  63491. */
  63492. get value(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the output component
  63495. */
  63496. get output(): NodeMaterialConnectionPoint;
  63497. protected _buildBlock(state: NodeMaterialBuildState): this;
  63498. }
  63499. }
  63500. declare module BABYLON {
  63501. /**
  63502. * Block used to get the value of the first parameter raised to the power of the second
  63503. */
  63504. export class PowBlock extends NodeMaterialBlock {
  63505. /**
  63506. * Creates a new PowBlock
  63507. * @param name defines the block name
  63508. */
  63509. constructor(name: string);
  63510. /**
  63511. * Gets the current class name
  63512. * @returns the class name
  63513. */
  63514. getClassName(): string;
  63515. /**
  63516. * Gets the value operand input component
  63517. */
  63518. get value(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the power operand input component
  63521. */
  63522. get power(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the output component
  63525. */
  63526. get output(): NodeMaterialConnectionPoint;
  63527. protected _buildBlock(state: NodeMaterialBuildState): this;
  63528. }
  63529. }
  63530. declare module BABYLON {
  63531. /**
  63532. * Block used to get a random number
  63533. */
  63534. export class RandomNumberBlock extends NodeMaterialBlock {
  63535. /**
  63536. * Creates a new RandomNumberBlock
  63537. * @param name defines the block name
  63538. */
  63539. constructor(name: string);
  63540. /**
  63541. * Gets the current class name
  63542. * @returns the class name
  63543. */
  63544. getClassName(): string;
  63545. /**
  63546. * Gets the seed input component
  63547. */
  63548. get seed(): NodeMaterialConnectionPoint;
  63549. /**
  63550. * Gets the output component
  63551. */
  63552. get output(): NodeMaterialConnectionPoint;
  63553. protected _buildBlock(state: NodeMaterialBuildState): this;
  63554. }
  63555. }
  63556. declare module BABYLON {
  63557. /**
  63558. * Block used to compute arc tangent of 2 values
  63559. */
  63560. export class ArcTan2Block extends NodeMaterialBlock {
  63561. /**
  63562. * Creates a new ArcTan2Block
  63563. * @param name defines the block name
  63564. */
  63565. constructor(name: string);
  63566. /**
  63567. * Gets the current class name
  63568. * @returns the class name
  63569. */
  63570. getClassName(): string;
  63571. /**
  63572. * Gets the x operand input component
  63573. */
  63574. get x(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the y operand input component
  63577. */
  63578. get y(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the output component
  63581. */
  63582. get output(): NodeMaterialConnectionPoint;
  63583. protected _buildBlock(state: NodeMaterialBuildState): this;
  63584. }
  63585. }
  63586. declare module BABYLON {
  63587. /**
  63588. * Block used to smooth step a value
  63589. */
  63590. export class SmoothStepBlock extends NodeMaterialBlock {
  63591. /**
  63592. * Creates a new SmoothStepBlock
  63593. * @param name defines the block name
  63594. */
  63595. constructor(name: string);
  63596. /**
  63597. * Gets the current class name
  63598. * @returns the class name
  63599. */
  63600. getClassName(): string;
  63601. /**
  63602. * Gets the value operand input component
  63603. */
  63604. get value(): NodeMaterialConnectionPoint;
  63605. /**
  63606. * Gets the first edge operand input component
  63607. */
  63608. get edge0(): NodeMaterialConnectionPoint;
  63609. /**
  63610. * Gets the second edge operand input component
  63611. */
  63612. get edge1(): NodeMaterialConnectionPoint;
  63613. /**
  63614. * Gets the output component
  63615. */
  63616. get output(): NodeMaterialConnectionPoint;
  63617. protected _buildBlock(state: NodeMaterialBuildState): this;
  63618. }
  63619. }
  63620. declare module BABYLON {
  63621. /**
  63622. * Block used to get the reciprocal (1 / x) of a value
  63623. */
  63624. export class ReciprocalBlock extends NodeMaterialBlock {
  63625. /**
  63626. * Creates a new ReciprocalBlock
  63627. * @param name defines the block name
  63628. */
  63629. constructor(name: string);
  63630. /**
  63631. * Gets the current class name
  63632. * @returns the class name
  63633. */
  63634. getClassName(): string;
  63635. /**
  63636. * Gets the input component
  63637. */
  63638. get input(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the output component
  63641. */
  63642. get output(): NodeMaterialConnectionPoint;
  63643. protected _buildBlock(state: NodeMaterialBuildState): this;
  63644. }
  63645. }
  63646. declare module BABYLON {
  63647. /**
  63648. * Block used to replace a color by another one
  63649. */
  63650. export class ReplaceColorBlock extends NodeMaterialBlock {
  63651. /**
  63652. * Creates a new ReplaceColorBlock
  63653. * @param name defines the block name
  63654. */
  63655. constructor(name: string);
  63656. /**
  63657. * Gets the current class name
  63658. * @returns the class name
  63659. */
  63660. getClassName(): string;
  63661. /**
  63662. * Gets the value input component
  63663. */
  63664. get value(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the reference input component
  63667. */
  63668. get reference(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the distance input component
  63671. */
  63672. get distance(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the replacement input component
  63675. */
  63676. get replacement(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the output component
  63679. */
  63680. get output(): NodeMaterialConnectionPoint;
  63681. protected _buildBlock(state: NodeMaterialBuildState): this;
  63682. }
  63683. }
  63684. declare module BABYLON {
  63685. /**
  63686. * Block used to posterize a value
  63687. * @see https://en.wikipedia.org/wiki/Posterization
  63688. */
  63689. export class PosterizeBlock extends NodeMaterialBlock {
  63690. /**
  63691. * Creates a new PosterizeBlock
  63692. * @param name defines the block name
  63693. */
  63694. constructor(name: string);
  63695. /**
  63696. * Gets the current class name
  63697. * @returns the class name
  63698. */
  63699. getClassName(): string;
  63700. /**
  63701. * Gets the value input component
  63702. */
  63703. get value(): NodeMaterialConnectionPoint;
  63704. /**
  63705. * Gets the steps input component
  63706. */
  63707. get steps(): NodeMaterialConnectionPoint;
  63708. /**
  63709. * Gets the output component
  63710. */
  63711. get output(): NodeMaterialConnectionPoint;
  63712. protected _buildBlock(state: NodeMaterialBuildState): this;
  63713. }
  63714. }
  63715. declare module BABYLON {
  63716. /**
  63717. * Operations supported by the Wave block
  63718. */
  63719. export enum WaveBlockKind {
  63720. /** SawTooth */
  63721. SawTooth = 0,
  63722. /** Square */
  63723. Square = 1,
  63724. /** Triangle */
  63725. Triangle = 2
  63726. }
  63727. /**
  63728. * Block used to apply wave operation to floats
  63729. */
  63730. export class WaveBlock extends NodeMaterialBlock {
  63731. /**
  63732. * Gets or sets the kibnd of wave to be applied by the block
  63733. */
  63734. kind: WaveBlockKind;
  63735. /**
  63736. * Creates a new WaveBlock
  63737. * @param name defines the block name
  63738. */
  63739. constructor(name: string);
  63740. /**
  63741. * Gets the current class name
  63742. * @returns the class name
  63743. */
  63744. getClassName(): string;
  63745. /**
  63746. * Gets the input component
  63747. */
  63748. get input(): NodeMaterialConnectionPoint;
  63749. /**
  63750. * Gets the output component
  63751. */
  63752. get output(): NodeMaterialConnectionPoint;
  63753. protected _buildBlock(state: NodeMaterialBuildState): this;
  63754. serialize(): any;
  63755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63756. }
  63757. }
  63758. declare module BABYLON {
  63759. /**
  63760. * Class used to store a color step for the GradientBlock
  63761. */
  63762. export class GradientBlockColorStep {
  63763. /**
  63764. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63765. */
  63766. step: number;
  63767. /**
  63768. * Gets or sets the color associated with this step
  63769. */
  63770. color: Color3;
  63771. /**
  63772. * Creates a new GradientBlockColorStep
  63773. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63774. * @param color defines the color associated with this step
  63775. */
  63776. constructor(
  63777. /**
  63778. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63779. */
  63780. step: number,
  63781. /**
  63782. * Gets or sets the color associated with this step
  63783. */
  63784. color: Color3);
  63785. }
  63786. /**
  63787. * Block used to return a color from a gradient based on an input value between 0 and 1
  63788. */
  63789. export class GradientBlock extends NodeMaterialBlock {
  63790. /**
  63791. * Gets or sets the list of color steps
  63792. */
  63793. colorSteps: GradientBlockColorStep[];
  63794. /**
  63795. * Creates a new GradientBlock
  63796. * @param name defines the block name
  63797. */
  63798. constructor(name: string);
  63799. /**
  63800. * Gets the current class name
  63801. * @returns the class name
  63802. */
  63803. getClassName(): string;
  63804. /**
  63805. * Gets the gradient input component
  63806. */
  63807. get gradient(): NodeMaterialConnectionPoint;
  63808. /**
  63809. * Gets the output component
  63810. */
  63811. get output(): NodeMaterialConnectionPoint;
  63812. private _writeColorConstant;
  63813. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63814. serialize(): any;
  63815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63816. protected _dumpPropertiesCode(): string;
  63817. }
  63818. }
  63819. declare module BABYLON {
  63820. /**
  63821. * Block used to normalize lerp between 2 values
  63822. */
  63823. export class NLerpBlock extends NodeMaterialBlock {
  63824. /**
  63825. * Creates a new NLerpBlock
  63826. * @param name defines the block name
  63827. */
  63828. constructor(name: string);
  63829. /**
  63830. * Gets the current class name
  63831. * @returns the class name
  63832. */
  63833. getClassName(): string;
  63834. /**
  63835. * Gets the left operand input component
  63836. */
  63837. get left(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the right operand input component
  63840. */
  63841. get right(): NodeMaterialConnectionPoint;
  63842. /**
  63843. * Gets the gradient operand input component
  63844. */
  63845. get gradient(): NodeMaterialConnectionPoint;
  63846. /**
  63847. * Gets the output component
  63848. */
  63849. get output(): NodeMaterialConnectionPoint;
  63850. protected _buildBlock(state: NodeMaterialBuildState): this;
  63851. }
  63852. }
  63853. declare module BABYLON {
  63854. /**
  63855. * block used to Generate a Worley Noise 3D Noise Pattern
  63856. */
  63857. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63858. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63859. manhattanDistance: boolean;
  63860. /**
  63861. * Creates a new WorleyNoise3DBlock
  63862. * @param name defines the block name
  63863. */
  63864. constructor(name: string);
  63865. /**
  63866. * Gets the current class name
  63867. * @returns the class name
  63868. */
  63869. getClassName(): string;
  63870. /**
  63871. * Gets the seed input component
  63872. */
  63873. get seed(): NodeMaterialConnectionPoint;
  63874. /**
  63875. * Gets the jitter input component
  63876. */
  63877. get jitter(): NodeMaterialConnectionPoint;
  63878. /**
  63879. * Gets the output component
  63880. */
  63881. get output(): NodeMaterialConnectionPoint;
  63882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63883. /**
  63884. * Exposes the properties to the UI?
  63885. */
  63886. protected _dumpPropertiesCode(): string;
  63887. /**
  63888. * Exposes the properties to the Seralize?
  63889. */
  63890. serialize(): any;
  63891. /**
  63892. * Exposes the properties to the deseralize?
  63893. */
  63894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63895. }
  63896. }
  63897. declare module BABYLON {
  63898. /**
  63899. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63900. */
  63901. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63902. /**
  63903. * Creates a new SimplexPerlin3DBlock
  63904. * @param name defines the block name
  63905. */
  63906. constructor(name: string);
  63907. /**
  63908. * Gets the current class name
  63909. * @returns the class name
  63910. */
  63911. getClassName(): string;
  63912. /**
  63913. * Gets the seed operand input component
  63914. */
  63915. get seed(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the output component
  63918. */
  63919. get output(): NodeMaterialConnectionPoint;
  63920. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * Block used to blend normals
  63926. */
  63927. export class NormalBlendBlock extends NodeMaterialBlock {
  63928. /**
  63929. * Creates a new NormalBlendBlock
  63930. * @param name defines the block name
  63931. */
  63932. constructor(name: string);
  63933. /**
  63934. * Gets the current class name
  63935. * @returns the class name
  63936. */
  63937. getClassName(): string;
  63938. /**
  63939. * Gets the first input component
  63940. */
  63941. get normalMap0(): NodeMaterialConnectionPoint;
  63942. /**
  63943. * Gets the second input component
  63944. */
  63945. get normalMap1(): NodeMaterialConnectionPoint;
  63946. /**
  63947. * Gets the output component
  63948. */
  63949. get output(): NodeMaterialConnectionPoint;
  63950. protected _buildBlock(state: NodeMaterialBuildState): this;
  63951. }
  63952. }
  63953. declare module BABYLON {
  63954. /**
  63955. * Block used to rotate a 2d vector by a given angle
  63956. */
  63957. export class Rotate2dBlock extends NodeMaterialBlock {
  63958. /**
  63959. * Creates a new Rotate2dBlock
  63960. * @param name defines the block name
  63961. */
  63962. constructor(name: string);
  63963. /**
  63964. * Gets the current class name
  63965. * @returns the class name
  63966. */
  63967. getClassName(): string;
  63968. /**
  63969. * Gets the input vector
  63970. */
  63971. get input(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the input angle
  63974. */
  63975. get angle(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the output component
  63978. */
  63979. get output(): NodeMaterialConnectionPoint;
  63980. autoConfigure(material: NodeMaterial): void;
  63981. protected _buildBlock(state: NodeMaterialBuildState): this;
  63982. }
  63983. }
  63984. declare module BABYLON {
  63985. /**
  63986. * Block used to get the reflected vector from a direction and a normal
  63987. */
  63988. export class ReflectBlock extends NodeMaterialBlock {
  63989. /**
  63990. * Creates a new ReflectBlock
  63991. * @param name defines the block name
  63992. */
  63993. constructor(name: string);
  63994. /**
  63995. * Gets the current class name
  63996. * @returns the class name
  63997. */
  63998. getClassName(): string;
  63999. /**
  64000. * Gets the incident component
  64001. */
  64002. get incident(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the normal component
  64005. */
  64006. get normal(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the output component
  64009. */
  64010. get output(): NodeMaterialConnectionPoint;
  64011. protected _buildBlock(state: NodeMaterialBuildState): this;
  64012. }
  64013. }
  64014. declare module BABYLON {
  64015. /**
  64016. * Block used to get the refracted vector from a direction and a normal
  64017. */
  64018. export class RefractBlock extends NodeMaterialBlock {
  64019. /**
  64020. * Creates a new RefractBlock
  64021. * @param name defines the block name
  64022. */
  64023. constructor(name: string);
  64024. /**
  64025. * Gets the current class name
  64026. * @returns the class name
  64027. */
  64028. getClassName(): string;
  64029. /**
  64030. * Gets the incident component
  64031. */
  64032. get incident(): NodeMaterialConnectionPoint;
  64033. /**
  64034. * Gets the normal component
  64035. */
  64036. get normal(): NodeMaterialConnectionPoint;
  64037. /**
  64038. * Gets the index of refraction component
  64039. */
  64040. get ior(): NodeMaterialConnectionPoint;
  64041. /**
  64042. * Gets the output component
  64043. */
  64044. get output(): NodeMaterialConnectionPoint;
  64045. protected _buildBlock(state: NodeMaterialBuildState): this;
  64046. }
  64047. }
  64048. declare module BABYLON {
  64049. /**
  64050. * Block used to desaturate a color
  64051. */
  64052. export class DesaturateBlock extends NodeMaterialBlock {
  64053. /**
  64054. * Creates a new DesaturateBlock
  64055. * @param name defines the block name
  64056. */
  64057. constructor(name: string);
  64058. /**
  64059. * Gets the current class name
  64060. * @returns the class name
  64061. */
  64062. getClassName(): string;
  64063. /**
  64064. * Gets the color operand input component
  64065. */
  64066. get color(): NodeMaterialConnectionPoint;
  64067. /**
  64068. * Gets the level operand input component
  64069. */
  64070. get level(): NodeMaterialConnectionPoint;
  64071. /**
  64072. * Gets the output component
  64073. */
  64074. get output(): NodeMaterialConnectionPoint;
  64075. protected _buildBlock(state: NodeMaterialBuildState): this;
  64076. }
  64077. }
  64078. declare module BABYLON {
  64079. /**
  64080. * Block used to implement the ambient occlusion module of the PBR material
  64081. */
  64082. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64083. /**
  64084. * Create a new AmbientOcclusionBlock
  64085. * @param name defines the block name
  64086. */
  64087. constructor(name: string);
  64088. /**
  64089. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64090. */
  64091. useAmbientInGrayScale: boolean;
  64092. /**
  64093. * Initialize the block and prepare the context for build
  64094. * @param state defines the state that will be used for the build
  64095. */
  64096. initialize(state: NodeMaterialBuildState): void;
  64097. /**
  64098. * Gets the current class name
  64099. * @returns the class name
  64100. */
  64101. getClassName(): string;
  64102. /**
  64103. * Gets the texture input component
  64104. */
  64105. get texture(): NodeMaterialConnectionPoint;
  64106. /**
  64107. * Gets the texture intensity component
  64108. */
  64109. get intensity(): NodeMaterialConnectionPoint;
  64110. /**
  64111. * Gets the direct light intensity input component
  64112. */
  64113. get directLightIntensity(): NodeMaterialConnectionPoint;
  64114. /**
  64115. * Gets the ambient occlusion object output component
  64116. */
  64117. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64118. /**
  64119. * Gets the main code of the block (fragment side)
  64120. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64121. * @returns the shader code
  64122. */
  64123. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64125. protected _buildBlock(state: NodeMaterialBuildState): this;
  64126. protected _dumpPropertiesCode(): string;
  64127. serialize(): any;
  64128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64129. }
  64130. }
  64131. declare module BABYLON {
  64132. /**
  64133. * Block used to implement the reflection module of the PBR material
  64134. */
  64135. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64136. /** @hidden */
  64137. _defineLODReflectionAlpha: string;
  64138. /** @hidden */
  64139. _defineLinearSpecularReflection: string;
  64140. private _vEnvironmentIrradianceName;
  64141. /** @hidden */
  64142. _vReflectionMicrosurfaceInfosName: string;
  64143. /** @hidden */
  64144. _vReflectionInfosName: string;
  64145. /** @hidden */
  64146. _vReflectionFilteringInfoName: string;
  64147. private _scene;
  64148. /**
  64149. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64150. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64151. * It's less burden on the user side in the editor part.
  64152. */
  64153. /** @hidden */
  64154. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64155. /** @hidden */
  64156. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64157. /** @hidden */
  64158. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64159. /**
  64160. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64161. * diffuse part of the IBL.
  64162. */
  64163. useSphericalHarmonics: boolean;
  64164. /**
  64165. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64166. */
  64167. forceIrradianceInFragment: boolean;
  64168. /**
  64169. * Create a new ReflectionBlock
  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 position input component
  64180. */
  64181. get position(): NodeMaterialConnectionPoint;
  64182. /**
  64183. * Gets the world position input component
  64184. */
  64185. get worldPosition(): NodeMaterialConnectionPoint;
  64186. /**
  64187. * Gets the world normal input component
  64188. */
  64189. get worldNormal(): NodeMaterialConnectionPoint;
  64190. /**
  64191. * Gets the world input component
  64192. */
  64193. get world(): NodeMaterialConnectionPoint;
  64194. /**
  64195. * Gets the camera (or eye) position component
  64196. */
  64197. get cameraPosition(): NodeMaterialConnectionPoint;
  64198. /**
  64199. * Gets the view input component
  64200. */
  64201. get view(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the color input component
  64204. */
  64205. get color(): NodeMaterialConnectionPoint;
  64206. /**
  64207. * Gets the reflection object output component
  64208. */
  64209. get reflection(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64212. */
  64213. get hasTexture(): boolean;
  64214. /**
  64215. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64216. */
  64217. get reflectionColor(): string;
  64218. protected _getTexture(): Nullable<BaseTexture>;
  64219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64221. /**
  64222. * Gets the code to inject in the vertex shader
  64223. * @param state current state of the node material building
  64224. * @returns the shader code
  64225. */
  64226. handleVertexSide(state: NodeMaterialBuildState): string;
  64227. /**
  64228. * Gets the main code of the block (fragment side)
  64229. * @param state current state of the node material building
  64230. * @param normalVarName name of the existing variable corresponding to the normal
  64231. * @returns the shader code
  64232. */
  64233. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64234. protected _buildBlock(state: NodeMaterialBuildState): this;
  64235. protected _dumpPropertiesCode(): string;
  64236. serialize(): any;
  64237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /**
  64242. * Block used to implement the sheen module of the PBR material
  64243. */
  64244. export class SheenBlock extends NodeMaterialBlock {
  64245. /**
  64246. * Create a new SheenBlock
  64247. * @param name defines the block name
  64248. */
  64249. constructor(name: string);
  64250. /**
  64251. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64252. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64253. * making it easier to setup and tweak the effect
  64254. */
  64255. albedoScaling: boolean;
  64256. /**
  64257. * Defines if the sheen is linked to the sheen color.
  64258. */
  64259. linkSheenWithAlbedo: boolean;
  64260. /**
  64261. * Initialize the block and prepare the context for build
  64262. * @param state defines the state that will be used for the build
  64263. */
  64264. initialize(state: NodeMaterialBuildState): void;
  64265. /**
  64266. * Gets the current class name
  64267. * @returns the class name
  64268. */
  64269. getClassName(): string;
  64270. /**
  64271. * Gets the intensity input component
  64272. */
  64273. get intensity(): NodeMaterialConnectionPoint;
  64274. /**
  64275. * Gets the color input component
  64276. */
  64277. get color(): NodeMaterialConnectionPoint;
  64278. /**
  64279. * Gets the roughness input component
  64280. */
  64281. get roughness(): NodeMaterialConnectionPoint;
  64282. /**
  64283. * Gets the sheen object output component
  64284. */
  64285. get sheen(): NodeMaterialConnectionPoint;
  64286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64287. /**
  64288. * Gets the main code of the block (fragment side)
  64289. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64290. * @returns the shader code
  64291. */
  64292. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64293. protected _buildBlock(state: NodeMaterialBuildState): this;
  64294. protected _dumpPropertiesCode(): string;
  64295. serialize(): any;
  64296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64297. }
  64298. }
  64299. declare module BABYLON {
  64300. /**
  64301. * Block used to implement the reflectivity module of the PBR material
  64302. */
  64303. export class ReflectivityBlock extends NodeMaterialBlock {
  64304. private _metallicReflectanceColor;
  64305. private _metallicF0Factor;
  64306. /** @hidden */
  64307. _vMetallicReflectanceFactorsName: string;
  64308. /**
  64309. * The property below is set by the main PBR block prior to calling methods of this class.
  64310. */
  64311. /** @hidden */
  64312. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64313. /**
  64314. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64315. */
  64316. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64317. /**
  64318. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64319. */
  64320. useMetallnessFromMetallicTextureBlue: boolean;
  64321. /**
  64322. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64323. */
  64324. useRoughnessFromMetallicTextureAlpha: boolean;
  64325. /**
  64326. * Specifies if the metallic texture contains the roughness information in its green channel.
  64327. */
  64328. useRoughnessFromMetallicTextureGreen: boolean;
  64329. /**
  64330. * Create a new ReflectivityBlock
  64331. * @param name defines the block name
  64332. */
  64333. constructor(name: string);
  64334. /**
  64335. * Initialize the block and prepare the context for build
  64336. * @param state defines the state that will be used for the build
  64337. */
  64338. initialize(state: NodeMaterialBuildState): void;
  64339. /**
  64340. * Gets the current class name
  64341. * @returns the class name
  64342. */
  64343. getClassName(): string;
  64344. /**
  64345. * Gets the metallic input component
  64346. */
  64347. get metallic(): NodeMaterialConnectionPoint;
  64348. /**
  64349. * Gets the roughness input component
  64350. */
  64351. get roughness(): NodeMaterialConnectionPoint;
  64352. /**
  64353. * Gets the texture input component
  64354. */
  64355. get texture(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the reflectivity object output component
  64358. */
  64359. get reflectivity(): NodeMaterialConnectionPoint;
  64360. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64361. /**
  64362. * Gets the main code of the block (fragment side)
  64363. * @param state current state of the node material building
  64364. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64365. * @returns the shader code
  64366. */
  64367. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64369. protected _buildBlock(state: NodeMaterialBuildState): this;
  64370. protected _dumpPropertiesCode(): string;
  64371. serialize(): any;
  64372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64373. }
  64374. }
  64375. declare module BABYLON {
  64376. /**
  64377. * Block used to implement the anisotropy module of the PBR material
  64378. */
  64379. export class AnisotropyBlock extends NodeMaterialBlock {
  64380. /**
  64381. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64382. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64383. * It's less burden on the user side in the editor part.
  64384. */
  64385. /** @hidden */
  64386. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64387. /** @hidden */
  64388. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64389. /**
  64390. * Create a new AnisotropyBlock
  64391. * @param name defines the block name
  64392. */
  64393. constructor(name: string);
  64394. /**
  64395. * Initialize the block and prepare the context for build
  64396. * @param state defines the state that will be used for the build
  64397. */
  64398. initialize(state: NodeMaterialBuildState): void;
  64399. /**
  64400. * Gets the current class name
  64401. * @returns the class name
  64402. */
  64403. getClassName(): string;
  64404. /**
  64405. * Gets the intensity input component
  64406. */
  64407. get intensity(): NodeMaterialConnectionPoint;
  64408. /**
  64409. * Gets the direction input component
  64410. */
  64411. get direction(): NodeMaterialConnectionPoint;
  64412. /**
  64413. * Gets the texture input component
  64414. */
  64415. get texture(): NodeMaterialConnectionPoint;
  64416. /**
  64417. * Gets the uv input component
  64418. */
  64419. get uv(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the worldTangent input component
  64422. */
  64423. get worldTangent(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the anisotropy object output component
  64426. */
  64427. get anisotropy(): NodeMaterialConnectionPoint;
  64428. private _generateTBNSpace;
  64429. /**
  64430. * Gets the main code of the block (fragment side)
  64431. * @param state current state of the node material building
  64432. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64433. * @returns the shader code
  64434. */
  64435. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64436. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64437. protected _buildBlock(state: NodeMaterialBuildState): this;
  64438. }
  64439. }
  64440. declare module BABYLON {
  64441. /**
  64442. * Block used to implement the clear coat module of the PBR material
  64443. */
  64444. export class ClearCoatBlock extends NodeMaterialBlock {
  64445. private _scene;
  64446. /**
  64447. * Create a new ClearCoatBlock
  64448. * @param name defines the block name
  64449. */
  64450. constructor(name: string);
  64451. /**
  64452. * Initialize the block and prepare the context for build
  64453. * @param state defines the state that will be used for the build
  64454. */
  64455. initialize(state: NodeMaterialBuildState): void;
  64456. /**
  64457. * Gets the current class name
  64458. * @returns the class name
  64459. */
  64460. getClassName(): string;
  64461. /**
  64462. * Gets the intensity input component
  64463. */
  64464. get intensity(): NodeMaterialConnectionPoint;
  64465. /**
  64466. * Gets the roughness input component
  64467. */
  64468. get roughness(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the ior input component
  64471. */
  64472. get ior(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the texture input component
  64475. */
  64476. get texture(): NodeMaterialConnectionPoint;
  64477. /**
  64478. * Gets the bump texture input component
  64479. */
  64480. get bumpTexture(): NodeMaterialConnectionPoint;
  64481. /**
  64482. * Gets the uv input component
  64483. */
  64484. get uv(): NodeMaterialConnectionPoint;
  64485. /**
  64486. * Gets the tint color input component
  64487. */
  64488. get tintColor(): NodeMaterialConnectionPoint;
  64489. /**
  64490. * Gets the tint "at distance" input component
  64491. */
  64492. get tintAtDistance(): NodeMaterialConnectionPoint;
  64493. /**
  64494. * Gets the tint thickness input component
  64495. */
  64496. get tintThickness(): NodeMaterialConnectionPoint;
  64497. /**
  64498. * Gets the world tangent input component
  64499. */
  64500. get worldTangent(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the clear coat object output component
  64503. */
  64504. get clearcoat(): NodeMaterialConnectionPoint;
  64505. autoConfigure(material: NodeMaterial): void;
  64506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64508. private _generateTBNSpace;
  64509. /**
  64510. * Gets the main code of the block (fragment side)
  64511. * @param state current state of the node material building
  64512. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64513. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64514. * @param worldPosVarName name of the variable holding the world position
  64515. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64516. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64517. * @param worldNormalVarName name of the variable holding the world normal
  64518. * @returns the shader code
  64519. */
  64520. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64521. protected _buildBlock(state: NodeMaterialBuildState): this;
  64522. }
  64523. }
  64524. declare module BABYLON {
  64525. /**
  64526. * Block used to implement the sub surface module of the PBR material
  64527. */
  64528. export class SubSurfaceBlock extends NodeMaterialBlock {
  64529. /**
  64530. * Create a new SubSurfaceBlock
  64531. * @param name defines the block name
  64532. */
  64533. constructor(name: string);
  64534. /**
  64535. * Stores the intensity of the different subsurface effects in the thickness texture.
  64536. * * the green channel is the translucency intensity.
  64537. * * the blue channel is the scattering intensity.
  64538. * * the alpha channel is the refraction intensity.
  64539. */
  64540. useMaskFromThicknessTexture: boolean;
  64541. /**
  64542. * Initialize the block and prepare the context for build
  64543. * @param state defines the state that will be used for the build
  64544. */
  64545. initialize(state: NodeMaterialBuildState): void;
  64546. /**
  64547. * Gets the current class name
  64548. * @returns the class name
  64549. */
  64550. getClassName(): string;
  64551. /**
  64552. * Gets the min thickness input component
  64553. */
  64554. get minThickness(): NodeMaterialConnectionPoint;
  64555. /**
  64556. * Gets the max thickness input component
  64557. */
  64558. get maxThickness(): NodeMaterialConnectionPoint;
  64559. /**
  64560. * Gets the thickness texture component
  64561. */
  64562. get thicknessTexture(): NodeMaterialConnectionPoint;
  64563. /**
  64564. * Gets the tint color input component
  64565. */
  64566. get tintColor(): NodeMaterialConnectionPoint;
  64567. /**
  64568. * Gets the translucency intensity input component
  64569. */
  64570. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64571. /**
  64572. * Gets the translucency diffusion distance input component
  64573. */
  64574. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64575. /**
  64576. * Gets the refraction object parameters
  64577. */
  64578. get refraction(): NodeMaterialConnectionPoint;
  64579. /**
  64580. * Gets the sub surface object output component
  64581. */
  64582. get subsurface(): NodeMaterialConnectionPoint;
  64583. autoConfigure(material: NodeMaterial): void;
  64584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64585. /**
  64586. * Gets the main code of the block (fragment side)
  64587. * @param state current state of the node material building
  64588. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64589. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64590. * @param worldPosVarName name of the variable holding the world position
  64591. * @returns the shader code
  64592. */
  64593. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64594. protected _buildBlock(state: NodeMaterialBuildState): this;
  64595. }
  64596. }
  64597. declare module BABYLON {
  64598. /**
  64599. * Block used to implement the PBR metallic/roughness model
  64600. */
  64601. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64602. /**
  64603. * Gets or sets the light associated with this block
  64604. */
  64605. light: Nullable<Light>;
  64606. private _lightId;
  64607. private _scene;
  64608. private _environmentBRDFTexture;
  64609. private _environmentBrdfSamplerName;
  64610. private _vNormalWName;
  64611. private _invertNormalName;
  64612. /**
  64613. * Create a new ReflectionBlock
  64614. * @param name defines the block name
  64615. */
  64616. constructor(name: string);
  64617. /**
  64618. * Intensity of the direct lights e.g. the four lights available in your scene.
  64619. * This impacts both the direct diffuse and specular highlights.
  64620. */
  64621. directIntensity: number;
  64622. /**
  64623. * Intensity of the environment e.g. how much the environment will light the object
  64624. * either through harmonics for rough material or through the refelction for shiny ones.
  64625. */
  64626. environmentIntensity: number;
  64627. /**
  64628. * This is a special control allowing the reduction of the specular highlights coming from the
  64629. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64630. */
  64631. specularIntensity: number;
  64632. /**
  64633. * Defines the falloff type used in this material.
  64634. * It by default is Physical.
  64635. */
  64636. lightFalloff: number;
  64637. /**
  64638. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64639. */
  64640. useAlphaFromAlbedoTexture: boolean;
  64641. /**
  64642. * Specifies that alpha test should be used
  64643. */
  64644. useAlphaTest: boolean;
  64645. /**
  64646. * Defines the alpha limits in alpha test mode.
  64647. */
  64648. alphaTestCutoff: number;
  64649. /**
  64650. * Specifies that alpha blending should be used
  64651. */
  64652. useAlphaBlending: boolean;
  64653. /**
  64654. * Defines if the alpha value should be determined via the rgb values.
  64655. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64656. */
  64657. opacityRGB: boolean;
  64658. /**
  64659. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64660. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64661. */
  64662. useRadianceOverAlpha: boolean;
  64663. /**
  64664. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64665. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64666. */
  64667. useSpecularOverAlpha: boolean;
  64668. /**
  64669. * Enables specular anti aliasing in the PBR shader.
  64670. * It will both interacts on the Geometry for analytical and IBL lighting.
  64671. * It also prefilter the roughness map based on the bump values.
  64672. */
  64673. enableSpecularAntiAliasing: boolean;
  64674. /**
  64675. * Enables realtime filtering on the texture.
  64676. */
  64677. realTimeFiltering: boolean;
  64678. /**
  64679. * Quality switch for realtime filtering
  64680. */
  64681. realTimeFilteringQuality: number;
  64682. /**
  64683. * Defines if the material uses energy conservation.
  64684. */
  64685. useEnergyConservation: boolean;
  64686. /**
  64687. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64688. * too much the area relying on ambient texture to define their ambient occlusion.
  64689. */
  64690. useRadianceOcclusion: boolean;
  64691. /**
  64692. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64693. * makes the reflect vector face the model (under horizon).
  64694. */
  64695. useHorizonOcclusion: boolean;
  64696. /**
  64697. * If set to true, no lighting calculations will be applied.
  64698. */
  64699. unlit: boolean;
  64700. /**
  64701. * Force normal to face away from face.
  64702. */
  64703. forceNormalForward: boolean;
  64704. /**
  64705. * Defines the material debug mode.
  64706. * It helps seeing only some components of the material while troubleshooting.
  64707. */
  64708. debugMode: number;
  64709. /**
  64710. * Specify from where on screen the debug mode should start.
  64711. * The value goes from -1 (full screen) to 1 (not visible)
  64712. * It helps with side by side comparison against the final render
  64713. * This defaults to 0
  64714. */
  64715. debugLimit: number;
  64716. /**
  64717. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64718. * You can use the factor to better multiply the final value.
  64719. */
  64720. debugFactor: number;
  64721. /**
  64722. * Initialize the block and prepare the context for build
  64723. * @param state defines the state that will be used for the build
  64724. */
  64725. initialize(state: NodeMaterialBuildState): void;
  64726. /**
  64727. * Gets the current class name
  64728. * @returns the class name
  64729. */
  64730. getClassName(): string;
  64731. /**
  64732. * Gets the world position input component
  64733. */
  64734. get worldPosition(): NodeMaterialConnectionPoint;
  64735. /**
  64736. * Gets the world normal input component
  64737. */
  64738. get worldNormal(): NodeMaterialConnectionPoint;
  64739. /**
  64740. * Gets the perturbed normal input component
  64741. */
  64742. get perturbedNormal(): NodeMaterialConnectionPoint;
  64743. /**
  64744. * Gets the camera position input component
  64745. */
  64746. get cameraPosition(): NodeMaterialConnectionPoint;
  64747. /**
  64748. * Gets the base color input component
  64749. */
  64750. get baseColor(): NodeMaterialConnectionPoint;
  64751. /**
  64752. * Gets the opacity texture input component
  64753. */
  64754. get opacityTexture(): NodeMaterialConnectionPoint;
  64755. /**
  64756. * Gets the ambient color input component
  64757. */
  64758. get ambientColor(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the reflectivity object parameters
  64761. */
  64762. get reflectivity(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the ambient occlusion object parameters
  64765. */
  64766. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64767. /**
  64768. * Gets the reflection object parameters
  64769. */
  64770. get reflection(): NodeMaterialConnectionPoint;
  64771. /**
  64772. * Gets the sheen object parameters
  64773. */
  64774. get sheen(): NodeMaterialConnectionPoint;
  64775. /**
  64776. * Gets the clear coat object parameters
  64777. */
  64778. get clearcoat(): NodeMaterialConnectionPoint;
  64779. /**
  64780. * Gets the sub surface object parameters
  64781. */
  64782. get subsurface(): NodeMaterialConnectionPoint;
  64783. /**
  64784. * Gets the anisotropy object parameters
  64785. */
  64786. get anisotropy(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the ambient output component
  64789. */
  64790. get ambient(): NodeMaterialConnectionPoint;
  64791. /**
  64792. * Gets the diffuse output component
  64793. */
  64794. get diffuse(): NodeMaterialConnectionPoint;
  64795. /**
  64796. * Gets the specular output component
  64797. */
  64798. get specular(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the sheen output component
  64801. */
  64802. get sheenDir(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the clear coat output component
  64805. */
  64806. get clearcoatDir(): NodeMaterialConnectionPoint;
  64807. /**
  64808. * Gets the indirect diffuse output component
  64809. */
  64810. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64811. /**
  64812. * Gets the indirect specular output component
  64813. */
  64814. get specularIndirect(): NodeMaterialConnectionPoint;
  64815. /**
  64816. * Gets the indirect sheen output component
  64817. */
  64818. get sheenIndirect(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the indirect clear coat output component
  64821. */
  64822. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the refraction output component
  64825. */
  64826. get refraction(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the global lighting output component
  64829. */
  64830. get lighting(): NodeMaterialConnectionPoint;
  64831. /**
  64832. * Gets the shadow output component
  64833. */
  64834. get shadow(): NodeMaterialConnectionPoint;
  64835. /**
  64836. * Gets the alpha output component
  64837. */
  64838. get alpha(): NodeMaterialConnectionPoint;
  64839. autoConfigure(material: NodeMaterial): void;
  64840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64841. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64843. private _injectVertexCode;
  64844. /**
  64845. * Gets the code corresponding to the albedo/opacity module
  64846. * @returns the shader code
  64847. */
  64848. getAlbedoOpacityCode(): string;
  64849. protected _buildBlock(state: NodeMaterialBuildState): this;
  64850. protected _dumpPropertiesCode(): string;
  64851. serialize(): any;
  64852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64853. }
  64854. }
  64855. declare module BABYLON {
  64856. /**
  64857. * Block used to compute value of one parameter modulo another
  64858. */
  64859. export class ModBlock extends NodeMaterialBlock {
  64860. /**
  64861. * Creates a new ModBlock
  64862. * @param name defines the block name
  64863. */
  64864. constructor(name: string);
  64865. /**
  64866. * Gets the current class name
  64867. * @returns the class name
  64868. */
  64869. getClassName(): string;
  64870. /**
  64871. * Gets the left operand input component
  64872. */
  64873. get left(): NodeMaterialConnectionPoint;
  64874. /**
  64875. * Gets the right operand input component
  64876. */
  64877. get right(): NodeMaterialConnectionPoint;
  64878. /**
  64879. * Gets the output component
  64880. */
  64881. get output(): NodeMaterialConnectionPoint;
  64882. protected _buildBlock(state: NodeMaterialBuildState): this;
  64883. }
  64884. }
  64885. declare module BABYLON {
  64886. /**
  64887. * Helper class to push actions to a pool of workers.
  64888. */
  64889. export class WorkerPool implements IDisposable {
  64890. private _workerInfos;
  64891. private _pendingActions;
  64892. /**
  64893. * Constructor
  64894. * @param workers Array of workers to use for actions
  64895. */
  64896. constructor(workers: Array<Worker>);
  64897. /**
  64898. * Terminates all workers and clears any pending actions.
  64899. */
  64900. dispose(): void;
  64901. /**
  64902. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64903. * pended until a worker has completed its action.
  64904. * @param action The action to perform. Call onComplete when the action is complete.
  64905. */
  64906. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64907. private _execute;
  64908. }
  64909. }
  64910. declare module BABYLON {
  64911. /**
  64912. * Configuration for Draco compression
  64913. */
  64914. export interface IDracoCompressionConfiguration {
  64915. /**
  64916. * Configuration for the decoder.
  64917. */
  64918. decoder: {
  64919. /**
  64920. * The url to the WebAssembly module.
  64921. */
  64922. wasmUrl?: string;
  64923. /**
  64924. * The url to the WebAssembly binary.
  64925. */
  64926. wasmBinaryUrl?: string;
  64927. /**
  64928. * The url to the fallback JavaScript module.
  64929. */
  64930. fallbackUrl?: string;
  64931. };
  64932. }
  64933. /**
  64934. * Draco compression (https://google.github.io/draco/)
  64935. *
  64936. * This class wraps the Draco module.
  64937. *
  64938. * **Encoder**
  64939. *
  64940. * The encoder is not currently implemented.
  64941. *
  64942. * **Decoder**
  64943. *
  64944. * 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.
  64945. *
  64946. * To update the configuration, use the following code:
  64947. * ```javascript
  64948. * DracoCompression.Configuration = {
  64949. * decoder: {
  64950. * wasmUrl: "<url to the WebAssembly library>",
  64951. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64952. * fallbackUrl: "<url to the fallback JavaScript library>",
  64953. * }
  64954. * };
  64955. * ```
  64956. *
  64957. * 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.
  64958. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64959. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64960. *
  64961. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64962. * ```javascript
  64963. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64964. * ```
  64965. *
  64966. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64967. */
  64968. export class DracoCompression implements IDisposable {
  64969. private _workerPoolPromise?;
  64970. private _decoderModulePromise?;
  64971. /**
  64972. * The configuration. Defaults to the following urls:
  64973. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64974. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64975. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64976. */
  64977. static Configuration: IDracoCompressionConfiguration;
  64978. /**
  64979. * Returns true if the decoder configuration is available.
  64980. */
  64981. static get DecoderAvailable(): boolean;
  64982. /**
  64983. * Default number of workers to create when creating the draco compression object.
  64984. */
  64985. static DefaultNumWorkers: number;
  64986. private static GetDefaultNumWorkers;
  64987. private static _Default;
  64988. /**
  64989. * Default instance for the draco compression object.
  64990. */
  64991. static get Default(): DracoCompression;
  64992. /**
  64993. * Constructor
  64994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64995. */
  64996. constructor(numWorkers?: number);
  64997. /**
  64998. * Stop all async operations and release resources.
  64999. */
  65000. dispose(): void;
  65001. /**
  65002. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65003. * @returns a promise that resolves when ready
  65004. */
  65005. whenReadyAsync(): Promise<void>;
  65006. /**
  65007. * Decode Draco compressed mesh data to vertex data.
  65008. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65009. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65010. * @returns A promise that resolves with the decoded vertex data
  65011. */
  65012. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65013. [kind: string]: number;
  65014. }): Promise<VertexData>;
  65015. }
  65016. }
  65017. declare module BABYLON {
  65018. /**
  65019. * Class for building Constructive Solid Geometry
  65020. */
  65021. export class CSG {
  65022. private polygons;
  65023. /**
  65024. * The world matrix
  65025. */
  65026. matrix: Matrix;
  65027. /**
  65028. * Stores the position
  65029. */
  65030. position: Vector3;
  65031. /**
  65032. * Stores the rotation
  65033. */
  65034. rotation: Vector3;
  65035. /**
  65036. * Stores the rotation quaternion
  65037. */
  65038. rotationQuaternion: Nullable<Quaternion>;
  65039. /**
  65040. * Stores the scaling vector
  65041. */
  65042. scaling: Vector3;
  65043. /**
  65044. * Convert the Mesh to CSG
  65045. * @param mesh The Mesh to convert to CSG
  65046. * @returns A new CSG from the Mesh
  65047. */
  65048. static FromMesh(mesh: Mesh): CSG;
  65049. /**
  65050. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65051. * @param polygons Polygons used to construct a CSG solid
  65052. */
  65053. private static FromPolygons;
  65054. /**
  65055. * Clones, or makes a deep copy, of the CSG
  65056. * @returns A new CSG
  65057. */
  65058. clone(): CSG;
  65059. /**
  65060. * Unions this CSG with another CSG
  65061. * @param csg The CSG to union against this CSG
  65062. * @returns The unioned CSG
  65063. */
  65064. union(csg: CSG): CSG;
  65065. /**
  65066. * Unions this CSG with another CSG in place
  65067. * @param csg The CSG to union against this CSG
  65068. */
  65069. unionInPlace(csg: CSG): void;
  65070. /**
  65071. * Subtracts this CSG with another CSG
  65072. * @param csg The CSG to subtract against this CSG
  65073. * @returns A new CSG
  65074. */
  65075. subtract(csg: CSG): CSG;
  65076. /**
  65077. * Subtracts this CSG with another CSG in place
  65078. * @param csg The CSG to subtact against this CSG
  65079. */
  65080. subtractInPlace(csg: CSG): void;
  65081. /**
  65082. * Intersect this CSG with another CSG
  65083. * @param csg The CSG to intersect against this CSG
  65084. * @returns A new CSG
  65085. */
  65086. intersect(csg: CSG): CSG;
  65087. /**
  65088. * Intersects this CSG with another CSG in place
  65089. * @param csg The CSG to intersect against this CSG
  65090. */
  65091. intersectInPlace(csg: CSG): void;
  65092. /**
  65093. * Return a new CSG solid with solid and empty space switched. This solid is
  65094. * not modified.
  65095. * @returns A new CSG solid with solid and empty space switched
  65096. */
  65097. inverse(): CSG;
  65098. /**
  65099. * Inverses the CSG in place
  65100. */
  65101. inverseInPlace(): void;
  65102. /**
  65103. * This is used to keep meshes transformations so they can be restored
  65104. * when we build back a Babylon Mesh
  65105. * NB : All CSG operations are performed in world coordinates
  65106. * @param csg The CSG to copy the transform attributes from
  65107. * @returns This CSG
  65108. */
  65109. copyTransformAttributes(csg: CSG): CSG;
  65110. /**
  65111. * Build Raw mesh from CSG
  65112. * Coordinates here are in world space
  65113. * @param name The name of the mesh geometry
  65114. * @param scene The Scene
  65115. * @param keepSubMeshes Specifies if the submeshes should be kept
  65116. * @returns A new Mesh
  65117. */
  65118. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65119. /**
  65120. * Build Mesh from CSG taking material and transforms into account
  65121. * @param name The name of the Mesh
  65122. * @param material The material of the Mesh
  65123. * @param scene The Scene
  65124. * @param keepSubMeshes Specifies if submeshes should be kept
  65125. * @returns The new Mesh
  65126. */
  65127. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65128. }
  65129. }
  65130. declare module BABYLON {
  65131. /**
  65132. * Class used to create a trail following a mesh
  65133. */
  65134. export class TrailMesh extends Mesh {
  65135. private _generator;
  65136. private _autoStart;
  65137. private _running;
  65138. private _diameter;
  65139. private _length;
  65140. private _sectionPolygonPointsCount;
  65141. private _sectionVectors;
  65142. private _sectionNormalVectors;
  65143. private _beforeRenderObserver;
  65144. /**
  65145. * @constructor
  65146. * @param name The value used by scene.getMeshByName() to do a lookup.
  65147. * @param generator The mesh or transform node to generate a trail.
  65148. * @param scene The scene to add this mesh to.
  65149. * @param diameter Diameter of trailing mesh. Default is 1.
  65150. * @param length Length of trailing mesh. Default is 60.
  65151. * @param autoStart Automatically start trailing mesh. Default true.
  65152. */
  65153. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65154. /**
  65155. * "TrailMesh"
  65156. * @returns "TrailMesh"
  65157. */
  65158. getClassName(): string;
  65159. private _createMesh;
  65160. /**
  65161. * Start trailing mesh.
  65162. */
  65163. start(): void;
  65164. /**
  65165. * Stop trailing mesh.
  65166. */
  65167. stop(): void;
  65168. /**
  65169. * Update trailing mesh geometry.
  65170. */
  65171. update(): void;
  65172. /**
  65173. * Returns a new TrailMesh object.
  65174. * @param name is a string, the name given to the new mesh
  65175. * @param newGenerator use new generator object for cloned trail mesh
  65176. * @returns a new mesh
  65177. */
  65178. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65179. /**
  65180. * Serializes this trail mesh
  65181. * @param serializationObject object to write serialization to
  65182. */
  65183. serialize(serializationObject: any): void;
  65184. /**
  65185. * Parses a serialized trail mesh
  65186. * @param parsedMesh the serialized mesh
  65187. * @param scene the scene to create the trail mesh in
  65188. * @returns the created trail mesh
  65189. */
  65190. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65191. }
  65192. }
  65193. declare module BABYLON {
  65194. /**
  65195. * Class containing static functions to help procedurally build meshes
  65196. */
  65197. export class TiledBoxBuilder {
  65198. /**
  65199. * Creates a box mesh
  65200. * 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)
  65201. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65203. * * 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
  65204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65205. * @param name defines the name of the mesh
  65206. * @param options defines the options used to create the mesh
  65207. * @param scene defines the hosting scene
  65208. * @returns the box mesh
  65209. */
  65210. static CreateTiledBox(name: string, options: {
  65211. pattern?: number;
  65212. width?: number;
  65213. height?: number;
  65214. depth?: number;
  65215. tileSize?: number;
  65216. tileWidth?: number;
  65217. tileHeight?: number;
  65218. alignHorizontal?: number;
  65219. alignVertical?: number;
  65220. faceUV?: Vector4[];
  65221. faceColors?: Color4[];
  65222. sideOrientation?: number;
  65223. updatable?: boolean;
  65224. }, scene?: Nullable<Scene>): Mesh;
  65225. }
  65226. }
  65227. declare module BABYLON {
  65228. /**
  65229. * Class containing static functions to help procedurally build meshes
  65230. */
  65231. export class TorusKnotBuilder {
  65232. /**
  65233. * Creates a torus knot mesh
  65234. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65235. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65236. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65237. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65239. * * 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
  65240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65241. * @param name defines the name of the mesh
  65242. * @param options defines the options used to create the mesh
  65243. * @param scene defines the hosting scene
  65244. * @returns the torus knot mesh
  65245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65246. */
  65247. static CreateTorusKnot(name: string, options: {
  65248. radius?: number;
  65249. tube?: number;
  65250. radialSegments?: number;
  65251. tubularSegments?: number;
  65252. p?: number;
  65253. q?: number;
  65254. updatable?: boolean;
  65255. sideOrientation?: number;
  65256. frontUVs?: Vector4;
  65257. backUVs?: Vector4;
  65258. }, scene: any): Mesh;
  65259. }
  65260. }
  65261. declare module BABYLON {
  65262. /**
  65263. * Polygon
  65264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65265. */
  65266. export class Polygon {
  65267. /**
  65268. * Creates a rectangle
  65269. * @param xmin bottom X coord
  65270. * @param ymin bottom Y coord
  65271. * @param xmax top X coord
  65272. * @param ymax top Y coord
  65273. * @returns points that make the resulting rectation
  65274. */
  65275. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65276. /**
  65277. * Creates a circle
  65278. * @param radius radius of circle
  65279. * @param cx scale in x
  65280. * @param cy scale in y
  65281. * @param numberOfSides number of sides that make up the circle
  65282. * @returns points that make the resulting circle
  65283. */
  65284. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65285. /**
  65286. * Creates a polygon from input string
  65287. * @param input Input polygon data
  65288. * @returns the parsed points
  65289. */
  65290. static Parse(input: string): Vector2[];
  65291. /**
  65292. * Starts building a polygon from x and y coordinates
  65293. * @param x x coordinate
  65294. * @param y y coordinate
  65295. * @returns the started path2
  65296. */
  65297. static StartingAt(x: number, y: number): Path2;
  65298. }
  65299. /**
  65300. * Builds a polygon
  65301. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65302. */
  65303. export class PolygonMeshBuilder {
  65304. private _points;
  65305. private _outlinepoints;
  65306. private _holes;
  65307. private _name;
  65308. private _scene;
  65309. private _epoints;
  65310. private _eholes;
  65311. private _addToepoint;
  65312. /**
  65313. * Babylon reference to the earcut plugin.
  65314. */
  65315. bjsEarcut: any;
  65316. /**
  65317. * Creates a PolygonMeshBuilder
  65318. * @param name name of the builder
  65319. * @param contours Path of the polygon
  65320. * @param scene scene to add to when creating the mesh
  65321. * @param earcutInjection can be used to inject your own earcut reference
  65322. */
  65323. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65324. /**
  65325. * Adds a whole within the polygon
  65326. * @param hole Array of points defining the hole
  65327. * @returns this
  65328. */
  65329. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65330. /**
  65331. * Creates the polygon
  65332. * @param updatable If the mesh should be updatable
  65333. * @param depth The depth of the mesh created
  65334. * @returns the created mesh
  65335. */
  65336. build(updatable?: boolean, depth?: number): Mesh;
  65337. /**
  65338. * Creates the polygon
  65339. * @param depth The depth of the mesh created
  65340. * @returns the created VertexData
  65341. */
  65342. buildVertexData(depth?: number): VertexData;
  65343. /**
  65344. * Adds a side to the polygon
  65345. * @param positions points that make the polygon
  65346. * @param normals normals of the polygon
  65347. * @param uvs uvs of the polygon
  65348. * @param indices indices of the polygon
  65349. * @param bounds bounds of the polygon
  65350. * @param points points of the polygon
  65351. * @param depth depth of the polygon
  65352. * @param flip flip of the polygon
  65353. */
  65354. private addSide;
  65355. }
  65356. }
  65357. declare module BABYLON {
  65358. /**
  65359. * Class containing static functions to help procedurally build meshes
  65360. */
  65361. export class PolygonBuilder {
  65362. /**
  65363. * Creates a polygon mesh
  65364. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65365. * * 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
  65366. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65368. * * 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)
  65369. * * Remember you can only change the shape positions, not their number when updating a polygon
  65370. * @param name defines the name of the mesh
  65371. * @param options defines the options used to create the mesh
  65372. * @param scene defines the hosting scene
  65373. * @param earcutInjection can be used to inject your own earcut reference
  65374. * @returns the polygon mesh
  65375. */
  65376. static CreatePolygon(name: string, options: {
  65377. shape: Vector3[];
  65378. holes?: Vector3[][];
  65379. depth?: number;
  65380. faceUV?: Vector4[];
  65381. faceColors?: Color4[];
  65382. updatable?: boolean;
  65383. sideOrientation?: number;
  65384. frontUVs?: Vector4;
  65385. backUVs?: Vector4;
  65386. wrap?: boolean;
  65387. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65388. /**
  65389. * Creates an extruded polygon mesh, with depth in the Y direction.
  65390. * * 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)
  65391. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65392. * @param name defines the name of the mesh
  65393. * @param options defines the options used to create the mesh
  65394. * @param scene defines the hosting scene
  65395. * @param earcutInjection can be used to inject your own earcut reference
  65396. * @returns the polygon mesh
  65397. */
  65398. static ExtrudePolygon(name: string, options: {
  65399. shape: Vector3[];
  65400. holes?: Vector3[][];
  65401. depth?: number;
  65402. faceUV?: Vector4[];
  65403. faceColors?: Color4[];
  65404. updatable?: boolean;
  65405. sideOrientation?: number;
  65406. frontUVs?: Vector4;
  65407. backUVs?: Vector4;
  65408. wrap?: boolean;
  65409. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65410. }
  65411. }
  65412. declare module BABYLON {
  65413. /**
  65414. * Class containing static functions to help procedurally build meshes
  65415. */
  65416. export class LatheBuilder {
  65417. /**
  65418. * Creates lathe mesh.
  65419. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65420. * * 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
  65421. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65422. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65423. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65424. * * 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
  65425. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65426. * * 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
  65427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65428. * * 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
  65429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65431. * @param name defines the name of the mesh
  65432. * @param options defines the options used to create the mesh
  65433. * @param scene defines the hosting scene
  65434. * @returns the lathe mesh
  65435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65436. */
  65437. static CreateLathe(name: string, options: {
  65438. shape: Vector3[];
  65439. radius?: number;
  65440. tessellation?: number;
  65441. clip?: number;
  65442. arc?: number;
  65443. closed?: boolean;
  65444. updatable?: boolean;
  65445. sideOrientation?: number;
  65446. frontUVs?: Vector4;
  65447. backUVs?: Vector4;
  65448. cap?: number;
  65449. invertUV?: boolean;
  65450. }, scene?: Nullable<Scene>): Mesh;
  65451. }
  65452. }
  65453. declare module BABYLON {
  65454. /**
  65455. * Class containing static functions to help procedurally build meshes
  65456. */
  65457. export class TiledPlaneBuilder {
  65458. /**
  65459. * Creates a tiled plane mesh
  65460. * * The parameter `pattern` will, depending on value, do nothing or
  65461. * * * flip (reflect about central vertical) alternate tiles across and up
  65462. * * * flip every tile on alternate rows
  65463. * * * rotate (180 degs) alternate tiles across and up
  65464. * * * rotate every tile on alternate rows
  65465. * * * flip and rotate alternate tiles across and up
  65466. * * * flip and rotate every tile on alternate rows
  65467. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65468. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65469. * * 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
  65470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65471. * * 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)
  65472. * * 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)
  65473. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65474. * @param name defines the name of the mesh
  65475. * @param options defines the options used to create the mesh
  65476. * @param scene defines the hosting scene
  65477. * @returns the box mesh
  65478. */
  65479. static CreateTiledPlane(name: string, options: {
  65480. pattern?: number;
  65481. tileSize?: number;
  65482. tileWidth?: number;
  65483. tileHeight?: number;
  65484. size?: number;
  65485. width?: number;
  65486. height?: number;
  65487. alignHorizontal?: number;
  65488. alignVertical?: number;
  65489. sideOrientation?: number;
  65490. frontUVs?: Vector4;
  65491. backUVs?: Vector4;
  65492. updatable?: boolean;
  65493. }, scene?: Nullable<Scene>): Mesh;
  65494. }
  65495. }
  65496. declare module BABYLON {
  65497. /**
  65498. * Class containing static functions to help procedurally build meshes
  65499. */
  65500. export class TubeBuilder {
  65501. /**
  65502. * Creates a tube mesh.
  65503. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65504. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65505. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65506. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65507. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65508. * * 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)
  65509. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65510. * * 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
  65511. * * 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
  65512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65513. * * 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
  65514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65516. * @param name defines the name of the mesh
  65517. * @param options defines the options used to create the mesh
  65518. * @param scene defines the hosting scene
  65519. * @returns the tube mesh
  65520. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65521. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65522. */
  65523. static CreateTube(name: string, options: {
  65524. path: Vector3[];
  65525. radius?: number;
  65526. tessellation?: number;
  65527. radiusFunction?: {
  65528. (i: number, distance: number): number;
  65529. };
  65530. cap?: number;
  65531. arc?: number;
  65532. updatable?: boolean;
  65533. sideOrientation?: number;
  65534. frontUVs?: Vector4;
  65535. backUVs?: Vector4;
  65536. instance?: Mesh;
  65537. invertUV?: boolean;
  65538. }, scene?: Nullable<Scene>): Mesh;
  65539. }
  65540. }
  65541. declare module BABYLON {
  65542. /**
  65543. * Class containing static functions to help procedurally build meshes
  65544. */
  65545. export class IcoSphereBuilder {
  65546. /**
  65547. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65548. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65549. * * 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`)
  65550. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65551. * * 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
  65552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65553. * * 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
  65554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65555. * @param name defines the name of the mesh
  65556. * @param options defines the options used to create the mesh
  65557. * @param scene defines the hosting scene
  65558. * @returns the icosahedron mesh
  65559. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65560. */
  65561. static CreateIcoSphere(name: string, options: {
  65562. radius?: number;
  65563. radiusX?: number;
  65564. radiusY?: number;
  65565. radiusZ?: number;
  65566. flat?: boolean;
  65567. subdivisions?: number;
  65568. sideOrientation?: number;
  65569. frontUVs?: Vector4;
  65570. backUVs?: Vector4;
  65571. updatable?: boolean;
  65572. }, scene?: Nullable<Scene>): Mesh;
  65573. }
  65574. }
  65575. declare module BABYLON {
  65576. /**
  65577. * Class containing static functions to help procedurally build meshes
  65578. */
  65579. export class DecalBuilder {
  65580. /**
  65581. * Creates a decal mesh.
  65582. * 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
  65583. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65584. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65585. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65586. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65587. * @param name defines the name of the mesh
  65588. * @param sourceMesh defines the mesh where the decal must be applied
  65589. * @param options defines the options used to create the mesh
  65590. * @param scene defines the hosting scene
  65591. * @returns the decal mesh
  65592. * @see https://doc.babylonjs.com/how_to/decals
  65593. */
  65594. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65595. position?: Vector3;
  65596. normal?: Vector3;
  65597. size?: Vector3;
  65598. angle?: number;
  65599. }): Mesh;
  65600. }
  65601. }
  65602. declare module BABYLON {
  65603. /**
  65604. * Class containing static functions to help procedurally build meshes
  65605. */
  65606. export class MeshBuilder {
  65607. /**
  65608. * Creates a box mesh
  65609. * * The parameter `size` sets the size (float) of each box side (default 1)
  65610. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65611. * * 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)
  65612. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65614. * * 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
  65615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65616. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65617. * @param name defines the name of the mesh
  65618. * @param options defines the options used to create the mesh
  65619. * @param scene defines the hosting scene
  65620. * @returns the box mesh
  65621. */
  65622. static CreateBox(name: string, options: {
  65623. size?: number;
  65624. width?: number;
  65625. height?: number;
  65626. depth?: number;
  65627. faceUV?: Vector4[];
  65628. faceColors?: Color4[];
  65629. sideOrientation?: number;
  65630. frontUVs?: Vector4;
  65631. backUVs?: Vector4;
  65632. wrap?: boolean;
  65633. topBaseAt?: number;
  65634. bottomBaseAt?: number;
  65635. updatable?: boolean;
  65636. }, scene?: Nullable<Scene>): Mesh;
  65637. /**
  65638. * Creates a tiled box mesh
  65639. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65641. * @param name defines the name of the mesh
  65642. * @param options defines the options used to create the mesh
  65643. * @param scene defines the hosting scene
  65644. * @returns the tiled box mesh
  65645. */
  65646. static CreateTiledBox(name: string, options: {
  65647. pattern?: number;
  65648. size?: number;
  65649. width?: number;
  65650. height?: number;
  65651. depth: number;
  65652. tileSize?: number;
  65653. tileWidth?: number;
  65654. tileHeight?: number;
  65655. faceUV?: Vector4[];
  65656. faceColors?: Color4[];
  65657. alignHorizontal?: number;
  65658. alignVertical?: number;
  65659. sideOrientation?: number;
  65660. updatable?: boolean;
  65661. }, scene?: Nullable<Scene>): Mesh;
  65662. /**
  65663. * Creates a sphere mesh
  65664. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65665. * * 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`)
  65666. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65667. * * 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
  65668. * * 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)
  65669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65670. * * 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
  65671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65672. * @param name defines the name of the mesh
  65673. * @param options defines the options used to create the mesh
  65674. * @param scene defines the hosting scene
  65675. * @returns the sphere mesh
  65676. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65677. */
  65678. static CreateSphere(name: string, options: {
  65679. segments?: number;
  65680. diameter?: number;
  65681. diameterX?: number;
  65682. diameterY?: number;
  65683. diameterZ?: number;
  65684. arc?: number;
  65685. slice?: number;
  65686. sideOrientation?: number;
  65687. frontUVs?: Vector4;
  65688. backUVs?: Vector4;
  65689. updatable?: boolean;
  65690. }, scene?: Nullable<Scene>): Mesh;
  65691. /**
  65692. * Creates a plane polygonal mesh. By default, this is a disc
  65693. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65694. * * 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
  65695. * * 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
  65696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65697. * * 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
  65698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65699. * @param name defines the name of the mesh
  65700. * @param options defines the options used to create the mesh
  65701. * @param scene defines the hosting scene
  65702. * @returns the plane polygonal mesh
  65703. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65704. */
  65705. static CreateDisc(name: string, options: {
  65706. radius?: number;
  65707. tessellation?: number;
  65708. arc?: number;
  65709. updatable?: boolean;
  65710. sideOrientation?: number;
  65711. frontUVs?: Vector4;
  65712. backUVs?: Vector4;
  65713. }, scene?: Nullable<Scene>): Mesh;
  65714. /**
  65715. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65716. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65717. * * 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`)
  65718. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65719. * * 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
  65720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65721. * * 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
  65722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65723. * @param name defines the name of the mesh
  65724. * @param options defines the options used to create the mesh
  65725. * @param scene defines the hosting scene
  65726. * @returns the icosahedron mesh
  65727. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65728. */
  65729. static CreateIcoSphere(name: string, options: {
  65730. radius?: number;
  65731. radiusX?: number;
  65732. radiusY?: number;
  65733. radiusZ?: number;
  65734. flat?: boolean;
  65735. subdivisions?: number;
  65736. sideOrientation?: number;
  65737. frontUVs?: Vector4;
  65738. backUVs?: Vector4;
  65739. updatable?: boolean;
  65740. }, scene?: Nullable<Scene>): Mesh;
  65741. /**
  65742. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65743. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65744. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65745. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65746. * * 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
  65747. * * 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
  65748. * * 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
  65749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65750. * * 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
  65751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65752. * * 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
  65753. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65754. * * 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
  65755. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65757. * @param name defines the name of the mesh
  65758. * @param options defines the options used to create the mesh
  65759. * @param scene defines the hosting scene
  65760. * @returns the ribbon mesh
  65761. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65763. */
  65764. static CreateRibbon(name: string, options: {
  65765. pathArray: Vector3[][];
  65766. closeArray?: boolean;
  65767. closePath?: boolean;
  65768. offset?: number;
  65769. updatable?: boolean;
  65770. sideOrientation?: number;
  65771. frontUVs?: Vector4;
  65772. backUVs?: Vector4;
  65773. instance?: Mesh;
  65774. invertUV?: boolean;
  65775. uvs?: Vector2[];
  65776. colors?: Color4[];
  65777. }, scene?: Nullable<Scene>): Mesh;
  65778. /**
  65779. * Creates a cylinder or a cone mesh
  65780. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65781. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65782. * * 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.
  65783. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65784. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65785. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65786. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65787. * * 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).
  65788. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65789. * * 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).
  65790. * * 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
  65791. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65792. * * 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
  65793. * * 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.
  65794. * * If `enclose` is false, a ring surface is one element.
  65795. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65796. * * 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
  65797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65798. * * 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
  65799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65800. * @param name defines the name of the mesh
  65801. * @param options defines the options used to create the mesh
  65802. * @param scene defines the hosting scene
  65803. * @returns the cylinder mesh
  65804. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65805. */
  65806. static CreateCylinder(name: string, options: {
  65807. height?: number;
  65808. diameterTop?: number;
  65809. diameterBottom?: number;
  65810. diameter?: number;
  65811. tessellation?: number;
  65812. subdivisions?: number;
  65813. arc?: number;
  65814. faceColors?: Color4[];
  65815. faceUV?: Vector4[];
  65816. updatable?: boolean;
  65817. hasRings?: boolean;
  65818. enclose?: boolean;
  65819. cap?: number;
  65820. sideOrientation?: number;
  65821. frontUVs?: Vector4;
  65822. backUVs?: Vector4;
  65823. }, scene?: Nullable<Scene>): Mesh;
  65824. /**
  65825. * Creates a torus mesh
  65826. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65827. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65828. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65830. * * 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
  65831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65832. * @param name defines the name of the mesh
  65833. * @param options defines the options used to create the mesh
  65834. * @param scene defines the hosting scene
  65835. * @returns the torus mesh
  65836. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65837. */
  65838. static CreateTorus(name: string, options: {
  65839. diameter?: number;
  65840. thickness?: number;
  65841. tessellation?: number;
  65842. updatable?: boolean;
  65843. sideOrientation?: number;
  65844. frontUVs?: Vector4;
  65845. backUVs?: Vector4;
  65846. }, scene?: Nullable<Scene>): Mesh;
  65847. /**
  65848. * Creates a torus knot mesh
  65849. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65850. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65851. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65852. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65854. * * 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
  65855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65856. * @param name defines the name of the mesh
  65857. * @param options defines the options used to create the mesh
  65858. * @param scene defines the hosting scene
  65859. * @returns the torus knot mesh
  65860. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65861. */
  65862. static CreateTorusKnot(name: string, options: {
  65863. radius?: number;
  65864. tube?: number;
  65865. radialSegments?: number;
  65866. tubularSegments?: number;
  65867. p?: number;
  65868. q?: number;
  65869. updatable?: boolean;
  65870. sideOrientation?: number;
  65871. frontUVs?: Vector4;
  65872. backUVs?: Vector4;
  65873. }, scene?: Nullable<Scene>): Mesh;
  65874. /**
  65875. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65876. * * 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
  65877. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65878. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65879. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65880. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65881. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65882. * * 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
  65883. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65886. * @param name defines the name of the new line system
  65887. * @param options defines the options used to create the line system
  65888. * @param scene defines the hosting scene
  65889. * @returns a new line system mesh
  65890. */
  65891. static CreateLineSystem(name: string, options: {
  65892. lines: Vector3[][];
  65893. updatable?: boolean;
  65894. instance?: Nullable<LinesMesh>;
  65895. colors?: Nullable<Color4[][]>;
  65896. useVertexAlpha?: boolean;
  65897. }, scene: Nullable<Scene>): LinesMesh;
  65898. /**
  65899. * Creates a line mesh
  65900. * 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
  65901. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65902. * * The parameter `points` is an array successive Vector3
  65903. * * 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
  65904. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65905. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65906. * * When updating an instance, remember that only point positions can change, not the number of points
  65907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65909. * @param name defines the name of the new line system
  65910. * @param options defines the options used to create the line system
  65911. * @param scene defines the hosting scene
  65912. * @returns a new line mesh
  65913. */
  65914. static CreateLines(name: string, options: {
  65915. points: Vector3[];
  65916. updatable?: boolean;
  65917. instance?: Nullable<LinesMesh>;
  65918. colors?: Color4[];
  65919. useVertexAlpha?: boolean;
  65920. }, scene?: Nullable<Scene>): LinesMesh;
  65921. /**
  65922. * Creates a dashed line mesh
  65923. * * 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
  65924. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65925. * * The parameter `points` is an array successive Vector3
  65926. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65927. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65928. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65929. * * 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
  65930. * * When updating an instance, remember that only point positions can change, not the number of points
  65931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65932. * @param name defines the name of the mesh
  65933. * @param options defines the options used to create the mesh
  65934. * @param scene defines the hosting scene
  65935. * @returns the dashed line mesh
  65936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65937. */
  65938. static CreateDashedLines(name: string, options: {
  65939. points: Vector3[];
  65940. dashSize?: number;
  65941. gapSize?: number;
  65942. dashNb?: number;
  65943. updatable?: boolean;
  65944. instance?: LinesMesh;
  65945. }, scene?: Nullable<Scene>): LinesMesh;
  65946. /**
  65947. * 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.
  65948. * * 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.
  65949. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65950. * * 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.
  65951. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65952. * * 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
  65953. * * 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
  65954. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65956. * * 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
  65957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65959. * @param name defines the name of the mesh
  65960. * @param options defines the options used to create the mesh
  65961. * @param scene defines the hosting scene
  65962. * @returns the extruded shape mesh
  65963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65965. */
  65966. static ExtrudeShape(name: string, options: {
  65967. shape: Vector3[];
  65968. path: Vector3[];
  65969. scale?: number;
  65970. rotation?: number;
  65971. cap?: number;
  65972. updatable?: boolean;
  65973. sideOrientation?: number;
  65974. frontUVs?: Vector4;
  65975. backUVs?: Vector4;
  65976. instance?: Mesh;
  65977. invertUV?: boolean;
  65978. }, scene?: Nullable<Scene>): Mesh;
  65979. /**
  65980. * Creates an custom extruded shape mesh.
  65981. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65982. * * 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.
  65983. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65984. * * 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
  65985. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65986. * * 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
  65987. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65988. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65989. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65990. * * 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
  65991. * * 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
  65992. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65994. * * 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
  65995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65997. * @param name defines the name of the mesh
  65998. * @param options defines the options used to create the mesh
  65999. * @param scene defines the hosting scene
  66000. * @returns the custom extruded shape mesh
  66001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66004. */
  66005. static ExtrudeShapeCustom(name: string, options: {
  66006. shape: Vector3[];
  66007. path: Vector3[];
  66008. scaleFunction?: any;
  66009. rotationFunction?: any;
  66010. ribbonCloseArray?: boolean;
  66011. ribbonClosePath?: boolean;
  66012. cap?: number;
  66013. updatable?: boolean;
  66014. sideOrientation?: number;
  66015. frontUVs?: Vector4;
  66016. backUVs?: Vector4;
  66017. instance?: Mesh;
  66018. invertUV?: boolean;
  66019. }, scene?: Nullable<Scene>): Mesh;
  66020. /**
  66021. * Creates lathe mesh.
  66022. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66023. * * 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
  66024. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66025. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66026. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66027. * * 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
  66028. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66029. * * 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
  66030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66031. * * 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
  66032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66034. * @param name defines the name of the mesh
  66035. * @param options defines the options used to create the mesh
  66036. * @param scene defines the hosting scene
  66037. * @returns the lathe mesh
  66038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66039. */
  66040. static CreateLathe(name: string, options: {
  66041. shape: Vector3[];
  66042. radius?: number;
  66043. tessellation?: number;
  66044. clip?: number;
  66045. arc?: number;
  66046. closed?: boolean;
  66047. updatable?: boolean;
  66048. sideOrientation?: number;
  66049. frontUVs?: Vector4;
  66050. backUVs?: Vector4;
  66051. cap?: number;
  66052. invertUV?: boolean;
  66053. }, scene?: Nullable<Scene>): Mesh;
  66054. /**
  66055. * Creates a tiled plane mesh
  66056. * * You can set a limited pattern arrangement with the tiles
  66057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66058. * * 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
  66059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66060. * @param name defines the name of the mesh
  66061. * @param options defines the options used to create the mesh
  66062. * @param scene defines the hosting scene
  66063. * @returns the plane mesh
  66064. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66065. */
  66066. static CreateTiledPlane(name: string, options: {
  66067. pattern?: number;
  66068. tileSize?: number;
  66069. tileWidth?: number;
  66070. tileHeight?: number;
  66071. size?: number;
  66072. width?: number;
  66073. height?: number;
  66074. alignHorizontal?: number;
  66075. alignVertical?: number;
  66076. sideOrientation?: number;
  66077. frontUVs?: Vector4;
  66078. backUVs?: Vector4;
  66079. updatable?: boolean;
  66080. }, scene?: Nullable<Scene>): Mesh;
  66081. /**
  66082. * Creates a plane mesh
  66083. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66084. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66085. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66087. * * 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
  66088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66089. * @param name defines the name of the mesh
  66090. * @param options defines the options used to create the mesh
  66091. * @param scene defines the hosting scene
  66092. * @returns the plane mesh
  66093. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66094. */
  66095. static CreatePlane(name: string, options: {
  66096. size?: number;
  66097. width?: number;
  66098. height?: number;
  66099. sideOrientation?: number;
  66100. frontUVs?: Vector4;
  66101. backUVs?: Vector4;
  66102. updatable?: boolean;
  66103. sourcePlane?: Plane;
  66104. }, scene?: Nullable<Scene>): Mesh;
  66105. /**
  66106. * Creates a ground mesh
  66107. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66108. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66110. * @param name defines the name of the mesh
  66111. * @param options defines the options used to create the mesh
  66112. * @param scene defines the hosting scene
  66113. * @returns the ground mesh
  66114. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66115. */
  66116. static CreateGround(name: string, options: {
  66117. width?: number;
  66118. height?: number;
  66119. subdivisions?: number;
  66120. subdivisionsX?: number;
  66121. subdivisionsY?: number;
  66122. updatable?: boolean;
  66123. }, scene?: Nullable<Scene>): Mesh;
  66124. /**
  66125. * Creates a tiled ground mesh
  66126. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66127. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66128. * * 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
  66129. * * 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
  66130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66131. * @param name defines the name of the mesh
  66132. * @param options defines the options used to create the mesh
  66133. * @param scene defines the hosting scene
  66134. * @returns the tiled ground mesh
  66135. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66136. */
  66137. static CreateTiledGround(name: string, options: {
  66138. xmin: number;
  66139. zmin: number;
  66140. xmax: number;
  66141. zmax: number;
  66142. subdivisions?: {
  66143. w: number;
  66144. h: number;
  66145. };
  66146. precision?: {
  66147. w: number;
  66148. h: number;
  66149. };
  66150. updatable?: boolean;
  66151. }, scene?: Nullable<Scene>): Mesh;
  66152. /**
  66153. * Creates a ground mesh from a height map
  66154. * * The parameter `url` sets the URL of the height map image resource.
  66155. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66156. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66157. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66158. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66159. * * 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.
  66160. * * 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).
  66161. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66163. * @param name defines the name of the mesh
  66164. * @param url defines the url to the height map
  66165. * @param options defines the options used to create the mesh
  66166. * @param scene defines the hosting scene
  66167. * @returns the ground mesh
  66168. * @see https://doc.babylonjs.com/babylon101/height_map
  66169. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66170. */
  66171. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66172. width?: number;
  66173. height?: number;
  66174. subdivisions?: number;
  66175. minHeight?: number;
  66176. maxHeight?: number;
  66177. colorFilter?: Color3;
  66178. alphaFilter?: number;
  66179. updatable?: boolean;
  66180. onReady?: (mesh: GroundMesh) => void;
  66181. }, scene?: Nullable<Scene>): GroundMesh;
  66182. /**
  66183. * Creates a polygon mesh
  66184. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66185. * * 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
  66186. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66188. * * 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)
  66189. * * Remember you can only change the shape positions, not their number when updating a polygon
  66190. * @param name defines the name of the mesh
  66191. * @param options defines the options used to create the mesh
  66192. * @param scene defines the hosting scene
  66193. * @param earcutInjection can be used to inject your own earcut reference
  66194. * @returns the polygon mesh
  66195. */
  66196. static CreatePolygon(name: string, options: {
  66197. shape: Vector3[];
  66198. holes?: Vector3[][];
  66199. depth?: number;
  66200. faceUV?: Vector4[];
  66201. faceColors?: Color4[];
  66202. updatable?: boolean;
  66203. sideOrientation?: number;
  66204. frontUVs?: Vector4;
  66205. backUVs?: Vector4;
  66206. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66207. /**
  66208. * Creates an extruded polygon mesh, with depth in the Y direction.
  66209. * * 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)
  66210. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66211. * @param name defines the name of the mesh
  66212. * @param options defines the options used to create the mesh
  66213. * @param scene defines the hosting scene
  66214. * @param earcutInjection can be used to inject your own earcut reference
  66215. * @returns the polygon mesh
  66216. */
  66217. static ExtrudePolygon(name: string, options: {
  66218. shape: Vector3[];
  66219. holes?: Vector3[][];
  66220. depth?: number;
  66221. faceUV?: Vector4[];
  66222. faceColors?: Color4[];
  66223. updatable?: boolean;
  66224. sideOrientation?: number;
  66225. frontUVs?: Vector4;
  66226. backUVs?: Vector4;
  66227. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66228. /**
  66229. * Creates a tube mesh.
  66230. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66231. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66232. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66233. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66234. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66235. * * 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)
  66236. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66237. * * 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
  66238. * * 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
  66239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66240. * * 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
  66241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66243. * @param name defines the name of the mesh
  66244. * @param options defines the options used to create the mesh
  66245. * @param scene defines the hosting scene
  66246. * @returns the tube mesh
  66247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66248. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66249. */
  66250. static CreateTube(name: string, options: {
  66251. path: Vector3[];
  66252. radius?: number;
  66253. tessellation?: number;
  66254. radiusFunction?: {
  66255. (i: number, distance: number): number;
  66256. };
  66257. cap?: number;
  66258. arc?: number;
  66259. updatable?: boolean;
  66260. sideOrientation?: number;
  66261. frontUVs?: Vector4;
  66262. backUVs?: Vector4;
  66263. instance?: Mesh;
  66264. invertUV?: boolean;
  66265. }, scene?: Nullable<Scene>): Mesh;
  66266. /**
  66267. * Creates a polyhedron mesh
  66268. * * 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
  66269. * * The parameter `size` (positive float, default 1) sets the polygon size
  66270. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66271. * * 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`
  66272. * * 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
  66273. * * 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)`)
  66274. * * 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
  66275. * * 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
  66276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66277. * * 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
  66278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66279. * @param name defines the name of the mesh
  66280. * @param options defines the options used to create the mesh
  66281. * @param scene defines the hosting scene
  66282. * @returns the polyhedron mesh
  66283. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66284. */
  66285. static CreatePolyhedron(name: string, options: {
  66286. type?: number;
  66287. size?: number;
  66288. sizeX?: number;
  66289. sizeY?: number;
  66290. sizeZ?: number;
  66291. custom?: any;
  66292. faceUV?: Vector4[];
  66293. faceColors?: Color4[];
  66294. flat?: boolean;
  66295. updatable?: boolean;
  66296. sideOrientation?: number;
  66297. frontUVs?: Vector4;
  66298. backUVs?: Vector4;
  66299. }, scene?: Nullable<Scene>): Mesh;
  66300. /**
  66301. * Creates a decal mesh.
  66302. * 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
  66303. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66304. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66305. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66306. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66307. * @param name defines the name of the mesh
  66308. * @param sourceMesh defines the mesh where the decal must be applied
  66309. * @param options defines the options used to create the mesh
  66310. * @param scene defines the hosting scene
  66311. * @returns the decal mesh
  66312. * @see https://doc.babylonjs.com/how_to/decals
  66313. */
  66314. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66315. position?: Vector3;
  66316. normal?: Vector3;
  66317. size?: Vector3;
  66318. angle?: number;
  66319. }): Mesh;
  66320. }
  66321. }
  66322. declare module BABYLON {
  66323. /**
  66324. * A simplifier interface for future simplification implementations
  66325. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66326. */
  66327. export interface ISimplifier {
  66328. /**
  66329. * Simplification of a given mesh according to the given settings.
  66330. * Since this requires computation, it is assumed that the function runs async.
  66331. * @param settings The settings of the simplification, including quality and distance
  66332. * @param successCallback A callback that will be called after the mesh was simplified.
  66333. * @param errorCallback in case of an error, this callback will be called. optional.
  66334. */
  66335. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66336. }
  66337. /**
  66338. * Expected simplification settings.
  66339. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66340. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66341. */
  66342. export interface ISimplificationSettings {
  66343. /**
  66344. * Gets or sets the expected quality
  66345. */
  66346. quality: number;
  66347. /**
  66348. * Gets or sets the distance when this optimized version should be used
  66349. */
  66350. distance: number;
  66351. /**
  66352. * Gets an already optimized mesh
  66353. */
  66354. optimizeMesh?: boolean;
  66355. }
  66356. /**
  66357. * Class used to specify simplification options
  66358. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66359. */
  66360. export class SimplificationSettings implements ISimplificationSettings {
  66361. /** expected quality */
  66362. quality: number;
  66363. /** distance when this optimized version should be used */
  66364. distance: number;
  66365. /** already optimized mesh */
  66366. optimizeMesh?: boolean | undefined;
  66367. /**
  66368. * Creates a SimplificationSettings
  66369. * @param quality expected quality
  66370. * @param distance distance when this optimized version should be used
  66371. * @param optimizeMesh already optimized mesh
  66372. */
  66373. constructor(
  66374. /** expected quality */
  66375. quality: number,
  66376. /** distance when this optimized version should be used */
  66377. distance: number,
  66378. /** already optimized mesh */
  66379. optimizeMesh?: boolean | undefined);
  66380. }
  66381. /**
  66382. * Interface used to define a simplification task
  66383. */
  66384. export interface ISimplificationTask {
  66385. /**
  66386. * Array of settings
  66387. */
  66388. settings: Array<ISimplificationSettings>;
  66389. /**
  66390. * Simplification type
  66391. */
  66392. simplificationType: SimplificationType;
  66393. /**
  66394. * Mesh to simplify
  66395. */
  66396. mesh: Mesh;
  66397. /**
  66398. * Callback called on success
  66399. */
  66400. successCallback?: () => void;
  66401. /**
  66402. * Defines if parallel processing can be used
  66403. */
  66404. parallelProcessing: boolean;
  66405. }
  66406. /**
  66407. * Queue used to order the simplification tasks
  66408. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66409. */
  66410. export class SimplificationQueue {
  66411. private _simplificationArray;
  66412. /**
  66413. * Gets a boolean indicating that the process is still running
  66414. */
  66415. running: boolean;
  66416. /**
  66417. * Creates a new queue
  66418. */
  66419. constructor();
  66420. /**
  66421. * Adds a new simplification task
  66422. * @param task defines a task to add
  66423. */
  66424. addTask(task: ISimplificationTask): void;
  66425. /**
  66426. * Execute next task
  66427. */
  66428. executeNext(): void;
  66429. /**
  66430. * Execute a simplification task
  66431. * @param task defines the task to run
  66432. */
  66433. runSimplification(task: ISimplificationTask): void;
  66434. private getSimplifier;
  66435. }
  66436. /**
  66437. * The implemented types of simplification
  66438. * At the moment only Quadratic Error Decimation is implemented
  66439. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66440. */
  66441. export enum SimplificationType {
  66442. /** Quadratic error decimation */
  66443. QUADRATIC = 0
  66444. }
  66445. /**
  66446. * An implementation of the Quadratic Error simplification algorithm.
  66447. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66448. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66449. * @author RaananW
  66450. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66451. */
  66452. export class QuadraticErrorSimplification implements ISimplifier {
  66453. private _mesh;
  66454. private triangles;
  66455. private vertices;
  66456. private references;
  66457. private _reconstructedMesh;
  66458. /** Gets or sets the number pf sync interations */
  66459. syncIterations: number;
  66460. /** Gets or sets the aggressiveness of the simplifier */
  66461. aggressiveness: number;
  66462. /** Gets or sets the number of allowed iterations for decimation */
  66463. decimationIterations: number;
  66464. /** Gets or sets the espilon to use for bounding box computation */
  66465. boundingBoxEpsilon: number;
  66466. /**
  66467. * Creates a new QuadraticErrorSimplification
  66468. * @param _mesh defines the target mesh
  66469. */
  66470. constructor(_mesh: Mesh);
  66471. /**
  66472. * Simplification of a given mesh according to the given settings.
  66473. * Since this requires computation, it is assumed that the function runs async.
  66474. * @param settings The settings of the simplification, including quality and distance
  66475. * @param successCallback A callback that will be called after the mesh was simplified.
  66476. */
  66477. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66478. private runDecimation;
  66479. private initWithMesh;
  66480. private init;
  66481. private reconstructMesh;
  66482. private initDecimatedMesh;
  66483. private isFlipped;
  66484. private updateTriangles;
  66485. private identifyBorder;
  66486. private updateMesh;
  66487. private vertexError;
  66488. private calculateError;
  66489. }
  66490. }
  66491. declare module BABYLON {
  66492. interface Scene {
  66493. /** @hidden (Backing field) */
  66494. _simplificationQueue: SimplificationQueue;
  66495. /**
  66496. * Gets or sets the simplification queue attached to the scene
  66497. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66498. */
  66499. simplificationQueue: SimplificationQueue;
  66500. }
  66501. interface Mesh {
  66502. /**
  66503. * Simplify the mesh according to the given array of settings.
  66504. * Function will return immediately and will simplify async
  66505. * @param settings a collection of simplification settings
  66506. * @param parallelProcessing should all levels calculate parallel or one after the other
  66507. * @param simplificationType the type of simplification to run
  66508. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66509. * @returns the current mesh
  66510. */
  66511. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66512. }
  66513. /**
  66514. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66515. * created in a scene
  66516. */
  66517. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66518. /**
  66519. * The component name helpfull to identify the component in the list of scene components.
  66520. */
  66521. readonly name: string;
  66522. /**
  66523. * The scene the component belongs to.
  66524. */
  66525. scene: Scene;
  66526. /**
  66527. * Creates a new instance of the component for the given scene
  66528. * @param scene Defines the scene to register the component in
  66529. */
  66530. constructor(scene: Scene);
  66531. /**
  66532. * Registers the component in a given scene
  66533. */
  66534. register(): void;
  66535. /**
  66536. * Rebuilds the elements related to this component in case of
  66537. * context lost for instance.
  66538. */
  66539. rebuild(): void;
  66540. /**
  66541. * Disposes the component and the associated ressources
  66542. */
  66543. dispose(): void;
  66544. private _beforeCameraUpdate;
  66545. }
  66546. }
  66547. declare module BABYLON {
  66548. interface Mesh {
  66549. /**
  66550. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66551. */
  66552. thinInstanceEnablePicking: boolean;
  66553. /**
  66554. * Creates a new thin instance
  66555. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66556. * @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
  66557. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66558. */
  66559. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66560. /**
  66561. * Adds the transformation (matrix) of the current mesh as a thin instance
  66562. * @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
  66563. * @returns the thin instance index number
  66564. */
  66565. thinInstanceAddSelf(refresh: boolean): number;
  66566. /**
  66567. * Registers a custom attribute to be used with thin instances
  66568. * @param kind name of the attribute
  66569. * @param stride size in floats of the attribute
  66570. */
  66571. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66572. /**
  66573. * Sets the matrix of a thin instance
  66574. * @param index index of the thin instance
  66575. * @param matrix matrix to set
  66576. * @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
  66577. */
  66578. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66579. /**
  66580. * Sets the value of a custom attribute for a thin instance
  66581. * @param kind name of the attribute
  66582. * @param index index of the thin instance
  66583. * @param value value to set
  66584. * @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
  66585. */
  66586. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66587. /**
  66588. * 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.
  66589. */
  66590. thinInstanceCount: number;
  66591. /**
  66592. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66593. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66594. * @param buffer buffer to set
  66595. * @param stride size in floats of each value of the buffer
  66596. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66597. */
  66598. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66599. /**
  66600. * Gets the list of world matrices
  66601. * @return an array containing all the world matrices from the thin instances
  66602. */
  66603. thinInstanceGetWorldMatrices(): Matrix[];
  66604. /**
  66605. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66606. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66607. */
  66608. thinInstanceBufferUpdated(kind: string): void;
  66609. /**
  66610. * Refreshes the bounding info, taking into account all the thin instances defined
  66611. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66612. */
  66613. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66614. /** @hidden */
  66615. _thinInstanceInitializeUserStorage(): void;
  66616. /** @hidden */
  66617. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66618. /** @hidden */
  66619. _userThinInstanceBuffersStorage: {
  66620. data: {
  66621. [key: string]: Float32Array;
  66622. };
  66623. sizes: {
  66624. [key: string]: number;
  66625. };
  66626. vertexBuffers: {
  66627. [key: string]: Nullable<VertexBuffer>;
  66628. };
  66629. strides: {
  66630. [key: string]: number;
  66631. };
  66632. };
  66633. }
  66634. }
  66635. declare module BABYLON {
  66636. /**
  66637. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66638. */
  66639. export interface INavigationEnginePlugin {
  66640. /**
  66641. * plugin name
  66642. */
  66643. name: string;
  66644. /**
  66645. * Creates a navigation mesh
  66646. * @param meshes array of all the geometry used to compute the navigatio mesh
  66647. * @param parameters bunch of parameters used to filter geometry
  66648. */
  66649. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66650. /**
  66651. * Create a navigation mesh debug mesh
  66652. * @param scene is where the mesh will be added
  66653. * @returns debug display mesh
  66654. */
  66655. createDebugNavMesh(scene: Scene): Mesh;
  66656. /**
  66657. * Get a navigation mesh constrained position, closest to the parameter position
  66658. * @param position world position
  66659. * @returns the closest point to position constrained by the navigation mesh
  66660. */
  66661. getClosestPoint(position: Vector3): Vector3;
  66662. /**
  66663. * Get a navigation mesh constrained position, closest to the parameter position
  66664. * @param position world position
  66665. * @param result output the closest point to position constrained by the navigation mesh
  66666. */
  66667. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66668. /**
  66669. * Get a navigation mesh constrained position, within a particular radius
  66670. * @param position world position
  66671. * @param maxRadius the maximum distance to the constrained world position
  66672. * @returns the closest point to position constrained by the navigation mesh
  66673. */
  66674. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66675. /**
  66676. * Get a navigation mesh constrained position, within a particular radius
  66677. * @param position world position
  66678. * @param maxRadius the maximum distance to the constrained world position
  66679. * @param result output the closest point to position constrained by the navigation mesh
  66680. */
  66681. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66682. /**
  66683. * Compute the final position from a segment made of destination-position
  66684. * @param position world position
  66685. * @param destination world position
  66686. * @returns the resulting point along the navmesh
  66687. */
  66688. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66689. /**
  66690. * Compute the final position from a segment made of destination-position
  66691. * @param position world position
  66692. * @param destination world position
  66693. * @param result output the resulting point along the navmesh
  66694. */
  66695. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66696. /**
  66697. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66698. * @param start world position
  66699. * @param end world position
  66700. * @returns array containing world position composing the path
  66701. */
  66702. computePath(start: Vector3, end: Vector3): Vector3[];
  66703. /**
  66704. * If this plugin is supported
  66705. * @returns true if plugin is supported
  66706. */
  66707. isSupported(): boolean;
  66708. /**
  66709. * Create a new Crowd so you can add agents
  66710. * @param maxAgents the maximum agent count in the crowd
  66711. * @param maxAgentRadius the maximum radius an agent can have
  66712. * @param scene to attach the crowd to
  66713. * @returns the crowd you can add agents to
  66714. */
  66715. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66716. /**
  66717. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66718. * The queries will try to find a solution within those bounds
  66719. * default is (1,1,1)
  66720. * @param extent x,y,z value that define the extent around the queries point of reference
  66721. */
  66722. setDefaultQueryExtent(extent: Vector3): void;
  66723. /**
  66724. * Get the Bounding box extent specified by setDefaultQueryExtent
  66725. * @returns the box extent values
  66726. */
  66727. getDefaultQueryExtent(): Vector3;
  66728. /**
  66729. * build the navmesh from a previously saved state using getNavmeshData
  66730. * @param data the Uint8Array returned by getNavmeshData
  66731. */
  66732. buildFromNavmeshData(data: Uint8Array): void;
  66733. /**
  66734. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66735. * @returns data the Uint8Array that can be saved and reused
  66736. */
  66737. getNavmeshData(): Uint8Array;
  66738. /**
  66739. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66740. * @param result output the box extent values
  66741. */
  66742. getDefaultQueryExtentToRef(result: Vector3): void;
  66743. /**
  66744. * Release all resources
  66745. */
  66746. dispose(): void;
  66747. }
  66748. /**
  66749. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66750. */
  66751. export interface ICrowd {
  66752. /**
  66753. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66754. * You can attach anything to that node. The node position is updated in the scene update tick.
  66755. * @param pos world position that will be constrained by the navigation mesh
  66756. * @param parameters agent parameters
  66757. * @param transform hooked to the agent that will be update by the scene
  66758. * @returns agent index
  66759. */
  66760. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66761. /**
  66762. * Returns the agent position in world space
  66763. * @param index agent index returned by addAgent
  66764. * @returns world space position
  66765. */
  66766. getAgentPosition(index: number): Vector3;
  66767. /**
  66768. * Gets the agent position result in world space
  66769. * @param index agent index returned by addAgent
  66770. * @param result output world space position
  66771. */
  66772. getAgentPositionToRef(index: number, result: Vector3): void;
  66773. /**
  66774. * Gets the agent velocity in world space
  66775. * @param index agent index returned by addAgent
  66776. * @returns world space velocity
  66777. */
  66778. getAgentVelocity(index: number): Vector3;
  66779. /**
  66780. * Gets the agent velocity result in world space
  66781. * @param index agent index returned by addAgent
  66782. * @param result output world space velocity
  66783. */
  66784. getAgentVelocityToRef(index: number, result: Vector3): void;
  66785. /**
  66786. * remove a particular agent previously created
  66787. * @param index agent index returned by addAgent
  66788. */
  66789. removeAgent(index: number): void;
  66790. /**
  66791. * get the list of all agents attached to this crowd
  66792. * @returns list of agent indices
  66793. */
  66794. getAgents(): number[];
  66795. /**
  66796. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66797. * @param deltaTime in seconds
  66798. */
  66799. update(deltaTime: number): void;
  66800. /**
  66801. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66802. * @param index agent index returned by addAgent
  66803. * @param destination targeted world position
  66804. */
  66805. agentGoto(index: number, destination: Vector3): void;
  66806. /**
  66807. * Teleport the agent to a new position
  66808. * @param index agent index returned by addAgent
  66809. * @param destination targeted world position
  66810. */
  66811. agentTeleport(index: number, destination: Vector3): void;
  66812. /**
  66813. * Update agent parameters
  66814. * @param index agent index returned by addAgent
  66815. * @param parameters agent parameters
  66816. */
  66817. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66818. /**
  66819. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66820. * The queries will try to find a solution within those bounds
  66821. * default is (1,1,1)
  66822. * @param extent x,y,z value that define the extent around the queries point of reference
  66823. */
  66824. setDefaultQueryExtent(extent: Vector3): void;
  66825. /**
  66826. * Get the Bounding box extent specified by setDefaultQueryExtent
  66827. * @returns the box extent values
  66828. */
  66829. getDefaultQueryExtent(): Vector3;
  66830. /**
  66831. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66832. * @param result output the box extent values
  66833. */
  66834. getDefaultQueryExtentToRef(result: Vector3): void;
  66835. /**
  66836. * Release all resources
  66837. */
  66838. dispose(): void;
  66839. }
  66840. /**
  66841. * Configures an agent
  66842. */
  66843. export interface IAgentParameters {
  66844. /**
  66845. * Agent radius. [Limit: >= 0]
  66846. */
  66847. radius: number;
  66848. /**
  66849. * Agent height. [Limit: > 0]
  66850. */
  66851. height: number;
  66852. /**
  66853. * Maximum allowed acceleration. [Limit: >= 0]
  66854. */
  66855. maxAcceleration: number;
  66856. /**
  66857. * Maximum allowed speed. [Limit: >= 0]
  66858. */
  66859. maxSpeed: number;
  66860. /**
  66861. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66862. */
  66863. collisionQueryRange: number;
  66864. /**
  66865. * The path visibility optimization range. [Limit: > 0]
  66866. */
  66867. pathOptimizationRange: number;
  66868. /**
  66869. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66870. */
  66871. separationWeight: number;
  66872. }
  66873. /**
  66874. * Configures the navigation mesh creation
  66875. */
  66876. export interface INavMeshParameters {
  66877. /**
  66878. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66879. */
  66880. cs: number;
  66881. /**
  66882. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66883. */
  66884. ch: number;
  66885. /**
  66886. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66887. */
  66888. walkableSlopeAngle: number;
  66889. /**
  66890. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66891. * be considered walkable. [Limit: >= 3] [Units: vx]
  66892. */
  66893. walkableHeight: number;
  66894. /**
  66895. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66896. */
  66897. walkableClimb: number;
  66898. /**
  66899. * The distance to erode/shrink the walkable area of the heightfield away from
  66900. * obstructions. [Limit: >=0] [Units: vx]
  66901. */
  66902. walkableRadius: number;
  66903. /**
  66904. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66905. */
  66906. maxEdgeLen: number;
  66907. /**
  66908. * The maximum distance a simplfied contour's border edges should deviate
  66909. * the original raw contour. [Limit: >=0] [Units: vx]
  66910. */
  66911. maxSimplificationError: number;
  66912. /**
  66913. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66914. */
  66915. minRegionArea: number;
  66916. /**
  66917. * Any regions with a span count smaller than this value will, if possible,
  66918. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66919. */
  66920. mergeRegionArea: number;
  66921. /**
  66922. * The maximum number of vertices allowed for polygons generated during the
  66923. * contour to polygon conversion process. [Limit: >= 3]
  66924. */
  66925. maxVertsPerPoly: number;
  66926. /**
  66927. * Sets the sampling distance to use when generating the detail mesh.
  66928. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66929. */
  66930. detailSampleDist: number;
  66931. /**
  66932. * The maximum distance the detail mesh surface should deviate from heightfield
  66933. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66934. */
  66935. detailSampleMaxError: number;
  66936. }
  66937. }
  66938. declare module BABYLON {
  66939. /**
  66940. * RecastJS navigation plugin
  66941. */
  66942. export class RecastJSPlugin implements INavigationEnginePlugin {
  66943. /**
  66944. * Reference to the Recast library
  66945. */
  66946. bjsRECAST: any;
  66947. /**
  66948. * plugin name
  66949. */
  66950. name: string;
  66951. /**
  66952. * the first navmesh created. We might extend this to support multiple navmeshes
  66953. */
  66954. navMesh: any;
  66955. /**
  66956. * Initializes the recastJS plugin
  66957. * @param recastInjection can be used to inject your own recast reference
  66958. */
  66959. constructor(recastInjection?: any);
  66960. /**
  66961. * Creates a navigation mesh
  66962. * @param meshes array of all the geometry used to compute the navigatio mesh
  66963. * @param parameters bunch of parameters used to filter geometry
  66964. */
  66965. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66966. /**
  66967. * Create a navigation mesh debug mesh
  66968. * @param scene is where the mesh will be added
  66969. * @returns debug display mesh
  66970. */
  66971. createDebugNavMesh(scene: Scene): Mesh;
  66972. /**
  66973. * Get a navigation mesh constrained position, closest to the parameter position
  66974. * @param position world position
  66975. * @returns the closest point to position constrained by the navigation mesh
  66976. */
  66977. getClosestPoint(position: Vector3): Vector3;
  66978. /**
  66979. * Get a navigation mesh constrained position, closest to the parameter position
  66980. * @param position world position
  66981. * @param result output the closest point to position constrained by the navigation mesh
  66982. */
  66983. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66984. /**
  66985. * Get a navigation mesh constrained position, within a particular radius
  66986. * @param position world position
  66987. * @param maxRadius the maximum distance to the constrained world position
  66988. * @returns the closest point to position constrained by the navigation mesh
  66989. */
  66990. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66991. /**
  66992. * Get a navigation mesh constrained position, within a particular radius
  66993. * @param position world position
  66994. * @param maxRadius the maximum distance to the constrained world position
  66995. * @param result output the closest point to position constrained by the navigation mesh
  66996. */
  66997. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66998. /**
  66999. * Compute the final position from a segment made of destination-position
  67000. * @param position world position
  67001. * @param destination world position
  67002. * @returns the resulting point along the navmesh
  67003. */
  67004. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67005. /**
  67006. * Compute the final position from a segment made of destination-position
  67007. * @param position world position
  67008. * @param destination world position
  67009. * @param result output the resulting point along the navmesh
  67010. */
  67011. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67012. /**
  67013. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67014. * @param start world position
  67015. * @param end world position
  67016. * @returns array containing world position composing the path
  67017. */
  67018. computePath(start: Vector3, end: Vector3): Vector3[];
  67019. /**
  67020. * Create a new Crowd so you can add agents
  67021. * @param maxAgents the maximum agent count in the crowd
  67022. * @param maxAgentRadius the maximum radius an agent can have
  67023. * @param scene to attach the crowd to
  67024. * @returns the crowd you can add agents to
  67025. */
  67026. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67027. /**
  67028. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67029. * The queries will try to find a solution within those bounds
  67030. * default is (1,1,1)
  67031. * @param extent x,y,z value that define the extent around the queries point of reference
  67032. */
  67033. setDefaultQueryExtent(extent: Vector3): void;
  67034. /**
  67035. * Get the Bounding box extent specified by setDefaultQueryExtent
  67036. * @returns the box extent values
  67037. */
  67038. getDefaultQueryExtent(): Vector3;
  67039. /**
  67040. * build the navmesh from a previously saved state using getNavmeshData
  67041. * @param data the Uint8Array returned by getNavmeshData
  67042. */
  67043. buildFromNavmeshData(data: Uint8Array): void;
  67044. /**
  67045. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67046. * @returns data the Uint8Array that can be saved and reused
  67047. */
  67048. getNavmeshData(): Uint8Array;
  67049. /**
  67050. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67051. * @param result output the box extent values
  67052. */
  67053. getDefaultQueryExtentToRef(result: Vector3): void;
  67054. /**
  67055. * Disposes
  67056. */
  67057. dispose(): void;
  67058. /**
  67059. * If this plugin is supported
  67060. * @returns true if plugin is supported
  67061. */
  67062. isSupported(): boolean;
  67063. }
  67064. /**
  67065. * Recast detour crowd implementation
  67066. */
  67067. export class RecastJSCrowd implements ICrowd {
  67068. /**
  67069. * Recast/detour plugin
  67070. */
  67071. bjsRECASTPlugin: RecastJSPlugin;
  67072. /**
  67073. * Link to the detour crowd
  67074. */
  67075. recastCrowd: any;
  67076. /**
  67077. * One transform per agent
  67078. */
  67079. transforms: TransformNode[];
  67080. /**
  67081. * All agents created
  67082. */
  67083. agents: number[];
  67084. /**
  67085. * Link to the scene is kept to unregister the crowd from the scene
  67086. */
  67087. private _scene;
  67088. /**
  67089. * Observer for crowd updates
  67090. */
  67091. private _onBeforeAnimationsObserver;
  67092. /**
  67093. * Constructor
  67094. * @param plugin recastJS plugin
  67095. * @param maxAgents the maximum agent count in the crowd
  67096. * @param maxAgentRadius the maximum radius an agent can have
  67097. * @param scene to attach the crowd to
  67098. * @returns the crowd you can add agents to
  67099. */
  67100. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67101. /**
  67102. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67103. * You can attach anything to that node. The node position is updated in the scene update tick.
  67104. * @param pos world position that will be constrained by the navigation mesh
  67105. * @param parameters agent parameters
  67106. * @param transform hooked to the agent that will be update by the scene
  67107. * @returns agent index
  67108. */
  67109. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67110. /**
  67111. * Returns the agent position in world space
  67112. * @param index agent index returned by addAgent
  67113. * @returns world space position
  67114. */
  67115. getAgentPosition(index: number): Vector3;
  67116. /**
  67117. * Returns the agent position result in world space
  67118. * @param index agent index returned by addAgent
  67119. * @param result output world space position
  67120. */
  67121. getAgentPositionToRef(index: number, result: Vector3): void;
  67122. /**
  67123. * Returns the agent velocity in world space
  67124. * @param index agent index returned by addAgent
  67125. * @returns world space velocity
  67126. */
  67127. getAgentVelocity(index: number): Vector3;
  67128. /**
  67129. * Returns the agent velocity result in world space
  67130. * @param index agent index returned by addAgent
  67131. * @param result output world space velocity
  67132. */
  67133. getAgentVelocityToRef(index: number, result: Vector3): void;
  67134. /**
  67135. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67136. * @param index agent index returned by addAgent
  67137. * @param destination targeted world position
  67138. */
  67139. agentGoto(index: number, destination: Vector3): void;
  67140. /**
  67141. * Teleport the agent to a new position
  67142. * @param index agent index returned by addAgent
  67143. * @param destination targeted world position
  67144. */
  67145. agentTeleport(index: number, destination: Vector3): void;
  67146. /**
  67147. * Update agent parameters
  67148. * @param index agent index returned by addAgent
  67149. * @param parameters agent parameters
  67150. */
  67151. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67152. /**
  67153. * remove a particular agent previously created
  67154. * @param index agent index returned by addAgent
  67155. */
  67156. removeAgent(index: number): void;
  67157. /**
  67158. * get the list of all agents attached to this crowd
  67159. * @returns list of agent indices
  67160. */
  67161. getAgents(): number[];
  67162. /**
  67163. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67164. * @param deltaTime in seconds
  67165. */
  67166. update(deltaTime: number): void;
  67167. /**
  67168. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67169. * The queries will try to find a solution within those bounds
  67170. * default is (1,1,1)
  67171. * @param extent x,y,z value that define the extent around the queries point of reference
  67172. */
  67173. setDefaultQueryExtent(extent: Vector3): void;
  67174. /**
  67175. * Get the Bounding box extent specified by setDefaultQueryExtent
  67176. * @returns the box extent values
  67177. */
  67178. getDefaultQueryExtent(): Vector3;
  67179. /**
  67180. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67181. * @param result output the box extent values
  67182. */
  67183. getDefaultQueryExtentToRef(result: Vector3): void;
  67184. /**
  67185. * Release all resources
  67186. */
  67187. dispose(): void;
  67188. }
  67189. }
  67190. declare module BABYLON {
  67191. /**
  67192. * Class used to enable access to IndexedDB
  67193. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67194. */
  67195. export class Database implements IOfflineProvider {
  67196. private _callbackManifestChecked;
  67197. private _currentSceneUrl;
  67198. private _db;
  67199. private _enableSceneOffline;
  67200. private _enableTexturesOffline;
  67201. private _manifestVersionFound;
  67202. private _mustUpdateRessources;
  67203. private _hasReachedQuota;
  67204. private _isSupported;
  67205. private _idbFactory;
  67206. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67207. private static IsUASupportingBlobStorage;
  67208. /**
  67209. * Gets a boolean indicating if Database storate is enabled (off by default)
  67210. */
  67211. static IDBStorageEnabled: boolean;
  67212. /**
  67213. * Gets a boolean indicating if scene must be saved in the database
  67214. */
  67215. get enableSceneOffline(): boolean;
  67216. /**
  67217. * Gets a boolean indicating if textures must be saved in the database
  67218. */
  67219. get enableTexturesOffline(): boolean;
  67220. /**
  67221. * Creates a new Database
  67222. * @param urlToScene defines the url to load the scene
  67223. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67224. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67225. */
  67226. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67227. private static _ParseURL;
  67228. private static _ReturnFullUrlLocation;
  67229. private _checkManifestFile;
  67230. /**
  67231. * Open the database and make it available
  67232. * @param successCallback defines the callback to call on success
  67233. * @param errorCallback defines the callback to call on error
  67234. */
  67235. open(successCallback: () => void, errorCallback: () => void): void;
  67236. /**
  67237. * Loads an image from the database
  67238. * @param url defines the url to load from
  67239. * @param image defines the target DOM image
  67240. */
  67241. loadImage(url: string, image: HTMLImageElement): void;
  67242. private _loadImageFromDBAsync;
  67243. private _saveImageIntoDBAsync;
  67244. private _checkVersionFromDB;
  67245. private _loadVersionFromDBAsync;
  67246. private _saveVersionIntoDBAsync;
  67247. /**
  67248. * Loads a file from database
  67249. * @param url defines the URL to load from
  67250. * @param sceneLoaded defines a callback to call on success
  67251. * @param progressCallBack defines a callback to call when progress changed
  67252. * @param errorCallback defines a callback to call on error
  67253. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67254. */
  67255. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67256. private _loadFileAsync;
  67257. private _saveFileAsync;
  67258. /**
  67259. * Validates if xhr data is correct
  67260. * @param xhr defines the request to validate
  67261. * @param dataType defines the expected data type
  67262. * @returns true if data is correct
  67263. */
  67264. private static _ValidateXHRData;
  67265. }
  67266. }
  67267. declare module BABYLON {
  67268. /** @hidden */
  67269. export var gpuUpdateParticlesPixelShader: {
  67270. name: string;
  67271. shader: string;
  67272. };
  67273. }
  67274. declare module BABYLON {
  67275. /** @hidden */
  67276. export var gpuUpdateParticlesVertexShader: {
  67277. name: string;
  67278. shader: string;
  67279. };
  67280. }
  67281. declare module BABYLON {
  67282. /** @hidden */
  67283. export var clipPlaneFragmentDeclaration2: {
  67284. name: string;
  67285. shader: string;
  67286. };
  67287. }
  67288. declare module BABYLON {
  67289. /** @hidden */
  67290. export var gpuRenderParticlesPixelShader: {
  67291. name: string;
  67292. shader: string;
  67293. };
  67294. }
  67295. declare module BABYLON {
  67296. /** @hidden */
  67297. export var clipPlaneVertexDeclaration2: {
  67298. name: string;
  67299. shader: string;
  67300. };
  67301. }
  67302. declare module BABYLON {
  67303. /** @hidden */
  67304. export var gpuRenderParticlesVertexShader: {
  67305. name: string;
  67306. shader: string;
  67307. };
  67308. }
  67309. declare module BABYLON {
  67310. /**
  67311. * This represents a GPU particle system in Babylon
  67312. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67313. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67314. */
  67315. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67316. /**
  67317. * The layer mask we are rendering the particles through.
  67318. */
  67319. layerMask: number;
  67320. private _capacity;
  67321. private _activeCount;
  67322. private _currentActiveCount;
  67323. private _accumulatedCount;
  67324. private _renderEffect;
  67325. private _updateEffect;
  67326. private _buffer0;
  67327. private _buffer1;
  67328. private _spriteBuffer;
  67329. private _updateVAO;
  67330. private _renderVAO;
  67331. private _targetIndex;
  67332. private _sourceBuffer;
  67333. private _targetBuffer;
  67334. private _currentRenderId;
  67335. private _started;
  67336. private _stopped;
  67337. private _timeDelta;
  67338. private _randomTexture;
  67339. private _randomTexture2;
  67340. private _attributesStrideSize;
  67341. private _updateEffectOptions;
  67342. private _randomTextureSize;
  67343. private _actualFrame;
  67344. private _customEffect;
  67345. private readonly _rawTextureWidth;
  67346. /**
  67347. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67348. */
  67349. static get IsSupported(): boolean;
  67350. /**
  67351. * An event triggered when the system is disposed.
  67352. */
  67353. onDisposeObservable: Observable<IParticleSystem>;
  67354. /**
  67355. * Gets the maximum number of particles active at the same time.
  67356. * @returns The max number of active particles.
  67357. */
  67358. getCapacity(): number;
  67359. /**
  67360. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67361. * to override the particles.
  67362. */
  67363. forceDepthWrite: boolean;
  67364. /**
  67365. * Gets or set the number of active particles
  67366. */
  67367. get activeParticleCount(): number;
  67368. set activeParticleCount(value: number);
  67369. private _preWarmDone;
  67370. /**
  67371. * Specifies if the particles are updated in emitter local space or world space.
  67372. */
  67373. isLocal: boolean;
  67374. /** Gets or sets a matrix to use to compute projection */
  67375. defaultProjectionMatrix: Matrix;
  67376. /**
  67377. * Is this system ready to be used/rendered
  67378. * @return true if the system is ready
  67379. */
  67380. isReady(): boolean;
  67381. /**
  67382. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67383. * @returns True if it has been started, otherwise false.
  67384. */
  67385. isStarted(): boolean;
  67386. /**
  67387. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67388. * @returns True if it has been stopped, otherwise false.
  67389. */
  67390. isStopped(): boolean;
  67391. /**
  67392. * Gets a boolean indicating that the system is stopping
  67393. * @returns true if the system is currently stopping
  67394. */
  67395. isStopping(): boolean;
  67396. /**
  67397. * Gets the number of particles active at the same time.
  67398. * @returns The number of active particles.
  67399. */
  67400. getActiveCount(): number;
  67401. /**
  67402. * Starts the particle system and begins to emit
  67403. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67404. */
  67405. start(delay?: number): void;
  67406. /**
  67407. * Stops the particle system.
  67408. */
  67409. stop(): void;
  67410. /**
  67411. * Remove all active particles
  67412. */
  67413. reset(): void;
  67414. /**
  67415. * Returns the string "GPUParticleSystem"
  67416. * @returns a string containing the class name
  67417. */
  67418. getClassName(): string;
  67419. /**
  67420. * Gets the custom effect used to render the particles
  67421. * @param blendMode Blend mode for which the effect should be retrieved
  67422. * @returns The effect
  67423. */
  67424. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67425. /**
  67426. * Sets the custom effect used to render the particles
  67427. * @param effect The effect to set
  67428. * @param blendMode Blend mode for which the effect should be set
  67429. */
  67430. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67431. /** @hidden */
  67432. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67433. /**
  67434. * Observable that will be called just before the particles are drawn
  67435. */
  67436. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67437. /**
  67438. * Gets the name of the particle vertex shader
  67439. */
  67440. get vertexShaderName(): string;
  67441. private _colorGradientsTexture;
  67442. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67443. /**
  67444. * Adds a new color gradient
  67445. * @param gradient defines the gradient to use (between 0 and 1)
  67446. * @param color1 defines the color to affect to the specified gradient
  67447. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67448. * @returns the current particle system
  67449. */
  67450. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67451. private _refreshColorGradient;
  67452. /** Force the system to rebuild all gradients that need to be resync */
  67453. forceRefreshGradients(): void;
  67454. /**
  67455. * Remove a specific color gradient
  67456. * @param gradient defines the gradient to remove
  67457. * @returns the current particle system
  67458. */
  67459. removeColorGradient(gradient: number): GPUParticleSystem;
  67460. private _angularSpeedGradientsTexture;
  67461. private _sizeGradientsTexture;
  67462. private _velocityGradientsTexture;
  67463. private _limitVelocityGradientsTexture;
  67464. private _dragGradientsTexture;
  67465. private _addFactorGradient;
  67466. /**
  67467. * Adds a new size gradient
  67468. * @param gradient defines the gradient to use (between 0 and 1)
  67469. * @param factor defines the size factor to affect to the specified gradient
  67470. * @returns the current particle system
  67471. */
  67472. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67473. /**
  67474. * Remove a specific size gradient
  67475. * @param gradient defines the gradient to remove
  67476. * @returns the current particle system
  67477. */
  67478. removeSizeGradient(gradient: number): GPUParticleSystem;
  67479. private _refreshFactorGradient;
  67480. /**
  67481. * Adds a new angular speed gradient
  67482. * @param gradient defines the gradient to use (between 0 and 1)
  67483. * @param factor defines the angular speed to affect to the specified gradient
  67484. * @returns the current particle system
  67485. */
  67486. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67487. /**
  67488. * Remove a specific angular speed gradient
  67489. * @param gradient defines the gradient to remove
  67490. * @returns the current particle system
  67491. */
  67492. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67493. /**
  67494. * Adds a new velocity gradient
  67495. * @param gradient defines the gradient to use (between 0 and 1)
  67496. * @param factor defines the velocity to affect to the specified gradient
  67497. * @returns the current particle system
  67498. */
  67499. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67500. /**
  67501. * Remove a specific velocity gradient
  67502. * @param gradient defines the gradient to remove
  67503. * @returns the current particle system
  67504. */
  67505. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67506. /**
  67507. * Adds a new limit velocity gradient
  67508. * @param gradient defines the gradient to use (between 0 and 1)
  67509. * @param factor defines the limit velocity value to affect to the specified gradient
  67510. * @returns the current particle system
  67511. */
  67512. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67513. /**
  67514. * Remove a specific limit velocity gradient
  67515. * @param gradient defines the gradient to remove
  67516. * @returns the current particle system
  67517. */
  67518. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67519. /**
  67520. * Adds a new drag gradient
  67521. * @param gradient defines the gradient to use (between 0 and 1)
  67522. * @param factor defines the drag value to affect to the specified gradient
  67523. * @returns the current particle system
  67524. */
  67525. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67526. /**
  67527. * Remove a specific drag gradient
  67528. * @param gradient defines the gradient to remove
  67529. * @returns the current particle system
  67530. */
  67531. removeDragGradient(gradient: number): GPUParticleSystem;
  67532. /**
  67533. * Not supported by GPUParticleSystem
  67534. * @param gradient defines the gradient to use (between 0 and 1)
  67535. * @param factor defines the emit rate value to affect to the specified gradient
  67536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67537. * @returns the current particle system
  67538. */
  67539. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67540. /**
  67541. * Not supported by GPUParticleSystem
  67542. * @param gradient defines the gradient to remove
  67543. * @returns the current particle system
  67544. */
  67545. removeEmitRateGradient(gradient: number): IParticleSystem;
  67546. /**
  67547. * Not supported by GPUParticleSystem
  67548. * @param gradient defines the gradient to use (between 0 and 1)
  67549. * @param factor defines the start size value to affect to the specified gradient
  67550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67551. * @returns the current particle system
  67552. */
  67553. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67554. /**
  67555. * Not supported by GPUParticleSystem
  67556. * @param gradient defines the gradient to remove
  67557. * @returns the current particle system
  67558. */
  67559. removeStartSizeGradient(gradient: number): IParticleSystem;
  67560. /**
  67561. * Not supported by GPUParticleSystem
  67562. * @param gradient defines the gradient to use (between 0 and 1)
  67563. * @param min defines the color remap minimal range
  67564. * @param max defines the color remap maximal range
  67565. * @returns the current particle system
  67566. */
  67567. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67568. /**
  67569. * Not supported by GPUParticleSystem
  67570. * @param gradient defines the gradient to remove
  67571. * @returns the current particle system
  67572. */
  67573. removeColorRemapGradient(): IParticleSystem;
  67574. /**
  67575. * Not supported by GPUParticleSystem
  67576. * @param gradient defines the gradient to use (between 0 and 1)
  67577. * @param min defines the alpha remap minimal range
  67578. * @param max defines the alpha remap maximal range
  67579. * @returns the current particle system
  67580. */
  67581. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67582. /**
  67583. * Not supported by GPUParticleSystem
  67584. * @param gradient defines the gradient to remove
  67585. * @returns the current particle system
  67586. */
  67587. removeAlphaRemapGradient(): IParticleSystem;
  67588. /**
  67589. * Not supported by GPUParticleSystem
  67590. * @param gradient defines the gradient to use (between 0 and 1)
  67591. * @param color defines the color to affect to the specified gradient
  67592. * @returns the current particle system
  67593. */
  67594. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67595. /**
  67596. * Not supported by GPUParticleSystem
  67597. * @param gradient defines the gradient to remove
  67598. * @returns the current particle system
  67599. */
  67600. removeRampGradient(): IParticleSystem;
  67601. /**
  67602. * Not supported by GPUParticleSystem
  67603. * @returns the list of ramp gradients
  67604. */
  67605. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67606. /**
  67607. * Not supported by GPUParticleSystem
  67608. * Gets or sets a boolean indicating that ramp gradients must be used
  67609. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67610. */
  67611. get useRampGradients(): boolean;
  67612. set useRampGradients(value: boolean);
  67613. /**
  67614. * Not supported by GPUParticleSystem
  67615. * @param gradient defines the gradient to use (between 0 and 1)
  67616. * @param factor defines the life time factor to affect to the specified gradient
  67617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67618. * @returns the current particle system
  67619. */
  67620. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67621. /**
  67622. * Not supported by GPUParticleSystem
  67623. * @param gradient defines the gradient to remove
  67624. * @returns the current particle system
  67625. */
  67626. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67627. /**
  67628. * Instantiates a GPU particle system.
  67629. * 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.
  67630. * @param name The name of the particle system
  67631. * @param options The options used to create the system
  67632. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67633. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67634. * @param customEffect a custom effect used to change the way particles are rendered by default
  67635. */
  67636. constructor(name: string, options: Partial<{
  67637. capacity: number;
  67638. randomTextureSize: number;
  67639. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67640. protected _reset(): void;
  67641. private _createUpdateVAO;
  67642. private _createRenderVAO;
  67643. private _initialize;
  67644. /** @hidden */
  67645. _recreateUpdateEffect(): void;
  67646. private _getEffect;
  67647. /**
  67648. * Fill the defines array according to the current settings of the particle system
  67649. * @param defines Array to be updated
  67650. * @param blendMode blend mode to take into account when updating the array
  67651. */
  67652. fillDefines(defines: Array<string>, blendMode?: number): void;
  67653. /**
  67654. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67655. * @param uniforms Uniforms array to fill
  67656. * @param attributes Attributes array to fill
  67657. * @param samplers Samplers array to fill
  67658. */
  67659. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67660. /** @hidden */
  67661. _recreateRenderEffect(): Effect;
  67662. /**
  67663. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67664. * @param preWarm defines if we are in the pre-warmimg phase
  67665. */
  67666. animate(preWarm?: boolean): void;
  67667. private _createFactorGradientTexture;
  67668. private _createSizeGradientTexture;
  67669. private _createAngularSpeedGradientTexture;
  67670. private _createVelocityGradientTexture;
  67671. private _createLimitVelocityGradientTexture;
  67672. private _createDragGradientTexture;
  67673. private _createColorGradientTexture;
  67674. /**
  67675. * Renders the particle system in its current state
  67676. * @param preWarm defines if the system should only update the particles but not render them
  67677. * @returns the current number of particles
  67678. */
  67679. render(preWarm?: boolean): number;
  67680. /**
  67681. * Rebuilds the particle system
  67682. */
  67683. rebuild(): void;
  67684. private _releaseBuffers;
  67685. private _releaseVAOs;
  67686. /**
  67687. * Disposes the particle system and free the associated resources
  67688. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67689. */
  67690. dispose(disposeTexture?: boolean): void;
  67691. /**
  67692. * Clones the particle system.
  67693. * @param name The name of the cloned object
  67694. * @param newEmitter The new emitter to use
  67695. * @returns the cloned particle system
  67696. */
  67697. clone(name: string, newEmitter: any): GPUParticleSystem;
  67698. /**
  67699. * Serializes the particle system to a JSON object
  67700. * @param serializeTexture defines if the texture must be serialized as well
  67701. * @returns the JSON object
  67702. */
  67703. serialize(serializeTexture?: boolean): any;
  67704. /**
  67705. * Parses a JSON object to create a GPU particle system.
  67706. * @param parsedParticleSystem The JSON object to parse
  67707. * @param sceneOrEngine The scene or the engine to create the particle system in
  67708. * @param rootUrl The root url to use to load external dependencies like texture
  67709. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67710. * @returns the parsed GPU particle system
  67711. */
  67712. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67713. }
  67714. }
  67715. declare module BABYLON {
  67716. /**
  67717. * Represents a set of particle systems working together to create a specific effect
  67718. */
  67719. export class ParticleSystemSet implements IDisposable {
  67720. /**
  67721. * Gets or sets base Assets URL
  67722. */
  67723. static BaseAssetsUrl: string;
  67724. private _emitterCreationOptions;
  67725. private _emitterNode;
  67726. /**
  67727. * Gets the particle system list
  67728. */
  67729. systems: IParticleSystem[];
  67730. /**
  67731. * Gets the emitter node used with this set
  67732. */
  67733. get emitterNode(): Nullable<TransformNode>;
  67734. /**
  67735. * Creates a new emitter mesh as a sphere
  67736. * @param options defines the options used to create the sphere
  67737. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67738. * @param scene defines the hosting scene
  67739. */
  67740. setEmitterAsSphere(options: {
  67741. diameter: number;
  67742. segments: number;
  67743. color: Color3;
  67744. }, renderingGroupId: number, scene: Scene): void;
  67745. /**
  67746. * Starts all particle systems of the set
  67747. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67748. */
  67749. start(emitter?: AbstractMesh): void;
  67750. /**
  67751. * Release all associated resources
  67752. */
  67753. dispose(): void;
  67754. /**
  67755. * Serialize the set into a JSON compatible object
  67756. * @param serializeTexture defines if the texture must be serialized as well
  67757. * @returns a JSON compatible representation of the set
  67758. */
  67759. serialize(serializeTexture?: boolean): any;
  67760. /**
  67761. * Parse a new ParticleSystemSet from a serialized source
  67762. * @param data defines a JSON compatible representation of the set
  67763. * @param scene defines the hosting scene
  67764. * @param gpu defines if we want GPU particles or CPU particles
  67765. * @returns a new ParticleSystemSet
  67766. */
  67767. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67768. }
  67769. }
  67770. declare module BABYLON {
  67771. /**
  67772. * This class is made for on one-liner static method to help creating particle system set.
  67773. */
  67774. export class ParticleHelper {
  67775. /**
  67776. * Gets or sets base Assets URL
  67777. */
  67778. static BaseAssetsUrl: string;
  67779. /** Define the Url to load snippets */
  67780. static SnippetUrl: string;
  67781. /**
  67782. * Create a default particle system that you can tweak
  67783. * @param emitter defines the emitter to use
  67784. * @param capacity defines the system capacity (default is 500 particles)
  67785. * @param scene defines the hosting scene
  67786. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67787. * @returns the new Particle system
  67788. */
  67789. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67790. /**
  67791. * This is the main static method (one-liner) of this helper to create different particle systems
  67792. * @param type This string represents the type to the particle system to create
  67793. * @param scene The scene where the particle system should live
  67794. * @param gpu If the system will use gpu
  67795. * @returns the ParticleSystemSet created
  67796. */
  67797. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67798. /**
  67799. * Static function used to export a particle system to a ParticleSystemSet variable.
  67800. * Please note that the emitter shape is not exported
  67801. * @param systems defines the particle systems to export
  67802. * @returns the created particle system set
  67803. */
  67804. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67805. /**
  67806. * Creates a particle system from a snippet saved in a remote file
  67807. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67808. * @param url defines the url to load from
  67809. * @param scene defines the hosting scene
  67810. * @param gpu If the system will use gpu
  67811. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67812. * @returns a promise that will resolve to the new particle system
  67813. */
  67814. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67815. /**
  67816. * Creates a particle system from a snippet saved by the particle system editor
  67817. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67818. * @param scene defines the hosting scene
  67819. * @param gpu If the system will use gpu
  67820. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67821. * @returns a promise that will resolve to the new particle system
  67822. */
  67823. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67824. }
  67825. }
  67826. declare module BABYLON {
  67827. interface Engine {
  67828. /**
  67829. * Create an effect to use with particle systems.
  67830. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67831. * the particle system for which you want to create a custom effect in the last parameter
  67832. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67833. * @param uniformsNames defines a list of attribute names
  67834. * @param samplers defines an array of string used to represent textures
  67835. * @param defines defines the string containing the defines to use to compile the shaders
  67836. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67837. * @param onCompiled defines a function to call when the effect creation is successful
  67838. * @param onError defines a function to call when the effect creation has failed
  67839. * @param particleSystem the particle system you want to create the effect for
  67840. * @returns the new Effect
  67841. */
  67842. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67843. }
  67844. interface Mesh {
  67845. /**
  67846. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67847. * @returns an array of IParticleSystem
  67848. */
  67849. getEmittedParticleSystems(): IParticleSystem[];
  67850. /**
  67851. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67852. * @returns an array of IParticleSystem
  67853. */
  67854. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67855. }
  67856. }
  67857. declare module BABYLON {
  67858. /** Defines the 4 color options */
  67859. export enum PointColor {
  67860. /** color value */
  67861. Color = 2,
  67862. /** uv value */
  67863. UV = 1,
  67864. /** random value */
  67865. Random = 0,
  67866. /** stated value */
  67867. Stated = 3
  67868. }
  67869. /**
  67870. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67871. * 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.
  67872. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67873. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67874. *
  67875. * Full documentation here : TO BE ENTERED
  67876. */
  67877. export class PointsCloudSystem implements IDisposable {
  67878. /**
  67879. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67880. * Example : var p = SPS.particles[i];
  67881. */
  67882. particles: CloudPoint[];
  67883. /**
  67884. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67885. */
  67886. nbParticles: number;
  67887. /**
  67888. * This a counter for your own usage. It's not set by any SPS functions.
  67889. */
  67890. counter: number;
  67891. /**
  67892. * The PCS name. This name is also given to the underlying mesh.
  67893. */
  67894. name: string;
  67895. /**
  67896. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67897. */
  67898. mesh: Mesh;
  67899. /**
  67900. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67901. * Please read :
  67902. */
  67903. vars: any;
  67904. /**
  67905. * @hidden
  67906. */
  67907. _size: number;
  67908. private _scene;
  67909. private _promises;
  67910. private _positions;
  67911. private _indices;
  67912. private _normals;
  67913. private _colors;
  67914. private _uvs;
  67915. private _indices32;
  67916. private _positions32;
  67917. private _colors32;
  67918. private _uvs32;
  67919. private _updatable;
  67920. private _isVisibilityBoxLocked;
  67921. private _alwaysVisible;
  67922. private _groups;
  67923. private _groupCounter;
  67924. private _computeParticleColor;
  67925. private _computeParticleTexture;
  67926. private _computeParticleRotation;
  67927. private _computeBoundingBox;
  67928. private _isReady;
  67929. /**
  67930. * Creates a PCS (Points Cloud System) object
  67931. * @param name (String) is the PCS name, this will be the underlying mesh name
  67932. * @param pointSize (number) is the size for each point
  67933. * @param scene (Scene) is the scene in which the PCS is added
  67934. * @param options defines the options of the PCS e.g.
  67935. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67936. */
  67937. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67938. updatable?: boolean;
  67939. });
  67940. /**
  67941. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67942. * If no points were added to the PCS, the returned mesh is just a single point.
  67943. * @returns a promise for the created mesh
  67944. */
  67945. buildMeshAsync(): Promise<Mesh>;
  67946. /**
  67947. * @hidden
  67948. */
  67949. private _buildMesh;
  67950. private _addParticle;
  67951. private _randomUnitVector;
  67952. private _getColorIndicesForCoord;
  67953. private _setPointsColorOrUV;
  67954. private _colorFromTexture;
  67955. private _calculateDensity;
  67956. /**
  67957. * Adds points to the PCS in random positions within a unit sphere
  67958. * @param nb (positive integer) the number of particles to be created from this model
  67959. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67960. * @returns the number of groups in the system
  67961. */
  67962. addPoints(nb: number, pointFunction?: any): number;
  67963. /**
  67964. * Adds points to the PCS from the surface of the model shape
  67965. * @param mesh is any Mesh object that will be used as a surface model for the points
  67966. * @param nb (positive integer) the number of particles to be created from this model
  67967. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67968. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67969. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67970. * @returns the number of groups in the system
  67971. */
  67972. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67973. /**
  67974. * Adds points to the PCS inside the model shape
  67975. * @param mesh is any Mesh object that will be used as a surface model for the points
  67976. * @param nb (positive integer) the number of particles to be created from this model
  67977. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67978. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67979. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67980. * @returns the number of groups in the system
  67981. */
  67982. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67983. /**
  67984. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67985. * This method calls `updateParticle()` for each particle of the SPS.
  67986. * For an animated SPS, it is usually called within the render loop.
  67987. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67988. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67989. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67990. * @returns the PCS.
  67991. */
  67992. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67993. /**
  67994. * Disposes the PCS.
  67995. */
  67996. dispose(): void;
  67997. /**
  67998. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67999. * doc :
  68000. * @returns the PCS.
  68001. */
  68002. refreshVisibleSize(): PointsCloudSystem;
  68003. /**
  68004. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68005. * @param size the size (float) of the visibility box
  68006. * note : this doesn't lock the PCS mesh bounding box.
  68007. * doc :
  68008. */
  68009. setVisibilityBox(size: number): void;
  68010. /**
  68011. * Gets whether the PCS is always visible or not
  68012. * doc :
  68013. */
  68014. get isAlwaysVisible(): boolean;
  68015. /**
  68016. * Sets the PCS as always visible or not
  68017. * doc :
  68018. */
  68019. set isAlwaysVisible(val: boolean);
  68020. /**
  68021. * Tells to `setParticles()` to compute the particle rotations or not
  68022. * Default value : false. The PCS is faster when it's set to false
  68023. * Note : particle rotations are only applied to parent particles
  68024. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68025. */
  68026. set computeParticleRotation(val: boolean);
  68027. /**
  68028. * Tells to `setParticles()` to compute the particle colors or not.
  68029. * Default value : true. The PCS is faster when it's set to false.
  68030. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68031. */
  68032. set computeParticleColor(val: boolean);
  68033. set computeParticleTexture(val: boolean);
  68034. /**
  68035. * Gets if `setParticles()` computes the particle colors or not.
  68036. * Default value : false. The PCS is faster when it's set to false.
  68037. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68038. */
  68039. get computeParticleColor(): boolean;
  68040. /**
  68041. * Gets if `setParticles()` computes the particle textures or not.
  68042. * Default value : false. The PCS is faster when it's set to false.
  68043. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68044. */
  68045. get computeParticleTexture(): boolean;
  68046. /**
  68047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68048. */
  68049. set computeBoundingBox(val: boolean);
  68050. /**
  68051. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68052. */
  68053. get computeBoundingBox(): boolean;
  68054. /**
  68055. * This function does nothing. It may be overwritten to set all the particle first values.
  68056. * The PCS doesn't call this function, you may have to call it by your own.
  68057. * doc :
  68058. */
  68059. initParticles(): void;
  68060. /**
  68061. * This function does nothing. It may be overwritten to recycle a particle
  68062. * The PCS doesn't call this function, you can to call it
  68063. * doc :
  68064. * @param particle The particle to recycle
  68065. * @returns the recycled particle
  68066. */
  68067. recycleParticle(particle: CloudPoint): CloudPoint;
  68068. /**
  68069. * Updates a particle : this function should be overwritten by the user.
  68070. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68071. * doc :
  68072. * @example : just set a particle position or velocity and recycle conditions
  68073. * @param particle The particle to update
  68074. * @returns the updated particle
  68075. */
  68076. updateParticle(particle: CloudPoint): CloudPoint;
  68077. /**
  68078. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68079. * This does nothing and may be overwritten by the user.
  68080. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68081. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68082. * @param update the boolean update value actually passed to setParticles()
  68083. */
  68084. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68085. /**
  68086. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68087. * This will be passed three parameters.
  68088. * This does nothing and may be overwritten by the user.
  68089. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68090. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68091. * @param update the boolean update value actually passed to setParticles()
  68092. */
  68093. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68094. }
  68095. }
  68096. declare module BABYLON {
  68097. /**
  68098. * Represents one particle of a points cloud system.
  68099. */
  68100. export class CloudPoint {
  68101. /**
  68102. * particle global index
  68103. */
  68104. idx: number;
  68105. /**
  68106. * The color of the particle
  68107. */
  68108. color: Nullable<Color4>;
  68109. /**
  68110. * The world space position of the particle.
  68111. */
  68112. position: Vector3;
  68113. /**
  68114. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68115. */
  68116. rotation: Vector3;
  68117. /**
  68118. * The world space rotation quaternion of the particle.
  68119. */
  68120. rotationQuaternion: Nullable<Quaternion>;
  68121. /**
  68122. * The uv of the particle.
  68123. */
  68124. uv: Nullable<Vector2>;
  68125. /**
  68126. * The current speed of the particle.
  68127. */
  68128. velocity: Vector3;
  68129. /**
  68130. * The pivot point in the particle local space.
  68131. */
  68132. pivot: Vector3;
  68133. /**
  68134. * Must the particle be translated from its pivot point in its local space ?
  68135. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68136. * Default : false
  68137. */
  68138. translateFromPivot: boolean;
  68139. /**
  68140. * Index of this particle in the global "positions" array (Internal use)
  68141. * @hidden
  68142. */
  68143. _pos: number;
  68144. /**
  68145. * @hidden Index of this particle in the global "indices" array (Internal use)
  68146. */
  68147. _ind: number;
  68148. /**
  68149. * Group this particle belongs to
  68150. */
  68151. _group: PointsGroup;
  68152. /**
  68153. * Group id of this particle
  68154. */
  68155. groupId: number;
  68156. /**
  68157. * Index of the particle in its group id (Internal use)
  68158. */
  68159. idxInGroup: number;
  68160. /**
  68161. * @hidden Particle BoundingInfo object (Internal use)
  68162. */
  68163. _boundingInfo: BoundingInfo;
  68164. /**
  68165. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68166. */
  68167. _pcs: PointsCloudSystem;
  68168. /**
  68169. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68170. */
  68171. _stillInvisible: boolean;
  68172. /**
  68173. * @hidden Last computed particle rotation matrix
  68174. */
  68175. _rotationMatrix: number[];
  68176. /**
  68177. * Parent particle Id, if any.
  68178. * Default null.
  68179. */
  68180. parentId: Nullable<number>;
  68181. /**
  68182. * @hidden Internal global position in the PCS.
  68183. */
  68184. _globalPosition: Vector3;
  68185. /**
  68186. * Creates a Point Cloud object.
  68187. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68188. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68189. * @param group (PointsGroup) is the group the particle belongs to
  68190. * @param groupId (integer) is the group identifier in the PCS.
  68191. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68192. * @param pcs defines the PCS it is associated to
  68193. */
  68194. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68195. /**
  68196. * get point size
  68197. */
  68198. get size(): Vector3;
  68199. /**
  68200. * Set point size
  68201. */
  68202. set size(scale: Vector3);
  68203. /**
  68204. * Legacy support, changed quaternion to rotationQuaternion
  68205. */
  68206. get quaternion(): Nullable<Quaternion>;
  68207. /**
  68208. * Legacy support, changed quaternion to rotationQuaternion
  68209. */
  68210. set quaternion(q: Nullable<Quaternion>);
  68211. /**
  68212. * Returns a boolean. True if the particle intersects a mesh, else false
  68213. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68214. * @param target is the object (point or mesh) what the intersection is computed against
  68215. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68216. * @returns true if it intersects
  68217. */
  68218. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68219. /**
  68220. * get the rotation matrix of the particle
  68221. * @hidden
  68222. */
  68223. getRotationMatrix(m: Matrix): void;
  68224. }
  68225. /**
  68226. * Represents a group of points in a points cloud system
  68227. * * PCS internal tool, don't use it manually.
  68228. */
  68229. export class PointsGroup {
  68230. /**
  68231. * The group id
  68232. * @hidden
  68233. */
  68234. groupID: number;
  68235. /**
  68236. * image data for group (internal use)
  68237. * @hidden
  68238. */
  68239. _groupImageData: Nullable<ArrayBufferView>;
  68240. /**
  68241. * Image Width (internal use)
  68242. * @hidden
  68243. */
  68244. _groupImgWidth: number;
  68245. /**
  68246. * Image Height (internal use)
  68247. * @hidden
  68248. */
  68249. _groupImgHeight: number;
  68250. /**
  68251. * Custom position function (internal use)
  68252. * @hidden
  68253. */
  68254. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68255. /**
  68256. * density per facet for surface points
  68257. * @hidden
  68258. */
  68259. _groupDensity: number[];
  68260. /**
  68261. * Only when points are colored by texture carries pointer to texture list array
  68262. * @hidden
  68263. */
  68264. _textureNb: number;
  68265. /**
  68266. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68267. * PCS internal tool, don't use it manually.
  68268. * @hidden
  68269. */
  68270. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68271. }
  68272. }
  68273. declare module BABYLON {
  68274. interface Scene {
  68275. /** @hidden (Backing field) */
  68276. _physicsEngine: Nullable<IPhysicsEngine>;
  68277. /** @hidden */
  68278. _physicsTimeAccumulator: number;
  68279. /**
  68280. * Gets the current physics engine
  68281. * @returns a IPhysicsEngine or null if none attached
  68282. */
  68283. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68284. /**
  68285. * Enables physics to the current scene
  68286. * @param gravity defines the scene's gravity for the physics engine
  68287. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68288. * @return a boolean indicating if the physics engine was initialized
  68289. */
  68290. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68291. /**
  68292. * Disables and disposes the physics engine associated with the scene
  68293. */
  68294. disablePhysicsEngine(): void;
  68295. /**
  68296. * Gets a boolean indicating if there is an active physics engine
  68297. * @returns a boolean indicating if there is an active physics engine
  68298. */
  68299. isPhysicsEnabled(): boolean;
  68300. /**
  68301. * Deletes a physics compound impostor
  68302. * @param compound defines the compound to delete
  68303. */
  68304. deleteCompoundImpostor(compound: any): void;
  68305. /**
  68306. * An event triggered when physic simulation is about to be run
  68307. */
  68308. onBeforePhysicsObservable: Observable<Scene>;
  68309. /**
  68310. * An event triggered when physic simulation has been done
  68311. */
  68312. onAfterPhysicsObservable: Observable<Scene>;
  68313. }
  68314. interface AbstractMesh {
  68315. /** @hidden */
  68316. _physicsImpostor: Nullable<PhysicsImpostor>;
  68317. /**
  68318. * Gets or sets impostor used for physic simulation
  68319. * @see https://doc.babylonjs.com/features/physics_engine
  68320. */
  68321. physicsImpostor: Nullable<PhysicsImpostor>;
  68322. /**
  68323. * Gets the current physics impostor
  68324. * @see https://doc.babylonjs.com/features/physics_engine
  68325. * @returns a physics impostor or null
  68326. */
  68327. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68328. /** Apply a physic impulse to the mesh
  68329. * @param force defines the force to apply
  68330. * @param contactPoint defines where to apply the force
  68331. * @returns the current mesh
  68332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68333. */
  68334. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68335. /**
  68336. * Creates a physic joint between two meshes
  68337. * @param otherMesh defines the other mesh to use
  68338. * @param pivot1 defines the pivot to use on this mesh
  68339. * @param pivot2 defines the pivot to use on the other mesh
  68340. * @param options defines additional options (can be plugin dependent)
  68341. * @returns the current mesh
  68342. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68343. */
  68344. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68345. /** @hidden */
  68346. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68347. }
  68348. /**
  68349. * Defines the physics engine scene component responsible to manage a physics engine
  68350. */
  68351. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68352. /**
  68353. * The component name helpful to identify the component in the list of scene components.
  68354. */
  68355. readonly name: string;
  68356. /**
  68357. * The scene the component belongs to.
  68358. */
  68359. scene: Scene;
  68360. /**
  68361. * Creates a new instance of the component for the given scene
  68362. * @param scene Defines the scene to register the component in
  68363. */
  68364. constructor(scene: Scene);
  68365. /**
  68366. * Registers the component in a given scene
  68367. */
  68368. register(): void;
  68369. /**
  68370. * Rebuilds the elements related to this component in case of
  68371. * context lost for instance.
  68372. */
  68373. rebuild(): void;
  68374. /**
  68375. * Disposes the component and the associated ressources
  68376. */
  68377. dispose(): void;
  68378. }
  68379. }
  68380. declare module BABYLON {
  68381. /**
  68382. * A helper for physics simulations
  68383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68384. */
  68385. export class PhysicsHelper {
  68386. private _scene;
  68387. private _physicsEngine;
  68388. /**
  68389. * Initializes the Physics helper
  68390. * @param scene Babylon.js scene
  68391. */
  68392. constructor(scene: Scene);
  68393. /**
  68394. * Applies a radial explosion impulse
  68395. * @param origin the origin of the explosion
  68396. * @param radiusOrEventOptions the radius or the options of radial explosion
  68397. * @param strength the explosion strength
  68398. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68399. * @returns A physics radial explosion event, or null
  68400. */
  68401. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68402. /**
  68403. * Applies a radial explosion force
  68404. * @param origin the origin of the explosion
  68405. * @param radiusOrEventOptions the radius or the options of radial explosion
  68406. * @param strength the explosion strength
  68407. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68408. * @returns A physics radial explosion event, or null
  68409. */
  68410. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68411. /**
  68412. * Creates a gravitational field
  68413. * @param origin the origin of the explosion
  68414. * @param radiusOrEventOptions the radius or the options of radial explosion
  68415. * @param strength the explosion strength
  68416. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68417. * @returns A physics gravitational field event, or null
  68418. */
  68419. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68420. /**
  68421. * Creates a physics updraft event
  68422. * @param origin the origin of the updraft
  68423. * @param radiusOrEventOptions the radius or the options of the updraft
  68424. * @param strength the strength of the updraft
  68425. * @param height the height of the updraft
  68426. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68427. * @returns A physics updraft event, or null
  68428. */
  68429. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68430. /**
  68431. * Creates a physics vortex event
  68432. * @param origin the of the vortex
  68433. * @param radiusOrEventOptions the radius or the options of the vortex
  68434. * @param strength the strength of the vortex
  68435. * @param height the height of the vortex
  68436. * @returns a Physics vortex event, or null
  68437. * A physics vortex event or null
  68438. */
  68439. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68440. }
  68441. /**
  68442. * Represents a physics radial explosion event
  68443. */
  68444. class PhysicsRadialExplosionEvent {
  68445. private _scene;
  68446. private _options;
  68447. private _sphere;
  68448. private _dataFetched;
  68449. /**
  68450. * Initializes a radial explosioin event
  68451. * @param _scene BabylonJS scene
  68452. * @param _options The options for the vortex event
  68453. */
  68454. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68455. /**
  68456. * Returns the data related to the radial explosion event (sphere).
  68457. * @returns The radial explosion event data
  68458. */
  68459. getData(): PhysicsRadialExplosionEventData;
  68460. /**
  68461. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68462. * @param impostor A physics imposter
  68463. * @param origin the origin of the explosion
  68464. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68465. */
  68466. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68467. /**
  68468. * Triggers affecterd impostors callbacks
  68469. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68470. */
  68471. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68472. /**
  68473. * Disposes the sphere.
  68474. * @param force Specifies if the sphere should be disposed by force
  68475. */
  68476. dispose(force?: boolean): void;
  68477. /*** Helpers ***/
  68478. private _prepareSphere;
  68479. private _intersectsWithSphere;
  68480. }
  68481. /**
  68482. * Represents a gravitational field event
  68483. */
  68484. class PhysicsGravitationalFieldEvent {
  68485. private _physicsHelper;
  68486. private _scene;
  68487. private _origin;
  68488. private _options;
  68489. private _tickCallback;
  68490. private _sphere;
  68491. private _dataFetched;
  68492. /**
  68493. * Initializes the physics gravitational field event
  68494. * @param _physicsHelper A physics helper
  68495. * @param _scene BabylonJS scene
  68496. * @param _origin The origin position of the gravitational field event
  68497. * @param _options The options for the vortex event
  68498. */
  68499. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68500. /**
  68501. * Returns the data related to the gravitational field event (sphere).
  68502. * @returns A gravitational field event
  68503. */
  68504. getData(): PhysicsGravitationalFieldEventData;
  68505. /**
  68506. * Enables the gravitational field.
  68507. */
  68508. enable(): void;
  68509. /**
  68510. * Disables the gravitational field.
  68511. */
  68512. disable(): void;
  68513. /**
  68514. * Disposes the sphere.
  68515. * @param force The force to dispose from the gravitational field event
  68516. */
  68517. dispose(force?: boolean): void;
  68518. private _tick;
  68519. }
  68520. /**
  68521. * Represents a physics updraft event
  68522. */
  68523. class PhysicsUpdraftEvent {
  68524. private _scene;
  68525. private _origin;
  68526. private _options;
  68527. private _physicsEngine;
  68528. private _originTop;
  68529. private _originDirection;
  68530. private _tickCallback;
  68531. private _cylinder;
  68532. private _cylinderPosition;
  68533. private _dataFetched;
  68534. /**
  68535. * Initializes the physics updraft event
  68536. * @param _scene BabylonJS scene
  68537. * @param _origin The origin position of the updraft
  68538. * @param _options The options for the updraft event
  68539. */
  68540. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68541. /**
  68542. * Returns the data related to the updraft event (cylinder).
  68543. * @returns A physics updraft event
  68544. */
  68545. getData(): PhysicsUpdraftEventData;
  68546. /**
  68547. * Enables the updraft.
  68548. */
  68549. enable(): void;
  68550. /**
  68551. * Disables the updraft.
  68552. */
  68553. disable(): void;
  68554. /**
  68555. * Disposes the cylinder.
  68556. * @param force Specifies if the updraft should be disposed by force
  68557. */
  68558. dispose(force?: boolean): void;
  68559. private getImpostorHitData;
  68560. private _tick;
  68561. /*** Helpers ***/
  68562. private _prepareCylinder;
  68563. private _intersectsWithCylinder;
  68564. }
  68565. /**
  68566. * Represents a physics vortex event
  68567. */
  68568. class PhysicsVortexEvent {
  68569. private _scene;
  68570. private _origin;
  68571. private _options;
  68572. private _physicsEngine;
  68573. private _originTop;
  68574. private _tickCallback;
  68575. private _cylinder;
  68576. private _cylinderPosition;
  68577. private _dataFetched;
  68578. /**
  68579. * Initializes the physics vortex event
  68580. * @param _scene The BabylonJS scene
  68581. * @param _origin The origin position of the vortex
  68582. * @param _options The options for the vortex event
  68583. */
  68584. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68585. /**
  68586. * Returns the data related to the vortex event (cylinder).
  68587. * @returns The physics vortex event data
  68588. */
  68589. getData(): PhysicsVortexEventData;
  68590. /**
  68591. * Enables the vortex.
  68592. */
  68593. enable(): void;
  68594. /**
  68595. * Disables the cortex.
  68596. */
  68597. disable(): void;
  68598. /**
  68599. * Disposes the sphere.
  68600. * @param force
  68601. */
  68602. dispose(force?: boolean): void;
  68603. private getImpostorHitData;
  68604. private _tick;
  68605. /*** Helpers ***/
  68606. private _prepareCylinder;
  68607. private _intersectsWithCylinder;
  68608. }
  68609. /**
  68610. * Options fot the radial explosion event
  68611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68612. */
  68613. export class PhysicsRadialExplosionEventOptions {
  68614. /**
  68615. * The radius of the sphere for the radial explosion.
  68616. */
  68617. radius: number;
  68618. /**
  68619. * The strenth of the explosion.
  68620. */
  68621. strength: number;
  68622. /**
  68623. * The strenght of the force in correspondence to the distance of the affected object
  68624. */
  68625. falloff: PhysicsRadialImpulseFalloff;
  68626. /**
  68627. * Sphere options for the radial explosion.
  68628. */
  68629. sphere: {
  68630. segments: number;
  68631. diameter: number;
  68632. };
  68633. /**
  68634. * Sphere options for the radial explosion.
  68635. */
  68636. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68637. }
  68638. /**
  68639. * Options fot the updraft event
  68640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68641. */
  68642. export class PhysicsUpdraftEventOptions {
  68643. /**
  68644. * The radius of the cylinder for the vortex
  68645. */
  68646. radius: number;
  68647. /**
  68648. * The strenth of the updraft.
  68649. */
  68650. strength: number;
  68651. /**
  68652. * The height of the cylinder for the updraft.
  68653. */
  68654. height: number;
  68655. /**
  68656. * The mode for the the updraft.
  68657. */
  68658. updraftMode: PhysicsUpdraftMode;
  68659. }
  68660. /**
  68661. * Options fot the vortex event
  68662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68663. */
  68664. export class PhysicsVortexEventOptions {
  68665. /**
  68666. * The radius of the cylinder for the vortex
  68667. */
  68668. radius: number;
  68669. /**
  68670. * The strenth of the vortex.
  68671. */
  68672. strength: number;
  68673. /**
  68674. * The height of the cylinder for the vortex.
  68675. */
  68676. height: number;
  68677. /**
  68678. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68679. */
  68680. centripetalForceThreshold: number;
  68681. /**
  68682. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68683. */
  68684. centripetalForceMultiplier: number;
  68685. /**
  68686. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68687. */
  68688. centrifugalForceMultiplier: number;
  68689. /**
  68690. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68691. */
  68692. updraftForceMultiplier: number;
  68693. }
  68694. /**
  68695. * The strenght of the force in correspondence to the distance of the affected object
  68696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68697. */
  68698. export enum PhysicsRadialImpulseFalloff {
  68699. /** Defines that impulse is constant in strength across it's whole radius */
  68700. Constant = 0,
  68701. /** Defines that impulse gets weaker if it's further from the origin */
  68702. Linear = 1
  68703. }
  68704. /**
  68705. * The strength of the force in correspondence to the distance of the affected object
  68706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68707. */
  68708. export enum PhysicsUpdraftMode {
  68709. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68710. Center = 0,
  68711. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68712. Perpendicular = 1
  68713. }
  68714. /**
  68715. * Interface for a physics hit data
  68716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68717. */
  68718. export interface PhysicsHitData {
  68719. /**
  68720. * The force applied at the contact point
  68721. */
  68722. force: Vector3;
  68723. /**
  68724. * The contact point
  68725. */
  68726. contactPoint: Vector3;
  68727. /**
  68728. * The distance from the origin to the contact point
  68729. */
  68730. distanceFromOrigin: number;
  68731. }
  68732. /**
  68733. * Interface for radial explosion event data
  68734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68735. */
  68736. export interface PhysicsRadialExplosionEventData {
  68737. /**
  68738. * A sphere used for the radial explosion event
  68739. */
  68740. sphere: Mesh;
  68741. }
  68742. /**
  68743. * Interface for gravitational field event data
  68744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68745. */
  68746. export interface PhysicsGravitationalFieldEventData {
  68747. /**
  68748. * A sphere mesh used for the gravitational field event
  68749. */
  68750. sphere: Mesh;
  68751. }
  68752. /**
  68753. * Interface for updraft event data
  68754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68755. */
  68756. export interface PhysicsUpdraftEventData {
  68757. /**
  68758. * A cylinder used for the updraft event
  68759. */
  68760. cylinder: Mesh;
  68761. }
  68762. /**
  68763. * Interface for vortex event data
  68764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68765. */
  68766. export interface PhysicsVortexEventData {
  68767. /**
  68768. * A cylinder used for the vortex event
  68769. */
  68770. cylinder: Mesh;
  68771. }
  68772. /**
  68773. * Interface for an affected physics impostor
  68774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68775. */
  68776. export interface PhysicsAffectedImpostorWithData {
  68777. /**
  68778. * The impostor affected by the effect
  68779. */
  68780. impostor: PhysicsImpostor;
  68781. /**
  68782. * The data about the hit/horce from the explosion
  68783. */
  68784. hitData: PhysicsHitData;
  68785. }
  68786. }
  68787. declare module BABYLON {
  68788. /** @hidden */
  68789. export var blackAndWhitePixelShader: {
  68790. name: string;
  68791. shader: string;
  68792. };
  68793. }
  68794. declare module BABYLON {
  68795. /**
  68796. * Post process used to render in black and white
  68797. */
  68798. export class BlackAndWhitePostProcess extends PostProcess {
  68799. /**
  68800. * Linear about to convert he result to black and white (default: 1)
  68801. */
  68802. degree: number;
  68803. /**
  68804. * Gets a string identifying the name of the class
  68805. * @returns "BlackAndWhitePostProcess" string
  68806. */
  68807. getClassName(): string;
  68808. /**
  68809. * Creates a black and white post process
  68810. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68811. * @param name The name of the effect.
  68812. * @param options The required width/height ratio to downsize to before computing the render pass.
  68813. * @param camera The camera to apply the render pass to.
  68814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68815. * @param engine The engine which the post process will be applied. (default: current engine)
  68816. * @param reusable If the post process can be reused on the same frame. (default: false)
  68817. */
  68818. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68819. /** @hidden */
  68820. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68821. }
  68822. }
  68823. declare module BABYLON {
  68824. /**
  68825. * This represents a set of one or more post processes in Babylon.
  68826. * A post process can be used to apply a shader to a texture after it is rendered.
  68827. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68828. */
  68829. export class PostProcessRenderEffect {
  68830. private _postProcesses;
  68831. private _getPostProcesses;
  68832. private _singleInstance;
  68833. private _cameras;
  68834. private _indicesForCamera;
  68835. /**
  68836. * Name of the effect
  68837. * @hidden
  68838. */
  68839. _name: string;
  68840. /**
  68841. * Instantiates a post process render effect.
  68842. * A post process can be used to apply a shader to a texture after it is rendered.
  68843. * @param engine The engine the effect is tied to
  68844. * @param name The name of the effect
  68845. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68846. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68847. */
  68848. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68849. /**
  68850. * Checks if all the post processes in the effect are supported.
  68851. */
  68852. get isSupported(): boolean;
  68853. /**
  68854. * Updates the current state of the effect
  68855. * @hidden
  68856. */
  68857. _update(): void;
  68858. /**
  68859. * Attaches the effect on cameras
  68860. * @param cameras The camera to attach to.
  68861. * @hidden
  68862. */
  68863. _attachCameras(cameras: Camera): void;
  68864. /**
  68865. * Attaches the effect on cameras
  68866. * @param cameras The camera to attach to.
  68867. * @hidden
  68868. */
  68869. _attachCameras(cameras: Camera[]): void;
  68870. /**
  68871. * Detaches the effect on cameras
  68872. * @param cameras The camera to detatch from.
  68873. * @hidden
  68874. */
  68875. _detachCameras(cameras: Camera): void;
  68876. /**
  68877. * Detatches the effect on cameras
  68878. * @param cameras The camera to detatch from.
  68879. * @hidden
  68880. */
  68881. _detachCameras(cameras: Camera[]): void;
  68882. /**
  68883. * Enables the effect on given cameras
  68884. * @param cameras The camera to enable.
  68885. * @hidden
  68886. */
  68887. _enable(cameras: Camera): void;
  68888. /**
  68889. * Enables the effect on given cameras
  68890. * @param cameras The camera to enable.
  68891. * @hidden
  68892. */
  68893. _enable(cameras: Nullable<Camera[]>): void;
  68894. /**
  68895. * Disables the effect on the given cameras
  68896. * @param cameras The camera to disable.
  68897. * @hidden
  68898. */
  68899. _disable(cameras: Camera): void;
  68900. /**
  68901. * Disables the effect on the given cameras
  68902. * @param cameras The camera to disable.
  68903. * @hidden
  68904. */
  68905. _disable(cameras: Nullable<Camera[]>): void;
  68906. /**
  68907. * Gets a list of the post processes contained in the effect.
  68908. * @param camera The camera to get the post processes on.
  68909. * @returns The list of the post processes in the effect.
  68910. */
  68911. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68912. }
  68913. }
  68914. declare module BABYLON {
  68915. /** @hidden */
  68916. export var extractHighlightsPixelShader: {
  68917. name: string;
  68918. shader: string;
  68919. };
  68920. }
  68921. declare module BABYLON {
  68922. /**
  68923. * 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.
  68924. */
  68925. export class ExtractHighlightsPostProcess extends PostProcess {
  68926. /**
  68927. * The luminance threshold, pixels below this value will be set to black.
  68928. */
  68929. threshold: number;
  68930. /** @hidden */
  68931. _exposure: number;
  68932. /**
  68933. * Post process which has the input texture to be used when performing highlight extraction
  68934. * @hidden
  68935. */
  68936. _inputPostProcess: Nullable<PostProcess>;
  68937. /**
  68938. * Gets a string identifying the name of the class
  68939. * @returns "ExtractHighlightsPostProcess" string
  68940. */
  68941. getClassName(): string;
  68942. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68943. }
  68944. }
  68945. declare module BABYLON {
  68946. /** @hidden */
  68947. export var bloomMergePixelShader: {
  68948. name: string;
  68949. shader: string;
  68950. };
  68951. }
  68952. declare module BABYLON {
  68953. /**
  68954. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68955. */
  68956. export class BloomMergePostProcess extends PostProcess {
  68957. /** Weight of the bloom to be added to the original input. */
  68958. weight: number;
  68959. /**
  68960. * Gets a string identifying the name of the class
  68961. * @returns "BloomMergePostProcess" string
  68962. */
  68963. getClassName(): string;
  68964. /**
  68965. * Creates a new instance of @see BloomMergePostProcess
  68966. * @param name The name of the effect.
  68967. * @param originalFromInput Post process which's input will be used for the merge.
  68968. * @param blurred Blurred highlights post process which's output will be used.
  68969. * @param weight Weight of the bloom to be added to the original input.
  68970. * @param options The required width/height ratio to downsize to before computing the render pass.
  68971. * @param camera The camera to apply the render pass to.
  68972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68973. * @param engine The engine which the post process will be applied. (default: current engine)
  68974. * @param reusable If the post process can be reused on the same frame. (default: false)
  68975. * @param textureType Type of textures used when performing the post process. (default: 0)
  68976. * @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)
  68977. */
  68978. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68979. /** Weight of the bloom to be added to the original input. */
  68980. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68981. }
  68982. }
  68983. declare module BABYLON {
  68984. /**
  68985. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68986. */
  68987. export class BloomEffect extends PostProcessRenderEffect {
  68988. private bloomScale;
  68989. /**
  68990. * @hidden Internal
  68991. */
  68992. _effects: Array<PostProcess>;
  68993. /**
  68994. * @hidden Internal
  68995. */
  68996. _downscale: ExtractHighlightsPostProcess;
  68997. private _blurX;
  68998. private _blurY;
  68999. private _merge;
  69000. /**
  69001. * The luminance threshold to find bright areas of the image to bloom.
  69002. */
  69003. get threshold(): number;
  69004. set threshold(value: number);
  69005. /**
  69006. * The strength of the bloom.
  69007. */
  69008. get weight(): number;
  69009. set weight(value: number);
  69010. /**
  69011. * Specifies the size of the bloom blur kernel, relative to the final output size
  69012. */
  69013. get kernel(): number;
  69014. set kernel(value: number);
  69015. /**
  69016. * Creates a new instance of @see BloomEffect
  69017. * @param scene The scene the effect belongs to.
  69018. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69019. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69020. * @param bloomWeight The the strength of bloom.
  69021. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69022. * @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)
  69023. */
  69024. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69025. /**
  69026. * Disposes each of the internal effects for a given camera.
  69027. * @param camera The camera to dispose the effect on.
  69028. */
  69029. disposeEffects(camera: Camera): void;
  69030. /**
  69031. * @hidden Internal
  69032. */
  69033. _updateEffects(): void;
  69034. /**
  69035. * Internal
  69036. * @returns if all the contained post processes are ready.
  69037. * @hidden
  69038. */
  69039. _isReady(): boolean;
  69040. }
  69041. }
  69042. declare module BABYLON {
  69043. /** @hidden */
  69044. export var chromaticAberrationPixelShader: {
  69045. name: string;
  69046. shader: string;
  69047. };
  69048. }
  69049. declare module BABYLON {
  69050. /**
  69051. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69052. */
  69053. export class ChromaticAberrationPostProcess extends PostProcess {
  69054. /**
  69055. * The amount of seperation of rgb channels (default: 30)
  69056. */
  69057. aberrationAmount: number;
  69058. /**
  69059. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69060. */
  69061. radialIntensity: number;
  69062. /**
  69063. * 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))
  69064. */
  69065. direction: Vector2;
  69066. /**
  69067. * 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))
  69068. */
  69069. centerPosition: Vector2;
  69070. /** The width of the screen to apply the effect on */
  69071. screenWidth: number;
  69072. /** The height of the screen to apply the effect on */
  69073. screenHeight: number;
  69074. /**
  69075. * Gets a string identifying the name of the class
  69076. * @returns "ChromaticAberrationPostProcess" string
  69077. */
  69078. getClassName(): string;
  69079. /**
  69080. * Creates a new instance ChromaticAberrationPostProcess
  69081. * @param name The name of the effect.
  69082. * @param screenWidth The width of the screen to apply the effect on.
  69083. * @param screenHeight The height of the screen to apply the effect on.
  69084. * @param options The required width/height ratio to downsize to before computing the render pass.
  69085. * @param camera The camera to apply the render pass to.
  69086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69087. * @param engine The engine which the post process will be applied. (default: current engine)
  69088. * @param reusable If the post process can be reused on the same frame. (default: false)
  69089. * @param textureType Type of textures used when performing the post process. (default: 0)
  69090. * @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)
  69091. */
  69092. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69093. /** @hidden */
  69094. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69095. }
  69096. }
  69097. declare module BABYLON {
  69098. /** @hidden */
  69099. export var circleOfConfusionPixelShader: {
  69100. name: string;
  69101. shader: string;
  69102. };
  69103. }
  69104. declare module BABYLON {
  69105. /**
  69106. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69107. */
  69108. export class CircleOfConfusionPostProcess extends PostProcess {
  69109. /**
  69110. * 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.
  69111. */
  69112. lensSize: number;
  69113. /**
  69114. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69115. */
  69116. fStop: number;
  69117. /**
  69118. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69119. */
  69120. focusDistance: number;
  69121. /**
  69122. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69123. */
  69124. focalLength: number;
  69125. /**
  69126. * Gets a string identifying the name of the class
  69127. * @returns "CircleOfConfusionPostProcess" string
  69128. */
  69129. getClassName(): string;
  69130. private _depthTexture;
  69131. /**
  69132. * Creates a new instance CircleOfConfusionPostProcess
  69133. * @param name The name of the effect.
  69134. * @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.
  69135. * @param options The required width/height ratio to downsize to before computing the render pass.
  69136. * @param camera The camera to apply the render pass to.
  69137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69138. * @param engine The engine which the post process will be applied. (default: current engine)
  69139. * @param reusable If the post process can be reused on the same frame. (default: false)
  69140. * @param textureType Type of textures used when performing the post process. (default: 0)
  69141. * @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)
  69142. */
  69143. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69144. /**
  69145. * 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.
  69146. */
  69147. set depthTexture(value: RenderTargetTexture);
  69148. }
  69149. }
  69150. declare module BABYLON {
  69151. /** @hidden */
  69152. export var colorCorrectionPixelShader: {
  69153. name: string;
  69154. shader: string;
  69155. };
  69156. }
  69157. declare module BABYLON {
  69158. /**
  69159. *
  69160. * This post-process allows the modification of rendered colors by using
  69161. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69162. *
  69163. * The object needs to be provided an url to a texture containing the color
  69164. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69165. * Use an image editing software to tweak the LUT to match your needs.
  69166. *
  69167. * For an example of a color LUT, see here:
  69168. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69169. * For explanations on color grading, see here:
  69170. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69171. *
  69172. */
  69173. export class ColorCorrectionPostProcess extends PostProcess {
  69174. private _colorTableTexture;
  69175. /**
  69176. * Gets the color table url used to create the LUT texture
  69177. */
  69178. colorTableUrl: string;
  69179. /**
  69180. * Gets a string identifying the name of the class
  69181. * @returns "ColorCorrectionPostProcess" string
  69182. */
  69183. getClassName(): string;
  69184. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69185. /** @hidden */
  69186. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69187. }
  69188. }
  69189. declare module BABYLON {
  69190. /** @hidden */
  69191. export var convolutionPixelShader: {
  69192. name: string;
  69193. shader: string;
  69194. };
  69195. }
  69196. declare module BABYLON {
  69197. /**
  69198. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69199. * input texture to perform effects such as edge detection or sharpening
  69200. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69201. */
  69202. export class ConvolutionPostProcess extends PostProcess {
  69203. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69204. kernel: number[];
  69205. /**
  69206. * Gets a string identifying the name of the class
  69207. * @returns "ConvolutionPostProcess" string
  69208. */
  69209. getClassName(): string;
  69210. /**
  69211. * Creates a new instance ConvolutionPostProcess
  69212. * @param name The name of the effect.
  69213. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69214. * @param options The required width/height ratio to downsize to before computing the render pass.
  69215. * @param camera The camera to apply the render pass to.
  69216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69217. * @param engine The engine which the post process will be applied. (default: current engine)
  69218. * @param reusable If the post process can be reused on the same frame. (default: false)
  69219. * @param textureType Type of textures used when performing the post process. (default: 0)
  69220. */
  69221. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69222. /** @hidden */
  69223. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69224. /**
  69225. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69226. */
  69227. static EdgeDetect0Kernel: number[];
  69228. /**
  69229. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69230. */
  69231. static EdgeDetect1Kernel: number[];
  69232. /**
  69233. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69234. */
  69235. static EdgeDetect2Kernel: number[];
  69236. /**
  69237. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69238. */
  69239. static SharpenKernel: number[];
  69240. /**
  69241. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69242. */
  69243. static EmbossKernel: number[];
  69244. /**
  69245. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69246. */
  69247. static GaussianKernel: number[];
  69248. }
  69249. }
  69250. declare module BABYLON {
  69251. /**
  69252. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69253. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69254. * based on samples that have a large difference in distance than the center pixel.
  69255. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69256. */
  69257. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69258. /**
  69259. * The direction the blur should be applied
  69260. */
  69261. direction: Vector2;
  69262. /**
  69263. * Gets a string identifying the name of the class
  69264. * @returns "DepthOfFieldBlurPostProcess" string
  69265. */
  69266. getClassName(): string;
  69267. /**
  69268. * Creates a new instance CircleOfConfusionPostProcess
  69269. * @param name The name of the effect.
  69270. * @param scene The scene the effect belongs to.
  69271. * @param direction The direction the blur should be applied.
  69272. * @param kernel The size of the kernel used to blur.
  69273. * @param options The required width/height ratio to downsize to before computing the render pass.
  69274. * @param camera The camera to apply the render pass to.
  69275. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69276. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69278. * @param engine The engine which the post process will be applied. (default: current engine)
  69279. * @param reusable If the post process can be reused on the same frame. (default: false)
  69280. * @param textureType Type of textures used when performing the post process. (default: 0)
  69281. * @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)
  69282. */
  69283. 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);
  69284. }
  69285. }
  69286. declare module BABYLON {
  69287. /** @hidden */
  69288. export var depthOfFieldMergePixelShader: {
  69289. name: string;
  69290. shader: string;
  69291. };
  69292. }
  69293. declare module BABYLON {
  69294. /**
  69295. * Options to be set when merging outputs from the default pipeline.
  69296. */
  69297. export class DepthOfFieldMergePostProcessOptions {
  69298. /**
  69299. * The original image to merge on top of
  69300. */
  69301. originalFromInput: PostProcess;
  69302. /**
  69303. * Parameters to perform the merge of the depth of field effect
  69304. */
  69305. depthOfField?: {
  69306. circleOfConfusion: PostProcess;
  69307. blurSteps: Array<PostProcess>;
  69308. };
  69309. /**
  69310. * Parameters to perform the merge of bloom effect
  69311. */
  69312. bloom?: {
  69313. blurred: PostProcess;
  69314. weight: number;
  69315. };
  69316. }
  69317. /**
  69318. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69319. */
  69320. export class DepthOfFieldMergePostProcess extends PostProcess {
  69321. private blurSteps;
  69322. /**
  69323. * Gets a string identifying the name of the class
  69324. * @returns "DepthOfFieldMergePostProcess" string
  69325. */
  69326. getClassName(): string;
  69327. /**
  69328. * Creates a new instance of DepthOfFieldMergePostProcess
  69329. * @param name The name of the effect.
  69330. * @param originalFromInput Post process which's input will be used for the merge.
  69331. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69332. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69333. * @param options The required width/height ratio to downsize to before computing the render pass.
  69334. * @param camera The camera to apply the render pass to.
  69335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69336. * @param engine The engine which the post process will be applied. (default: current engine)
  69337. * @param reusable If the post process can be reused on the same frame. (default: false)
  69338. * @param textureType Type of textures used when performing the post process. (default: 0)
  69339. * @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)
  69340. */
  69341. 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);
  69342. /**
  69343. * Updates the effect with the current post process compile time values and recompiles the shader.
  69344. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69345. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69346. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69347. * @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
  69348. * @param onCompiled Called when the shader has been compiled.
  69349. * @param onError Called if there is an error when compiling a shader.
  69350. */
  69351. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69352. }
  69353. }
  69354. declare module BABYLON {
  69355. /**
  69356. * Specifies the level of max blur that should be applied when using the depth of field effect
  69357. */
  69358. export enum DepthOfFieldEffectBlurLevel {
  69359. /**
  69360. * Subtle blur
  69361. */
  69362. Low = 0,
  69363. /**
  69364. * Medium blur
  69365. */
  69366. Medium = 1,
  69367. /**
  69368. * Large blur
  69369. */
  69370. High = 2
  69371. }
  69372. /**
  69373. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69374. */
  69375. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69376. private _circleOfConfusion;
  69377. /**
  69378. * @hidden Internal, blurs from high to low
  69379. */
  69380. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69381. private _depthOfFieldBlurY;
  69382. private _dofMerge;
  69383. /**
  69384. * @hidden Internal post processes in depth of field effect
  69385. */
  69386. _effects: Array<PostProcess>;
  69387. /**
  69388. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69389. */
  69390. set focalLength(value: number);
  69391. get focalLength(): number;
  69392. /**
  69393. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69394. */
  69395. set fStop(value: number);
  69396. get fStop(): number;
  69397. /**
  69398. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69399. */
  69400. set focusDistance(value: number);
  69401. get focusDistance(): number;
  69402. /**
  69403. * 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.
  69404. */
  69405. set lensSize(value: number);
  69406. get lensSize(): number;
  69407. /**
  69408. * Creates a new instance DepthOfFieldEffect
  69409. * @param scene The scene the effect belongs to.
  69410. * @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.
  69411. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69412. * @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)
  69413. */
  69414. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69415. /**
  69416. * Get the current class name of the current effet
  69417. * @returns "DepthOfFieldEffect"
  69418. */
  69419. getClassName(): string;
  69420. /**
  69421. * 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.
  69422. */
  69423. set depthTexture(value: RenderTargetTexture);
  69424. /**
  69425. * Disposes each of the internal effects for a given camera.
  69426. * @param camera The camera to dispose the effect on.
  69427. */
  69428. disposeEffects(camera: Camera): void;
  69429. /**
  69430. * @hidden Internal
  69431. */
  69432. _updateEffects(): void;
  69433. /**
  69434. * Internal
  69435. * @returns if all the contained post processes are ready.
  69436. * @hidden
  69437. */
  69438. _isReady(): boolean;
  69439. }
  69440. }
  69441. declare module BABYLON {
  69442. /** @hidden */
  69443. export var displayPassPixelShader: {
  69444. name: string;
  69445. shader: string;
  69446. };
  69447. }
  69448. declare module BABYLON {
  69449. /**
  69450. * DisplayPassPostProcess which produces an output the same as it's input
  69451. */
  69452. export class DisplayPassPostProcess extends PostProcess {
  69453. /**
  69454. * Gets a string identifying the name of the class
  69455. * @returns "DisplayPassPostProcess" string
  69456. */
  69457. getClassName(): string;
  69458. /**
  69459. * Creates the DisplayPassPostProcess
  69460. * @param name The name of the effect.
  69461. * @param options The required width/height ratio to downsize to before computing the render pass.
  69462. * @param camera The camera to apply the render pass to.
  69463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69464. * @param engine The engine which the post process will be applied. (default: current engine)
  69465. * @param reusable If the post process can be reused on the same frame. (default: false)
  69466. */
  69467. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69468. /** @hidden */
  69469. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69470. }
  69471. }
  69472. declare module BABYLON {
  69473. /** @hidden */
  69474. export var filterPixelShader: {
  69475. name: string;
  69476. shader: string;
  69477. };
  69478. }
  69479. declare module BABYLON {
  69480. /**
  69481. * Applies a kernel filter to the image
  69482. */
  69483. export class FilterPostProcess extends PostProcess {
  69484. /** The matrix to be applied to the image */
  69485. kernelMatrix: Matrix;
  69486. /**
  69487. * Gets a string identifying the name of the class
  69488. * @returns "FilterPostProcess" string
  69489. */
  69490. getClassName(): string;
  69491. /**
  69492. *
  69493. * @param name The name of the effect.
  69494. * @param kernelMatrix The matrix to be applied to the image
  69495. * @param options The required width/height ratio to downsize to before computing the render pass.
  69496. * @param camera The camera to apply the render pass to.
  69497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69498. * @param engine The engine which the post process will be applied. (default: current engine)
  69499. * @param reusable If the post process can be reused on the same frame. (default: false)
  69500. */
  69501. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69502. /** @hidden */
  69503. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69504. }
  69505. }
  69506. declare module BABYLON {
  69507. /** @hidden */
  69508. export var fxaaPixelShader: {
  69509. name: string;
  69510. shader: string;
  69511. };
  69512. }
  69513. declare module BABYLON {
  69514. /** @hidden */
  69515. export var fxaaVertexShader: {
  69516. name: string;
  69517. shader: string;
  69518. };
  69519. }
  69520. declare module BABYLON {
  69521. /**
  69522. * Fxaa post process
  69523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69524. */
  69525. export class FxaaPostProcess extends PostProcess {
  69526. /**
  69527. * Gets a string identifying the name of the class
  69528. * @returns "FxaaPostProcess" string
  69529. */
  69530. getClassName(): string;
  69531. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69532. private _getDefines;
  69533. /** @hidden */
  69534. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69535. }
  69536. }
  69537. declare module BABYLON {
  69538. /** @hidden */
  69539. export var grainPixelShader: {
  69540. name: string;
  69541. shader: string;
  69542. };
  69543. }
  69544. declare module BABYLON {
  69545. /**
  69546. * The GrainPostProcess adds noise to the image at mid luminance levels
  69547. */
  69548. export class GrainPostProcess extends PostProcess {
  69549. /**
  69550. * The intensity of the grain added (default: 30)
  69551. */
  69552. intensity: number;
  69553. /**
  69554. * If the grain should be randomized on every frame
  69555. */
  69556. animated: boolean;
  69557. /**
  69558. * Gets a string identifying the name of the class
  69559. * @returns "GrainPostProcess" string
  69560. */
  69561. getClassName(): string;
  69562. /**
  69563. * Creates a new instance of @see GrainPostProcess
  69564. * @param name The name of the effect.
  69565. * @param options The required width/height ratio to downsize to before computing the render pass.
  69566. * @param camera The camera to apply the render pass to.
  69567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69568. * @param engine The engine which the post process will be applied. (default: current engine)
  69569. * @param reusable If the post process can be reused on the same frame. (default: false)
  69570. * @param textureType Type of textures used when performing the post process. (default: 0)
  69571. * @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)
  69572. */
  69573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69574. /** @hidden */
  69575. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. /** @hidden */
  69580. export var highlightsPixelShader: {
  69581. name: string;
  69582. shader: string;
  69583. };
  69584. }
  69585. declare module BABYLON {
  69586. /**
  69587. * Extracts highlights from the image
  69588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69589. */
  69590. export class HighlightsPostProcess extends PostProcess {
  69591. /**
  69592. * Gets a string identifying the name of the class
  69593. * @returns "HighlightsPostProcess" string
  69594. */
  69595. getClassName(): string;
  69596. /**
  69597. * Extracts highlights from the image
  69598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69599. * @param name The name of the effect.
  69600. * @param options The required width/height ratio to downsize to before computing the render pass.
  69601. * @param camera The camera to apply the render pass to.
  69602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69603. * @param engine The engine which the post process will be applied. (default: current engine)
  69604. * @param reusable If the post process can be reused on the same frame. (default: false)
  69605. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69606. */
  69607. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69608. }
  69609. }
  69610. declare module BABYLON {
  69611. /** @hidden */
  69612. export var mrtFragmentDeclaration: {
  69613. name: string;
  69614. shader: string;
  69615. };
  69616. }
  69617. declare module BABYLON {
  69618. /** @hidden */
  69619. export var geometryPixelShader: {
  69620. name: string;
  69621. shader: string;
  69622. };
  69623. }
  69624. declare module BABYLON {
  69625. /** @hidden */
  69626. export var geometryVertexShader: {
  69627. name: string;
  69628. shader: string;
  69629. };
  69630. }
  69631. declare module BABYLON {
  69632. /** @hidden */
  69633. interface ISavedTransformationMatrix {
  69634. world: Matrix;
  69635. viewProjection: Matrix;
  69636. }
  69637. /**
  69638. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69639. */
  69640. export class GeometryBufferRenderer {
  69641. /**
  69642. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69643. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69644. */
  69645. static readonly POSITION_TEXTURE_TYPE: number;
  69646. /**
  69647. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69648. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69649. */
  69650. static readonly VELOCITY_TEXTURE_TYPE: number;
  69651. /**
  69652. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69653. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69654. */
  69655. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69656. /**
  69657. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69658. * in order to compute objects velocities when enableVelocity is set to "true"
  69659. * @hidden
  69660. */
  69661. _previousTransformationMatrices: {
  69662. [index: number]: ISavedTransformationMatrix;
  69663. };
  69664. /**
  69665. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69666. * in order to compute objects velocities when enableVelocity is set to "true"
  69667. * @hidden
  69668. */
  69669. _previousBonesTransformationMatrices: {
  69670. [index: number]: Float32Array;
  69671. };
  69672. /**
  69673. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69674. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69675. */
  69676. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69677. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69678. renderTransparentMeshes: boolean;
  69679. private _scene;
  69680. private _resizeObserver;
  69681. private _multiRenderTarget;
  69682. private _ratio;
  69683. private _enablePosition;
  69684. private _enableVelocity;
  69685. private _enableReflectivity;
  69686. private _positionIndex;
  69687. private _velocityIndex;
  69688. private _reflectivityIndex;
  69689. protected _effect: Effect;
  69690. protected _cachedDefines: string;
  69691. /**
  69692. * Set the render list (meshes to be rendered) used in the G buffer.
  69693. */
  69694. set renderList(meshes: Mesh[]);
  69695. /**
  69696. * Gets wether or not G buffer are supported by the running hardware.
  69697. * This requires draw buffer supports
  69698. */
  69699. get isSupported(): boolean;
  69700. /**
  69701. * Returns the index of the given texture type in the G-Buffer textures array
  69702. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69703. * @returns the index of the given texture type in the G-Buffer textures array
  69704. */
  69705. getTextureIndex(textureType: number): number;
  69706. /**
  69707. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69708. */
  69709. get enablePosition(): boolean;
  69710. /**
  69711. * Sets whether or not objects positions are enabled for the G buffer.
  69712. */
  69713. set enablePosition(enable: boolean);
  69714. /**
  69715. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69716. */
  69717. get enableVelocity(): boolean;
  69718. /**
  69719. * Sets wether or not objects velocities are enabled for the G buffer.
  69720. */
  69721. set enableVelocity(enable: boolean);
  69722. /**
  69723. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69724. */
  69725. get enableReflectivity(): boolean;
  69726. /**
  69727. * Sets wether or not objects roughness are enabled for the G buffer.
  69728. */
  69729. set enableReflectivity(enable: boolean);
  69730. /**
  69731. * Gets the scene associated with the buffer.
  69732. */
  69733. get scene(): Scene;
  69734. /**
  69735. * Gets the ratio used by the buffer during its creation.
  69736. * How big is the buffer related to the main canvas.
  69737. */
  69738. get ratio(): number;
  69739. /** @hidden */
  69740. static _SceneComponentInitialization: (scene: Scene) => void;
  69741. /**
  69742. * Creates a new G Buffer for the scene
  69743. * @param scene The scene the buffer belongs to
  69744. * @param ratio How big is the buffer related to the main canvas.
  69745. */
  69746. constructor(scene: Scene, ratio?: number);
  69747. /**
  69748. * Checks wether everything is ready to render a submesh to the G buffer.
  69749. * @param subMesh the submesh to check readiness for
  69750. * @param useInstances is the mesh drawn using instance or not
  69751. * @returns true if ready otherwise false
  69752. */
  69753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69754. /**
  69755. * Gets the current underlying G Buffer.
  69756. * @returns the buffer
  69757. */
  69758. getGBuffer(): MultiRenderTarget;
  69759. /**
  69760. * Gets the number of samples used to render the buffer (anti aliasing).
  69761. */
  69762. get samples(): number;
  69763. /**
  69764. * Sets the number of samples used to render the buffer (anti aliasing).
  69765. */
  69766. set samples(value: number);
  69767. /**
  69768. * Disposes the renderer and frees up associated resources.
  69769. */
  69770. dispose(): void;
  69771. protected _createRenderTargets(): void;
  69772. private _copyBonesTransformationMatrices;
  69773. }
  69774. }
  69775. declare module BABYLON {
  69776. interface Scene {
  69777. /** @hidden (Backing field) */
  69778. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69779. /**
  69780. * Gets or Sets the current geometry buffer associated to the scene.
  69781. */
  69782. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69783. /**
  69784. * Enables a GeometryBufferRender and associates it with the scene
  69785. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69786. * @returns the GeometryBufferRenderer
  69787. */
  69788. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69789. /**
  69790. * Disables the GeometryBufferRender associated with the scene
  69791. */
  69792. disableGeometryBufferRenderer(): void;
  69793. }
  69794. /**
  69795. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69796. * in several rendering techniques.
  69797. */
  69798. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69799. /**
  69800. * The component name helpful to identify the component in the list of scene components.
  69801. */
  69802. readonly name: string;
  69803. /**
  69804. * The scene the component belongs to.
  69805. */
  69806. scene: Scene;
  69807. /**
  69808. * Creates a new instance of the component for the given scene
  69809. * @param scene Defines the scene to register the component in
  69810. */
  69811. constructor(scene: Scene);
  69812. /**
  69813. * Registers the component in a given scene
  69814. */
  69815. register(): void;
  69816. /**
  69817. * Rebuilds the elements related to this component in case of
  69818. * context lost for instance.
  69819. */
  69820. rebuild(): void;
  69821. /**
  69822. * Disposes the component and the associated ressources
  69823. */
  69824. dispose(): void;
  69825. private _gatherRenderTargets;
  69826. }
  69827. }
  69828. declare module BABYLON {
  69829. /** @hidden */
  69830. export var motionBlurPixelShader: {
  69831. name: string;
  69832. shader: string;
  69833. };
  69834. }
  69835. declare module BABYLON {
  69836. /**
  69837. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69838. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69839. * As an example, all you have to do is to create the post-process:
  69840. * var mb = new BABYLON.MotionBlurPostProcess(
  69841. * 'mb', // The name of the effect.
  69842. * scene, // The scene containing the objects to blur according to their velocity.
  69843. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69844. * camera // The camera to apply the render pass to.
  69845. * );
  69846. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69847. */
  69848. export class MotionBlurPostProcess extends PostProcess {
  69849. /**
  69850. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69851. */
  69852. motionStrength: number;
  69853. /**
  69854. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69855. */
  69856. get motionBlurSamples(): number;
  69857. /**
  69858. * Sets the number of iterations to be used for motion blur quality
  69859. */
  69860. set motionBlurSamples(samples: number);
  69861. private _motionBlurSamples;
  69862. private _geometryBufferRenderer;
  69863. /**
  69864. * Gets a string identifying the name of the class
  69865. * @returns "MotionBlurPostProcess" string
  69866. */
  69867. getClassName(): string;
  69868. /**
  69869. * Creates a new instance MotionBlurPostProcess
  69870. * @param name The name of the effect.
  69871. * @param scene The scene containing the objects to blur according to their velocity.
  69872. * @param options The required width/height ratio to downsize to before computing the render pass.
  69873. * @param camera The camera to apply the render pass to.
  69874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69875. * @param engine The engine which the post process will be applied. (default: current engine)
  69876. * @param reusable If the post process can be reused on the same frame. (default: false)
  69877. * @param textureType Type of textures used when performing the post process. (default: 0)
  69878. * @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)
  69879. */
  69880. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69881. /**
  69882. * Excludes the given skinned mesh from computing bones velocities.
  69883. * 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.
  69884. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69885. */
  69886. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69887. /**
  69888. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69889. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69890. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69891. */
  69892. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69893. /**
  69894. * Disposes the post process.
  69895. * @param camera The camera to dispose the post process on.
  69896. */
  69897. dispose(camera?: Camera): void;
  69898. /** @hidden */
  69899. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  69900. }
  69901. }
  69902. declare module BABYLON {
  69903. /** @hidden */
  69904. export var refractionPixelShader: {
  69905. name: string;
  69906. shader: string;
  69907. };
  69908. }
  69909. declare module BABYLON {
  69910. /**
  69911. * Post process which applies a refractin texture
  69912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69913. */
  69914. export class RefractionPostProcess extends PostProcess {
  69915. private _refTexture;
  69916. private _ownRefractionTexture;
  69917. /** the base color of the refraction (used to taint the rendering) */
  69918. color: Color3;
  69919. /** simulated refraction depth */
  69920. depth: number;
  69921. /** the coefficient of the base color (0 to remove base color tainting) */
  69922. colorLevel: number;
  69923. /** Gets the url used to load the refraction texture */
  69924. refractionTextureUrl: string;
  69925. /**
  69926. * Gets or sets the refraction texture
  69927. * Please note that you are responsible for disposing the texture if you set it manually
  69928. */
  69929. get refractionTexture(): Texture;
  69930. set refractionTexture(value: Texture);
  69931. /**
  69932. * Gets a string identifying the name of the class
  69933. * @returns "RefractionPostProcess" string
  69934. */
  69935. getClassName(): string;
  69936. /**
  69937. * Initializes the RefractionPostProcess
  69938. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69939. * @param name The name of the effect.
  69940. * @param refractionTextureUrl Url of the refraction texture to use
  69941. * @param color the base color of the refraction (used to taint the rendering)
  69942. * @param depth simulated refraction depth
  69943. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69944. * @param camera The camera to apply the render pass to.
  69945. * @param options The required width/height ratio to downsize to before computing the render pass.
  69946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69947. * @param engine The engine which the post process will be applied. (default: current engine)
  69948. * @param reusable If the post process can be reused on the same frame. (default: false)
  69949. */
  69950. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69951. /**
  69952. * Disposes of the post process
  69953. * @param camera Camera to dispose post process on
  69954. */
  69955. dispose(camera: Camera): void;
  69956. /** @hidden */
  69957. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  69958. }
  69959. }
  69960. declare module BABYLON {
  69961. /** @hidden */
  69962. export var sharpenPixelShader: {
  69963. name: string;
  69964. shader: string;
  69965. };
  69966. }
  69967. declare module BABYLON {
  69968. /**
  69969. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69970. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69971. */
  69972. export class SharpenPostProcess extends PostProcess {
  69973. /**
  69974. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69975. */
  69976. colorAmount: number;
  69977. /**
  69978. * How much sharpness should be applied (default: 0.3)
  69979. */
  69980. edgeAmount: number;
  69981. /**
  69982. * Gets a string identifying the name of the class
  69983. * @returns "SharpenPostProcess" string
  69984. */
  69985. getClassName(): string;
  69986. /**
  69987. * Creates a new instance ConvolutionPostProcess
  69988. * @param name The name of the effect.
  69989. * @param options The required width/height ratio to downsize to before computing the render pass.
  69990. * @param camera The camera to apply the render pass to.
  69991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69992. * @param engine The engine which the post process will be applied. (default: current engine)
  69993. * @param reusable If the post process can be reused on the same frame. (default: false)
  69994. * @param textureType Type of textures used when performing the post process. (default: 0)
  69995. * @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)
  69996. */
  69997. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69998. /** @hidden */
  69999. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70000. }
  70001. }
  70002. declare module BABYLON {
  70003. /**
  70004. * PostProcessRenderPipeline
  70005. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70006. */
  70007. export class PostProcessRenderPipeline {
  70008. private engine;
  70009. private _renderEffects;
  70010. private _renderEffectsForIsolatedPass;
  70011. /**
  70012. * List of inspectable custom properties (used by the Inspector)
  70013. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70014. */
  70015. inspectableCustomProperties: IInspectable[];
  70016. /**
  70017. * @hidden
  70018. */
  70019. protected _cameras: Camera[];
  70020. /** @hidden */
  70021. _name: string;
  70022. /**
  70023. * Gets pipeline name
  70024. */
  70025. get name(): string;
  70026. /** Gets the list of attached cameras */
  70027. get cameras(): Camera[];
  70028. /**
  70029. * Initializes a PostProcessRenderPipeline
  70030. * @param engine engine to add the pipeline to
  70031. * @param name name of the pipeline
  70032. */
  70033. constructor(engine: Engine, name: string);
  70034. /**
  70035. * Gets the class name
  70036. * @returns "PostProcessRenderPipeline"
  70037. */
  70038. getClassName(): string;
  70039. /**
  70040. * If all the render effects in the pipeline are supported
  70041. */
  70042. get isSupported(): boolean;
  70043. /**
  70044. * Adds an effect to the pipeline
  70045. * @param renderEffect the effect to add
  70046. */
  70047. addEffect(renderEffect: PostProcessRenderEffect): void;
  70048. /** @hidden */
  70049. _rebuild(): void;
  70050. /** @hidden */
  70051. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70052. /** @hidden */
  70053. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70054. /** @hidden */
  70055. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70056. /** @hidden */
  70057. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70058. /** @hidden */
  70059. _attachCameras(cameras: Camera, unique: boolean): void;
  70060. /** @hidden */
  70061. _attachCameras(cameras: Camera[], unique: boolean): void;
  70062. /** @hidden */
  70063. _detachCameras(cameras: Camera): void;
  70064. /** @hidden */
  70065. _detachCameras(cameras: Nullable<Camera[]>): void;
  70066. /** @hidden */
  70067. _update(): void;
  70068. /** @hidden */
  70069. _reset(): void;
  70070. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70071. /**
  70072. * Sets the required values to the prepass renderer.
  70073. * @param prePassRenderer defines the prepass renderer to setup.
  70074. * @returns true if the pre pass is needed.
  70075. */
  70076. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70077. /**
  70078. * Disposes of the pipeline
  70079. */
  70080. dispose(): void;
  70081. }
  70082. }
  70083. declare module BABYLON {
  70084. /**
  70085. * PostProcessRenderPipelineManager class
  70086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70087. */
  70088. export class PostProcessRenderPipelineManager {
  70089. private _renderPipelines;
  70090. /**
  70091. * Initializes a PostProcessRenderPipelineManager
  70092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70093. */
  70094. constructor();
  70095. /**
  70096. * Gets the list of supported render pipelines
  70097. */
  70098. get supportedPipelines(): PostProcessRenderPipeline[];
  70099. /**
  70100. * Adds a pipeline to the manager
  70101. * @param renderPipeline The pipeline to add
  70102. */
  70103. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70104. /**
  70105. * Attaches a camera to the pipeline
  70106. * @param renderPipelineName The name of the pipeline to attach to
  70107. * @param cameras the camera to attach
  70108. * @param unique if the camera can be attached multiple times to the pipeline
  70109. */
  70110. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70111. /**
  70112. * Detaches a camera from the pipeline
  70113. * @param renderPipelineName The name of the pipeline to detach from
  70114. * @param cameras the camera to detach
  70115. */
  70116. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70117. /**
  70118. * Enables an effect by name on a pipeline
  70119. * @param renderPipelineName the name of the pipeline to enable the effect in
  70120. * @param renderEffectName the name of the effect to enable
  70121. * @param cameras the cameras that the effect should be enabled on
  70122. */
  70123. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70124. /**
  70125. * Disables an effect by name on a pipeline
  70126. * @param renderPipelineName the name of the pipeline to disable the effect in
  70127. * @param renderEffectName the name of the effect to disable
  70128. * @param cameras the cameras that the effect should be disabled on
  70129. */
  70130. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70131. /**
  70132. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70133. */
  70134. update(): void;
  70135. /** @hidden */
  70136. _rebuild(): void;
  70137. /**
  70138. * Disposes of the manager and pipelines
  70139. */
  70140. dispose(): void;
  70141. }
  70142. }
  70143. declare module BABYLON {
  70144. interface Scene {
  70145. /** @hidden (Backing field) */
  70146. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70147. /**
  70148. * Gets the postprocess render pipeline manager
  70149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70150. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70151. */
  70152. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70153. }
  70154. /**
  70155. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70156. */
  70157. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70158. /**
  70159. * The component name helpfull to identify the component in the list of scene components.
  70160. */
  70161. readonly name: string;
  70162. /**
  70163. * The scene the component belongs to.
  70164. */
  70165. scene: Scene;
  70166. /**
  70167. * Creates a new instance of the component for the given scene
  70168. * @param scene Defines the scene to register the component in
  70169. */
  70170. constructor(scene: Scene);
  70171. /**
  70172. * Registers the component in a given scene
  70173. */
  70174. register(): void;
  70175. /**
  70176. * Rebuilds the elements related to this component in case of
  70177. * context lost for instance.
  70178. */
  70179. rebuild(): void;
  70180. /**
  70181. * Disposes the component and the associated ressources
  70182. */
  70183. dispose(): void;
  70184. private _gatherRenderTargets;
  70185. }
  70186. }
  70187. declare module BABYLON {
  70188. /**
  70189. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70190. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70191. */
  70192. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70193. private _scene;
  70194. private _camerasToBeAttached;
  70195. /**
  70196. * ID of the sharpen post process,
  70197. */
  70198. private readonly SharpenPostProcessId;
  70199. /**
  70200. * @ignore
  70201. * ID of the image processing post process;
  70202. */
  70203. readonly ImageProcessingPostProcessId: string;
  70204. /**
  70205. * @ignore
  70206. * ID of the Fast Approximate Anti-Aliasing post process;
  70207. */
  70208. readonly FxaaPostProcessId: string;
  70209. /**
  70210. * ID of the chromatic aberration post process,
  70211. */
  70212. private readonly ChromaticAberrationPostProcessId;
  70213. /**
  70214. * ID of the grain post process
  70215. */
  70216. private readonly GrainPostProcessId;
  70217. /**
  70218. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70219. */
  70220. sharpen: SharpenPostProcess;
  70221. private _sharpenEffect;
  70222. private bloom;
  70223. /**
  70224. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70225. */
  70226. depthOfField: DepthOfFieldEffect;
  70227. /**
  70228. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70229. */
  70230. fxaa: FxaaPostProcess;
  70231. /**
  70232. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70233. */
  70234. imageProcessing: ImageProcessingPostProcess;
  70235. /**
  70236. * Chromatic aberration post process which will shift rgb colors in the image
  70237. */
  70238. chromaticAberration: ChromaticAberrationPostProcess;
  70239. private _chromaticAberrationEffect;
  70240. /**
  70241. * Grain post process which add noise to the image
  70242. */
  70243. grain: GrainPostProcess;
  70244. private _grainEffect;
  70245. /**
  70246. * Glow post process which adds a glow to emissive areas of the image
  70247. */
  70248. private _glowLayer;
  70249. /**
  70250. * Animations which can be used to tweak settings over a period of time
  70251. */
  70252. animations: Animation[];
  70253. private _imageProcessingConfigurationObserver;
  70254. private _sharpenEnabled;
  70255. private _bloomEnabled;
  70256. private _depthOfFieldEnabled;
  70257. private _depthOfFieldBlurLevel;
  70258. private _fxaaEnabled;
  70259. private _imageProcessingEnabled;
  70260. private _defaultPipelineTextureType;
  70261. private _bloomScale;
  70262. private _chromaticAberrationEnabled;
  70263. private _grainEnabled;
  70264. private _buildAllowed;
  70265. /**
  70266. * Gets active scene
  70267. */
  70268. get scene(): Scene;
  70269. /**
  70270. * Enable or disable the sharpen process from the pipeline
  70271. */
  70272. set sharpenEnabled(enabled: boolean);
  70273. get sharpenEnabled(): boolean;
  70274. private _resizeObserver;
  70275. private _hardwareScaleLevel;
  70276. private _bloomKernel;
  70277. /**
  70278. * Specifies the size of the bloom blur kernel, relative to the final output size
  70279. */
  70280. get bloomKernel(): number;
  70281. set bloomKernel(value: number);
  70282. /**
  70283. * Specifies the weight of the bloom in the final rendering
  70284. */
  70285. private _bloomWeight;
  70286. /**
  70287. * Specifies the luma threshold for the area that will be blurred by the bloom
  70288. */
  70289. private _bloomThreshold;
  70290. private _hdr;
  70291. /**
  70292. * The strength of the bloom.
  70293. */
  70294. set bloomWeight(value: number);
  70295. get bloomWeight(): number;
  70296. /**
  70297. * The strength of the bloom.
  70298. */
  70299. set bloomThreshold(value: number);
  70300. get bloomThreshold(): number;
  70301. /**
  70302. * The scale of the bloom, lower value will provide better performance.
  70303. */
  70304. set bloomScale(value: number);
  70305. get bloomScale(): number;
  70306. /**
  70307. * Enable or disable the bloom from the pipeline
  70308. */
  70309. set bloomEnabled(enabled: boolean);
  70310. get bloomEnabled(): boolean;
  70311. private _rebuildBloom;
  70312. /**
  70313. * If the depth of field is enabled.
  70314. */
  70315. get depthOfFieldEnabled(): boolean;
  70316. set depthOfFieldEnabled(enabled: boolean);
  70317. /**
  70318. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70319. */
  70320. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70321. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70322. /**
  70323. * If the anti aliasing is enabled.
  70324. */
  70325. set fxaaEnabled(enabled: boolean);
  70326. get fxaaEnabled(): boolean;
  70327. private _samples;
  70328. /**
  70329. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70330. */
  70331. set samples(sampleCount: number);
  70332. get samples(): number;
  70333. /**
  70334. * If image processing is enabled.
  70335. */
  70336. set imageProcessingEnabled(enabled: boolean);
  70337. get imageProcessingEnabled(): boolean;
  70338. /**
  70339. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70340. */
  70341. set glowLayerEnabled(enabled: boolean);
  70342. get glowLayerEnabled(): boolean;
  70343. /**
  70344. * Gets the glow layer (or null if not defined)
  70345. */
  70346. get glowLayer(): Nullable<GlowLayer>;
  70347. /**
  70348. * Enable or disable the chromaticAberration process from the pipeline
  70349. */
  70350. set chromaticAberrationEnabled(enabled: boolean);
  70351. get chromaticAberrationEnabled(): boolean;
  70352. /**
  70353. * Enable or disable the grain process from the pipeline
  70354. */
  70355. set grainEnabled(enabled: boolean);
  70356. get grainEnabled(): boolean;
  70357. /**
  70358. * @constructor
  70359. * @param name - The rendering pipeline name (default: "")
  70360. * @param hdr - If high dynamic range textures should be used (default: true)
  70361. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70362. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70363. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70364. */
  70365. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70366. /**
  70367. * Get the class name
  70368. * @returns "DefaultRenderingPipeline"
  70369. */
  70370. getClassName(): string;
  70371. /**
  70372. * Force the compilation of the entire pipeline.
  70373. */
  70374. prepare(): void;
  70375. private _hasCleared;
  70376. private _prevPostProcess;
  70377. private _prevPrevPostProcess;
  70378. private _setAutoClearAndTextureSharing;
  70379. private _depthOfFieldSceneObserver;
  70380. private _buildPipeline;
  70381. private _disposePostProcesses;
  70382. /**
  70383. * Adds a camera to the pipeline
  70384. * @param camera the camera to be added
  70385. */
  70386. addCamera(camera: Camera): void;
  70387. /**
  70388. * Removes a camera from the pipeline
  70389. * @param camera the camera to remove
  70390. */
  70391. removeCamera(camera: Camera): void;
  70392. /**
  70393. * Dispose of the pipeline and stop all post processes
  70394. */
  70395. dispose(): void;
  70396. /**
  70397. * Serialize the rendering pipeline (Used when exporting)
  70398. * @returns the serialized object
  70399. */
  70400. serialize(): any;
  70401. /**
  70402. * Parse the serialized pipeline
  70403. * @param source Source pipeline.
  70404. * @param scene The scene to load the pipeline to.
  70405. * @param rootUrl The URL of the serialized pipeline.
  70406. * @returns An instantiated pipeline from the serialized object.
  70407. */
  70408. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70409. }
  70410. }
  70411. declare module BABYLON {
  70412. /** @hidden */
  70413. export var lensHighlightsPixelShader: {
  70414. name: string;
  70415. shader: string;
  70416. };
  70417. }
  70418. declare module BABYLON {
  70419. /** @hidden */
  70420. export var depthOfFieldPixelShader: {
  70421. name: string;
  70422. shader: string;
  70423. };
  70424. }
  70425. declare module BABYLON {
  70426. /**
  70427. * BABYLON.JS Chromatic Aberration GLSL Shader
  70428. * Author: Olivier Guyot
  70429. * Separates very slightly R, G and B colors on the edges of the screen
  70430. * Inspired by Francois Tarlier & Martins Upitis
  70431. */
  70432. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70433. /**
  70434. * @ignore
  70435. * The chromatic aberration PostProcess id in the pipeline
  70436. */
  70437. LensChromaticAberrationEffect: string;
  70438. /**
  70439. * @ignore
  70440. * The highlights enhancing PostProcess id in the pipeline
  70441. */
  70442. HighlightsEnhancingEffect: string;
  70443. /**
  70444. * @ignore
  70445. * The depth-of-field PostProcess id in the pipeline
  70446. */
  70447. LensDepthOfFieldEffect: string;
  70448. private _scene;
  70449. private _depthTexture;
  70450. private _grainTexture;
  70451. private _chromaticAberrationPostProcess;
  70452. private _highlightsPostProcess;
  70453. private _depthOfFieldPostProcess;
  70454. private _edgeBlur;
  70455. private _grainAmount;
  70456. private _chromaticAberration;
  70457. private _distortion;
  70458. private _highlightsGain;
  70459. private _highlightsThreshold;
  70460. private _dofDistance;
  70461. private _dofAperture;
  70462. private _dofDarken;
  70463. private _dofPentagon;
  70464. private _blurNoise;
  70465. /**
  70466. * @constructor
  70467. *
  70468. * Effect parameters are as follow:
  70469. * {
  70470. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70471. * edge_blur: number; // from 0 to x (1 for realism)
  70472. * distortion: number; // from 0 to x (1 for realism)
  70473. * grain_amount: number; // from 0 to 1
  70474. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70475. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70476. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70477. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70478. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70479. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70480. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70481. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70482. * }
  70483. * Note: if an effect parameter is unset, effect is disabled
  70484. *
  70485. * @param name The rendering pipeline name
  70486. * @param parameters - An object containing all parameters (see above)
  70487. * @param scene The scene linked to this pipeline
  70488. * @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)
  70489. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70490. */
  70491. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70492. /**
  70493. * Get the class name
  70494. * @returns "LensRenderingPipeline"
  70495. */
  70496. getClassName(): string;
  70497. /**
  70498. * Gets associated scene
  70499. */
  70500. get scene(): Scene;
  70501. /**
  70502. * Gets or sets the edge blur
  70503. */
  70504. get edgeBlur(): number;
  70505. set edgeBlur(value: number);
  70506. /**
  70507. * Gets or sets the grain amount
  70508. */
  70509. get grainAmount(): number;
  70510. set grainAmount(value: number);
  70511. /**
  70512. * Gets or sets the chromatic aberration amount
  70513. */
  70514. get chromaticAberration(): number;
  70515. set chromaticAberration(value: number);
  70516. /**
  70517. * Gets or sets the depth of field aperture
  70518. */
  70519. get dofAperture(): number;
  70520. set dofAperture(value: number);
  70521. /**
  70522. * Gets or sets the edge distortion
  70523. */
  70524. get edgeDistortion(): number;
  70525. set edgeDistortion(value: number);
  70526. /**
  70527. * Gets or sets the depth of field distortion
  70528. */
  70529. get dofDistortion(): number;
  70530. set dofDistortion(value: number);
  70531. /**
  70532. * Gets or sets the darken out of focus amount
  70533. */
  70534. get darkenOutOfFocus(): number;
  70535. set darkenOutOfFocus(value: number);
  70536. /**
  70537. * Gets or sets a boolean indicating if blur noise is enabled
  70538. */
  70539. get blurNoise(): boolean;
  70540. set blurNoise(value: boolean);
  70541. /**
  70542. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70543. */
  70544. get pentagonBokeh(): boolean;
  70545. set pentagonBokeh(value: boolean);
  70546. /**
  70547. * Gets or sets the highlight grain amount
  70548. */
  70549. get highlightsGain(): number;
  70550. set highlightsGain(value: number);
  70551. /**
  70552. * Gets or sets the highlight threshold
  70553. */
  70554. get highlightsThreshold(): number;
  70555. set highlightsThreshold(value: number);
  70556. /**
  70557. * Sets the amount of blur at the edges
  70558. * @param amount blur amount
  70559. */
  70560. setEdgeBlur(amount: number): void;
  70561. /**
  70562. * Sets edge blur to 0
  70563. */
  70564. disableEdgeBlur(): void;
  70565. /**
  70566. * Sets the amout of grain
  70567. * @param amount Amount of grain
  70568. */
  70569. setGrainAmount(amount: number): void;
  70570. /**
  70571. * Set grain amount to 0
  70572. */
  70573. disableGrain(): void;
  70574. /**
  70575. * Sets the chromatic aberration amount
  70576. * @param amount amount of chromatic aberration
  70577. */
  70578. setChromaticAberration(amount: number): void;
  70579. /**
  70580. * Sets chromatic aberration amount to 0
  70581. */
  70582. disableChromaticAberration(): void;
  70583. /**
  70584. * Sets the EdgeDistortion amount
  70585. * @param amount amount of EdgeDistortion
  70586. */
  70587. setEdgeDistortion(amount: number): void;
  70588. /**
  70589. * Sets edge distortion to 0
  70590. */
  70591. disableEdgeDistortion(): void;
  70592. /**
  70593. * Sets the FocusDistance amount
  70594. * @param amount amount of FocusDistance
  70595. */
  70596. setFocusDistance(amount: number): void;
  70597. /**
  70598. * Disables depth of field
  70599. */
  70600. disableDepthOfField(): void;
  70601. /**
  70602. * Sets the Aperture amount
  70603. * @param amount amount of Aperture
  70604. */
  70605. setAperture(amount: number): void;
  70606. /**
  70607. * Sets the DarkenOutOfFocus amount
  70608. * @param amount amount of DarkenOutOfFocus
  70609. */
  70610. setDarkenOutOfFocus(amount: number): void;
  70611. private _pentagonBokehIsEnabled;
  70612. /**
  70613. * Creates a pentagon bokeh effect
  70614. */
  70615. enablePentagonBokeh(): void;
  70616. /**
  70617. * Disables the pentagon bokeh effect
  70618. */
  70619. disablePentagonBokeh(): void;
  70620. /**
  70621. * Enables noise blur
  70622. */
  70623. enableNoiseBlur(): void;
  70624. /**
  70625. * Disables noise blur
  70626. */
  70627. disableNoiseBlur(): void;
  70628. /**
  70629. * Sets the HighlightsGain amount
  70630. * @param amount amount of HighlightsGain
  70631. */
  70632. setHighlightsGain(amount: number): void;
  70633. /**
  70634. * Sets the HighlightsThreshold amount
  70635. * @param amount amount of HighlightsThreshold
  70636. */
  70637. setHighlightsThreshold(amount: number): void;
  70638. /**
  70639. * Disables highlights
  70640. */
  70641. disableHighlights(): void;
  70642. /**
  70643. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70644. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70645. */
  70646. dispose(disableDepthRender?: boolean): void;
  70647. private _createChromaticAberrationPostProcess;
  70648. private _createHighlightsPostProcess;
  70649. private _createDepthOfFieldPostProcess;
  70650. private _createGrainTexture;
  70651. }
  70652. }
  70653. declare module BABYLON {
  70654. /** @hidden */
  70655. export var ssao2PixelShader: {
  70656. name: string;
  70657. shader: string;
  70658. };
  70659. }
  70660. declare module BABYLON {
  70661. /** @hidden */
  70662. export var ssaoCombinePixelShader: {
  70663. name: string;
  70664. shader: string;
  70665. };
  70666. }
  70667. declare module BABYLON {
  70668. /**
  70669. * Render pipeline to produce ssao effect
  70670. */
  70671. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70672. /**
  70673. * @ignore
  70674. * The PassPostProcess id in the pipeline that contains the original scene color
  70675. */
  70676. SSAOOriginalSceneColorEffect: string;
  70677. /**
  70678. * @ignore
  70679. * The SSAO PostProcess id in the pipeline
  70680. */
  70681. SSAORenderEffect: string;
  70682. /**
  70683. * @ignore
  70684. * The horizontal blur PostProcess id in the pipeline
  70685. */
  70686. SSAOBlurHRenderEffect: string;
  70687. /**
  70688. * @ignore
  70689. * The vertical blur PostProcess id in the pipeline
  70690. */
  70691. SSAOBlurVRenderEffect: string;
  70692. /**
  70693. * @ignore
  70694. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70695. */
  70696. SSAOCombineRenderEffect: string;
  70697. /**
  70698. * The output strength of the SSAO post-process. Default value is 1.0.
  70699. */
  70700. totalStrength: number;
  70701. /**
  70702. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70703. */
  70704. maxZ: number;
  70705. /**
  70706. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70707. */
  70708. minZAspect: number;
  70709. private _samples;
  70710. /**
  70711. * Number of samples used for the SSAO calculations. Default value is 8
  70712. */
  70713. set samples(n: number);
  70714. get samples(): number;
  70715. private _textureSamples;
  70716. /**
  70717. * Number of samples to use for antialiasing
  70718. */
  70719. set textureSamples(n: number);
  70720. get textureSamples(): number;
  70721. /**
  70722. * Force rendering the geometry through geometry buffer
  70723. */
  70724. private _forceGeometryBuffer;
  70725. /**
  70726. * Ratio object used for SSAO ratio and blur ratio
  70727. */
  70728. private _ratio;
  70729. /**
  70730. * Dynamically generated sphere sampler.
  70731. */
  70732. private _sampleSphere;
  70733. /**
  70734. * Blur filter offsets
  70735. */
  70736. private _samplerOffsets;
  70737. private _expensiveBlur;
  70738. /**
  70739. * If bilateral blur should be used
  70740. */
  70741. set expensiveBlur(b: boolean);
  70742. get expensiveBlur(): boolean;
  70743. /**
  70744. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70745. */
  70746. radius: number;
  70747. /**
  70748. * The base color of the SSAO post-process
  70749. * The final result is "base + ssao" between [0, 1]
  70750. */
  70751. base: number;
  70752. /**
  70753. * Support test.
  70754. */
  70755. static get IsSupported(): boolean;
  70756. private _scene;
  70757. private _randomTexture;
  70758. private _originalColorPostProcess;
  70759. private _ssaoPostProcess;
  70760. private _blurHPostProcess;
  70761. private _blurVPostProcess;
  70762. private _ssaoCombinePostProcess;
  70763. private _prePassRenderer;
  70764. /**
  70765. * Gets active scene
  70766. */
  70767. get scene(): Scene;
  70768. /**
  70769. * @constructor
  70770. * @param name The rendering pipeline name
  70771. * @param scene The scene linked to this pipeline
  70772. * @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 }
  70773. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70774. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70775. */
  70776. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70777. /**
  70778. * Get the class name
  70779. * @returns "SSAO2RenderingPipeline"
  70780. */
  70781. getClassName(): string;
  70782. /**
  70783. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70784. */
  70785. dispose(disableGeometryBufferRenderer?: boolean): void;
  70786. private _createBlurPostProcess;
  70787. /** @hidden */
  70788. _rebuild(): void;
  70789. private _bits;
  70790. private _radicalInverse_VdC;
  70791. private _hammersley;
  70792. private _hemisphereSample_uniform;
  70793. private _generateHemisphere;
  70794. private _getDefinesForSSAO;
  70795. private _createSSAOPostProcess;
  70796. private _createSSAOCombinePostProcess;
  70797. private _createRandomTexture;
  70798. /**
  70799. * Serialize the rendering pipeline (Used when exporting)
  70800. * @returns the serialized object
  70801. */
  70802. serialize(): any;
  70803. /**
  70804. * Parse the serialized pipeline
  70805. * @param source Source pipeline.
  70806. * @param scene The scene to load the pipeline to.
  70807. * @param rootUrl The URL of the serialized pipeline.
  70808. * @returns An instantiated pipeline from the serialized object.
  70809. */
  70810. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70811. /**
  70812. * Sets the required values to the prepass renderer.
  70813. * @param prePassRenderer defines the prepass renderer to setup
  70814. * @returns true if the pre pass is needed.
  70815. */
  70816. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70817. }
  70818. }
  70819. declare module BABYLON {
  70820. /** @hidden */
  70821. export var ssaoPixelShader: {
  70822. name: string;
  70823. shader: string;
  70824. };
  70825. }
  70826. declare module BABYLON {
  70827. /**
  70828. * Render pipeline to produce ssao effect
  70829. */
  70830. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70831. /**
  70832. * @ignore
  70833. * The PassPostProcess id in the pipeline that contains the original scene color
  70834. */
  70835. SSAOOriginalSceneColorEffect: string;
  70836. /**
  70837. * @ignore
  70838. * The SSAO PostProcess id in the pipeline
  70839. */
  70840. SSAORenderEffect: string;
  70841. /**
  70842. * @ignore
  70843. * The horizontal blur PostProcess id in the pipeline
  70844. */
  70845. SSAOBlurHRenderEffect: string;
  70846. /**
  70847. * @ignore
  70848. * The vertical blur PostProcess id in the pipeline
  70849. */
  70850. SSAOBlurVRenderEffect: string;
  70851. /**
  70852. * @ignore
  70853. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70854. */
  70855. SSAOCombineRenderEffect: string;
  70856. /**
  70857. * The output strength of the SSAO post-process. Default value is 1.0.
  70858. */
  70859. totalStrength: number;
  70860. /**
  70861. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70862. */
  70863. radius: number;
  70864. /**
  70865. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70866. * Must not be equal to fallOff and superior to fallOff.
  70867. * Default value is 0.0075
  70868. */
  70869. area: number;
  70870. /**
  70871. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70872. * Must not be equal to area and inferior to area.
  70873. * Default value is 0.000001
  70874. */
  70875. fallOff: number;
  70876. /**
  70877. * The base color of the SSAO post-process
  70878. * The final result is "base + ssao" between [0, 1]
  70879. */
  70880. base: number;
  70881. private _scene;
  70882. private _depthTexture;
  70883. private _randomTexture;
  70884. private _originalColorPostProcess;
  70885. private _ssaoPostProcess;
  70886. private _blurHPostProcess;
  70887. private _blurVPostProcess;
  70888. private _ssaoCombinePostProcess;
  70889. private _firstUpdate;
  70890. /**
  70891. * Gets active scene
  70892. */
  70893. get scene(): Scene;
  70894. /**
  70895. * @constructor
  70896. * @param name - The rendering pipeline name
  70897. * @param scene - The scene linked to this pipeline
  70898. * @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 }
  70899. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70900. */
  70901. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70902. /**
  70903. * Get the class name
  70904. * @returns "SSAORenderingPipeline"
  70905. */
  70906. getClassName(): string;
  70907. /**
  70908. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70909. */
  70910. dispose(disableDepthRender?: boolean): void;
  70911. private _createBlurPostProcess;
  70912. /** @hidden */
  70913. _rebuild(): void;
  70914. private _createSSAOPostProcess;
  70915. private _createSSAOCombinePostProcess;
  70916. private _createRandomTexture;
  70917. }
  70918. }
  70919. declare module BABYLON {
  70920. /** @hidden */
  70921. export var screenSpaceReflectionPixelShader: {
  70922. name: string;
  70923. shader: string;
  70924. };
  70925. }
  70926. declare module BABYLON {
  70927. /**
  70928. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70929. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70930. */
  70931. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70932. /**
  70933. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70934. */
  70935. threshold: number;
  70936. /**
  70937. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70938. */
  70939. strength: number;
  70940. /**
  70941. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70942. */
  70943. reflectionSpecularFalloffExponent: number;
  70944. /**
  70945. * 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]
  70946. */
  70947. step: number;
  70948. /**
  70949. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70950. */
  70951. roughnessFactor: number;
  70952. private _geometryBufferRenderer;
  70953. private _enableSmoothReflections;
  70954. private _reflectionSamples;
  70955. private _smoothSteps;
  70956. /**
  70957. * Gets a string identifying the name of the class
  70958. * @returns "ScreenSpaceReflectionPostProcess" string
  70959. */
  70960. getClassName(): string;
  70961. /**
  70962. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70963. * @param name The name of the effect.
  70964. * @param scene The scene containing the objects to calculate reflections.
  70965. * @param options The required width/height ratio to downsize to before computing the render pass.
  70966. * @param camera The camera to apply the render pass to.
  70967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70968. * @param engine The engine which the post process will be applied. (default: current engine)
  70969. * @param reusable If the post process can be reused on the same frame. (default: false)
  70970. * @param textureType Type of textures used when performing the post process. (default: 0)
  70971. * @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)
  70972. */
  70973. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70974. /**
  70975. * Gets wether or not smoothing reflections is enabled.
  70976. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70977. */
  70978. get enableSmoothReflections(): boolean;
  70979. /**
  70980. * Sets wether or not smoothing reflections is enabled.
  70981. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70982. */
  70983. set enableSmoothReflections(enabled: boolean);
  70984. /**
  70985. * Gets the number of samples taken while computing reflections. More samples count is high,
  70986. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70987. */
  70988. get reflectionSamples(): number;
  70989. /**
  70990. * Sets the number of samples taken while computing reflections. More samples count is high,
  70991. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70992. */
  70993. set reflectionSamples(samples: number);
  70994. /**
  70995. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70996. * more the post-process will require GPU power and can generate a drop in FPS.
  70997. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70998. */
  70999. get smoothSteps(): number;
  71000. set smoothSteps(steps: number);
  71001. private _updateEffectDefines;
  71002. /** @hidden */
  71003. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71004. }
  71005. }
  71006. declare module BABYLON {
  71007. /** @hidden */
  71008. export var standardPixelShader: {
  71009. name: string;
  71010. shader: string;
  71011. };
  71012. }
  71013. declare module BABYLON {
  71014. /**
  71015. * Standard rendering pipeline
  71016. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71017. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71018. */
  71019. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71020. /**
  71021. * Public members
  71022. */
  71023. /**
  71024. * Post-process which contains the original scene color before the pipeline applies all the effects
  71025. */
  71026. originalPostProcess: Nullable<PostProcess>;
  71027. /**
  71028. * Post-process used to down scale an image x4
  71029. */
  71030. downSampleX4PostProcess: Nullable<PostProcess>;
  71031. /**
  71032. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71033. */
  71034. brightPassPostProcess: Nullable<PostProcess>;
  71035. /**
  71036. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71037. */
  71038. blurHPostProcesses: PostProcess[];
  71039. /**
  71040. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71041. */
  71042. blurVPostProcesses: PostProcess[];
  71043. /**
  71044. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71045. */
  71046. textureAdderPostProcess: Nullable<PostProcess>;
  71047. /**
  71048. * Post-process used to create volumetric lighting effect
  71049. */
  71050. volumetricLightPostProcess: Nullable<PostProcess>;
  71051. /**
  71052. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71053. */
  71054. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71055. /**
  71056. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71057. */
  71058. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71059. /**
  71060. * Post-process used to merge the volumetric light effect and the real scene color
  71061. */
  71062. volumetricLightMergePostProces: Nullable<PostProcess>;
  71063. /**
  71064. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71065. */
  71066. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71067. /**
  71068. * Base post-process used to calculate the average luminance of the final image for HDR
  71069. */
  71070. luminancePostProcess: Nullable<PostProcess>;
  71071. /**
  71072. * Post-processes used to create down sample post-processes in order to get
  71073. * the average luminance of the final image for HDR
  71074. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71075. */
  71076. luminanceDownSamplePostProcesses: PostProcess[];
  71077. /**
  71078. * Post-process used to create a HDR effect (light adaptation)
  71079. */
  71080. hdrPostProcess: Nullable<PostProcess>;
  71081. /**
  71082. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71083. */
  71084. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71085. /**
  71086. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71087. */
  71088. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71089. /**
  71090. * Post-process used to merge the final HDR post-process and the real scene color
  71091. */
  71092. hdrFinalPostProcess: Nullable<PostProcess>;
  71093. /**
  71094. * Post-process used to create a lens flare effect
  71095. */
  71096. lensFlarePostProcess: Nullable<PostProcess>;
  71097. /**
  71098. * Post-process that merges the result of the lens flare post-process and the real scene color
  71099. */
  71100. lensFlareComposePostProcess: Nullable<PostProcess>;
  71101. /**
  71102. * Post-process used to create a motion blur effect
  71103. */
  71104. motionBlurPostProcess: Nullable<PostProcess>;
  71105. /**
  71106. * Post-process used to create a depth of field effect
  71107. */
  71108. depthOfFieldPostProcess: Nullable<PostProcess>;
  71109. /**
  71110. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71111. */
  71112. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71113. /**
  71114. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71115. */
  71116. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71117. /**
  71118. * Represents the brightness threshold in order to configure the illuminated surfaces
  71119. */
  71120. brightThreshold: number;
  71121. /**
  71122. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71123. */
  71124. blurWidth: number;
  71125. /**
  71126. * Sets if the blur for highlighted surfaces must be only horizontal
  71127. */
  71128. horizontalBlur: boolean;
  71129. /**
  71130. * Gets the overall exposure used by the pipeline
  71131. */
  71132. get exposure(): number;
  71133. /**
  71134. * Sets the overall exposure used by the pipeline
  71135. */
  71136. set exposure(value: number);
  71137. /**
  71138. * Texture used typically to simulate "dirty" on camera lens
  71139. */
  71140. lensTexture: Nullable<Texture>;
  71141. /**
  71142. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71143. */
  71144. volumetricLightCoefficient: number;
  71145. /**
  71146. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71147. */
  71148. volumetricLightPower: number;
  71149. /**
  71150. * Used the set the blur intensity to smooth the volumetric lights
  71151. */
  71152. volumetricLightBlurScale: number;
  71153. /**
  71154. * Light (spot or directional) used to generate the volumetric lights rays
  71155. * The source light must have a shadow generate so the pipeline can get its
  71156. * depth map
  71157. */
  71158. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71159. /**
  71160. * For eye adaptation, represents the minimum luminance the eye can see
  71161. */
  71162. hdrMinimumLuminance: number;
  71163. /**
  71164. * For eye adaptation, represents the decrease luminance speed
  71165. */
  71166. hdrDecreaseRate: number;
  71167. /**
  71168. * For eye adaptation, represents the increase luminance speed
  71169. */
  71170. hdrIncreaseRate: number;
  71171. /**
  71172. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71173. */
  71174. get hdrAutoExposure(): boolean;
  71175. /**
  71176. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71177. */
  71178. set hdrAutoExposure(value: boolean);
  71179. /**
  71180. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71181. */
  71182. lensColorTexture: Nullable<Texture>;
  71183. /**
  71184. * The overall strengh for the lens flare effect
  71185. */
  71186. lensFlareStrength: number;
  71187. /**
  71188. * Dispersion coefficient for lens flare ghosts
  71189. */
  71190. lensFlareGhostDispersal: number;
  71191. /**
  71192. * Main lens flare halo width
  71193. */
  71194. lensFlareHaloWidth: number;
  71195. /**
  71196. * Based on the lens distortion effect, defines how much the lens flare result
  71197. * is distorted
  71198. */
  71199. lensFlareDistortionStrength: number;
  71200. /**
  71201. * Configures the blur intensity used for for lens flare (halo)
  71202. */
  71203. lensFlareBlurWidth: number;
  71204. /**
  71205. * Lens star texture must be used to simulate rays on the flares and is available
  71206. * in the documentation
  71207. */
  71208. lensStarTexture: Nullable<Texture>;
  71209. /**
  71210. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71211. * flare effect by taking account of the dirt texture
  71212. */
  71213. lensFlareDirtTexture: Nullable<Texture>;
  71214. /**
  71215. * Represents the focal length for the depth of field effect
  71216. */
  71217. depthOfFieldDistance: number;
  71218. /**
  71219. * Represents the blur intensity for the blurred part of the depth of field effect
  71220. */
  71221. depthOfFieldBlurWidth: number;
  71222. /**
  71223. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71224. */
  71225. get motionStrength(): number;
  71226. /**
  71227. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71228. */
  71229. set motionStrength(strength: number);
  71230. /**
  71231. * Gets wether or not the motion blur post-process is object based or screen based.
  71232. */
  71233. get objectBasedMotionBlur(): boolean;
  71234. /**
  71235. * Sets wether or not the motion blur post-process should be object based or screen based
  71236. */
  71237. set objectBasedMotionBlur(value: boolean);
  71238. /**
  71239. * List of animations for the pipeline (IAnimatable implementation)
  71240. */
  71241. animations: Animation[];
  71242. /**
  71243. * Private members
  71244. */
  71245. private _scene;
  71246. private _currentDepthOfFieldSource;
  71247. private _basePostProcess;
  71248. private _fixedExposure;
  71249. private _currentExposure;
  71250. private _hdrAutoExposure;
  71251. private _hdrCurrentLuminance;
  71252. private _motionStrength;
  71253. private _isObjectBasedMotionBlur;
  71254. private _floatTextureType;
  71255. private _camerasToBeAttached;
  71256. private _ratio;
  71257. private _bloomEnabled;
  71258. private _depthOfFieldEnabled;
  71259. private _vlsEnabled;
  71260. private _lensFlareEnabled;
  71261. private _hdrEnabled;
  71262. private _motionBlurEnabled;
  71263. private _fxaaEnabled;
  71264. private _screenSpaceReflectionsEnabled;
  71265. private _motionBlurSamples;
  71266. private _volumetricLightStepsCount;
  71267. private _samples;
  71268. /**
  71269. * @ignore
  71270. * Specifies if the bloom pipeline is enabled
  71271. */
  71272. get BloomEnabled(): boolean;
  71273. set BloomEnabled(enabled: boolean);
  71274. /**
  71275. * @ignore
  71276. * Specifies if the depth of field pipeline is enabed
  71277. */
  71278. get DepthOfFieldEnabled(): boolean;
  71279. set DepthOfFieldEnabled(enabled: boolean);
  71280. /**
  71281. * @ignore
  71282. * Specifies if the lens flare pipeline is enabed
  71283. */
  71284. get LensFlareEnabled(): boolean;
  71285. set LensFlareEnabled(enabled: boolean);
  71286. /**
  71287. * @ignore
  71288. * Specifies if the HDR pipeline is enabled
  71289. */
  71290. get HDREnabled(): boolean;
  71291. set HDREnabled(enabled: boolean);
  71292. /**
  71293. * @ignore
  71294. * Specifies if the volumetric lights scattering effect is enabled
  71295. */
  71296. get VLSEnabled(): boolean;
  71297. set VLSEnabled(enabled: boolean);
  71298. /**
  71299. * @ignore
  71300. * Specifies if the motion blur effect is enabled
  71301. */
  71302. get MotionBlurEnabled(): boolean;
  71303. set MotionBlurEnabled(enabled: boolean);
  71304. /**
  71305. * Specifies if anti-aliasing is enabled
  71306. */
  71307. get fxaaEnabled(): boolean;
  71308. set fxaaEnabled(enabled: boolean);
  71309. /**
  71310. * Specifies if screen space reflections are enabled.
  71311. */
  71312. get screenSpaceReflectionsEnabled(): boolean;
  71313. set screenSpaceReflectionsEnabled(enabled: boolean);
  71314. /**
  71315. * Specifies the number of steps used to calculate the volumetric lights
  71316. * Typically in interval [50, 200]
  71317. */
  71318. get volumetricLightStepsCount(): number;
  71319. set volumetricLightStepsCount(count: number);
  71320. /**
  71321. * Specifies the number of samples used for the motion blur effect
  71322. * Typically in interval [16, 64]
  71323. */
  71324. get motionBlurSamples(): number;
  71325. set motionBlurSamples(samples: number);
  71326. /**
  71327. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71328. */
  71329. get samples(): number;
  71330. set samples(sampleCount: number);
  71331. /**
  71332. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71333. * @constructor
  71334. * @param name The rendering pipeline name
  71335. * @param scene The scene linked to this pipeline
  71336. * @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)
  71337. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71338. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71339. */
  71340. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71341. private _buildPipeline;
  71342. private _createDownSampleX4PostProcess;
  71343. private _createBrightPassPostProcess;
  71344. private _createBlurPostProcesses;
  71345. private _createTextureAdderPostProcess;
  71346. private _createVolumetricLightPostProcess;
  71347. private _createLuminancePostProcesses;
  71348. private _createHdrPostProcess;
  71349. private _createLensFlarePostProcess;
  71350. private _createDepthOfFieldPostProcess;
  71351. private _createMotionBlurPostProcess;
  71352. private _getDepthTexture;
  71353. private _disposePostProcesses;
  71354. /**
  71355. * Dispose of the pipeline and stop all post processes
  71356. */
  71357. dispose(): void;
  71358. /**
  71359. * Serialize the rendering pipeline (Used when exporting)
  71360. * @returns the serialized object
  71361. */
  71362. serialize(): any;
  71363. /**
  71364. * Parse the serialized pipeline
  71365. * @param source Source pipeline.
  71366. * @param scene The scene to load the pipeline to.
  71367. * @param rootUrl The URL of the serialized pipeline.
  71368. * @returns An instantiated pipeline from the serialized object.
  71369. */
  71370. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71371. /**
  71372. * Luminance steps
  71373. */
  71374. static LuminanceSteps: number;
  71375. }
  71376. }
  71377. declare module BABYLON {
  71378. /** @hidden */
  71379. export var stereoscopicInterlacePixelShader: {
  71380. name: string;
  71381. shader: string;
  71382. };
  71383. }
  71384. declare module BABYLON {
  71385. /**
  71386. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71387. */
  71388. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71389. private _stepSize;
  71390. private _passedProcess;
  71391. /**
  71392. * Gets a string identifying the name of the class
  71393. * @returns "StereoscopicInterlacePostProcessI" string
  71394. */
  71395. getClassName(): string;
  71396. /**
  71397. * Initializes a StereoscopicInterlacePostProcessI
  71398. * @param name The name of the effect.
  71399. * @param rigCameras The rig cameras to be appled to the post process
  71400. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71401. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71403. * @param engine The engine which the post process will be applied. (default: current engine)
  71404. * @param reusable If the post process can be reused on the same frame. (default: false)
  71405. */
  71406. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71407. }
  71408. /**
  71409. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71410. */
  71411. export class StereoscopicInterlacePostProcess extends PostProcess {
  71412. private _stepSize;
  71413. private _passedProcess;
  71414. /**
  71415. * Gets a string identifying the name of the class
  71416. * @returns "StereoscopicInterlacePostProcess" string
  71417. */
  71418. getClassName(): string;
  71419. /**
  71420. * Initializes a StereoscopicInterlacePostProcess
  71421. * @param name The name of the effect.
  71422. * @param rigCameras The rig cameras to be appled to the post process
  71423. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71425. * @param engine The engine which the post process will be applied. (default: current engine)
  71426. * @param reusable If the post process can be reused on the same frame. (default: false)
  71427. */
  71428. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71429. }
  71430. }
  71431. declare module BABYLON {
  71432. /** @hidden */
  71433. export var tonemapPixelShader: {
  71434. name: string;
  71435. shader: string;
  71436. };
  71437. }
  71438. declare module BABYLON {
  71439. /** Defines operator used for tonemapping */
  71440. export enum TonemappingOperator {
  71441. /** Hable */
  71442. Hable = 0,
  71443. /** Reinhard */
  71444. Reinhard = 1,
  71445. /** HejiDawson */
  71446. HejiDawson = 2,
  71447. /** Photographic */
  71448. Photographic = 3
  71449. }
  71450. /**
  71451. * Defines a post process to apply tone mapping
  71452. */
  71453. export class TonemapPostProcess extends PostProcess {
  71454. private _operator;
  71455. /** Defines the required exposure adjustement */
  71456. exposureAdjustment: number;
  71457. /**
  71458. * Gets a string identifying the name of the class
  71459. * @returns "TonemapPostProcess" string
  71460. */
  71461. getClassName(): string;
  71462. /**
  71463. * Creates a new TonemapPostProcess
  71464. * @param name defines the name of the postprocess
  71465. * @param _operator defines the operator to use
  71466. * @param exposureAdjustment defines the required exposure adjustement
  71467. * @param camera defines the camera to use (can be null)
  71468. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71469. * @param engine defines the hosting engine (can be ignore if camera is set)
  71470. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71471. */
  71472. constructor(name: string, _operator: TonemappingOperator,
  71473. /** Defines the required exposure adjustement */
  71474. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71475. }
  71476. }
  71477. declare module BABYLON {
  71478. /** @hidden */
  71479. export var volumetricLightScatteringPixelShader: {
  71480. name: string;
  71481. shader: string;
  71482. };
  71483. }
  71484. declare module BABYLON {
  71485. /** @hidden */
  71486. export var volumetricLightScatteringPassVertexShader: {
  71487. name: string;
  71488. shader: string;
  71489. };
  71490. }
  71491. declare module BABYLON {
  71492. /** @hidden */
  71493. export var volumetricLightScatteringPassPixelShader: {
  71494. name: string;
  71495. shader: string;
  71496. };
  71497. }
  71498. declare module BABYLON {
  71499. /**
  71500. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71501. */
  71502. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71503. private _volumetricLightScatteringPass;
  71504. private _volumetricLightScatteringRTT;
  71505. private _viewPort;
  71506. private _screenCoordinates;
  71507. private _cachedDefines;
  71508. /**
  71509. * If not undefined, the mesh position is computed from the attached node position
  71510. */
  71511. attachedNode: {
  71512. position: Vector3;
  71513. };
  71514. /**
  71515. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71516. */
  71517. customMeshPosition: Vector3;
  71518. /**
  71519. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71520. */
  71521. useCustomMeshPosition: boolean;
  71522. /**
  71523. * If the post-process should inverse the light scattering direction
  71524. */
  71525. invert: boolean;
  71526. /**
  71527. * The internal mesh used by the post-process
  71528. */
  71529. mesh: Mesh;
  71530. /**
  71531. * @hidden
  71532. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71533. */
  71534. get useDiffuseColor(): boolean;
  71535. set useDiffuseColor(useDiffuseColor: boolean);
  71536. /**
  71537. * Array containing the excluded meshes not rendered in the internal pass
  71538. */
  71539. excludedMeshes: AbstractMesh[];
  71540. /**
  71541. * Controls the overall intensity of the post-process
  71542. */
  71543. exposure: number;
  71544. /**
  71545. * Dissipates each sample's contribution in range [0, 1]
  71546. */
  71547. decay: number;
  71548. /**
  71549. * Controls the overall intensity of each sample
  71550. */
  71551. weight: number;
  71552. /**
  71553. * Controls the density of each sample
  71554. */
  71555. density: number;
  71556. /**
  71557. * @constructor
  71558. * @param name The post-process name
  71559. * @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)
  71560. * @param camera The camera that the post-process will be attached to
  71561. * @param mesh The mesh used to create the light scattering
  71562. * @param samples The post-process quality, default 100
  71563. * @param samplingModeThe post-process filtering mode
  71564. * @param engine The babylon engine
  71565. * @param reusable If the post-process is reusable
  71566. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71567. */
  71568. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71569. /**
  71570. * Returns the string "VolumetricLightScatteringPostProcess"
  71571. * @returns "VolumetricLightScatteringPostProcess"
  71572. */
  71573. getClassName(): string;
  71574. private _isReady;
  71575. /**
  71576. * Sets the new light position for light scattering effect
  71577. * @param position The new custom light position
  71578. */
  71579. setCustomMeshPosition(position: Vector3): void;
  71580. /**
  71581. * Returns the light position for light scattering effect
  71582. * @return Vector3 The custom light position
  71583. */
  71584. getCustomMeshPosition(): Vector3;
  71585. /**
  71586. * Disposes the internal assets and detaches the post-process from the camera
  71587. */
  71588. dispose(camera: Camera): void;
  71589. /**
  71590. * Returns the render target texture used by the post-process
  71591. * @return the render target texture used by the post-process
  71592. */
  71593. getPass(): RenderTargetTexture;
  71594. private _meshExcluded;
  71595. private _createPass;
  71596. private _updateMeshScreenCoordinates;
  71597. /**
  71598. * Creates a default mesh for the Volumeric Light Scattering post-process
  71599. * @param name The mesh name
  71600. * @param scene The scene where to create the mesh
  71601. * @return the default mesh
  71602. */
  71603. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71604. }
  71605. }
  71606. declare module BABYLON {
  71607. /** @hidden */
  71608. export var screenSpaceCurvaturePixelShader: {
  71609. name: string;
  71610. shader: string;
  71611. };
  71612. }
  71613. declare module BABYLON {
  71614. /**
  71615. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71616. */
  71617. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71618. /**
  71619. * Defines how much ridge the curvature effect displays.
  71620. */
  71621. ridge: number;
  71622. /**
  71623. * Defines how much valley the curvature effect displays.
  71624. */
  71625. valley: number;
  71626. private _geometryBufferRenderer;
  71627. /**
  71628. * Gets a string identifying the name of the class
  71629. * @returns "ScreenSpaceCurvaturePostProcess" string
  71630. */
  71631. getClassName(): string;
  71632. /**
  71633. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71634. * @param name The name of the effect.
  71635. * @param scene The scene containing the objects to blur according to their velocity.
  71636. * @param options The required width/height ratio to downsize to before computing the render pass.
  71637. * @param camera The camera to apply the render pass to.
  71638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71639. * @param engine The engine which the post process will be applied. (default: current engine)
  71640. * @param reusable If the post process can be reused on the same frame. (default: false)
  71641. * @param textureType Type of textures used when performing the post process. (default: 0)
  71642. * @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)
  71643. */
  71644. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71645. /**
  71646. * Support test.
  71647. */
  71648. static get IsSupported(): boolean;
  71649. /** @hidden */
  71650. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71651. }
  71652. }
  71653. declare module BABYLON {
  71654. interface Scene {
  71655. /** @hidden (Backing field) */
  71656. _boundingBoxRenderer: BoundingBoxRenderer;
  71657. /** @hidden (Backing field) */
  71658. _forceShowBoundingBoxes: boolean;
  71659. /**
  71660. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71661. */
  71662. forceShowBoundingBoxes: boolean;
  71663. /**
  71664. * Gets the bounding box renderer associated with the scene
  71665. * @returns a BoundingBoxRenderer
  71666. */
  71667. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71668. }
  71669. interface AbstractMesh {
  71670. /** @hidden (Backing field) */
  71671. _showBoundingBox: boolean;
  71672. /**
  71673. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71674. */
  71675. showBoundingBox: boolean;
  71676. }
  71677. /**
  71678. * Component responsible of rendering the bounding box of the meshes in a scene.
  71679. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71680. */
  71681. export class BoundingBoxRenderer implements ISceneComponent {
  71682. /**
  71683. * The component name helpfull to identify the component in the list of scene components.
  71684. */
  71685. readonly name: string;
  71686. /**
  71687. * The scene the component belongs to.
  71688. */
  71689. scene: Scene;
  71690. /**
  71691. * Color of the bounding box lines placed in front of an object
  71692. */
  71693. frontColor: Color3;
  71694. /**
  71695. * Color of the bounding box lines placed behind an object
  71696. */
  71697. backColor: Color3;
  71698. /**
  71699. * Defines if the renderer should show the back lines or not
  71700. */
  71701. showBackLines: boolean;
  71702. /**
  71703. * Observable raised before rendering a bounding box
  71704. */
  71705. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71706. /**
  71707. * Observable raised after rendering a bounding box
  71708. */
  71709. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71710. /**
  71711. * @hidden
  71712. */
  71713. renderList: SmartArray<BoundingBox>;
  71714. private _colorShader;
  71715. private _vertexBuffers;
  71716. private _indexBuffer;
  71717. private _fillIndexBuffer;
  71718. private _fillIndexData;
  71719. /**
  71720. * Instantiates a new bounding box renderer in a scene.
  71721. * @param scene the scene the renderer renders in
  71722. */
  71723. constructor(scene: Scene);
  71724. /**
  71725. * Registers the component in a given scene
  71726. */
  71727. register(): void;
  71728. private _evaluateSubMesh;
  71729. private _activeMesh;
  71730. private _prepareRessources;
  71731. private _createIndexBuffer;
  71732. /**
  71733. * Rebuilds the elements related to this component in case of
  71734. * context lost for instance.
  71735. */
  71736. rebuild(): void;
  71737. /**
  71738. * @hidden
  71739. */
  71740. reset(): void;
  71741. /**
  71742. * Render the bounding boxes of a specific rendering group
  71743. * @param renderingGroupId defines the rendering group to render
  71744. */
  71745. render(renderingGroupId: number): void;
  71746. /**
  71747. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71748. * @param mesh Define the mesh to render the occlusion bounding box for
  71749. */
  71750. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71751. /**
  71752. * Dispose and release the resources attached to this renderer.
  71753. */
  71754. dispose(): void;
  71755. }
  71756. }
  71757. declare module BABYLON {
  71758. interface Scene {
  71759. /** @hidden (Backing field) */
  71760. _depthRenderer: {
  71761. [id: string]: DepthRenderer;
  71762. };
  71763. /**
  71764. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71765. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71766. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71767. * @returns the created depth renderer
  71768. */
  71769. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71770. /**
  71771. * Disables a depth renderer for a given camera
  71772. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71773. */
  71774. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71775. }
  71776. /**
  71777. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71778. * in several rendering techniques.
  71779. */
  71780. export class DepthRendererSceneComponent implements ISceneComponent {
  71781. /**
  71782. * The component name helpfull to identify the component in the list of scene components.
  71783. */
  71784. readonly name: string;
  71785. /**
  71786. * The scene the component belongs to.
  71787. */
  71788. scene: Scene;
  71789. /**
  71790. * Creates a new instance of the component for the given scene
  71791. * @param scene Defines the scene to register the component in
  71792. */
  71793. constructor(scene: Scene);
  71794. /**
  71795. * Registers the component in a given scene
  71796. */
  71797. register(): void;
  71798. /**
  71799. * Rebuilds the elements related to this component in case of
  71800. * context lost for instance.
  71801. */
  71802. rebuild(): void;
  71803. /**
  71804. * Disposes the component and the associated ressources
  71805. */
  71806. dispose(): void;
  71807. private _gatherRenderTargets;
  71808. private _gatherActiveCameraRenderTargets;
  71809. }
  71810. }
  71811. declare module BABYLON {
  71812. interface AbstractScene {
  71813. /** @hidden (Backing field) */
  71814. _prePassRenderer: Nullable<PrePassRenderer>;
  71815. /**
  71816. * Gets or Sets the current prepass renderer associated to the scene.
  71817. */
  71818. prePassRenderer: Nullable<PrePassRenderer>;
  71819. /**
  71820. * Enables the prepass and associates it with the scene
  71821. * @returns the PrePassRenderer
  71822. */
  71823. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71824. /**
  71825. * Disables the prepass associated with the scene
  71826. */
  71827. disablePrePassRenderer(): void;
  71828. }
  71829. /**
  71830. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71831. * in several rendering techniques.
  71832. */
  71833. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71834. /**
  71835. * The component name helpful to identify the component in the list of scene components.
  71836. */
  71837. readonly name: string;
  71838. /**
  71839. * The scene the component belongs to.
  71840. */
  71841. scene: Scene;
  71842. /**
  71843. * Creates a new instance of the component for the given scene
  71844. * @param scene Defines the scene to register the component in
  71845. */
  71846. constructor(scene: Scene);
  71847. /**
  71848. * Registers the component in a given scene
  71849. */
  71850. register(): void;
  71851. private _beforeCameraDraw;
  71852. private _afterCameraDraw;
  71853. private _beforeClearStage;
  71854. /**
  71855. * Serializes the component data to the specified json object
  71856. * @param serializationObject The object to serialize to
  71857. */
  71858. serialize(serializationObject: any): void;
  71859. /**
  71860. * Adds all the elements from the container to the scene
  71861. * @param container the container holding the elements
  71862. */
  71863. addFromContainer(container: AbstractScene): void;
  71864. /**
  71865. * Removes all the elements in the container from the scene
  71866. * @param container contains the elements to remove
  71867. * @param dispose if the removed element should be disposed (default: false)
  71868. */
  71869. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71870. /**
  71871. * Rebuilds the elements related to this component in case of
  71872. * context lost for instance.
  71873. */
  71874. rebuild(): void;
  71875. /**
  71876. * Disposes the component and the associated ressources
  71877. */
  71878. dispose(): void;
  71879. }
  71880. }
  71881. declare module BABYLON {
  71882. /** @hidden */
  71883. export var outlinePixelShader: {
  71884. name: string;
  71885. shader: string;
  71886. };
  71887. }
  71888. declare module BABYLON {
  71889. /** @hidden */
  71890. export var outlineVertexShader: {
  71891. name: string;
  71892. shader: string;
  71893. };
  71894. }
  71895. declare module BABYLON {
  71896. interface Scene {
  71897. /** @hidden */
  71898. _outlineRenderer: OutlineRenderer;
  71899. /**
  71900. * Gets the outline renderer associated with the scene
  71901. * @returns a OutlineRenderer
  71902. */
  71903. getOutlineRenderer(): OutlineRenderer;
  71904. }
  71905. interface AbstractMesh {
  71906. /** @hidden (Backing field) */
  71907. _renderOutline: boolean;
  71908. /**
  71909. * Gets or sets a boolean indicating if the outline must be rendered as well
  71910. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71911. */
  71912. renderOutline: boolean;
  71913. /** @hidden (Backing field) */
  71914. _renderOverlay: boolean;
  71915. /**
  71916. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71917. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71918. */
  71919. renderOverlay: boolean;
  71920. }
  71921. /**
  71922. * This class is responsible to draw bothe outline/overlay of meshes.
  71923. * It should not be used directly but through the available method on mesh.
  71924. */
  71925. export class OutlineRenderer implements ISceneComponent {
  71926. /**
  71927. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71928. */
  71929. private static _StencilReference;
  71930. /**
  71931. * The name of the component. Each component must have a unique name.
  71932. */
  71933. name: string;
  71934. /**
  71935. * The scene the component belongs to.
  71936. */
  71937. scene: Scene;
  71938. /**
  71939. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71940. */
  71941. zOffset: number;
  71942. private _engine;
  71943. private _effect;
  71944. private _cachedDefines;
  71945. private _savedDepthWrite;
  71946. /**
  71947. * Instantiates a new outline renderer. (There could be only one per scene).
  71948. * @param scene Defines the scene it belongs to
  71949. */
  71950. constructor(scene: Scene);
  71951. /**
  71952. * Register the component to one instance of a scene.
  71953. */
  71954. register(): void;
  71955. /**
  71956. * Rebuilds the elements related to this component in case of
  71957. * context lost for instance.
  71958. */
  71959. rebuild(): void;
  71960. /**
  71961. * Disposes the component and the associated ressources.
  71962. */
  71963. dispose(): void;
  71964. /**
  71965. * Renders the outline in the canvas.
  71966. * @param subMesh Defines the sumesh to render
  71967. * @param batch Defines the batch of meshes in case of instances
  71968. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71969. */
  71970. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71971. /**
  71972. * Returns whether or not the outline renderer is ready for a given submesh.
  71973. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71974. * @param subMesh Defines the submesh to check readyness for
  71975. * @param useInstances Defines wheter wee are trying to render instances or not
  71976. * @returns true if ready otherwise false
  71977. */
  71978. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71979. private _beforeRenderingMesh;
  71980. private _afterRenderingMesh;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /**
  71985. * Defines the basic options interface of a Sprite Frame Source Size.
  71986. */
  71987. export interface ISpriteJSONSpriteSourceSize {
  71988. /**
  71989. * number of the original width of the Frame
  71990. */
  71991. w: number;
  71992. /**
  71993. * number of the original height of the Frame
  71994. */
  71995. h: number;
  71996. }
  71997. /**
  71998. * Defines the basic options interface of a Sprite Frame Data.
  71999. */
  72000. export interface ISpriteJSONSpriteFrameData {
  72001. /**
  72002. * number of the x offset of the Frame
  72003. */
  72004. x: number;
  72005. /**
  72006. * number of the y offset of the Frame
  72007. */
  72008. y: number;
  72009. /**
  72010. * number of the width of the Frame
  72011. */
  72012. w: number;
  72013. /**
  72014. * number of the height of the Frame
  72015. */
  72016. h: number;
  72017. }
  72018. /**
  72019. * Defines the basic options interface of a JSON Sprite.
  72020. */
  72021. export interface ISpriteJSONSprite {
  72022. /**
  72023. * string name of the Frame
  72024. */
  72025. filename: string;
  72026. /**
  72027. * ISpriteJSONSpriteFrame basic object of the frame data
  72028. */
  72029. frame: ISpriteJSONSpriteFrameData;
  72030. /**
  72031. * boolean to flag is the frame was rotated.
  72032. */
  72033. rotated: boolean;
  72034. /**
  72035. * boolean to flag is the frame was trimmed.
  72036. */
  72037. trimmed: boolean;
  72038. /**
  72039. * ISpriteJSONSpriteFrame basic object of the source data
  72040. */
  72041. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72042. /**
  72043. * ISpriteJSONSpriteFrame basic object of the source data
  72044. */
  72045. sourceSize: ISpriteJSONSpriteSourceSize;
  72046. }
  72047. /**
  72048. * Defines the basic options interface of a JSON atlas.
  72049. */
  72050. export interface ISpriteJSONAtlas {
  72051. /**
  72052. * Array of objects that contain the frame data.
  72053. */
  72054. frames: Array<ISpriteJSONSprite>;
  72055. /**
  72056. * object basic object containing the sprite meta data.
  72057. */
  72058. meta?: object;
  72059. }
  72060. }
  72061. declare module BABYLON {
  72062. /** @hidden */
  72063. export var spriteMapPixelShader: {
  72064. name: string;
  72065. shader: string;
  72066. };
  72067. }
  72068. declare module BABYLON {
  72069. /** @hidden */
  72070. export var spriteMapVertexShader: {
  72071. name: string;
  72072. shader: string;
  72073. };
  72074. }
  72075. declare module BABYLON {
  72076. /**
  72077. * Defines the basic options interface of a SpriteMap
  72078. */
  72079. export interface ISpriteMapOptions {
  72080. /**
  72081. * Vector2 of the number of cells in the grid.
  72082. */
  72083. stageSize?: Vector2;
  72084. /**
  72085. * Vector2 of the size of the output plane in World Units.
  72086. */
  72087. outputSize?: Vector2;
  72088. /**
  72089. * Vector3 of the position of the output plane in World Units.
  72090. */
  72091. outputPosition?: Vector3;
  72092. /**
  72093. * Vector3 of the rotation of the output plane.
  72094. */
  72095. outputRotation?: Vector3;
  72096. /**
  72097. * number of layers that the system will reserve in resources.
  72098. */
  72099. layerCount?: number;
  72100. /**
  72101. * number of max animation frames a single cell will reserve in resources.
  72102. */
  72103. maxAnimationFrames?: number;
  72104. /**
  72105. * number cell index of the base tile when the system compiles.
  72106. */
  72107. baseTile?: number;
  72108. /**
  72109. * boolean flip the sprite after its been repositioned by the framing data.
  72110. */
  72111. flipU?: boolean;
  72112. /**
  72113. * Vector3 scalar of the global RGB values of the SpriteMap.
  72114. */
  72115. colorMultiply?: Vector3;
  72116. }
  72117. /**
  72118. * Defines the IDisposable interface in order to be cleanable from resources.
  72119. */
  72120. export interface ISpriteMap extends IDisposable {
  72121. /**
  72122. * String name of the SpriteMap.
  72123. */
  72124. name: string;
  72125. /**
  72126. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72127. */
  72128. atlasJSON: ISpriteJSONAtlas;
  72129. /**
  72130. * Texture of the SpriteMap.
  72131. */
  72132. spriteSheet: Texture;
  72133. /**
  72134. * The parameters to initialize the SpriteMap with.
  72135. */
  72136. options: ISpriteMapOptions;
  72137. }
  72138. /**
  72139. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72140. */
  72141. export class SpriteMap implements ISpriteMap {
  72142. /** The Name of the spriteMap */
  72143. name: string;
  72144. /** The JSON file with the frame and meta data */
  72145. atlasJSON: ISpriteJSONAtlas;
  72146. /** The systems Sprite Sheet Texture */
  72147. spriteSheet: Texture;
  72148. /** Arguments passed with the Constructor */
  72149. options: ISpriteMapOptions;
  72150. /** Public Sprite Storage array, parsed from atlasJSON */
  72151. sprites: Array<ISpriteJSONSprite>;
  72152. /** Returns the Number of Sprites in the System */
  72153. get spriteCount(): number;
  72154. /** Returns the Position of Output Plane*/
  72155. get position(): Vector3;
  72156. /** Returns the Position of Output Plane*/
  72157. set position(v: Vector3);
  72158. /** Returns the Rotation of Output Plane*/
  72159. get rotation(): Vector3;
  72160. /** Returns the Rotation of Output Plane*/
  72161. set rotation(v: Vector3);
  72162. /** Sets the AnimationMap*/
  72163. get animationMap(): RawTexture;
  72164. /** Sets the AnimationMap*/
  72165. set animationMap(v: RawTexture);
  72166. /** Scene that the SpriteMap was created in */
  72167. private _scene;
  72168. /** Texture Buffer of Float32 that holds tile frame data*/
  72169. private _frameMap;
  72170. /** Texture Buffers of Float32 that holds tileMap data*/
  72171. private _tileMaps;
  72172. /** Texture Buffer of Float32 that holds Animation Data*/
  72173. private _animationMap;
  72174. /** Custom ShaderMaterial Central to the System*/
  72175. private _material;
  72176. /** Custom ShaderMaterial Central to the System*/
  72177. private _output;
  72178. /** Systems Time Ticker*/
  72179. private _time;
  72180. /**
  72181. * Creates a new SpriteMap
  72182. * @param name defines the SpriteMaps Name
  72183. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72184. * @param spriteSheet is the Texture that the Sprites are on.
  72185. * @param options a basic deployment configuration
  72186. * @param scene The Scene that the map is deployed on
  72187. */
  72188. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72189. /**
  72190. * Returns tileID location
  72191. * @returns Vector2 the cell position ID
  72192. */
  72193. getTileID(): Vector2;
  72194. /**
  72195. * Gets the UV location of the mouse over the SpriteMap.
  72196. * @returns Vector2 the UV position of the mouse interaction
  72197. */
  72198. getMousePosition(): Vector2;
  72199. /**
  72200. * Creates the "frame" texture Buffer
  72201. * -------------------------------------
  72202. * Structure of frames
  72203. * "filename": "Falling-Water-2.png",
  72204. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72205. * "rotated": true,
  72206. * "trimmed": true,
  72207. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72208. * "sourceSize": {"w":32,"h":32}
  72209. * @returns RawTexture of the frameMap
  72210. */
  72211. private _createFrameBuffer;
  72212. /**
  72213. * Creates the tileMap texture Buffer
  72214. * @param buffer normally and array of numbers, or a false to generate from scratch
  72215. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72216. * @returns RawTexture of the tileMap
  72217. */
  72218. private _createTileBuffer;
  72219. /**
  72220. * Modifies the data of the tileMaps
  72221. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72222. * @param pos is the iVector2 Coordinates of the Tile
  72223. * @param tile The SpriteIndex of the new Tile
  72224. */
  72225. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72226. /**
  72227. * Creates the animationMap texture Buffer
  72228. * @param buffer normally and array of numbers, or a false to generate from scratch
  72229. * @returns RawTexture of the animationMap
  72230. */
  72231. private _createTileAnimationBuffer;
  72232. /**
  72233. * Modifies the data of the animationMap
  72234. * @param cellID is the Index of the Sprite
  72235. * @param _frame is the target Animation frame
  72236. * @param toCell is the Target Index of the next frame of the animation
  72237. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72238. * @param speed is a global scalar of the time variable on the map.
  72239. */
  72240. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72241. /**
  72242. * Exports the .tilemaps file
  72243. */
  72244. saveTileMaps(): void;
  72245. /**
  72246. * Imports the .tilemaps file
  72247. * @param url of the .tilemaps file
  72248. */
  72249. loadTileMaps(url: string): void;
  72250. /**
  72251. * Release associated resources
  72252. */
  72253. dispose(): void;
  72254. }
  72255. }
  72256. declare module BABYLON {
  72257. /**
  72258. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72259. * @see https://doc.babylonjs.com/babylon101/sprites
  72260. */
  72261. export class SpritePackedManager extends SpriteManager {
  72262. /** defines the packed manager's name */
  72263. name: string;
  72264. /**
  72265. * Creates a new sprite manager from a packed sprite sheet
  72266. * @param name defines the manager's name
  72267. * @param imgUrl defines the sprite sheet url
  72268. * @param capacity defines the maximum allowed number of sprites
  72269. * @param scene defines the hosting scene
  72270. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72271. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72272. * @param samplingMode defines the smapling mode to use with spritesheet
  72273. * @param fromPacked set to true; do not alter
  72274. */
  72275. constructor(
  72276. /** defines the packed manager's name */
  72277. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72278. }
  72279. }
  72280. declare module BABYLON {
  72281. /**
  72282. * Defines the list of states available for a task inside a AssetsManager
  72283. */
  72284. export enum AssetTaskState {
  72285. /**
  72286. * Initialization
  72287. */
  72288. INIT = 0,
  72289. /**
  72290. * Running
  72291. */
  72292. RUNNING = 1,
  72293. /**
  72294. * Done
  72295. */
  72296. DONE = 2,
  72297. /**
  72298. * Error
  72299. */
  72300. ERROR = 3
  72301. }
  72302. /**
  72303. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72304. */
  72305. export abstract class AbstractAssetTask {
  72306. /**
  72307. * Task name
  72308. */ name: string;
  72309. /**
  72310. * Callback called when the task is successful
  72311. */
  72312. onSuccess: (task: any) => void;
  72313. /**
  72314. * Callback called when the task is not successful
  72315. */
  72316. onError: (task: any, message?: string, exception?: any) => void;
  72317. /**
  72318. * Creates a new AssetsManager
  72319. * @param name defines the name of the task
  72320. */
  72321. constructor(
  72322. /**
  72323. * Task name
  72324. */ name: string);
  72325. private _isCompleted;
  72326. private _taskState;
  72327. private _errorObject;
  72328. /**
  72329. * Get if the task is completed
  72330. */
  72331. get isCompleted(): boolean;
  72332. /**
  72333. * Gets the current state of the task
  72334. */
  72335. get taskState(): AssetTaskState;
  72336. /**
  72337. * Gets the current error object (if task is in error)
  72338. */
  72339. get errorObject(): {
  72340. message?: string;
  72341. exception?: any;
  72342. };
  72343. /**
  72344. * Internal only
  72345. * @hidden
  72346. */
  72347. _setErrorObject(message?: string, exception?: any): void;
  72348. /**
  72349. * Execute the current task
  72350. * @param scene defines the scene where you want your assets to be loaded
  72351. * @param onSuccess is a callback called when the task is successfully executed
  72352. * @param onError is a callback called if an error occurs
  72353. */
  72354. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72355. /**
  72356. * Execute the current task
  72357. * @param scene defines the scene where you want your assets to be loaded
  72358. * @param onSuccess is a callback called when the task is successfully executed
  72359. * @param onError is a callback called if an error occurs
  72360. */
  72361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72362. /**
  72363. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72364. * This can be used with failed tasks that have the reason for failure fixed.
  72365. */
  72366. reset(): void;
  72367. private onErrorCallback;
  72368. private onDoneCallback;
  72369. }
  72370. /**
  72371. * Define the interface used by progress events raised during assets loading
  72372. */
  72373. export interface IAssetsProgressEvent {
  72374. /**
  72375. * Defines the number of remaining tasks to process
  72376. */
  72377. remainingCount: number;
  72378. /**
  72379. * Defines the total number of tasks
  72380. */
  72381. totalCount: number;
  72382. /**
  72383. * Defines the task that was just processed
  72384. */
  72385. task: AbstractAssetTask;
  72386. }
  72387. /**
  72388. * Class used to share progress information about assets loading
  72389. */
  72390. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72391. /**
  72392. * Defines the number of remaining tasks to process
  72393. */
  72394. remainingCount: number;
  72395. /**
  72396. * Defines the total number of tasks
  72397. */
  72398. totalCount: number;
  72399. /**
  72400. * Defines the task that was just processed
  72401. */
  72402. task: AbstractAssetTask;
  72403. /**
  72404. * Creates a AssetsProgressEvent
  72405. * @param remainingCount defines the number of remaining tasks to process
  72406. * @param totalCount defines the total number of tasks
  72407. * @param task defines the task that was just processed
  72408. */
  72409. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72410. }
  72411. /**
  72412. * Define a task used by AssetsManager to load assets into a container
  72413. */
  72414. export class ContainerAssetTask extends AbstractAssetTask {
  72415. /**
  72416. * Defines the name of the task
  72417. */
  72418. name: string;
  72419. /**
  72420. * Defines the list of mesh's names you want to load
  72421. */
  72422. meshesNames: any;
  72423. /**
  72424. * Defines the root url to use as a base to load your meshes and associated resources
  72425. */
  72426. rootUrl: string;
  72427. /**
  72428. * Defines the filename or File of the scene to load from
  72429. */
  72430. sceneFilename: string | File;
  72431. /**
  72432. * Get the loaded asset container
  72433. */
  72434. loadedContainer: AssetContainer;
  72435. /**
  72436. * Gets the list of loaded meshes
  72437. */
  72438. loadedMeshes: Array<AbstractMesh>;
  72439. /**
  72440. * Gets the list of loaded particle systems
  72441. */
  72442. loadedParticleSystems: Array<IParticleSystem>;
  72443. /**
  72444. * Gets the list of loaded skeletons
  72445. */
  72446. loadedSkeletons: Array<Skeleton>;
  72447. /**
  72448. * Gets the list of loaded animation groups
  72449. */
  72450. loadedAnimationGroups: Array<AnimationGroup>;
  72451. /**
  72452. * Callback called when the task is successful
  72453. */
  72454. onSuccess: (task: ContainerAssetTask) => void;
  72455. /**
  72456. * Callback called when the task is successful
  72457. */
  72458. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72459. /**
  72460. * Creates a new ContainerAssetTask
  72461. * @param name defines the name of the task
  72462. * @param meshesNames defines the list of mesh's names you want to load
  72463. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72464. * @param sceneFilename defines the filename or File of the scene to load from
  72465. */
  72466. constructor(
  72467. /**
  72468. * Defines the name of the task
  72469. */
  72470. name: string,
  72471. /**
  72472. * Defines the list of mesh's names you want to load
  72473. */
  72474. meshesNames: any,
  72475. /**
  72476. * Defines the root url to use as a base to load your meshes and associated resources
  72477. */
  72478. rootUrl: string,
  72479. /**
  72480. * Defines the filename or File of the scene to load from
  72481. */
  72482. sceneFilename: string | File);
  72483. /**
  72484. * Execute the current task
  72485. * @param scene defines the scene where you want your assets to be loaded
  72486. * @param onSuccess is a callback called when the task is successfully executed
  72487. * @param onError is a callback called if an error occurs
  72488. */
  72489. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72490. }
  72491. /**
  72492. * Define a task used by AssetsManager to load meshes
  72493. */
  72494. export class MeshAssetTask extends AbstractAssetTask {
  72495. /**
  72496. * Defines the name of the task
  72497. */
  72498. name: string;
  72499. /**
  72500. * Defines the list of mesh's names you want to load
  72501. */
  72502. meshesNames: any;
  72503. /**
  72504. * Defines the root url to use as a base to load your meshes and associated resources
  72505. */
  72506. rootUrl: string;
  72507. /**
  72508. * Defines the filename or File of the scene to load from
  72509. */
  72510. sceneFilename: string | File;
  72511. /**
  72512. * Gets the list of loaded meshes
  72513. */
  72514. loadedMeshes: Array<AbstractMesh>;
  72515. /**
  72516. * Gets the list of loaded particle systems
  72517. */
  72518. loadedParticleSystems: Array<IParticleSystem>;
  72519. /**
  72520. * Gets the list of loaded skeletons
  72521. */
  72522. loadedSkeletons: Array<Skeleton>;
  72523. /**
  72524. * Gets the list of loaded animation groups
  72525. */
  72526. loadedAnimationGroups: Array<AnimationGroup>;
  72527. /**
  72528. * Callback called when the task is successful
  72529. */
  72530. onSuccess: (task: MeshAssetTask) => void;
  72531. /**
  72532. * Callback called when the task is successful
  72533. */
  72534. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72535. /**
  72536. * Creates a new MeshAssetTask
  72537. * @param name defines the name of the task
  72538. * @param meshesNames defines the list of mesh's names you want to load
  72539. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72540. * @param sceneFilename defines the filename or File of the scene to load from
  72541. */
  72542. constructor(
  72543. /**
  72544. * Defines the name of the task
  72545. */
  72546. name: string,
  72547. /**
  72548. * Defines the list of mesh's names you want to load
  72549. */
  72550. meshesNames: any,
  72551. /**
  72552. * Defines the root url to use as a base to load your meshes and associated resources
  72553. */
  72554. rootUrl: string,
  72555. /**
  72556. * Defines the filename or File of the scene to load from
  72557. */
  72558. sceneFilename: string | File);
  72559. /**
  72560. * Execute the current task
  72561. * @param scene defines the scene where you want your assets to be loaded
  72562. * @param onSuccess is a callback called when the task is successfully executed
  72563. * @param onError is a callback called if an error occurs
  72564. */
  72565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72566. }
  72567. /**
  72568. * Define a task used by AssetsManager to load text content
  72569. */
  72570. export class TextFileAssetTask extends AbstractAssetTask {
  72571. /**
  72572. * Defines the name of the task
  72573. */
  72574. name: string;
  72575. /**
  72576. * Defines the location of the file to load
  72577. */
  72578. url: string;
  72579. /**
  72580. * Gets the loaded text string
  72581. */
  72582. text: string;
  72583. /**
  72584. * Callback called when the task is successful
  72585. */
  72586. onSuccess: (task: TextFileAssetTask) => void;
  72587. /**
  72588. * Callback called when the task is successful
  72589. */
  72590. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72591. /**
  72592. * Creates a new TextFileAssetTask object
  72593. * @param name defines the name of the task
  72594. * @param url defines the location of the file to load
  72595. */
  72596. constructor(
  72597. /**
  72598. * Defines the name of the task
  72599. */
  72600. name: string,
  72601. /**
  72602. * Defines the location of the file to load
  72603. */
  72604. url: string);
  72605. /**
  72606. * Execute the current task
  72607. * @param scene defines the scene where you want your assets to be loaded
  72608. * @param onSuccess is a callback called when the task is successfully executed
  72609. * @param onError is a callback called if an error occurs
  72610. */
  72611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72612. }
  72613. /**
  72614. * Define a task used by AssetsManager to load binary data
  72615. */
  72616. export class BinaryFileAssetTask extends AbstractAssetTask {
  72617. /**
  72618. * Defines the name of the task
  72619. */
  72620. name: string;
  72621. /**
  72622. * Defines the location of the file to load
  72623. */
  72624. url: string;
  72625. /**
  72626. * Gets the lodaded data (as an array buffer)
  72627. */
  72628. data: ArrayBuffer;
  72629. /**
  72630. * Callback called when the task is successful
  72631. */
  72632. onSuccess: (task: BinaryFileAssetTask) => void;
  72633. /**
  72634. * Callback called when the task is successful
  72635. */
  72636. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72637. /**
  72638. * Creates a new BinaryFileAssetTask object
  72639. * @param name defines the name of the new task
  72640. * @param url defines the location of the file to load
  72641. */
  72642. constructor(
  72643. /**
  72644. * Defines the name of the task
  72645. */
  72646. name: string,
  72647. /**
  72648. * Defines the location of the file to load
  72649. */
  72650. url: string);
  72651. /**
  72652. * Execute the current task
  72653. * @param scene defines the scene where you want your assets to be loaded
  72654. * @param onSuccess is a callback called when the task is successfully executed
  72655. * @param onError is a callback called if an error occurs
  72656. */
  72657. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72658. }
  72659. /**
  72660. * Define a task used by AssetsManager to load images
  72661. */
  72662. export class ImageAssetTask extends AbstractAssetTask {
  72663. /**
  72664. * Defines the name of the task
  72665. */
  72666. name: string;
  72667. /**
  72668. * Defines the location of the image to load
  72669. */
  72670. url: string;
  72671. /**
  72672. * Gets the loaded images
  72673. */
  72674. image: HTMLImageElement;
  72675. /**
  72676. * Callback called when the task is successful
  72677. */
  72678. onSuccess: (task: ImageAssetTask) => void;
  72679. /**
  72680. * Callback called when the task is successful
  72681. */
  72682. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72683. /**
  72684. * Creates a new ImageAssetTask
  72685. * @param name defines the name of the task
  72686. * @param url defines the location of the image to load
  72687. */
  72688. constructor(
  72689. /**
  72690. * Defines the name of the task
  72691. */
  72692. name: string,
  72693. /**
  72694. * Defines the location of the image to load
  72695. */
  72696. url: string);
  72697. /**
  72698. * Execute the current task
  72699. * @param scene defines the scene where you want your assets to be loaded
  72700. * @param onSuccess is a callback called when the task is successfully executed
  72701. * @param onError is a callback called if an error occurs
  72702. */
  72703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72704. }
  72705. /**
  72706. * Defines the interface used by texture loading tasks
  72707. */
  72708. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72709. /**
  72710. * Gets the loaded texture
  72711. */
  72712. texture: TEX;
  72713. }
  72714. /**
  72715. * Define a task used by AssetsManager to load 2D textures
  72716. */
  72717. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72718. /**
  72719. * Defines the name of the task
  72720. */
  72721. name: string;
  72722. /**
  72723. * Defines the location of the file to load
  72724. */
  72725. url: string;
  72726. /**
  72727. * Defines if mipmap should not be generated (default is false)
  72728. */
  72729. noMipmap?: boolean | undefined;
  72730. /**
  72731. * Defines if texture must be inverted on Y axis (default is true)
  72732. */
  72733. invertY: boolean;
  72734. /**
  72735. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72736. */
  72737. samplingMode: number;
  72738. /**
  72739. * Gets the loaded texture
  72740. */
  72741. texture: Texture;
  72742. /**
  72743. * Callback called when the task is successful
  72744. */
  72745. onSuccess: (task: TextureAssetTask) => void;
  72746. /**
  72747. * Callback called when the task is successful
  72748. */
  72749. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72750. /**
  72751. * Creates a new TextureAssetTask object
  72752. * @param name defines the name of the task
  72753. * @param url defines the location of the file to load
  72754. * @param noMipmap defines if mipmap should not be generated (default is false)
  72755. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72756. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72757. */
  72758. constructor(
  72759. /**
  72760. * Defines the name of the task
  72761. */
  72762. name: string,
  72763. /**
  72764. * Defines the location of the file to load
  72765. */
  72766. url: string,
  72767. /**
  72768. * Defines if mipmap should not be generated (default is false)
  72769. */
  72770. noMipmap?: boolean | undefined,
  72771. /**
  72772. * Defines if texture must be inverted on Y axis (default is true)
  72773. */
  72774. invertY?: boolean,
  72775. /**
  72776. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72777. */
  72778. samplingMode?: number);
  72779. /**
  72780. * Execute the current task
  72781. * @param scene defines the scene where you want your assets to be loaded
  72782. * @param onSuccess is a callback called when the task is successfully executed
  72783. * @param onError is a callback called if an error occurs
  72784. */
  72785. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72786. }
  72787. /**
  72788. * Define a task used by AssetsManager to load cube textures
  72789. */
  72790. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72791. /**
  72792. * Defines the name of the task
  72793. */
  72794. name: string;
  72795. /**
  72796. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72797. */
  72798. url: string;
  72799. /**
  72800. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72801. */
  72802. extensions?: string[] | undefined;
  72803. /**
  72804. * Defines if mipmaps should not be generated (default is false)
  72805. */
  72806. noMipmap?: boolean | undefined;
  72807. /**
  72808. * Defines the explicit list of files (undefined by default)
  72809. */
  72810. files?: string[] | undefined;
  72811. /**
  72812. * Gets the loaded texture
  72813. */
  72814. texture: CubeTexture;
  72815. /**
  72816. * Callback called when the task is successful
  72817. */
  72818. onSuccess: (task: CubeTextureAssetTask) => void;
  72819. /**
  72820. * Callback called when the task is successful
  72821. */
  72822. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72823. /**
  72824. * Creates a new CubeTextureAssetTask
  72825. * @param name defines the name of the task
  72826. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72827. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72828. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72829. * @param files defines the explicit list of files (undefined by default)
  72830. */
  72831. constructor(
  72832. /**
  72833. * Defines the name of the task
  72834. */
  72835. name: string,
  72836. /**
  72837. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72838. */
  72839. url: string,
  72840. /**
  72841. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72842. */
  72843. extensions?: string[] | undefined,
  72844. /**
  72845. * Defines if mipmaps should not be generated (default is false)
  72846. */
  72847. noMipmap?: boolean | undefined,
  72848. /**
  72849. * Defines the explicit list of files (undefined by default)
  72850. */
  72851. files?: string[] | undefined);
  72852. /**
  72853. * Execute the current task
  72854. * @param scene defines the scene where you want your assets to be loaded
  72855. * @param onSuccess is a callback called when the task is successfully executed
  72856. * @param onError is a callback called if an error occurs
  72857. */
  72858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72859. }
  72860. /**
  72861. * Define a task used by AssetsManager to load HDR cube textures
  72862. */
  72863. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72864. /**
  72865. * Defines the name of the task
  72866. */
  72867. name: string;
  72868. /**
  72869. * Defines the location of the file to load
  72870. */
  72871. url: string;
  72872. /**
  72873. * Defines the desired size (the more it increases the longer the generation will be)
  72874. */
  72875. size: number;
  72876. /**
  72877. * Defines if mipmaps should not be generated (default is false)
  72878. */
  72879. noMipmap: boolean;
  72880. /**
  72881. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72882. */
  72883. generateHarmonics: boolean;
  72884. /**
  72885. * 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)
  72886. */
  72887. gammaSpace: boolean;
  72888. /**
  72889. * Internal Use Only
  72890. */
  72891. reserved: boolean;
  72892. /**
  72893. * Gets the loaded texture
  72894. */
  72895. texture: HDRCubeTexture;
  72896. /**
  72897. * Callback called when the task is successful
  72898. */
  72899. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72900. /**
  72901. * Callback called when the task is successful
  72902. */
  72903. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72904. /**
  72905. * Creates a new HDRCubeTextureAssetTask object
  72906. * @param name defines the name of the task
  72907. * @param url defines the location of the file to load
  72908. * @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.
  72909. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72910. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72911. * @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)
  72912. * @param reserved Internal use only
  72913. */
  72914. constructor(
  72915. /**
  72916. * Defines the name of the task
  72917. */
  72918. name: string,
  72919. /**
  72920. * Defines the location of the file to load
  72921. */
  72922. url: string,
  72923. /**
  72924. * Defines the desired size (the more it increases the longer the generation will be)
  72925. */
  72926. size: number,
  72927. /**
  72928. * Defines if mipmaps should not be generated (default is false)
  72929. */
  72930. noMipmap?: boolean,
  72931. /**
  72932. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72933. */
  72934. generateHarmonics?: boolean,
  72935. /**
  72936. * 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)
  72937. */
  72938. gammaSpace?: boolean,
  72939. /**
  72940. * Internal Use Only
  72941. */
  72942. reserved?: boolean);
  72943. /**
  72944. * Execute the current task
  72945. * @param scene defines the scene where you want your assets to be loaded
  72946. * @param onSuccess is a callback called when the task is successfully executed
  72947. * @param onError is a callback called if an error occurs
  72948. */
  72949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72950. }
  72951. /**
  72952. * Define a task used by AssetsManager to load Equirectangular cube textures
  72953. */
  72954. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72955. /**
  72956. * Defines the name of the task
  72957. */
  72958. name: string;
  72959. /**
  72960. * Defines the location of the file to load
  72961. */
  72962. url: string;
  72963. /**
  72964. * Defines the desired size (the more it increases the longer the generation will be)
  72965. */
  72966. size: number;
  72967. /**
  72968. * Defines if mipmaps should not be generated (default is false)
  72969. */
  72970. noMipmap: boolean;
  72971. /**
  72972. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72973. * but the standard material would require them in Gamma space) (default is true)
  72974. */
  72975. gammaSpace: boolean;
  72976. /**
  72977. * Gets the loaded texture
  72978. */
  72979. texture: EquiRectangularCubeTexture;
  72980. /**
  72981. * Callback called when the task is successful
  72982. */
  72983. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72984. /**
  72985. * Callback called when the task is successful
  72986. */
  72987. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72988. /**
  72989. * Creates a new EquiRectangularCubeTextureAssetTask object
  72990. * @param name defines the name of the task
  72991. * @param url defines the location of the file to load
  72992. * @param size defines the desired size (the more it increases the longer the generation will be)
  72993. * If the size is omitted this implies you are using a preprocessed cubemap.
  72994. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72995. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72996. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72997. * (default is true)
  72998. */
  72999. constructor(
  73000. /**
  73001. * Defines the name of the task
  73002. */
  73003. name: string,
  73004. /**
  73005. * Defines the location of the file to load
  73006. */
  73007. url: string,
  73008. /**
  73009. * Defines the desired size (the more it increases the longer the generation will be)
  73010. */
  73011. size: number,
  73012. /**
  73013. * Defines if mipmaps should not be generated (default is false)
  73014. */
  73015. noMipmap?: boolean,
  73016. /**
  73017. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73018. * but the standard material would require them in Gamma space) (default is true)
  73019. */
  73020. gammaSpace?: boolean);
  73021. /**
  73022. * Execute the current task
  73023. * @param scene defines the scene where you want your assets to be loaded
  73024. * @param onSuccess is a callback called when the task is successfully executed
  73025. * @param onError is a callback called if an error occurs
  73026. */
  73027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73028. }
  73029. /**
  73030. * This class can be used to easily import assets into a scene
  73031. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73032. */
  73033. export class AssetsManager {
  73034. private _scene;
  73035. private _isLoading;
  73036. protected _tasks: AbstractAssetTask[];
  73037. protected _waitingTasksCount: number;
  73038. protected _totalTasksCount: number;
  73039. /**
  73040. * Callback called when all tasks are processed
  73041. */
  73042. onFinish: (tasks: AbstractAssetTask[]) => void;
  73043. /**
  73044. * Callback called when a task is successful
  73045. */
  73046. onTaskSuccess: (task: AbstractAssetTask) => void;
  73047. /**
  73048. * Callback called when a task had an error
  73049. */
  73050. onTaskError: (task: AbstractAssetTask) => void;
  73051. /**
  73052. * Callback called when a task is done (whatever the result is)
  73053. */
  73054. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73055. /**
  73056. * Observable called when all tasks are processed
  73057. */
  73058. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73059. /**
  73060. * Observable called when a task had an error
  73061. */
  73062. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73063. /**
  73064. * Observable called when all tasks were executed
  73065. */
  73066. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73067. /**
  73068. * Observable called when a task is done (whatever the result is)
  73069. */
  73070. onProgressObservable: Observable<IAssetsProgressEvent>;
  73071. /**
  73072. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73073. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73074. */
  73075. useDefaultLoadingScreen: boolean;
  73076. /**
  73077. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73078. * when all assets have been downloaded.
  73079. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73080. */
  73081. autoHideLoadingUI: boolean;
  73082. /**
  73083. * Creates a new AssetsManager
  73084. * @param scene defines the scene to work on
  73085. */
  73086. constructor(scene: Scene);
  73087. /**
  73088. * Add a ContainerAssetTask to the list of active tasks
  73089. * @param taskName defines the name of the new task
  73090. * @param meshesNames defines the name of meshes to load
  73091. * @param rootUrl defines the root url to use to locate files
  73092. * @param sceneFilename defines the filename of the scene file
  73093. * @returns a new ContainerAssetTask object
  73094. */
  73095. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73096. /**
  73097. * Add a MeshAssetTask to the list of active tasks
  73098. * @param taskName defines the name of the new task
  73099. * @param meshesNames defines the name of meshes to load
  73100. * @param rootUrl defines the root url to use to locate files
  73101. * @param sceneFilename defines the filename of the scene file
  73102. * @returns a new MeshAssetTask object
  73103. */
  73104. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73105. /**
  73106. * Add a TextFileAssetTask to the list of active tasks
  73107. * @param taskName defines the name of the new task
  73108. * @param url defines the url of the file to load
  73109. * @returns a new TextFileAssetTask object
  73110. */
  73111. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73112. /**
  73113. * Add a BinaryFileAssetTask to the list of active tasks
  73114. * @param taskName defines the name of the new task
  73115. * @param url defines the url of the file to load
  73116. * @returns a new BinaryFileAssetTask object
  73117. */
  73118. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73119. /**
  73120. * Add a ImageAssetTask to the list of active tasks
  73121. * @param taskName defines the name of the new task
  73122. * @param url defines the url of the file to load
  73123. * @returns a new ImageAssetTask object
  73124. */
  73125. addImageTask(taskName: string, url: string): ImageAssetTask;
  73126. /**
  73127. * Add a TextureAssetTask to the list of active tasks
  73128. * @param taskName defines the name of the new task
  73129. * @param url defines the url of the file to load
  73130. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73131. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73132. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73133. * @returns a new TextureAssetTask object
  73134. */
  73135. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73136. /**
  73137. * Add a CubeTextureAssetTask to the list of active tasks
  73138. * @param taskName defines the name of the new task
  73139. * @param url defines the url of the file to load
  73140. * @param extensions defines the extension to use to load the cube map (can be null)
  73141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73142. * @param files defines the list of files to load (can be null)
  73143. * @returns a new CubeTextureAssetTask object
  73144. */
  73145. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73146. /**
  73147. *
  73148. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73149. * @param taskName defines the name of the new task
  73150. * @param url defines the url of the file to load
  73151. * @param size defines the size you want for the cubemap (can be null)
  73152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73153. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73154. * @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)
  73155. * @param reserved Internal use only
  73156. * @returns a new HDRCubeTextureAssetTask object
  73157. */
  73158. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73159. /**
  73160. *
  73161. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73162. * @param taskName defines the name of the new task
  73163. * @param url defines the url of the file to load
  73164. * @param size defines the size you want for the cubemap (can be null)
  73165. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73166. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73167. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73168. * @returns a new EquiRectangularCubeTextureAssetTask object
  73169. */
  73170. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73171. /**
  73172. * Remove a task from the assets manager.
  73173. * @param task the task to remove
  73174. */
  73175. removeTask(task: AbstractAssetTask): void;
  73176. private _decreaseWaitingTasksCount;
  73177. private _runTask;
  73178. /**
  73179. * Reset the AssetsManager and remove all tasks
  73180. * @return the current instance of the AssetsManager
  73181. */
  73182. reset(): AssetsManager;
  73183. /**
  73184. * Start the loading process
  73185. * @return the current instance of the AssetsManager
  73186. */
  73187. load(): AssetsManager;
  73188. /**
  73189. * Start the loading process as an async operation
  73190. * @return a promise returning the list of failed tasks
  73191. */
  73192. loadAsync(): Promise<void>;
  73193. }
  73194. }
  73195. declare module BABYLON {
  73196. /**
  73197. * Wrapper class for promise with external resolve and reject.
  73198. */
  73199. export class Deferred<T> {
  73200. /**
  73201. * The promise associated with this deferred object.
  73202. */
  73203. readonly promise: Promise<T>;
  73204. private _resolve;
  73205. private _reject;
  73206. /**
  73207. * The resolve method of the promise associated with this deferred object.
  73208. */
  73209. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73210. /**
  73211. * The reject method of the promise associated with this deferred object.
  73212. */
  73213. get reject(): (reason?: any) => void;
  73214. /**
  73215. * Constructor for this deferred object.
  73216. */
  73217. constructor();
  73218. }
  73219. }
  73220. declare module BABYLON {
  73221. /**
  73222. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73223. */
  73224. export class MeshExploder {
  73225. private _centerMesh;
  73226. private _meshes;
  73227. private _meshesOrigins;
  73228. private _toCenterVectors;
  73229. private _scaledDirection;
  73230. private _newPosition;
  73231. private _centerPosition;
  73232. /**
  73233. * Explodes meshes from a center mesh.
  73234. * @param meshes The meshes to explode.
  73235. * @param centerMesh The mesh to be center of explosion.
  73236. */
  73237. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73238. private _setCenterMesh;
  73239. /**
  73240. * Get class name
  73241. * @returns "MeshExploder"
  73242. */
  73243. getClassName(): string;
  73244. /**
  73245. * "Exploded meshes"
  73246. * @returns Array of meshes with the centerMesh at index 0.
  73247. */
  73248. getMeshes(): Array<Mesh>;
  73249. /**
  73250. * Explodes meshes giving a specific direction
  73251. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73252. */
  73253. explode(direction?: number): void;
  73254. }
  73255. }
  73256. declare module BABYLON {
  73257. /**
  73258. * Class used to help managing file picking and drag'n'drop
  73259. */
  73260. export class FilesInput {
  73261. /**
  73262. * List of files ready to be loaded
  73263. */
  73264. static get FilesToLoad(): {
  73265. [key: string]: File;
  73266. };
  73267. /**
  73268. * Callback called when a file is processed
  73269. */
  73270. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73271. private _engine;
  73272. private _currentScene;
  73273. private _sceneLoadedCallback;
  73274. private _progressCallback;
  73275. private _additionalRenderLoopLogicCallback;
  73276. private _textureLoadingCallback;
  73277. private _startingProcessingFilesCallback;
  73278. private _onReloadCallback;
  73279. private _errorCallback;
  73280. private _elementToMonitor;
  73281. private _sceneFileToLoad;
  73282. private _filesToLoad;
  73283. /**
  73284. * Creates a new FilesInput
  73285. * @param engine defines the rendering engine
  73286. * @param scene defines the hosting scene
  73287. * @param sceneLoadedCallback callback called when scene is loaded
  73288. * @param progressCallback callback called to track progress
  73289. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73290. * @param textureLoadingCallback callback called when a texture is loading
  73291. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73292. * @param onReloadCallback callback called when a reload is requested
  73293. * @param errorCallback callback call if an error occurs
  73294. */
  73295. 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>);
  73296. private _dragEnterHandler;
  73297. private _dragOverHandler;
  73298. private _dropHandler;
  73299. /**
  73300. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73301. * @param elementToMonitor defines the DOM element to track
  73302. */
  73303. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73304. /** Gets the current list of files to load */
  73305. get filesToLoad(): File[];
  73306. /**
  73307. * Release all associated resources
  73308. */
  73309. dispose(): void;
  73310. private renderFunction;
  73311. private drag;
  73312. private drop;
  73313. private _traverseFolder;
  73314. private _processFiles;
  73315. /**
  73316. * Load files from a drop event
  73317. * @param event defines the drop event to use as source
  73318. */
  73319. loadFiles(event: any): void;
  73320. private _processReload;
  73321. /**
  73322. * Reload the current scene from the loaded files
  73323. */
  73324. reload(): void;
  73325. }
  73326. }
  73327. declare module BABYLON {
  73328. /**
  73329. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73330. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73331. */
  73332. export class SceneOptimization {
  73333. /**
  73334. * Defines the priority of this optimization (0 by default which means first in the list)
  73335. */
  73336. priority: number;
  73337. /**
  73338. * Gets a string describing the action executed by the current optimization
  73339. * @returns description string
  73340. */
  73341. getDescription(): string;
  73342. /**
  73343. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73344. * @param scene defines the current scene where to apply this optimization
  73345. * @param optimizer defines the current optimizer
  73346. * @returns true if everything that can be done was applied
  73347. */
  73348. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73349. /**
  73350. * Creates the SceneOptimization object
  73351. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73352. * @param desc defines the description associated with the optimization
  73353. */
  73354. constructor(
  73355. /**
  73356. * Defines the priority of this optimization (0 by default which means first in the list)
  73357. */
  73358. priority?: number);
  73359. }
  73360. /**
  73361. * Defines an optimization used to reduce the size of render target textures
  73362. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73363. */
  73364. export class TextureOptimization extends SceneOptimization {
  73365. /**
  73366. * Defines the priority of this optimization (0 by default which means first in the list)
  73367. */
  73368. priority: number;
  73369. /**
  73370. * 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
  73371. */
  73372. maximumSize: number;
  73373. /**
  73374. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73375. */
  73376. step: number;
  73377. /**
  73378. * Gets a string describing the action executed by the current optimization
  73379. * @returns description string
  73380. */
  73381. getDescription(): string;
  73382. /**
  73383. * Creates the TextureOptimization object
  73384. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73385. * @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
  73386. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73387. */
  73388. constructor(
  73389. /**
  73390. * Defines the priority of this optimization (0 by default which means first in the list)
  73391. */
  73392. priority?: number,
  73393. /**
  73394. * 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
  73395. */
  73396. maximumSize?: number,
  73397. /**
  73398. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73399. */
  73400. step?: number);
  73401. /**
  73402. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73403. * @param scene defines the current scene where to apply this optimization
  73404. * @param optimizer defines the current optimizer
  73405. * @returns true if everything that can be done was applied
  73406. */
  73407. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73408. }
  73409. /**
  73410. * Defines an optimization used to increase or decrease the rendering resolution
  73411. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73412. */
  73413. export class HardwareScalingOptimization extends SceneOptimization {
  73414. /**
  73415. * Defines the priority of this optimization (0 by default which means first in the list)
  73416. */
  73417. priority: number;
  73418. /**
  73419. * Defines the maximum scale to use (2 by default)
  73420. */
  73421. maximumScale: number;
  73422. /**
  73423. * Defines the step to use between two passes (0.5 by default)
  73424. */
  73425. step: number;
  73426. private _currentScale;
  73427. private _directionOffset;
  73428. /**
  73429. * Gets a string describing the action executed by the current optimization
  73430. * @return description string
  73431. */
  73432. getDescription(): string;
  73433. /**
  73434. * Creates the HardwareScalingOptimization object
  73435. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73436. * @param maximumScale defines the maximum scale to use (2 by default)
  73437. * @param step defines the step to use between two passes (0.5 by default)
  73438. */
  73439. constructor(
  73440. /**
  73441. * Defines the priority of this optimization (0 by default which means first in the list)
  73442. */
  73443. priority?: number,
  73444. /**
  73445. * Defines the maximum scale to use (2 by default)
  73446. */
  73447. maximumScale?: number,
  73448. /**
  73449. * Defines the step to use between two passes (0.5 by default)
  73450. */
  73451. step?: number);
  73452. /**
  73453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73454. * @param scene defines the current scene where to apply this optimization
  73455. * @param optimizer defines the current optimizer
  73456. * @returns true if everything that can be done was applied
  73457. */
  73458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73459. }
  73460. /**
  73461. * Defines an optimization used to remove shadows
  73462. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73463. */
  73464. export class ShadowsOptimization extends SceneOptimization {
  73465. /**
  73466. * Gets a string describing the action executed by the current optimization
  73467. * @return description string
  73468. */
  73469. getDescription(): string;
  73470. /**
  73471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73472. * @param scene defines the current scene where to apply this optimization
  73473. * @param optimizer defines the current optimizer
  73474. * @returns true if everything that can be done was applied
  73475. */
  73476. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73477. }
  73478. /**
  73479. * Defines an optimization used to turn post-processes off
  73480. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73481. */
  73482. export class PostProcessesOptimization extends SceneOptimization {
  73483. /**
  73484. * Gets a string describing the action executed by the current optimization
  73485. * @return description string
  73486. */
  73487. getDescription(): string;
  73488. /**
  73489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73490. * @param scene defines the current scene where to apply this optimization
  73491. * @param optimizer defines the current optimizer
  73492. * @returns true if everything that can be done was applied
  73493. */
  73494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73495. }
  73496. /**
  73497. * Defines an optimization used to turn lens flares off
  73498. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73499. */
  73500. export class LensFlaresOptimization extends SceneOptimization {
  73501. /**
  73502. * Gets a string describing the action executed by the current optimization
  73503. * @return description string
  73504. */
  73505. getDescription(): string;
  73506. /**
  73507. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73508. * @param scene defines the current scene where to apply this optimization
  73509. * @param optimizer defines the current optimizer
  73510. * @returns true if everything that can be done was applied
  73511. */
  73512. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73513. }
  73514. /**
  73515. * Defines an optimization based on user defined callback.
  73516. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73517. */
  73518. export class CustomOptimization extends SceneOptimization {
  73519. /**
  73520. * Callback called to apply the custom optimization.
  73521. */
  73522. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73523. /**
  73524. * Callback called to get custom description
  73525. */
  73526. onGetDescription: () => string;
  73527. /**
  73528. * Gets a string describing the action executed by the current optimization
  73529. * @returns description string
  73530. */
  73531. getDescription(): string;
  73532. /**
  73533. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73534. * @param scene defines the current scene where to apply this optimization
  73535. * @param optimizer defines the current optimizer
  73536. * @returns true if everything that can be done was applied
  73537. */
  73538. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73539. }
  73540. /**
  73541. * Defines an optimization used to turn particles off
  73542. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73543. */
  73544. export class ParticlesOptimization extends SceneOptimization {
  73545. /**
  73546. * Gets a string describing the action executed by the current optimization
  73547. * @return description string
  73548. */
  73549. getDescription(): string;
  73550. /**
  73551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73552. * @param scene defines the current scene where to apply this optimization
  73553. * @param optimizer defines the current optimizer
  73554. * @returns true if everything that can be done was applied
  73555. */
  73556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73557. }
  73558. /**
  73559. * Defines an optimization used to turn render targets off
  73560. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73561. */
  73562. export class RenderTargetsOptimization extends SceneOptimization {
  73563. /**
  73564. * Gets a string describing the action executed by the current optimization
  73565. * @return description string
  73566. */
  73567. getDescription(): string;
  73568. /**
  73569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73570. * @param scene defines the current scene where to apply this optimization
  73571. * @param optimizer defines the current optimizer
  73572. * @returns true if everything that can be done was applied
  73573. */
  73574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73575. }
  73576. /**
  73577. * Defines an optimization used to merge meshes with compatible materials
  73578. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73579. */
  73580. export class MergeMeshesOptimization extends SceneOptimization {
  73581. private static _UpdateSelectionTree;
  73582. /**
  73583. * Gets or sets a boolean which defines if optimization octree has to be updated
  73584. */
  73585. static get UpdateSelectionTree(): boolean;
  73586. /**
  73587. * Gets or sets a boolean which defines if optimization octree has to be updated
  73588. */
  73589. static set UpdateSelectionTree(value: boolean);
  73590. /**
  73591. * Gets a string describing the action executed by the current optimization
  73592. * @return description string
  73593. */
  73594. getDescription(): string;
  73595. private _canBeMerged;
  73596. /**
  73597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73598. * @param scene defines the current scene where to apply this optimization
  73599. * @param optimizer defines the current optimizer
  73600. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73601. * @returns true if everything that can be done was applied
  73602. */
  73603. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73604. }
  73605. /**
  73606. * Defines a list of options used by SceneOptimizer
  73607. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73608. */
  73609. export class SceneOptimizerOptions {
  73610. /**
  73611. * Defines the target frame rate to reach (60 by default)
  73612. */
  73613. targetFrameRate: number;
  73614. /**
  73615. * Defines the interval between two checkes (2000ms by default)
  73616. */
  73617. trackerDuration: number;
  73618. /**
  73619. * Gets the list of optimizations to apply
  73620. */
  73621. optimizations: SceneOptimization[];
  73622. /**
  73623. * Creates a new list of options used by SceneOptimizer
  73624. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73625. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73626. */
  73627. constructor(
  73628. /**
  73629. * Defines the target frame rate to reach (60 by default)
  73630. */
  73631. targetFrameRate?: number,
  73632. /**
  73633. * Defines the interval between two checkes (2000ms by default)
  73634. */
  73635. trackerDuration?: number);
  73636. /**
  73637. * Add a new optimization
  73638. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73639. * @returns the current SceneOptimizerOptions
  73640. */
  73641. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73642. /**
  73643. * Add a new custom optimization
  73644. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73645. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73646. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73647. * @returns the current SceneOptimizerOptions
  73648. */
  73649. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73650. /**
  73651. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73652. * @param targetFrameRate defines the target frame rate (60 by default)
  73653. * @returns a SceneOptimizerOptions object
  73654. */
  73655. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73656. /**
  73657. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73658. * @param targetFrameRate defines the target frame rate (60 by default)
  73659. * @returns a SceneOptimizerOptions object
  73660. */
  73661. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73662. /**
  73663. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73664. * @param targetFrameRate defines the target frame rate (60 by default)
  73665. * @returns a SceneOptimizerOptions object
  73666. */
  73667. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73668. }
  73669. /**
  73670. * Class used to run optimizations in order to reach a target frame rate
  73671. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73672. */
  73673. export class SceneOptimizer implements IDisposable {
  73674. private _isRunning;
  73675. private _options;
  73676. private _scene;
  73677. private _currentPriorityLevel;
  73678. private _targetFrameRate;
  73679. private _trackerDuration;
  73680. private _currentFrameRate;
  73681. private _sceneDisposeObserver;
  73682. private _improvementMode;
  73683. /**
  73684. * Defines an observable called when the optimizer reaches the target frame rate
  73685. */
  73686. onSuccessObservable: Observable<SceneOptimizer>;
  73687. /**
  73688. * Defines an observable called when the optimizer enables an optimization
  73689. */
  73690. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73691. /**
  73692. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73693. */
  73694. onFailureObservable: Observable<SceneOptimizer>;
  73695. /**
  73696. * Gets a boolean indicating if the optimizer is in improvement mode
  73697. */
  73698. get isInImprovementMode(): boolean;
  73699. /**
  73700. * Gets the current priority level (0 at start)
  73701. */
  73702. get currentPriorityLevel(): number;
  73703. /**
  73704. * Gets the current frame rate checked by the SceneOptimizer
  73705. */
  73706. get currentFrameRate(): number;
  73707. /**
  73708. * Gets or sets the current target frame rate (60 by default)
  73709. */
  73710. get targetFrameRate(): number;
  73711. /**
  73712. * Gets or sets the current target frame rate (60 by default)
  73713. */
  73714. set targetFrameRate(value: number);
  73715. /**
  73716. * Gets or sets the current interval between two checks (every 2000ms by default)
  73717. */
  73718. get trackerDuration(): number;
  73719. /**
  73720. * Gets or sets the current interval between two checks (every 2000ms by default)
  73721. */
  73722. set trackerDuration(value: number);
  73723. /**
  73724. * Gets the list of active optimizations
  73725. */
  73726. get optimizations(): SceneOptimization[];
  73727. /**
  73728. * Creates a new SceneOptimizer
  73729. * @param scene defines the scene to work on
  73730. * @param options defines the options to use with the SceneOptimizer
  73731. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73732. * @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)
  73733. */
  73734. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73735. /**
  73736. * Stops the current optimizer
  73737. */
  73738. stop(): void;
  73739. /**
  73740. * Reset the optimizer to initial step (current priority level = 0)
  73741. */
  73742. reset(): void;
  73743. /**
  73744. * Start the optimizer. By default it will try to reach a specific framerate
  73745. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73746. */
  73747. start(): void;
  73748. private _checkCurrentState;
  73749. /**
  73750. * Release all resources
  73751. */
  73752. dispose(): void;
  73753. /**
  73754. * Helper function to create a SceneOptimizer with one single line of code
  73755. * @param scene defines the scene to work on
  73756. * @param options defines the options to use with the SceneOptimizer
  73757. * @param onSuccess defines a callback to call on success
  73758. * @param onFailure defines a callback to call on failure
  73759. * @returns the new SceneOptimizer object
  73760. */
  73761. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73762. }
  73763. }
  73764. declare module BABYLON {
  73765. /**
  73766. * Class used to serialize a scene into a string
  73767. */
  73768. export class SceneSerializer {
  73769. /**
  73770. * Clear cache used by a previous serialization
  73771. */
  73772. static ClearCache(): void;
  73773. /**
  73774. * Serialize a scene into a JSON compatible object
  73775. * @param scene defines the scene to serialize
  73776. * @returns a JSON compatible object
  73777. */
  73778. static Serialize(scene: Scene): any;
  73779. /**
  73780. * Serialize a mesh into a JSON compatible object
  73781. * @param toSerialize defines the mesh to serialize
  73782. * @param withParents defines if parents must be serialized as well
  73783. * @param withChildren defines if children must be serialized as well
  73784. * @returns a JSON compatible object
  73785. */
  73786. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Class used to host texture specific utilities
  73792. */
  73793. export class TextureTools {
  73794. /**
  73795. * Uses the GPU to create a copy texture rescaled at a given size
  73796. * @param texture Texture to copy from
  73797. * @param width defines the desired width
  73798. * @param height defines the desired height
  73799. * @param useBilinearMode defines if bilinear mode has to be used
  73800. * @return the generated texture
  73801. */
  73802. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73803. }
  73804. }
  73805. declare module BABYLON {
  73806. /**
  73807. * This represents the different options available for the video capture.
  73808. */
  73809. export interface VideoRecorderOptions {
  73810. /** Defines the mime type of the video. */
  73811. mimeType: string;
  73812. /** Defines the FPS the video should be recorded at. */
  73813. fps: number;
  73814. /** Defines the chunk size for the recording data. */
  73815. recordChunckSize: number;
  73816. /** The audio tracks to attach to the recording. */
  73817. audioTracks?: MediaStreamTrack[];
  73818. }
  73819. /**
  73820. * This can help with recording videos from BabylonJS.
  73821. * This is based on the available WebRTC functionalities of the browser.
  73822. *
  73823. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73824. */
  73825. export class VideoRecorder {
  73826. private static readonly _defaultOptions;
  73827. /**
  73828. * Returns whether or not the VideoRecorder is available in your browser.
  73829. * @param engine Defines the Babylon Engine.
  73830. * @returns true if supported otherwise false.
  73831. */
  73832. static IsSupported(engine: Engine): boolean;
  73833. private readonly _options;
  73834. private _canvas;
  73835. private _mediaRecorder;
  73836. private _recordedChunks;
  73837. private _fileName;
  73838. private _resolve;
  73839. private _reject;
  73840. /**
  73841. * True when a recording is already in progress.
  73842. */
  73843. get isRecording(): boolean;
  73844. /**
  73845. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73846. * @param engine Defines the BabylonJS Engine you wish to record.
  73847. * @param options Defines options that can be used to customize the capture.
  73848. */
  73849. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73850. /**
  73851. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73852. */
  73853. stopRecording(): void;
  73854. /**
  73855. * Starts recording the canvas for a max duration specified in parameters.
  73856. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73857. * If null no automatic download will start and you can rely on the promise to get the data back.
  73858. * @param maxDuration Defines the maximum recording time in seconds.
  73859. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73860. * @return A promise callback at the end of the recording with the video data in Blob.
  73861. */
  73862. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73863. /**
  73864. * Releases internal resources used during the recording.
  73865. */
  73866. dispose(): void;
  73867. private _handleDataAvailable;
  73868. private _handleError;
  73869. private _handleStop;
  73870. }
  73871. }
  73872. declare module BABYLON {
  73873. /**
  73874. * Class containing a set of static utilities functions for screenshots
  73875. */
  73876. export class ScreenshotTools {
  73877. /**
  73878. * Captures a screenshot of the current rendering
  73879. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73880. * @param engine defines the rendering engine
  73881. * @param camera defines the source camera
  73882. * @param size This parameter can be set to a single number or to an object with the
  73883. * following (optional) properties: precision, width, height. If a single number is passed,
  73884. * it will be used for both width and height. If an object is passed, the screenshot size
  73885. * will be derived from the parameters. The precision property is a multiplier allowing
  73886. * rendering at a higher or lower resolution
  73887. * @param successCallback defines the callback receives a single parameter which contains the
  73888. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73889. * src parameter of an <img> to display it
  73890. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73891. * Check your browser for supported MIME types
  73892. */
  73893. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73894. /**
  73895. * Captures a screenshot of the current rendering
  73896. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73897. * @param engine defines the rendering engine
  73898. * @param camera defines the source camera
  73899. * @param size This parameter can be set to a single number or to an object with the
  73900. * following (optional) properties: precision, width, height. If a single number is passed,
  73901. * it will be used for both width and height. If an object is passed, the screenshot size
  73902. * will be derived from the parameters. The precision property is a multiplier allowing
  73903. * rendering at a higher or lower resolution
  73904. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73905. * Check your browser for supported MIME types
  73906. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73907. * to the src parameter of an <img> to display it
  73908. */
  73909. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73910. /**
  73911. * Generates an image screenshot from the specified camera.
  73912. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73913. * @param engine The engine to use for rendering
  73914. * @param camera The camera to use for rendering
  73915. * @param size This parameter can be set to a single number or to an object with the
  73916. * following (optional) properties: precision, width, height. If a single number is passed,
  73917. * it will be used for both width and height. If an object is passed, the screenshot size
  73918. * will be derived from the parameters. The precision property is a multiplier allowing
  73919. * rendering at a higher or lower resolution
  73920. * @param successCallback The callback receives a single parameter which contains the
  73921. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73922. * src parameter of an <img> to display it
  73923. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73924. * Check your browser for supported MIME types
  73925. * @param samples Texture samples (default: 1)
  73926. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73927. * @param fileName A name for for the downloaded file.
  73928. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73929. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  73930. */
  73931. 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;
  73932. /**
  73933. * Generates an image screenshot from the specified camera.
  73934. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73935. * @param engine The engine to use for rendering
  73936. * @param camera The camera to use for rendering
  73937. * @param size This parameter can be set to a single number or to an object with the
  73938. * following (optional) properties: precision, width, height. If a single number is passed,
  73939. * it will be used for both width and height. If an object is passed, the screenshot size
  73940. * will be derived from the parameters. The precision property is a multiplier allowing
  73941. * rendering at a higher or lower resolution
  73942. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73943. * Check your browser for supported MIME types
  73944. * @param samples Texture samples (default: 1)
  73945. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73946. * @param fileName A name for for the downloaded file.
  73947. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73948. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73949. * to the src parameter of an <img> to display it
  73950. */
  73951. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73952. /**
  73953. * Gets height and width for screenshot size
  73954. * @private
  73955. */
  73956. private static _getScreenshotSize;
  73957. }
  73958. }
  73959. declare module BABYLON {
  73960. /**
  73961. * Interface for a data buffer
  73962. */
  73963. export interface IDataBuffer {
  73964. /**
  73965. * Reads bytes from the data buffer.
  73966. * @param byteOffset The byte offset to read
  73967. * @param byteLength The byte length to read
  73968. * @returns A promise that resolves when the bytes are read
  73969. */
  73970. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73971. /**
  73972. * The byte length of the buffer.
  73973. */
  73974. readonly byteLength: number;
  73975. }
  73976. /**
  73977. * Utility class for reading from a data buffer
  73978. */
  73979. export class DataReader {
  73980. /**
  73981. * The data buffer associated with this data reader.
  73982. */
  73983. readonly buffer: IDataBuffer;
  73984. /**
  73985. * The current byte offset from the beginning of the data buffer.
  73986. */
  73987. byteOffset: number;
  73988. private _dataView;
  73989. private _dataByteOffset;
  73990. /**
  73991. * Constructor
  73992. * @param buffer The buffer to read
  73993. */
  73994. constructor(buffer: IDataBuffer);
  73995. /**
  73996. * Loads the given byte length.
  73997. * @param byteLength The byte length to load
  73998. * @returns A promise that resolves when the load is complete
  73999. */
  74000. loadAsync(byteLength: number): Promise<void>;
  74001. /**
  74002. * Read a unsigned 32-bit integer from the currently loaded data range.
  74003. * @returns The 32-bit integer read
  74004. */
  74005. readUint32(): number;
  74006. /**
  74007. * Read a byte array from the currently loaded data range.
  74008. * @param byteLength The byte length to read
  74009. * @returns The byte array read
  74010. */
  74011. readUint8Array(byteLength: number): Uint8Array;
  74012. /**
  74013. * Read a string from the currently loaded data range.
  74014. * @param byteLength The byte length to read
  74015. * @returns The string read
  74016. */
  74017. readString(byteLength: number): string;
  74018. /**
  74019. * Skips the given byte length the currently loaded data range.
  74020. * @param byteLength The byte length to skip
  74021. */
  74022. skipBytes(byteLength: number): void;
  74023. }
  74024. }
  74025. declare module BABYLON {
  74026. /**
  74027. * Class for storing data to local storage if available or in-memory storage otherwise
  74028. */
  74029. export class DataStorage {
  74030. private static _Storage;
  74031. private static _GetStorage;
  74032. /**
  74033. * Reads a string from the data storage
  74034. * @param key The key to read
  74035. * @param defaultValue The value if the key doesn't exist
  74036. * @returns The string value
  74037. */
  74038. static ReadString(key: string, defaultValue: string): string;
  74039. /**
  74040. * Writes a string to the data storage
  74041. * @param key The key to write
  74042. * @param value The value to write
  74043. */
  74044. static WriteString(key: string, value: string): void;
  74045. /**
  74046. * Reads a boolean from the data storage
  74047. * @param key The key to read
  74048. * @param defaultValue The value if the key doesn't exist
  74049. * @returns The boolean value
  74050. */
  74051. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74052. /**
  74053. * Writes a boolean to the data storage
  74054. * @param key The key to write
  74055. * @param value The value to write
  74056. */
  74057. static WriteBoolean(key: string, value: boolean): void;
  74058. /**
  74059. * Reads a number from the data storage
  74060. * @param key The key to read
  74061. * @param defaultValue The value if the key doesn't exist
  74062. * @returns The number value
  74063. */
  74064. static ReadNumber(key: string, defaultValue: number): number;
  74065. /**
  74066. * Writes a number to the data storage
  74067. * @param key The key to write
  74068. * @param value The value to write
  74069. */
  74070. static WriteNumber(key: string, value: number): void;
  74071. }
  74072. }
  74073. declare module BABYLON {
  74074. /**
  74075. * Class used to record delta files between 2 scene states
  74076. */
  74077. export class SceneRecorder {
  74078. private _trackedScene;
  74079. private _savedJSON;
  74080. /**
  74081. * Track a given scene. This means the current scene state will be considered the original state
  74082. * @param scene defines the scene to track
  74083. */
  74084. track(scene: Scene): void;
  74085. /**
  74086. * Get the delta between current state and original state
  74087. * @returns a string containing the delta
  74088. */
  74089. getDelta(): any;
  74090. private _compareArray;
  74091. private _compareObjects;
  74092. private _compareCollections;
  74093. private static GetShadowGeneratorById;
  74094. /**
  74095. * Apply a given delta to a given scene
  74096. * @param deltaJSON defines the JSON containing the delta
  74097. * @param scene defines the scene to apply the delta to
  74098. */
  74099. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74100. private static _ApplyPropertiesToEntity;
  74101. private static _ApplyDeltaForEntity;
  74102. }
  74103. }
  74104. declare module BABYLON {
  74105. /**
  74106. * An interface for all Hit test features
  74107. */
  74108. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74109. /**
  74110. * Triggered when new babylon (transformed) hit test results are available
  74111. */
  74112. onHitTestResultObservable: Observable<T[]>;
  74113. }
  74114. /**
  74115. * Options used for hit testing
  74116. */
  74117. export interface IWebXRLegacyHitTestOptions {
  74118. /**
  74119. * Only test when user interacted with the scene. Default - hit test every frame
  74120. */
  74121. testOnPointerDownOnly?: boolean;
  74122. /**
  74123. * The node to use to transform the local results to world coordinates
  74124. */
  74125. worldParentNode?: TransformNode;
  74126. }
  74127. /**
  74128. * Interface defining the babylon result of raycasting/hit-test
  74129. */
  74130. export interface IWebXRLegacyHitResult {
  74131. /**
  74132. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74133. */
  74134. transformationMatrix: Matrix;
  74135. /**
  74136. * The native hit test result
  74137. */
  74138. xrHitResult: XRHitResult | XRHitTestResult;
  74139. }
  74140. /**
  74141. * The currently-working hit-test module.
  74142. * Hit test (or Ray-casting) is used to interact with the real world.
  74143. * For further information read here - https://github.com/immersive-web/hit-test
  74144. */
  74145. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74146. /**
  74147. * options to use when constructing this feature
  74148. */
  74149. readonly options: IWebXRLegacyHitTestOptions;
  74150. private _direction;
  74151. private _mat;
  74152. private _onSelectEnabled;
  74153. private _origin;
  74154. /**
  74155. * The module's name
  74156. */
  74157. static readonly Name: string;
  74158. /**
  74159. * The (Babylon) version of this module.
  74160. * This is an integer representing the implementation version.
  74161. * This number does not correspond to the WebXR specs version
  74162. */
  74163. static readonly Version: number;
  74164. /**
  74165. * Populated with the last native XR Hit Results
  74166. */
  74167. lastNativeXRHitResults: XRHitResult[];
  74168. /**
  74169. * Triggered when new babylon (transformed) hit test results are available
  74170. */
  74171. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74172. /**
  74173. * Creates a new instance of the (legacy version) hit test feature
  74174. * @param _xrSessionManager an instance of WebXRSessionManager
  74175. * @param options options to use when constructing this feature
  74176. */
  74177. constructor(_xrSessionManager: WebXRSessionManager,
  74178. /**
  74179. * options to use when constructing this feature
  74180. */
  74181. options?: IWebXRLegacyHitTestOptions);
  74182. /**
  74183. * execute a hit test with an XR Ray
  74184. *
  74185. * @param xrSession a native xrSession that will execute this hit test
  74186. * @param xrRay the ray (position and direction) to use for ray-casting
  74187. * @param referenceSpace native XR reference space to use for the hit-test
  74188. * @param filter filter function that will filter the results
  74189. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74190. */
  74191. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74192. /**
  74193. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74194. * @param event the (select) event to use to select with
  74195. * @param referenceSpace the reference space to use for this hit test
  74196. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74197. */
  74198. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74199. /**
  74200. * attach this feature
  74201. * Will usually be called by the features manager
  74202. *
  74203. * @returns true if successful.
  74204. */
  74205. attach(): boolean;
  74206. /**
  74207. * detach this feature.
  74208. * Will usually be called by the features manager
  74209. *
  74210. * @returns true if successful.
  74211. */
  74212. detach(): boolean;
  74213. /**
  74214. * Dispose this feature and all of the resources attached
  74215. */
  74216. dispose(): void;
  74217. protected _onXRFrame(frame: XRFrame): void;
  74218. private _onHitTestResults;
  74219. private _onSelect;
  74220. }
  74221. }
  74222. declare module BABYLON {
  74223. /**
  74224. * Options used for hit testing (version 2)
  74225. */
  74226. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74227. /**
  74228. * Do not create a permanent hit test. Will usually be used when only
  74229. * transient inputs are needed.
  74230. */
  74231. disablePermanentHitTest?: boolean;
  74232. /**
  74233. * Enable transient (for example touch-based) hit test inspections
  74234. */
  74235. enableTransientHitTest?: boolean;
  74236. /**
  74237. * Offset ray for the permanent hit test
  74238. */
  74239. offsetRay?: Vector3;
  74240. /**
  74241. * Offset ray for the transient hit test
  74242. */
  74243. transientOffsetRay?: Vector3;
  74244. /**
  74245. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74246. */
  74247. useReferenceSpace?: boolean;
  74248. /**
  74249. * Override the default entity type(s) of the hit-test result
  74250. */
  74251. entityTypes?: XRHitTestTrackableType[];
  74252. }
  74253. /**
  74254. * Interface defining the babylon result of hit-test
  74255. */
  74256. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74257. /**
  74258. * The input source that generated this hit test (if transient)
  74259. */
  74260. inputSource?: XRInputSource;
  74261. /**
  74262. * Is this a transient hit test
  74263. */
  74264. isTransient?: boolean;
  74265. /**
  74266. * Position of the hit test result
  74267. */
  74268. position: Vector3;
  74269. /**
  74270. * Rotation of the hit test result
  74271. */
  74272. rotationQuaternion: Quaternion;
  74273. /**
  74274. * The native hit test result
  74275. */
  74276. xrHitResult: XRHitTestResult;
  74277. }
  74278. /**
  74279. * The currently-working hit-test module.
  74280. * Hit test (or Ray-casting) is used to interact with the real world.
  74281. * For further information read here - https://github.com/immersive-web/hit-test
  74282. *
  74283. * Tested on chrome (mobile) 80.
  74284. */
  74285. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74286. /**
  74287. * options to use when constructing this feature
  74288. */
  74289. readonly options: IWebXRHitTestOptions;
  74290. private _tmpMat;
  74291. private _tmpPos;
  74292. private _tmpQuat;
  74293. private _transientXrHitTestSource;
  74294. private _xrHitTestSource;
  74295. private initHitTestSource;
  74296. /**
  74297. * The module's name
  74298. */
  74299. static readonly Name: string;
  74300. /**
  74301. * The (Babylon) version of this module.
  74302. * This is an integer representing the implementation version.
  74303. * This number does not correspond to the WebXR specs version
  74304. */
  74305. static readonly Version: number;
  74306. /**
  74307. * When set to true, each hit test will have its own position/rotation objects
  74308. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74309. * the developers will clone them or copy them as they see fit.
  74310. */
  74311. autoCloneTransformation: boolean;
  74312. /**
  74313. * Triggered when new babylon (transformed) hit test results are available
  74314. */
  74315. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74316. /**
  74317. * Use this to temporarily pause hit test checks.
  74318. */
  74319. paused: boolean;
  74320. /**
  74321. * Creates a new instance of the hit test feature
  74322. * @param _xrSessionManager an instance of WebXRSessionManager
  74323. * @param options options to use when constructing this feature
  74324. */
  74325. constructor(_xrSessionManager: WebXRSessionManager,
  74326. /**
  74327. * options to use when constructing this feature
  74328. */
  74329. options?: IWebXRHitTestOptions);
  74330. /**
  74331. * attach this feature
  74332. * Will usually be called by the features manager
  74333. *
  74334. * @returns true if successful.
  74335. */
  74336. attach(): boolean;
  74337. /**
  74338. * detach this feature.
  74339. * Will usually be called by the features manager
  74340. *
  74341. * @returns true if successful.
  74342. */
  74343. detach(): boolean;
  74344. /**
  74345. * Dispose this feature and all of the resources attached
  74346. */
  74347. dispose(): void;
  74348. protected _onXRFrame(frame: XRFrame): void;
  74349. private _processWebXRHitTestResult;
  74350. }
  74351. }
  74352. declare module BABYLON {
  74353. /**
  74354. * Configuration options of the anchor system
  74355. */
  74356. export interface IWebXRAnchorSystemOptions {
  74357. /**
  74358. * a node that will be used to convert local to world coordinates
  74359. */
  74360. worldParentNode?: TransformNode;
  74361. /**
  74362. * If set to true a reference of the created anchors will be kept until the next session starts
  74363. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74364. */
  74365. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74366. }
  74367. /**
  74368. * A babylon container for an XR Anchor
  74369. */
  74370. export interface IWebXRAnchor {
  74371. /**
  74372. * A babylon-assigned ID for this anchor
  74373. */
  74374. id: number;
  74375. /**
  74376. * Transformation matrix to apply to an object attached to this anchor
  74377. */
  74378. transformationMatrix: Matrix;
  74379. /**
  74380. * The native anchor object
  74381. */
  74382. xrAnchor: XRAnchor;
  74383. /**
  74384. * if defined, this object will be constantly updated by the anchor's position and rotation
  74385. */
  74386. attachedNode?: TransformNode;
  74387. }
  74388. /**
  74389. * An implementation of the anchor system for WebXR.
  74390. * For further information see https://github.com/immersive-web/anchors/
  74391. */
  74392. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74393. private _options;
  74394. private _lastFrameDetected;
  74395. private _trackedAnchors;
  74396. private _referenceSpaceForFrameAnchors;
  74397. private _futureAnchors;
  74398. /**
  74399. * The module's name
  74400. */
  74401. static readonly Name: string;
  74402. /**
  74403. * The (Babylon) version of this module.
  74404. * This is an integer representing the implementation version.
  74405. * This number does not correspond to the WebXR specs version
  74406. */
  74407. static readonly Version: number;
  74408. /**
  74409. * Observers registered here will be executed when a new anchor was added to the session
  74410. */
  74411. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74412. /**
  74413. * Observers registered here will be executed when an anchor was removed from the session
  74414. */
  74415. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74416. /**
  74417. * Observers registered here will be executed when an existing anchor updates
  74418. * This can execute N times every frame
  74419. */
  74420. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74421. /**
  74422. * Set the reference space to use for anchor creation, when not using a hit test.
  74423. * Will default to the session's reference space if not defined
  74424. */
  74425. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74426. /**
  74427. * constructs a new anchor system
  74428. * @param _xrSessionManager an instance of WebXRSessionManager
  74429. * @param _options configuration object for this feature
  74430. */
  74431. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74432. private _tmpVector;
  74433. private _tmpQuaternion;
  74434. private _populateTmpTransformation;
  74435. /**
  74436. * Create a new anchor point using a hit test result at a specific point in the scene
  74437. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74438. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74439. *
  74440. * @param hitTestResult The hit test result to use for this anchor creation
  74441. * @param position an optional position offset for this anchor
  74442. * @param rotationQuaternion an optional rotation offset for this anchor
  74443. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74444. */
  74445. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74446. /**
  74447. * Add a new anchor at a specific position and rotation
  74448. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74449. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74450. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74451. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74452. *
  74453. * @param position the position in which to add an anchor
  74454. * @param rotationQuaternion an optional rotation for the anchor transformation
  74455. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74456. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74457. */
  74458. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74459. /**
  74460. * detach this feature.
  74461. * Will usually be called by the features manager
  74462. *
  74463. * @returns true if successful.
  74464. */
  74465. detach(): boolean;
  74466. /**
  74467. * Dispose this feature and all of the resources attached
  74468. */
  74469. dispose(): void;
  74470. protected _onXRFrame(frame: XRFrame): void;
  74471. /**
  74472. * avoiding using Array.find for global support.
  74473. * @param xrAnchor the plane to find in the array
  74474. */
  74475. private _findIndexInAnchorArray;
  74476. private _updateAnchorWithXRFrame;
  74477. private _createAnchorAtTransformation;
  74478. }
  74479. }
  74480. declare module BABYLON {
  74481. /**
  74482. * Options used in the plane detector module
  74483. */
  74484. export interface IWebXRPlaneDetectorOptions {
  74485. /**
  74486. * The node to use to transform the local results to world coordinates
  74487. */
  74488. worldParentNode?: TransformNode;
  74489. /**
  74490. * If set to true a reference of the created planes will be kept until the next session starts
  74491. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74492. */
  74493. doNotRemovePlanesOnSessionEnded?: boolean;
  74494. }
  74495. /**
  74496. * A babylon interface for a WebXR plane.
  74497. * A Plane is actually a polygon, built from N points in space
  74498. *
  74499. * Supported in chrome 79, not supported in canary 81 ATM
  74500. */
  74501. export interface IWebXRPlane {
  74502. /**
  74503. * a babylon-assigned ID for this polygon
  74504. */
  74505. id: number;
  74506. /**
  74507. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74508. */
  74509. polygonDefinition: Array<Vector3>;
  74510. /**
  74511. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74512. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74513. */
  74514. transformationMatrix: Matrix;
  74515. /**
  74516. * the native xr-plane object
  74517. */
  74518. xrPlane: XRPlane;
  74519. }
  74520. /**
  74521. * The plane detector is used to detect planes in the real world when in AR
  74522. * For more information see https://github.com/immersive-web/real-world-geometry/
  74523. */
  74524. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74525. private _options;
  74526. private _detectedPlanes;
  74527. private _enabled;
  74528. private _lastFrameDetected;
  74529. /**
  74530. * The module's name
  74531. */
  74532. static readonly Name: string;
  74533. /**
  74534. * The (Babylon) version of this module.
  74535. * This is an integer representing the implementation version.
  74536. * This number does not correspond to the WebXR specs version
  74537. */
  74538. static readonly Version: number;
  74539. /**
  74540. * Observers registered here will be executed when a new plane was added to the session
  74541. */
  74542. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74543. /**
  74544. * Observers registered here will be executed when a plane is no longer detected in the session
  74545. */
  74546. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74547. /**
  74548. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74549. * This can execute N times every frame
  74550. */
  74551. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74552. /**
  74553. * construct a new Plane Detector
  74554. * @param _xrSessionManager an instance of xr Session manager
  74555. * @param _options configuration to use when constructing this feature
  74556. */
  74557. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74558. /**
  74559. * detach this feature.
  74560. * Will usually be called by the features manager
  74561. *
  74562. * @returns true if successful.
  74563. */
  74564. detach(): boolean;
  74565. /**
  74566. * Dispose this feature and all of the resources attached
  74567. */
  74568. dispose(): void;
  74569. protected _onXRFrame(frame: XRFrame): void;
  74570. private _init;
  74571. private _updatePlaneWithXRPlane;
  74572. /**
  74573. * avoiding using Array.find for global support.
  74574. * @param xrPlane the plane to find in the array
  74575. */
  74576. private findIndexInPlaneArray;
  74577. }
  74578. }
  74579. declare module BABYLON {
  74580. /**
  74581. * Options interface for the background remover plugin
  74582. */
  74583. export interface IWebXRBackgroundRemoverOptions {
  74584. /**
  74585. * Further background meshes to disable when entering AR
  74586. */
  74587. backgroundMeshes?: AbstractMesh[];
  74588. /**
  74589. * flags to configure the removal of the environment helper.
  74590. * If not set, the entire background will be removed. If set, flags should be set as well.
  74591. */
  74592. environmentHelperRemovalFlags?: {
  74593. /**
  74594. * Should the skybox be removed (default false)
  74595. */
  74596. skyBox?: boolean;
  74597. /**
  74598. * Should the ground be removed (default false)
  74599. */
  74600. ground?: boolean;
  74601. };
  74602. /**
  74603. * don't disable the environment helper
  74604. */
  74605. ignoreEnvironmentHelper?: boolean;
  74606. }
  74607. /**
  74608. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74609. */
  74610. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74611. /**
  74612. * read-only options to be used in this module
  74613. */
  74614. readonly options: IWebXRBackgroundRemoverOptions;
  74615. /**
  74616. * The module's name
  74617. */
  74618. static readonly Name: string;
  74619. /**
  74620. * The (Babylon) version of this module.
  74621. * This is an integer representing the implementation version.
  74622. * This number does not correspond to the WebXR specs version
  74623. */
  74624. static readonly Version: number;
  74625. /**
  74626. * registered observers will be triggered when the background state changes
  74627. */
  74628. onBackgroundStateChangedObservable: Observable<boolean>;
  74629. /**
  74630. * constructs a new background remover module
  74631. * @param _xrSessionManager the session manager for this module
  74632. * @param options read-only options to be used in this module
  74633. */
  74634. constructor(_xrSessionManager: WebXRSessionManager,
  74635. /**
  74636. * read-only options to be used in this module
  74637. */
  74638. options?: IWebXRBackgroundRemoverOptions);
  74639. /**
  74640. * attach this feature
  74641. * Will usually be called by the features manager
  74642. *
  74643. * @returns true if successful.
  74644. */
  74645. attach(): boolean;
  74646. /**
  74647. * detach this feature.
  74648. * Will usually be called by the features manager
  74649. *
  74650. * @returns true if successful.
  74651. */
  74652. detach(): boolean;
  74653. /**
  74654. * Dispose this feature and all of the resources attached
  74655. */
  74656. dispose(): void;
  74657. protected _onXRFrame(_xrFrame: XRFrame): void;
  74658. private _setBackgroundState;
  74659. }
  74660. }
  74661. declare module BABYLON {
  74662. /**
  74663. * Options for the controller physics feature
  74664. */
  74665. export class IWebXRControllerPhysicsOptions {
  74666. /**
  74667. * Should the headset get its own impostor
  74668. */
  74669. enableHeadsetImpostor?: boolean;
  74670. /**
  74671. * Optional parameters for the headset impostor
  74672. */
  74673. headsetImpostorParams?: {
  74674. /**
  74675. * The type of impostor to create. Default is sphere
  74676. */
  74677. impostorType: number;
  74678. /**
  74679. * the size of the impostor. Defaults to 10cm
  74680. */
  74681. impostorSize?: number | {
  74682. width: number;
  74683. height: number;
  74684. depth: number;
  74685. };
  74686. /**
  74687. * Friction definitions
  74688. */
  74689. friction?: number;
  74690. /**
  74691. * Restitution
  74692. */
  74693. restitution?: number;
  74694. };
  74695. /**
  74696. * The physics properties of the future impostors
  74697. */
  74698. physicsProperties?: {
  74699. /**
  74700. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74701. * Note that this requires a physics engine that supports mesh impostors!
  74702. */
  74703. useControllerMesh?: boolean;
  74704. /**
  74705. * The type of impostor to create. Default is sphere
  74706. */
  74707. impostorType?: number;
  74708. /**
  74709. * the size of the impostor. Defaults to 10cm
  74710. */
  74711. impostorSize?: number | {
  74712. width: number;
  74713. height: number;
  74714. depth: number;
  74715. };
  74716. /**
  74717. * Friction definitions
  74718. */
  74719. friction?: number;
  74720. /**
  74721. * Restitution
  74722. */
  74723. restitution?: number;
  74724. };
  74725. /**
  74726. * the xr input to use with this pointer selection
  74727. */
  74728. xrInput: WebXRInput;
  74729. }
  74730. /**
  74731. * Add physics impostor to your webxr controllers,
  74732. * including naive calculation of their linear and angular velocity
  74733. */
  74734. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74735. private readonly _options;
  74736. private _attachController;
  74737. private _controllers;
  74738. private _debugMode;
  74739. private _delta;
  74740. private _headsetImpostor?;
  74741. private _headsetMesh?;
  74742. private _lastTimestamp;
  74743. private _tmpQuaternion;
  74744. private _tmpVector;
  74745. /**
  74746. * The module's name
  74747. */
  74748. static readonly Name: string;
  74749. /**
  74750. * The (Babylon) version of this module.
  74751. * This is an integer representing the implementation version.
  74752. * This number does not correspond to the webxr specs version
  74753. */
  74754. static readonly Version: number;
  74755. /**
  74756. * Construct a new Controller Physics Feature
  74757. * @param _xrSessionManager the corresponding xr session manager
  74758. * @param _options options to create this feature with
  74759. */
  74760. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74761. /**
  74762. * @hidden
  74763. * enable debugging - will show console outputs and the impostor mesh
  74764. */
  74765. _enablePhysicsDebug(): void;
  74766. /**
  74767. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74768. * @param xrController the controller to add
  74769. */
  74770. addController(xrController: WebXRInputSource): void;
  74771. /**
  74772. * attach this feature
  74773. * Will usually be called by the features manager
  74774. *
  74775. * @returns true if successful.
  74776. */
  74777. attach(): boolean;
  74778. /**
  74779. * detach this feature.
  74780. * Will usually be called by the features manager
  74781. *
  74782. * @returns true if successful.
  74783. */
  74784. detach(): boolean;
  74785. /**
  74786. * Get the headset impostor, if enabled
  74787. * @returns the impostor
  74788. */
  74789. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74790. /**
  74791. * Get the physics impostor of a specific controller.
  74792. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74793. * @param controller the controller or the controller id of which to get the impostor
  74794. * @returns the impostor or null
  74795. */
  74796. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74797. /**
  74798. * Update the physics properties provided in the constructor
  74799. * @param newProperties the new properties object
  74800. */
  74801. setPhysicsProperties(newProperties: {
  74802. impostorType?: number;
  74803. impostorSize?: number | {
  74804. width: number;
  74805. height: number;
  74806. depth: number;
  74807. };
  74808. friction?: number;
  74809. restitution?: number;
  74810. }): void;
  74811. protected _onXRFrame(_xrFrame: any): void;
  74812. private _detachController;
  74813. }
  74814. }
  74815. declare module BABYLON {
  74816. /**
  74817. * A babylon interface for a "WebXR" feature point.
  74818. * Represents the position and confidence value of a given feature point.
  74819. */
  74820. export interface IWebXRFeaturePoint {
  74821. /**
  74822. * Represents the position of the feature point in world space.
  74823. */
  74824. position: Vector3;
  74825. /**
  74826. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  74827. */
  74828. confidenceValue: number;
  74829. }
  74830. /**
  74831. * The feature point system is used to detect feature points from real world geometry.
  74832. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  74833. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  74834. */
  74835. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  74836. private _enabled;
  74837. private _featurePointCloud;
  74838. /**
  74839. * The module's name
  74840. */
  74841. static readonly Name: string;
  74842. /**
  74843. * The (Babylon) version of this module.
  74844. * This is an integer representing the implementation version.
  74845. * This number does not correspond to the WebXR specs version
  74846. */
  74847. static readonly Version: number;
  74848. /**
  74849. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  74850. * Will notify the observers about which feature points have been added.
  74851. */
  74852. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  74853. /**
  74854. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  74855. * Will notify the observers about which feature points have been updated.
  74856. */
  74857. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  74858. /**
  74859. * The current feature point cloud maintained across frames.
  74860. */
  74861. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  74862. /**
  74863. * construct the feature point system
  74864. * @param _xrSessionManager an instance of xr Session manager
  74865. */
  74866. constructor(_xrSessionManager: WebXRSessionManager);
  74867. /**
  74868. * Detach this feature.
  74869. * Will usually be called by the features manager
  74870. *
  74871. * @returns true if successful.
  74872. */
  74873. detach(): boolean;
  74874. /**
  74875. * Dispose this feature and all of the resources attached
  74876. */
  74877. dispose(): void;
  74878. /**
  74879. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  74880. */
  74881. protected _onXRFrame(frame: XRFrame): void;
  74882. /**
  74883. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  74884. */
  74885. private _init;
  74886. }
  74887. }
  74888. declare module BABYLON {
  74889. /**
  74890. * Configuration interface for the hand tracking feature
  74891. */
  74892. export interface IWebXRHandTrackingOptions {
  74893. /**
  74894. * The xrInput that will be used as source for new hands
  74895. */
  74896. xrInput: WebXRInput;
  74897. /**
  74898. * Configuration object for the joint meshes
  74899. */
  74900. jointMeshes?: {
  74901. /**
  74902. * Should the meshes created be invisible (defaults to false)
  74903. */
  74904. invisible?: boolean;
  74905. /**
  74906. * A source mesh to be used to create instances. Defaults to a sphere.
  74907. * This mesh will be the source for all other (25) meshes.
  74908. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  74909. */
  74910. sourceMesh?: Mesh;
  74911. /**
  74912. * Should the source mesh stay visible. Defaults to false
  74913. */
  74914. keepOriginalVisible?: boolean;
  74915. /**
  74916. * Scale factor for all instances (defaults to 2)
  74917. */
  74918. scaleFactor?: number;
  74919. /**
  74920. * Should each instance have its own physics impostor
  74921. */
  74922. enablePhysics?: boolean;
  74923. /**
  74924. * If enabled, override default physics properties
  74925. */
  74926. physicsProps?: {
  74927. friction?: number;
  74928. restitution?: number;
  74929. impostorType?: number;
  74930. };
  74931. /**
  74932. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  74933. */
  74934. handMesh?: AbstractMesh;
  74935. };
  74936. }
  74937. /**
  74938. * Parts of the hands divided to writs and finger names
  74939. */
  74940. export const enum HandPart {
  74941. /**
  74942. * HandPart - Wrist
  74943. */
  74944. WRIST = "wrist",
  74945. /**
  74946. * HandPart - The THumb
  74947. */
  74948. THUMB = "thumb",
  74949. /**
  74950. * HandPart - Index finger
  74951. */
  74952. INDEX = "index",
  74953. /**
  74954. * HandPart - Middle finger
  74955. */
  74956. MIDDLE = "middle",
  74957. /**
  74958. * HandPart - Ring finger
  74959. */
  74960. RING = "ring",
  74961. /**
  74962. * HandPart - Little finger
  74963. */
  74964. LITTLE = "little"
  74965. }
  74966. /**
  74967. * Representing a single hand (with its corresponding native XRHand object)
  74968. */
  74969. export class WebXRHand implements IDisposable {
  74970. /** the controller to which the hand correlates */
  74971. readonly xrController: WebXRInputSource;
  74972. /** the meshes to be used to track the hand joints */
  74973. readonly trackedMeshes: AbstractMesh[];
  74974. /**
  74975. * Hand-parts definition (key is HandPart)
  74976. */
  74977. static HandPartsDefinition: {
  74978. [key: string]: number[];
  74979. };
  74980. /**
  74981. * Populate the HandPartsDefinition object.
  74982. * This is called as a side effect since certain browsers don't have XRHand defined.
  74983. */
  74984. static _PopulateHandPartsDefinition(): void;
  74985. /**
  74986. * Construct a new hand object
  74987. * @param xrController the controller to which the hand correlates
  74988. * @param trackedMeshes the meshes to be used to track the hand joints
  74989. */
  74990. constructor(
  74991. /** the controller to which the hand correlates */
  74992. xrController: WebXRInputSource,
  74993. /** the meshes to be used to track the hand joints */
  74994. trackedMeshes: AbstractMesh[]);
  74995. /**
  74996. * Update this hand from the latest xr frame
  74997. * @param xrFrame xrFrame to update from
  74998. * @param referenceSpace The current viewer reference space
  74999. * @param scaleFactor optional scale factor for the meshes
  75000. */
  75001. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75002. /**
  75003. * Get meshes of part of the hand
  75004. * @param part the part of hand to get
  75005. * @returns An array of meshes that correlate to the hand part requested
  75006. */
  75007. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75008. /**
  75009. * Dispose this Hand object
  75010. */
  75011. dispose(): void;
  75012. }
  75013. /**
  75014. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75015. */
  75016. export class WebXRHandTracking extends WebXRAbstractFeature {
  75017. /**
  75018. * options to use when constructing this feature
  75019. */
  75020. readonly options: IWebXRHandTrackingOptions;
  75021. private static _idCounter;
  75022. /**
  75023. * The module's name
  75024. */
  75025. static readonly Name: string;
  75026. /**
  75027. * The (Babylon) version of this module.
  75028. * This is an integer representing the implementation version.
  75029. * This number does not correspond to the WebXR specs version
  75030. */
  75031. static readonly Version: number;
  75032. /**
  75033. * This observable will notify registered observers when a new hand object was added and initialized
  75034. */
  75035. onHandAddedObservable: Observable<WebXRHand>;
  75036. /**
  75037. * This observable will notify its observers right before the hand object is disposed
  75038. */
  75039. onHandRemovedObservable: Observable<WebXRHand>;
  75040. private _hands;
  75041. /**
  75042. * Creates a new instance of the hit test feature
  75043. * @param _xrSessionManager an instance of WebXRSessionManager
  75044. * @param options options to use when constructing this feature
  75045. */
  75046. constructor(_xrSessionManager: WebXRSessionManager,
  75047. /**
  75048. * options to use when constructing this feature
  75049. */
  75050. options: IWebXRHandTrackingOptions);
  75051. /**
  75052. * Check if the needed objects are defined.
  75053. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75054. */
  75055. isCompatible(): boolean;
  75056. /**
  75057. * attach this feature
  75058. * Will usually be called by the features manager
  75059. *
  75060. * @returns true if successful.
  75061. */
  75062. attach(): boolean;
  75063. /**
  75064. * detach this feature.
  75065. * Will usually be called by the features manager
  75066. *
  75067. * @returns true if successful.
  75068. */
  75069. detach(): boolean;
  75070. /**
  75071. * Dispose this feature and all of the resources attached
  75072. */
  75073. dispose(): void;
  75074. /**
  75075. * Get the hand object according to the controller id
  75076. * @param controllerId the controller id to which we want to get the hand
  75077. * @returns null if not found or the WebXRHand object if found
  75078. */
  75079. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75080. /**
  75081. * Get a hand object according to the requested handedness
  75082. * @param handedness the handedness to request
  75083. * @returns null if not found or the WebXRHand object if found
  75084. */
  75085. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75086. protected _onXRFrame(_xrFrame: XRFrame): void;
  75087. private _attachHand;
  75088. private _detachHand;
  75089. }
  75090. }
  75091. declare module BABYLON {
  75092. /**
  75093. * The motion controller class for all microsoft mixed reality controllers
  75094. */
  75095. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75096. protected readonly _mapping: {
  75097. defaultButton: {
  75098. valueNodeName: string;
  75099. unpressedNodeName: string;
  75100. pressedNodeName: string;
  75101. };
  75102. defaultAxis: {
  75103. valueNodeName: string;
  75104. minNodeName: string;
  75105. maxNodeName: string;
  75106. };
  75107. buttons: {
  75108. "xr-standard-trigger": {
  75109. rootNodeName: string;
  75110. componentProperty: string;
  75111. states: string[];
  75112. };
  75113. "xr-standard-squeeze": {
  75114. rootNodeName: string;
  75115. componentProperty: string;
  75116. states: string[];
  75117. };
  75118. "xr-standard-touchpad": {
  75119. rootNodeName: string;
  75120. labelAnchorNodeName: string;
  75121. touchPointNodeName: string;
  75122. };
  75123. "xr-standard-thumbstick": {
  75124. rootNodeName: string;
  75125. componentProperty: string;
  75126. states: string[];
  75127. };
  75128. };
  75129. axes: {
  75130. "xr-standard-touchpad": {
  75131. "x-axis": {
  75132. rootNodeName: string;
  75133. };
  75134. "y-axis": {
  75135. rootNodeName: string;
  75136. };
  75137. };
  75138. "xr-standard-thumbstick": {
  75139. "x-axis": {
  75140. rootNodeName: string;
  75141. };
  75142. "y-axis": {
  75143. rootNodeName: string;
  75144. };
  75145. };
  75146. };
  75147. };
  75148. /**
  75149. * The base url used to load the left and right controller models
  75150. */
  75151. static MODEL_BASE_URL: string;
  75152. /**
  75153. * The name of the left controller model file
  75154. */
  75155. static MODEL_LEFT_FILENAME: string;
  75156. /**
  75157. * The name of the right controller model file
  75158. */
  75159. static MODEL_RIGHT_FILENAME: string;
  75160. profileId: string;
  75161. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75162. protected _getFilenameAndPath(): {
  75163. filename: string;
  75164. path: string;
  75165. };
  75166. protected _getModelLoadingConstraints(): boolean;
  75167. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75168. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75169. protected _updateModel(): void;
  75170. }
  75171. }
  75172. declare module BABYLON {
  75173. /**
  75174. * The motion controller class for oculus touch (quest, rift).
  75175. * This class supports legacy mapping as well the standard xr mapping
  75176. */
  75177. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75178. private _forceLegacyControllers;
  75179. private _modelRootNode;
  75180. /**
  75181. * The base url used to load the left and right controller models
  75182. */
  75183. static MODEL_BASE_URL: string;
  75184. /**
  75185. * The name of the left controller model file
  75186. */
  75187. static MODEL_LEFT_FILENAME: string;
  75188. /**
  75189. * The name of the right controller model file
  75190. */
  75191. static MODEL_RIGHT_FILENAME: string;
  75192. /**
  75193. * Base Url for the Quest controller model.
  75194. */
  75195. static QUEST_MODEL_BASE_URL: string;
  75196. profileId: string;
  75197. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75198. protected _getFilenameAndPath(): {
  75199. filename: string;
  75200. path: string;
  75201. };
  75202. protected _getModelLoadingConstraints(): boolean;
  75203. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75204. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75205. protected _updateModel(): void;
  75206. /**
  75207. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75208. * between the touch and touch 2.
  75209. */
  75210. private _isQuest;
  75211. }
  75212. }
  75213. declare module BABYLON {
  75214. /**
  75215. * The motion controller class for the standard HTC-Vive controllers
  75216. */
  75217. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75218. private _modelRootNode;
  75219. /**
  75220. * The base url used to load the left and right controller models
  75221. */
  75222. static MODEL_BASE_URL: string;
  75223. /**
  75224. * File name for the controller model.
  75225. */
  75226. static MODEL_FILENAME: string;
  75227. profileId: string;
  75228. /**
  75229. * Create a new Vive motion controller object
  75230. * @param scene the scene to use to create this controller
  75231. * @param gamepadObject the corresponding gamepad object
  75232. * @param handedness the handedness of the controller
  75233. */
  75234. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75235. protected _getFilenameAndPath(): {
  75236. filename: string;
  75237. path: string;
  75238. };
  75239. protected _getModelLoadingConstraints(): boolean;
  75240. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75241. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75242. protected _updateModel(): void;
  75243. }
  75244. }
  75245. declare module BABYLON {
  75246. /**
  75247. * A cursor which tracks a point on a path
  75248. */
  75249. export class PathCursor {
  75250. private path;
  75251. /**
  75252. * Stores path cursor callbacks for when an onchange event is triggered
  75253. */
  75254. private _onchange;
  75255. /**
  75256. * The value of the path cursor
  75257. */
  75258. value: number;
  75259. /**
  75260. * The animation array of the path cursor
  75261. */
  75262. animations: Animation[];
  75263. /**
  75264. * Initializes the path cursor
  75265. * @param path The path to track
  75266. */
  75267. constructor(path: Path2);
  75268. /**
  75269. * Gets the cursor point on the path
  75270. * @returns A point on the path cursor at the cursor location
  75271. */
  75272. getPoint(): Vector3;
  75273. /**
  75274. * Moves the cursor ahead by the step amount
  75275. * @param step The amount to move the cursor forward
  75276. * @returns This path cursor
  75277. */
  75278. moveAhead(step?: number): PathCursor;
  75279. /**
  75280. * Moves the cursor behind by the step amount
  75281. * @param step The amount to move the cursor back
  75282. * @returns This path cursor
  75283. */
  75284. moveBack(step?: number): PathCursor;
  75285. /**
  75286. * Moves the cursor by the step amount
  75287. * If the step amount is greater than one, an exception is thrown
  75288. * @param step The amount to move the cursor
  75289. * @returns This path cursor
  75290. */
  75291. move(step: number): PathCursor;
  75292. /**
  75293. * Ensures that the value is limited between zero and one
  75294. * @returns This path cursor
  75295. */
  75296. private ensureLimits;
  75297. /**
  75298. * Runs onchange callbacks on change (used by the animation engine)
  75299. * @returns This path cursor
  75300. */
  75301. private raiseOnChange;
  75302. /**
  75303. * Executes a function on change
  75304. * @param f A path cursor onchange callback
  75305. * @returns This path cursor
  75306. */
  75307. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75308. }
  75309. }
  75310. declare module BABYLON {
  75311. /** @hidden */
  75312. export var blurPixelShader: {
  75313. name: string;
  75314. shader: string;
  75315. };
  75316. }
  75317. declare module BABYLON {
  75318. /** @hidden */
  75319. export var pointCloudVertexDeclaration: {
  75320. name: string;
  75321. shader: string;
  75322. };
  75323. }
  75324. // Mixins
  75325. interface Window {
  75326. mozIndexedDB: IDBFactory;
  75327. webkitIndexedDB: IDBFactory;
  75328. msIndexedDB: IDBFactory;
  75329. webkitURL: typeof URL;
  75330. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75331. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75332. WebGLRenderingContext: WebGLRenderingContext;
  75333. MSGesture: MSGesture;
  75334. CANNON: any;
  75335. AudioContext: AudioContext;
  75336. webkitAudioContext: AudioContext;
  75337. PointerEvent: any;
  75338. Math: Math;
  75339. Uint8Array: Uint8ArrayConstructor;
  75340. Float32Array: Float32ArrayConstructor;
  75341. mozURL: typeof URL;
  75342. msURL: typeof URL;
  75343. VRFrameData: any; // WebVR, from specs 1.1
  75344. DracoDecoderModule: any;
  75345. setImmediate(handler: (...args: any[]) => void): number;
  75346. }
  75347. interface HTMLCanvasElement {
  75348. requestPointerLock(): void;
  75349. msRequestPointerLock?(): void;
  75350. mozRequestPointerLock?(): void;
  75351. webkitRequestPointerLock?(): void;
  75352. /** Track wether a record is in progress */
  75353. isRecording: boolean;
  75354. /** Capture Stream method defined by some browsers */
  75355. captureStream(fps?: number): MediaStream;
  75356. }
  75357. interface CanvasRenderingContext2D {
  75358. msImageSmoothingEnabled: boolean;
  75359. }
  75360. interface MouseEvent {
  75361. mozMovementX: number;
  75362. mozMovementY: number;
  75363. webkitMovementX: number;
  75364. webkitMovementY: number;
  75365. msMovementX: number;
  75366. msMovementY: number;
  75367. }
  75368. interface Navigator {
  75369. mozGetVRDevices: (any: any) => any;
  75370. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75371. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75372. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75373. webkitGetGamepads(): Gamepad[];
  75374. msGetGamepads(): Gamepad[];
  75375. webkitGamepads(): Gamepad[];
  75376. }
  75377. interface HTMLVideoElement {
  75378. mozSrcObject: any;
  75379. }
  75380. interface Math {
  75381. fround(x: number): number;
  75382. imul(a: number, b: number): number;
  75383. }
  75384. interface WebGLRenderingContext {
  75385. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75386. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75387. vertexAttribDivisor(index: number, divisor: number): void;
  75388. createVertexArray(): any;
  75389. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75390. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75391. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75392. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75393. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75394. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75395. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75396. // Queries
  75397. createQuery(): WebGLQuery;
  75398. deleteQuery(query: WebGLQuery): void;
  75399. beginQuery(target: number, query: WebGLQuery): void;
  75400. endQuery(target: number): void;
  75401. getQueryParameter(query: WebGLQuery, pname: number): any;
  75402. getQuery(target: number, pname: number): any;
  75403. MAX_SAMPLES: number;
  75404. RGBA8: number;
  75405. READ_FRAMEBUFFER: number;
  75406. DRAW_FRAMEBUFFER: number;
  75407. UNIFORM_BUFFER: number;
  75408. HALF_FLOAT_OES: number;
  75409. RGBA16F: number;
  75410. RGBA32F: number;
  75411. R32F: number;
  75412. RG32F: number;
  75413. RGB32F: number;
  75414. R16F: number;
  75415. RG16F: number;
  75416. RGB16F: number;
  75417. RED: number;
  75418. RG: number;
  75419. R8: number;
  75420. RG8: number;
  75421. UNSIGNED_INT_24_8: number;
  75422. DEPTH24_STENCIL8: number;
  75423. MIN: number;
  75424. MAX: number;
  75425. /* Multiple Render Targets */
  75426. drawBuffers(buffers: number[]): void;
  75427. readBuffer(src: number): void;
  75428. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75429. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75430. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75431. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75432. // Occlusion Query
  75433. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75434. ANY_SAMPLES_PASSED: number;
  75435. QUERY_RESULT_AVAILABLE: number;
  75436. QUERY_RESULT: number;
  75437. }
  75438. interface WebGLProgram {
  75439. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75440. }
  75441. interface EXT_disjoint_timer_query {
  75442. QUERY_COUNTER_BITS_EXT: number;
  75443. TIME_ELAPSED_EXT: number;
  75444. TIMESTAMP_EXT: number;
  75445. GPU_DISJOINT_EXT: number;
  75446. QUERY_RESULT_EXT: number;
  75447. QUERY_RESULT_AVAILABLE_EXT: number;
  75448. queryCounterEXT(query: WebGLQuery, target: number): void;
  75449. createQueryEXT(): WebGLQuery;
  75450. beginQueryEXT(target: number, query: WebGLQuery): void;
  75451. endQueryEXT(target: number): void;
  75452. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75453. deleteQueryEXT(query: WebGLQuery): void;
  75454. }
  75455. interface WebGLUniformLocation {
  75456. _currentState: any;
  75457. }
  75458. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75459. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75460. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75461. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75462. interface WebGLRenderingContext {
  75463. readonly RASTERIZER_DISCARD: number;
  75464. readonly DEPTH_COMPONENT24: number;
  75465. readonly TEXTURE_3D: number;
  75466. readonly TEXTURE_2D_ARRAY: number;
  75467. readonly TEXTURE_COMPARE_FUNC: number;
  75468. readonly TEXTURE_COMPARE_MODE: number;
  75469. readonly COMPARE_REF_TO_TEXTURE: number;
  75470. readonly TEXTURE_WRAP_R: number;
  75471. readonly HALF_FLOAT: number;
  75472. readonly RGB8: number;
  75473. readonly RED_INTEGER: number;
  75474. readonly RG_INTEGER: number;
  75475. readonly RGB_INTEGER: number;
  75476. readonly RGBA_INTEGER: number;
  75477. readonly R8_SNORM: number;
  75478. readonly RG8_SNORM: number;
  75479. readonly RGB8_SNORM: number;
  75480. readonly RGBA8_SNORM: number;
  75481. readonly R8I: number;
  75482. readonly RG8I: number;
  75483. readonly RGB8I: number;
  75484. readonly RGBA8I: number;
  75485. readonly R8UI: number;
  75486. readonly RG8UI: number;
  75487. readonly RGB8UI: number;
  75488. readonly RGBA8UI: number;
  75489. readonly R16I: number;
  75490. readonly RG16I: number;
  75491. readonly RGB16I: number;
  75492. readonly RGBA16I: number;
  75493. readonly R16UI: number;
  75494. readonly RG16UI: number;
  75495. readonly RGB16UI: number;
  75496. readonly RGBA16UI: number;
  75497. readonly R32I: number;
  75498. readonly RG32I: number;
  75499. readonly RGB32I: number;
  75500. readonly RGBA32I: number;
  75501. readonly R32UI: number;
  75502. readonly RG32UI: number;
  75503. readonly RGB32UI: number;
  75504. readonly RGBA32UI: number;
  75505. readonly RGB10_A2UI: number;
  75506. readonly R11F_G11F_B10F: number;
  75507. readonly RGB9_E5: number;
  75508. readonly RGB10_A2: number;
  75509. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75510. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75511. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75512. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75513. readonly DEPTH_COMPONENT32F: number;
  75514. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75515. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75516. 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;
  75517. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75518. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75519. readonly TRANSFORM_FEEDBACK: number;
  75520. readonly INTERLEAVED_ATTRIBS: number;
  75521. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75522. createTransformFeedback(): WebGLTransformFeedback;
  75523. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75524. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75525. beginTransformFeedback(primitiveMode: number): void;
  75526. endTransformFeedback(): void;
  75527. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75528. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75529. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75530. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75531. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75532. }
  75533. interface ImageBitmap {
  75534. readonly width: number;
  75535. readonly height: number;
  75536. close(): void;
  75537. }
  75538. interface WebGLQuery extends WebGLObject {
  75539. }
  75540. declare var WebGLQuery: {
  75541. prototype: WebGLQuery;
  75542. new(): WebGLQuery;
  75543. };
  75544. interface WebGLSampler extends WebGLObject {
  75545. }
  75546. declare var WebGLSampler: {
  75547. prototype: WebGLSampler;
  75548. new(): WebGLSampler;
  75549. };
  75550. interface WebGLSync extends WebGLObject {
  75551. }
  75552. declare var WebGLSync: {
  75553. prototype: WebGLSync;
  75554. new(): WebGLSync;
  75555. };
  75556. interface WebGLTransformFeedback extends WebGLObject {
  75557. }
  75558. declare var WebGLTransformFeedback: {
  75559. prototype: WebGLTransformFeedback;
  75560. new(): WebGLTransformFeedback;
  75561. };
  75562. interface WebGLVertexArrayObject extends WebGLObject {
  75563. }
  75564. declare var WebGLVertexArrayObject: {
  75565. prototype: WebGLVertexArrayObject;
  75566. new(): WebGLVertexArrayObject;
  75567. };
  75568. // Type definitions for WebVR API
  75569. // Project: https://w3c.github.io/webvr/
  75570. // Definitions by: six a <https://github.com/lostfictions>
  75571. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75572. interface VRDisplay extends EventTarget {
  75573. /**
  75574. * Dictionary of capabilities describing the VRDisplay.
  75575. */
  75576. readonly capabilities: VRDisplayCapabilities;
  75577. /**
  75578. * z-depth defining the far plane of the eye view frustum
  75579. * enables mapping of values in the render target depth
  75580. * attachment to scene coordinates. Initially set to 10000.0.
  75581. */
  75582. depthFar: number;
  75583. /**
  75584. * z-depth defining the near plane of the eye view frustum
  75585. * enables mapping of values in the render target depth
  75586. * attachment to scene coordinates. Initially set to 0.01.
  75587. */
  75588. depthNear: number;
  75589. /**
  75590. * An identifier for this distinct VRDisplay. Used as an
  75591. * association point in the Gamepad API.
  75592. */
  75593. readonly displayId: number;
  75594. /**
  75595. * A display name, a user-readable name identifying it.
  75596. */
  75597. readonly displayName: string;
  75598. readonly isConnected: boolean;
  75599. readonly isPresenting: boolean;
  75600. /**
  75601. * If this VRDisplay supports room-scale experiences, the optional
  75602. * stage attribute contains details on the room-scale parameters.
  75603. */
  75604. readonly stageParameters: VRStageParameters | null;
  75605. /**
  75606. * Passing the value returned by `requestAnimationFrame` to
  75607. * `cancelAnimationFrame` will unregister the callback.
  75608. * @param handle Define the hanle of the request to cancel
  75609. */
  75610. cancelAnimationFrame(handle: number): void;
  75611. /**
  75612. * Stops presenting to the VRDisplay.
  75613. * @returns a promise to know when it stopped
  75614. */
  75615. exitPresent(): Promise<void>;
  75616. /**
  75617. * Return the current VREyeParameters for the given eye.
  75618. * @param whichEye Define the eye we want the parameter for
  75619. * @returns the eye parameters
  75620. */
  75621. getEyeParameters(whichEye: string): VREyeParameters;
  75622. /**
  75623. * Populates the passed VRFrameData with the information required to render
  75624. * the current frame.
  75625. * @param frameData Define the data structure to populate
  75626. * @returns true if ok otherwise false
  75627. */
  75628. getFrameData(frameData: VRFrameData): boolean;
  75629. /**
  75630. * Get the layers currently being presented.
  75631. * @returns the list of VR layers
  75632. */
  75633. getLayers(): VRLayer[];
  75634. /**
  75635. * Return a VRPose containing the future predicted pose of the VRDisplay
  75636. * when the current frame will be presented. The value returned will not
  75637. * change until JavaScript has returned control to the browser.
  75638. *
  75639. * The VRPose will contain the position, orientation, velocity,
  75640. * and acceleration of each of these properties.
  75641. * @returns the pose object
  75642. */
  75643. getPose(): VRPose;
  75644. /**
  75645. * Return the current instantaneous pose of the VRDisplay, with no
  75646. * prediction applied.
  75647. * @returns the current instantaneous pose
  75648. */
  75649. getImmediatePose(): VRPose;
  75650. /**
  75651. * The callback passed to `requestAnimationFrame` will be called
  75652. * any time a new frame should be rendered. When the VRDisplay is
  75653. * presenting the callback will be called at the native refresh
  75654. * rate of the HMD. When not presenting this function acts
  75655. * identically to how window.requestAnimationFrame acts. Content should
  75656. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75657. * asynchronously from other displays and at differing refresh rates.
  75658. * @param callback Define the eaction to run next frame
  75659. * @returns the request handle it
  75660. */
  75661. requestAnimationFrame(callback: FrameRequestCallback): number;
  75662. /**
  75663. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75664. * Repeat calls while already presenting will update the VRLayers being displayed.
  75665. * @param layers Define the list of layer to present
  75666. * @returns a promise to know when the request has been fulfilled
  75667. */
  75668. requestPresent(layers: VRLayer[]): Promise<void>;
  75669. /**
  75670. * Reset the pose for this display, treating its current position and
  75671. * orientation as the "origin/zero" values. VRPose.position,
  75672. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75673. * updated when calling resetPose(). This should be called in only
  75674. * sitting-space experiences.
  75675. */
  75676. resetPose(): void;
  75677. /**
  75678. * The VRLayer provided to the VRDisplay will be captured and presented
  75679. * in the HMD. Calling this function has the same effect on the source
  75680. * canvas as any other operation that uses its source image, and canvases
  75681. * created without preserveDrawingBuffer set to true will be cleared.
  75682. * @param pose Define the pose to submit
  75683. */
  75684. submitFrame(pose?: VRPose): void;
  75685. }
  75686. declare var VRDisplay: {
  75687. prototype: VRDisplay;
  75688. new(): VRDisplay;
  75689. };
  75690. interface VRLayer {
  75691. leftBounds?: number[] | Float32Array | null;
  75692. rightBounds?: number[] | Float32Array | null;
  75693. source?: HTMLCanvasElement | null;
  75694. }
  75695. interface VRDisplayCapabilities {
  75696. readonly canPresent: boolean;
  75697. readonly hasExternalDisplay: boolean;
  75698. readonly hasOrientation: boolean;
  75699. readonly hasPosition: boolean;
  75700. readonly maxLayers: number;
  75701. }
  75702. interface VREyeParameters {
  75703. /** @deprecated */
  75704. readonly fieldOfView: VRFieldOfView;
  75705. readonly offset: Float32Array;
  75706. readonly renderHeight: number;
  75707. readonly renderWidth: number;
  75708. }
  75709. interface VRFieldOfView {
  75710. readonly downDegrees: number;
  75711. readonly leftDegrees: number;
  75712. readonly rightDegrees: number;
  75713. readonly upDegrees: number;
  75714. }
  75715. interface VRFrameData {
  75716. readonly leftProjectionMatrix: Float32Array;
  75717. readonly leftViewMatrix: Float32Array;
  75718. readonly pose: VRPose;
  75719. readonly rightProjectionMatrix: Float32Array;
  75720. readonly rightViewMatrix: Float32Array;
  75721. readonly timestamp: number;
  75722. }
  75723. interface VRPose {
  75724. readonly angularAcceleration: Float32Array | null;
  75725. readonly angularVelocity: Float32Array | null;
  75726. readonly linearAcceleration: Float32Array | null;
  75727. readonly linearVelocity: Float32Array | null;
  75728. readonly orientation: Float32Array | null;
  75729. readonly position: Float32Array | null;
  75730. readonly timestamp: number;
  75731. }
  75732. interface VRStageParameters {
  75733. sittingToStandingTransform?: Float32Array;
  75734. sizeX?: number;
  75735. sizeY?: number;
  75736. }
  75737. interface Navigator {
  75738. getVRDisplays(): Promise<VRDisplay[]>;
  75739. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75740. }
  75741. interface Window {
  75742. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75743. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75744. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75745. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75746. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75747. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75748. }
  75749. interface Gamepad {
  75750. readonly displayId: number;
  75751. }
  75752. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75753. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75754. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75755. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75756. type XRHandedness = "none" | "left" | "right";
  75757. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75758. type XREye = "none" | "left" | "right";
  75759. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75760. interface XRSpace extends EventTarget {}
  75761. interface XRRenderState {
  75762. depthNear?: number;
  75763. depthFar?: number;
  75764. inlineVerticalFieldOfView?: number;
  75765. baseLayer?: XRWebGLLayer;
  75766. }
  75767. interface XRInputSource {
  75768. handedness: XRHandedness;
  75769. targetRayMode: XRTargetRayMode;
  75770. targetRaySpace: XRSpace;
  75771. gripSpace: XRSpace | undefined;
  75772. gamepad: Gamepad | undefined;
  75773. profiles: Array<string>;
  75774. hand: XRHand | undefined;
  75775. }
  75776. interface XRSessionInit {
  75777. optionalFeatures?: string[];
  75778. requiredFeatures?: string[];
  75779. }
  75780. interface XRSession {
  75781. addEventListener: Function;
  75782. removeEventListener: Function;
  75783. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75784. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75785. requestAnimationFrame: Function;
  75786. end(): Promise<void>;
  75787. renderState: XRRenderState;
  75788. inputSources: Array<XRInputSource>;
  75789. // hit test
  75790. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75791. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75792. // legacy AR hit test
  75793. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75794. // legacy plane detection
  75795. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  75796. }
  75797. interface XRReferenceSpace extends XRSpace {
  75798. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75799. onreset: any;
  75800. }
  75801. type XRPlaneSet = Set<XRPlane>;
  75802. type XRAnchorSet = Set<XRAnchor>;
  75803. interface XRFrame {
  75804. session: XRSession;
  75805. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75806. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75807. // AR
  75808. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  75809. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75810. // Anchors
  75811. trackedAnchors?: XRAnchorSet;
  75812. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75813. // Planes
  75814. worldInformation: {
  75815. detectedPlanes?: XRPlaneSet;
  75816. };
  75817. // Hand tracking
  75818. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  75819. }
  75820. interface XRViewerPose extends XRPose {
  75821. views: Array<XRView>;
  75822. }
  75823. interface XRPose {
  75824. transform: XRRigidTransform;
  75825. emulatedPosition: boolean;
  75826. }
  75827. interface XRWebGLLayerOptions {
  75828. antialias?: boolean;
  75829. depth?: boolean;
  75830. stencil?: boolean;
  75831. alpha?: boolean;
  75832. multiview?: boolean;
  75833. framebufferScaleFactor?: number;
  75834. }
  75835. declare var XRWebGLLayer: {
  75836. prototype: XRWebGLLayer;
  75837. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75838. };
  75839. interface XRWebGLLayer {
  75840. framebuffer: WebGLFramebuffer;
  75841. framebufferWidth: number;
  75842. framebufferHeight: number;
  75843. getViewport: Function;
  75844. }
  75845. declare class XRRigidTransform {
  75846. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75847. position: DOMPointReadOnly;
  75848. orientation: DOMPointReadOnly;
  75849. matrix: Float32Array;
  75850. inverse: XRRigidTransform;
  75851. }
  75852. interface XRView {
  75853. eye: XREye;
  75854. projectionMatrix: Float32Array;
  75855. transform: XRRigidTransform;
  75856. }
  75857. interface XRInputSourceChangeEvent {
  75858. session: XRSession;
  75859. removed: Array<XRInputSource>;
  75860. added: Array<XRInputSource>;
  75861. }
  75862. interface XRInputSourceEvent extends Event {
  75863. readonly frame: XRFrame;
  75864. readonly inputSource: XRInputSource;
  75865. }
  75866. // Experimental(er) features
  75867. declare class XRRay {
  75868. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75869. origin: DOMPointReadOnly;
  75870. direction: DOMPointReadOnly;
  75871. matrix: Float32Array;
  75872. }
  75873. declare enum XRHitTestTrackableType {
  75874. "point",
  75875. "plane",
  75876. "mesh",
  75877. }
  75878. interface XRHitResult {
  75879. hitMatrix: Float32Array;
  75880. }
  75881. interface XRTransientInputHitTestResult {
  75882. readonly inputSource: XRInputSource;
  75883. readonly results: Array<XRHitTestResult>;
  75884. }
  75885. interface XRHitTestResult {
  75886. getPose(baseSpace: XRSpace): XRPose | undefined;
  75887. // When anchor system is enabled
  75888. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75889. }
  75890. interface XRHitTestSource {
  75891. cancel(): void;
  75892. }
  75893. interface XRTransientInputHitTestSource {
  75894. cancel(): void;
  75895. }
  75896. interface XRHitTestOptionsInit {
  75897. space: XRSpace;
  75898. entityTypes?: Array<XRHitTestTrackableType>;
  75899. offsetRay?: XRRay;
  75900. }
  75901. interface XRTransientInputHitTestOptionsInit {
  75902. profile: string;
  75903. entityTypes?: Array<XRHitTestTrackableType>;
  75904. offsetRay?: XRRay;
  75905. }
  75906. interface XRAnchor {
  75907. anchorSpace: XRSpace;
  75908. delete(): void;
  75909. }
  75910. interface XRPlane {
  75911. orientation: "Horizontal" | "Vertical";
  75912. planeSpace: XRSpace;
  75913. polygon: Array<DOMPointReadOnly>;
  75914. lastChangedTime: number;
  75915. }
  75916. interface XRJointSpace extends XRSpace {}
  75917. interface XRJointPose extends XRPose {
  75918. radius: number | undefined;
  75919. }
  75920. declare class XRHand extends Array<XRJointSpace> {
  75921. readonly length: number;
  75922. static readonly WRIST = 0;
  75923. static readonly THUMB_METACARPAL = 1;
  75924. static readonly THUMB_PHALANX_PROXIMAL = 2;
  75925. static readonly THUMB_PHALANX_DISTAL = 3;
  75926. static readonly THUMB_PHALANX_TIP = 4;
  75927. static readonly INDEX_METACARPAL = 5;
  75928. static readonly INDEX_PHALANX_PROXIMAL = 6;
  75929. static readonly INDEX_PHALANX_INTERMEDIATE = 7;
  75930. static readonly INDEX_PHALANX_DISTAL = 8;
  75931. static readonly INDEX_PHALANX_TIP = 9;
  75932. static readonly MIDDLE_METACARPAL = 10;
  75933. static readonly MIDDLE_PHALANX_PROXIMAL = 11;
  75934. static readonly MIDDLE_PHALANX_INTERMEDIATE = 12;
  75935. static readonly MIDDLE_PHALANX_DISTAL = 13;
  75936. static readonly MIDDLE_PHALANX_TIP = 14;
  75937. static readonly RING_METACARPAL = 15;
  75938. static readonly RING_PHALANX_PROXIMAL = 16;
  75939. static readonly RING_PHALANX_INTERMEDIATE = 17;
  75940. static readonly RING_PHALANX_DISTAL = 18;
  75941. static readonly RING_PHALANX_TIP = 19;
  75942. static readonly LITTLE_METACARPAL = 20;
  75943. static readonly LITTLE_PHALANX_PROXIMAL = 21;
  75944. static readonly LITTLE_PHALANX_INTERMEDIATE = 22;
  75945. static readonly LITTLE_PHALANX_DISTAL = 23;
  75946. static readonly LITTLE_PHALANX_TIP = 24;
  75947. }
  75948. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  75949. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  75950. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  75951. interface XRSession {
  75952. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  75953. }
  75954. interface XRFrame {
  75955. featurePointCloud? : Array<number>;
  75956. }
  75957. /**
  75958. * @ignore
  75959. */
  75960. declare module BABYLON.GLTF2.Exporter {
  75961. }
  75962. /**
  75963. * @ignore
  75964. */
  75965. declare module BABYLON.GLTF1 {
  75966. }
  75967. declare module BABYLON.GUI {
  75968. /**
  75969. * Class used to specific a value and its associated unit
  75970. */
  75971. export class ValueAndUnit {
  75972. /** defines the unit to store */
  75973. unit: number;
  75974. /** defines a boolean indicating if the value can be negative */
  75975. negativeValueAllowed: boolean;
  75976. private _value;
  75977. private _originalUnit;
  75978. /**
  75979. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75980. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75981. */
  75982. ignoreAdaptiveScaling: boolean;
  75983. /**
  75984. * Creates a new ValueAndUnit
  75985. * @param value defines the value to store
  75986. * @param unit defines the unit to store
  75987. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75988. */
  75989. constructor(value: number,
  75990. /** defines the unit to store */
  75991. unit?: number,
  75992. /** defines a boolean indicating if the value can be negative */
  75993. negativeValueAllowed?: boolean);
  75994. /** Gets a boolean indicating if the value is a percentage */
  75995. get isPercentage(): boolean;
  75996. /** Gets a boolean indicating if the value is store as pixel */
  75997. get isPixel(): boolean;
  75998. /** Gets direct internal value */
  75999. get internalValue(): number;
  76000. /**
  76001. * Gets value as pixel
  76002. * @param host defines the root host
  76003. * @param refValue defines the reference value for percentages
  76004. * @returns the value as pixel
  76005. */
  76006. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76007. /**
  76008. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76009. * @param value defines the value to store
  76010. * @param unit defines the unit to store
  76011. * @returns the current ValueAndUnit
  76012. */
  76013. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76014. /**
  76015. * Gets the value accordingly to its unit
  76016. * @param host defines the root host
  76017. * @returns the value
  76018. */
  76019. getValue(host: AdvancedDynamicTexture): number;
  76020. /**
  76021. * Gets a string representation of the value
  76022. * @param host defines the root host
  76023. * @param decimals defines an optional number of decimals to display
  76024. * @returns a string
  76025. */
  76026. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76027. /**
  76028. * Store a value parsed from a string
  76029. * @param source defines the source string
  76030. * @returns true if the value was successfully parsed
  76031. */
  76032. fromString(source: string | number): boolean;
  76033. private static _Regex;
  76034. private static _UNITMODE_PERCENTAGE;
  76035. private static _UNITMODE_PIXEL;
  76036. /** UNITMODE_PERCENTAGE */
  76037. static get UNITMODE_PERCENTAGE(): number;
  76038. /** UNITMODE_PIXEL */
  76039. static get UNITMODE_PIXEL(): number;
  76040. }
  76041. }
  76042. declare module BABYLON.GUI {
  76043. /**
  76044. * Define a style used by control to automatically setup properties based on a template.
  76045. * Only support font related properties so far
  76046. */
  76047. export class Style implements BABYLON.IDisposable {
  76048. private _fontFamily;
  76049. private _fontStyle;
  76050. private _fontWeight;
  76051. /** @hidden */
  76052. _host: AdvancedDynamicTexture;
  76053. /** @hidden */
  76054. _fontSize: ValueAndUnit;
  76055. /**
  76056. * BABYLON.Observable raised when the style values are changed
  76057. */
  76058. onChangedObservable: BABYLON.Observable<Style>;
  76059. /**
  76060. * Creates a new style object
  76061. * @param host defines the AdvancedDynamicTexture which hosts this style
  76062. */
  76063. constructor(host: AdvancedDynamicTexture);
  76064. /**
  76065. * Gets or sets the font size
  76066. */
  76067. get fontSize(): string | number;
  76068. set fontSize(value: string | number);
  76069. /**
  76070. * Gets or sets the font family
  76071. */
  76072. get fontFamily(): string;
  76073. set fontFamily(value: string);
  76074. /**
  76075. * Gets or sets the font style
  76076. */
  76077. get fontStyle(): string;
  76078. set fontStyle(value: string);
  76079. /** Gets or sets font weight */
  76080. get fontWeight(): string;
  76081. set fontWeight(value: string);
  76082. /** Dispose all associated resources */
  76083. dispose(): void;
  76084. }
  76085. }
  76086. declare module BABYLON.GUI {
  76087. /**
  76088. * Class used to transport BABYLON.Vector2 information for pointer events
  76089. */
  76090. export class Vector2WithInfo extends BABYLON.Vector2 {
  76091. /** defines the current mouse button index */
  76092. buttonIndex: number;
  76093. /**
  76094. * Creates a new Vector2WithInfo
  76095. * @param source defines the vector2 data to transport
  76096. * @param buttonIndex defines the current mouse button index
  76097. */
  76098. constructor(source: BABYLON.Vector2,
  76099. /** defines the current mouse button index */
  76100. buttonIndex?: number);
  76101. }
  76102. /** Class used to provide 2D matrix features */
  76103. export class Matrix2D {
  76104. /** Gets the internal array of 6 floats used to store matrix data */
  76105. m: Float32Array;
  76106. /**
  76107. * Creates a new matrix
  76108. * @param m00 defines value for (0, 0)
  76109. * @param m01 defines value for (0, 1)
  76110. * @param m10 defines value for (1, 0)
  76111. * @param m11 defines value for (1, 1)
  76112. * @param m20 defines value for (2, 0)
  76113. * @param m21 defines value for (2, 1)
  76114. */
  76115. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76116. /**
  76117. * Fills the matrix from direct values
  76118. * @param m00 defines value for (0, 0)
  76119. * @param m01 defines value for (0, 1)
  76120. * @param m10 defines value for (1, 0)
  76121. * @param m11 defines value for (1, 1)
  76122. * @param m20 defines value for (2, 0)
  76123. * @param m21 defines value for (2, 1)
  76124. * @returns the current modified matrix
  76125. */
  76126. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76127. /**
  76128. * Gets matrix determinant
  76129. * @returns the determinant
  76130. */
  76131. determinant(): number;
  76132. /**
  76133. * Inverses the matrix and stores it in a target matrix
  76134. * @param result defines the target matrix
  76135. * @returns the current matrix
  76136. */
  76137. invertToRef(result: Matrix2D): Matrix2D;
  76138. /**
  76139. * Multiplies the current matrix with another one
  76140. * @param other defines the second operand
  76141. * @param result defines the target matrix
  76142. * @returns the current matrix
  76143. */
  76144. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76145. /**
  76146. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76147. * @param x defines the x coordinate to transform
  76148. * @param y defines the x coordinate to transform
  76149. * @param result defines the target vector2
  76150. * @returns the current matrix
  76151. */
  76152. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76153. /**
  76154. * Creates an identity matrix
  76155. * @returns a new matrix
  76156. */
  76157. static Identity(): Matrix2D;
  76158. /**
  76159. * Creates a translation matrix and stores it in a target matrix
  76160. * @param x defines the x coordinate of the translation
  76161. * @param y defines the y coordinate of the translation
  76162. * @param result defines the target matrix
  76163. */
  76164. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76165. /**
  76166. * Creates a scaling matrix and stores it in a target matrix
  76167. * @param x defines the x coordinate of the scaling
  76168. * @param y defines the y coordinate of the scaling
  76169. * @param result defines the target matrix
  76170. */
  76171. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76172. /**
  76173. * Creates a rotation matrix and stores it in a target matrix
  76174. * @param angle defines the rotation angle
  76175. * @param result defines the target matrix
  76176. */
  76177. static RotationToRef(angle: number, result: Matrix2D): void;
  76178. private static _TempPreTranslationMatrix;
  76179. private static _TempPostTranslationMatrix;
  76180. private static _TempRotationMatrix;
  76181. private static _TempScalingMatrix;
  76182. private static _TempCompose0;
  76183. private static _TempCompose1;
  76184. private static _TempCompose2;
  76185. /**
  76186. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76187. * @param tx defines the x coordinate of the translation
  76188. * @param ty defines the y coordinate of the translation
  76189. * @param angle defines the rotation angle
  76190. * @param scaleX defines the x coordinate of the scaling
  76191. * @param scaleY defines the y coordinate of the scaling
  76192. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76193. * @param result defines the target matrix
  76194. */
  76195. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76196. }
  76197. }
  76198. declare module BABYLON.GUI {
  76199. /**
  76200. * Class used to store 2D control sizes
  76201. */
  76202. export class Measure {
  76203. /** defines left coordinate */
  76204. left: number;
  76205. /** defines top coordinate */
  76206. top: number;
  76207. /** defines width dimension */
  76208. width: number;
  76209. /** defines height dimension */
  76210. height: number;
  76211. /**
  76212. * Creates a new measure
  76213. * @param left defines left coordinate
  76214. * @param top defines top coordinate
  76215. * @param width defines width dimension
  76216. * @param height defines height dimension
  76217. */
  76218. constructor(
  76219. /** defines left coordinate */
  76220. left: number,
  76221. /** defines top coordinate */
  76222. top: number,
  76223. /** defines width dimension */
  76224. width: number,
  76225. /** defines height dimension */
  76226. height: number);
  76227. /**
  76228. * Copy from another measure
  76229. * @param other defines the other measure to copy from
  76230. */
  76231. copyFrom(other: Measure): void;
  76232. /**
  76233. * Copy from a group of 4 floats
  76234. * @param left defines left coordinate
  76235. * @param top defines top coordinate
  76236. * @param width defines width dimension
  76237. * @param height defines height dimension
  76238. */
  76239. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76240. /**
  76241. * Computes the axis aligned bounding box measure for two given measures
  76242. * @param a Input measure
  76243. * @param b Input measure
  76244. * @param result the resulting bounding measure
  76245. */
  76246. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76247. /**
  76248. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76249. * @param transform the matrix to transform the measure before computing the AABB
  76250. * @param addX number to add to left
  76251. * @param addY number to add to top
  76252. * @param addWidth number to add to width
  76253. * @param addHeight number to add to height
  76254. * @param result the resulting AABB
  76255. */
  76256. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76257. /**
  76258. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76259. * @param transform the matrix to transform the measure before computing the AABB
  76260. * @param result the resulting AABB
  76261. */
  76262. transformToRef(transform: Matrix2D, result: Measure): void;
  76263. /**
  76264. * Check equality between this measure and another one
  76265. * @param other defines the other measures
  76266. * @returns true if both measures are equals
  76267. */
  76268. isEqualsTo(other: Measure): boolean;
  76269. /**
  76270. * Creates an empty measure
  76271. * @returns a new measure
  76272. */
  76273. static Empty(): Measure;
  76274. }
  76275. }
  76276. declare module BABYLON.GUI {
  76277. /**
  76278. * Interface used to define a control that can receive focus
  76279. */
  76280. export interface IFocusableControl {
  76281. /**
  76282. * Function called when the control receives the focus
  76283. */
  76284. onFocus(): void;
  76285. /**
  76286. * Function called when the control loses the focus
  76287. */
  76288. onBlur(): void;
  76289. /**
  76290. * Function called to let the control handle keyboard events
  76291. * @param evt defines the current keyboard event
  76292. */
  76293. processKeyboard(evt: KeyboardEvent): void;
  76294. /**
  76295. * Function called to get the list of controls that should not steal the focus from this control
  76296. * @returns an array of controls
  76297. */
  76298. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76299. }
  76300. /**
  76301. * Class used to create texture to support 2D GUI elements
  76302. * @see https://doc.babylonjs.com/how_to/gui
  76303. */
  76304. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76305. private _isDirty;
  76306. private _renderObserver;
  76307. private _resizeObserver;
  76308. private _preKeyboardObserver;
  76309. private _pointerMoveObserver;
  76310. private _pointerObserver;
  76311. private _canvasPointerOutObserver;
  76312. private _canvasBlurObserver;
  76313. private _background;
  76314. /** @hidden */
  76315. _rootContainer: Container;
  76316. /** @hidden */
  76317. _lastPickedControl: Control;
  76318. /** @hidden */
  76319. _lastControlOver: {
  76320. [pointerId: number]: Control;
  76321. };
  76322. /** @hidden */
  76323. _lastControlDown: {
  76324. [pointerId: number]: Control;
  76325. };
  76326. /** @hidden */
  76327. _capturingControl: {
  76328. [pointerId: number]: Control;
  76329. };
  76330. /** @hidden */
  76331. _shouldBlockPointer: boolean;
  76332. /** @hidden */
  76333. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76334. /** @hidden */
  76335. _linkedControls: Control[];
  76336. private _isFullscreen;
  76337. private _fullscreenViewport;
  76338. private _idealWidth;
  76339. private _idealHeight;
  76340. private _useSmallestIdeal;
  76341. private _renderAtIdealSize;
  76342. private _focusedControl;
  76343. private _blockNextFocusCheck;
  76344. private _renderScale;
  76345. private _rootElement;
  76346. private _cursorChanged;
  76347. private _defaultMousePointerId;
  76348. /** @hidden */
  76349. _numLayoutCalls: number;
  76350. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76351. get numLayoutCalls(): number;
  76352. /** @hidden */
  76353. _numRenderCalls: number;
  76354. /** Gets the number of render calls made the last time the ADT has been rendered */
  76355. get numRenderCalls(): number;
  76356. /**
  76357. * Define type to string to ensure compatibility across browsers
  76358. * Safari doesn't support DataTransfer constructor
  76359. */
  76360. private _clipboardData;
  76361. /**
  76362. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76363. */
  76364. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76365. /**
  76366. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76367. */
  76368. onControlPickedObservable: BABYLON.Observable<Control>;
  76369. /**
  76370. * BABYLON.Observable event triggered before layout is evaluated
  76371. */
  76372. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76373. /**
  76374. * BABYLON.Observable event triggered after the layout was evaluated
  76375. */
  76376. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76377. /**
  76378. * BABYLON.Observable event triggered before the texture is rendered
  76379. */
  76380. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76381. /**
  76382. * BABYLON.Observable event triggered after the texture was rendered
  76383. */
  76384. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76385. /**
  76386. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76387. */
  76388. premulAlpha: boolean;
  76389. /**
  76390. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76391. * Useful when you want more antialiasing
  76392. */
  76393. get renderScale(): number;
  76394. set renderScale(value: number);
  76395. /** Gets or sets the background color */
  76396. get background(): string;
  76397. set background(value: string);
  76398. /**
  76399. * Gets or sets the ideal width used to design controls.
  76400. * The GUI will then rescale everything accordingly
  76401. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76402. */
  76403. get idealWidth(): number;
  76404. set idealWidth(value: number);
  76405. /**
  76406. * Gets or sets the ideal height used to design controls.
  76407. * The GUI will then rescale everything accordingly
  76408. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76409. */
  76410. get idealHeight(): number;
  76411. set idealHeight(value: number);
  76412. /**
  76413. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76414. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76415. */
  76416. get useSmallestIdeal(): boolean;
  76417. set useSmallestIdeal(value: boolean);
  76418. /**
  76419. * Gets or sets a boolean indicating if adaptive scaling must be used
  76420. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76421. */
  76422. get renderAtIdealSize(): boolean;
  76423. set renderAtIdealSize(value: boolean);
  76424. /**
  76425. * Gets the ratio used when in "ideal mode"
  76426. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76427. * */
  76428. get idealRatio(): number;
  76429. /**
  76430. * Gets the underlying layer used to render the texture when in fullscreen mode
  76431. */
  76432. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76433. /**
  76434. * Gets the root container control
  76435. */
  76436. get rootContainer(): Container;
  76437. /**
  76438. * Returns an array containing the root container.
  76439. * This is mostly used to let the Inspector introspects the ADT
  76440. * @returns an array containing the rootContainer
  76441. */
  76442. getChildren(): Array<Container>;
  76443. /**
  76444. * Will return all controls that are inside this texture
  76445. * @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
  76446. * @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
  76447. * @return all child controls
  76448. */
  76449. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76450. /**
  76451. * Gets or sets the current focused control
  76452. */
  76453. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76454. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76455. /**
  76456. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76457. */
  76458. get isForeground(): boolean;
  76459. set isForeground(value: boolean);
  76460. /**
  76461. * Gets or set information about clipboardData
  76462. */
  76463. get clipboardData(): string;
  76464. set clipboardData(value: string);
  76465. /**
  76466. * Creates a new AdvancedDynamicTexture
  76467. * @param name defines the name of the texture
  76468. * @param width defines the width of the texture
  76469. * @param height defines the height of the texture
  76470. * @param scene defines the hosting scene
  76471. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76472. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76473. */
  76474. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76475. /**
  76476. * Get the current class name of the texture useful for serialization or dynamic coding.
  76477. * @returns "AdvancedDynamicTexture"
  76478. */
  76479. getClassName(): string;
  76480. /**
  76481. * Function used to execute a function on all controls
  76482. * @param func defines the function to execute
  76483. * @param container defines the container where controls belong. If null the root container will be used
  76484. */
  76485. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76486. private _useInvalidateRectOptimization;
  76487. /**
  76488. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76489. */
  76490. get useInvalidateRectOptimization(): boolean;
  76491. set useInvalidateRectOptimization(value: boolean);
  76492. private _invalidatedRectangle;
  76493. /**
  76494. * Invalidates a rectangle area on the gui texture
  76495. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76496. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76497. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76498. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76499. */
  76500. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76501. /**
  76502. * Marks the texture as dirty forcing a complete update
  76503. */
  76504. markAsDirty(): void;
  76505. /**
  76506. * Helper function used to create a new style
  76507. * @returns a new style
  76508. * @see https://doc.babylonjs.com/how_to/gui#styles
  76509. */
  76510. createStyle(): Style;
  76511. /**
  76512. * Adds a new control to the root container
  76513. * @param control defines the control to add
  76514. * @returns the current texture
  76515. */
  76516. addControl(control: Control): AdvancedDynamicTexture;
  76517. /**
  76518. * Removes a control from the root container
  76519. * @param control defines the control to remove
  76520. * @returns the current texture
  76521. */
  76522. removeControl(control: Control): AdvancedDynamicTexture;
  76523. /**
  76524. * Release all resources
  76525. */
  76526. dispose(): void;
  76527. private _onResize;
  76528. /** @hidden */
  76529. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76530. /**
  76531. * Get screen coordinates for a vector3
  76532. * @param position defines the position to project
  76533. * @param worldMatrix defines the world matrix to use
  76534. * @returns the projected position
  76535. */
  76536. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76537. private _checkUpdate;
  76538. private _clearMeasure;
  76539. private _render;
  76540. /** @hidden */
  76541. _changeCursor(cursor: string): void;
  76542. /** @hidden */
  76543. _registerLastControlDown(control: Control, pointerId: number): void;
  76544. private _doPicking;
  76545. /** @hidden */
  76546. _cleanControlAfterRemovalFromList(list: {
  76547. [pointerId: number]: Control;
  76548. }, control: Control): void;
  76549. /** @hidden */
  76550. _cleanControlAfterRemoval(control: Control): void;
  76551. /** Attach to all scene events required to support pointer events */
  76552. attach(): void;
  76553. /** @hidden */
  76554. private onClipboardCopy;
  76555. /** @hidden */
  76556. private onClipboardCut;
  76557. /** @hidden */
  76558. private onClipboardPaste;
  76559. /**
  76560. * Register the clipboard Events onto the canvas
  76561. */
  76562. registerClipboardEvents(): void;
  76563. /**
  76564. * Unregister the clipboard Events from the canvas
  76565. */
  76566. unRegisterClipboardEvents(): void;
  76567. /**
  76568. * Connect the texture to a hosting mesh to enable interactions
  76569. * @param mesh defines the mesh to attach to
  76570. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76571. */
  76572. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76573. /**
  76574. * Move the focus to a specific control
  76575. * @param control defines the control which will receive the focus
  76576. */
  76577. moveFocusToControl(control: IFocusableControl): void;
  76578. private _manageFocus;
  76579. private _attachToOnPointerOut;
  76580. private _attachToOnBlur;
  76581. /**
  76582. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76583. * @param mesh defines the mesh which will receive the texture
  76584. * @param width defines the texture width (1024 by default)
  76585. * @param height defines the texture height (1024 by default)
  76586. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76587. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76588. * @returns a new AdvancedDynamicTexture
  76589. */
  76590. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76591. /**
  76592. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76593. * In this mode the texture will rely on a layer for its rendering.
  76594. * This allows it to be treated like any other layer.
  76595. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76596. * LayerMask is set through advancedTexture.layer.layerMask
  76597. * @param name defines name for the texture
  76598. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76599. * @param scene defines the hsoting scene
  76600. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76601. * @returns a new AdvancedDynamicTexture
  76602. */
  76603. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76604. }
  76605. }
  76606. declare module BABYLON.GUI {
  76607. /**
  76608. * Root class used for all 2D controls
  76609. * @see https://doc.babylonjs.com/how_to/gui#controls
  76610. */
  76611. export class Control {
  76612. /** defines the name of the control */
  76613. name?: string | undefined;
  76614. /**
  76615. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76616. */
  76617. static AllowAlphaInheritance: boolean;
  76618. private _alpha;
  76619. private _alphaSet;
  76620. private _zIndex;
  76621. /** @hidden */
  76622. _host: AdvancedDynamicTexture;
  76623. /** Gets or sets the control parent */
  76624. parent: BABYLON.Nullable<Container>;
  76625. /** @hidden */
  76626. _currentMeasure: Measure;
  76627. private _fontFamily;
  76628. private _fontStyle;
  76629. private _fontWeight;
  76630. private _fontSize;
  76631. private _font;
  76632. /** @hidden */
  76633. _width: ValueAndUnit;
  76634. /** @hidden */
  76635. _height: ValueAndUnit;
  76636. /** @hidden */
  76637. protected _fontOffset: {
  76638. ascent: number;
  76639. height: number;
  76640. descent: number;
  76641. };
  76642. private _color;
  76643. private _style;
  76644. private _styleObserver;
  76645. /** @hidden */
  76646. protected _horizontalAlignment: number;
  76647. /** @hidden */
  76648. protected _verticalAlignment: number;
  76649. /** @hidden */
  76650. protected _isDirty: boolean;
  76651. /** @hidden */
  76652. protected _wasDirty: boolean;
  76653. /** @hidden */
  76654. _tempParentMeasure: Measure;
  76655. /** @hidden */
  76656. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76657. /** @hidden */
  76658. protected _cachedParentMeasure: Measure;
  76659. private _paddingLeft;
  76660. private _paddingRight;
  76661. private _paddingTop;
  76662. private _paddingBottom;
  76663. /** @hidden */
  76664. _left: ValueAndUnit;
  76665. /** @hidden */
  76666. _top: ValueAndUnit;
  76667. private _scaleX;
  76668. private _scaleY;
  76669. private _rotation;
  76670. private _transformCenterX;
  76671. private _transformCenterY;
  76672. /** @hidden */
  76673. _transformMatrix: Matrix2D;
  76674. /** @hidden */
  76675. protected _invertTransformMatrix: Matrix2D;
  76676. /** @hidden */
  76677. protected _transformedPosition: BABYLON.Vector2;
  76678. private _isMatrixDirty;
  76679. private _cachedOffsetX;
  76680. private _cachedOffsetY;
  76681. private _isVisible;
  76682. private _isHighlighted;
  76683. /** @hidden */
  76684. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76685. private _fontSet;
  76686. private _dummyVector2;
  76687. private _downCount;
  76688. private _enterCount;
  76689. private _doNotRender;
  76690. private _downPointerIds;
  76691. protected _isEnabled: boolean;
  76692. protected _disabledColor: string;
  76693. protected _disabledColorItem: string;
  76694. /** @hidden */
  76695. protected _rebuildLayout: boolean;
  76696. /** @hidden */
  76697. _customData: any;
  76698. /** @hidden */
  76699. _isClipped: boolean;
  76700. /** @hidden */
  76701. _automaticSize: boolean;
  76702. /** @hidden */
  76703. _tag: any;
  76704. /**
  76705. * 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
  76706. */
  76707. uniqueId: number;
  76708. /**
  76709. * Gets or sets an object used to store user defined information for the node
  76710. */
  76711. metadata: any;
  76712. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76713. isHitTestVisible: boolean;
  76714. /** Gets or sets a boolean indicating if the control can block pointer events */
  76715. isPointerBlocker: boolean;
  76716. /** Gets or sets a boolean indicating if the control can be focusable */
  76717. isFocusInvisible: boolean;
  76718. /**
  76719. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76720. * 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
  76721. */
  76722. clipChildren: boolean;
  76723. /**
  76724. * Gets or sets a boolean indicating that control content must be clipped
  76725. * 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
  76726. */
  76727. clipContent: boolean;
  76728. /**
  76729. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76730. */
  76731. useBitmapCache: boolean;
  76732. private _cacheData;
  76733. private _shadowOffsetX;
  76734. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76735. get shadowOffsetX(): number;
  76736. set shadowOffsetX(value: number);
  76737. private _shadowOffsetY;
  76738. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76739. get shadowOffsetY(): number;
  76740. set shadowOffsetY(value: number);
  76741. private _shadowBlur;
  76742. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76743. get shadowBlur(): number;
  76744. set shadowBlur(value: number);
  76745. private _shadowColor;
  76746. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76747. get shadowColor(): string;
  76748. set shadowColor(value: string);
  76749. /** Gets or sets the cursor to use when the control is hovered */
  76750. hoverCursor: string;
  76751. /** @hidden */
  76752. protected _linkOffsetX: ValueAndUnit;
  76753. /** @hidden */
  76754. protected _linkOffsetY: ValueAndUnit;
  76755. /** Gets the control type name */
  76756. get typeName(): string;
  76757. /**
  76758. * Get the current class name of the control.
  76759. * @returns current class name
  76760. */
  76761. getClassName(): string;
  76762. /**
  76763. * An event triggered when pointer wheel is scrolled
  76764. */
  76765. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76766. /**
  76767. * An event triggered when the pointer move over the control.
  76768. */
  76769. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76770. /**
  76771. * An event triggered when the pointer move out of the control.
  76772. */
  76773. onPointerOutObservable: BABYLON.Observable<Control>;
  76774. /**
  76775. * An event triggered when the pointer taps the control
  76776. */
  76777. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76778. /**
  76779. * An event triggered when pointer up
  76780. */
  76781. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76782. /**
  76783. * An event triggered when a control is clicked on
  76784. */
  76785. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76786. /**
  76787. * An event triggered when pointer enters the control
  76788. */
  76789. onPointerEnterObservable: BABYLON.Observable<Control>;
  76790. /**
  76791. * An event triggered when the control is marked as dirty
  76792. */
  76793. onDirtyObservable: BABYLON.Observable<Control>;
  76794. /**
  76795. * An event triggered before drawing the control
  76796. */
  76797. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76798. /**
  76799. * An event triggered after the control was drawn
  76800. */
  76801. onAfterDrawObservable: BABYLON.Observable<Control>;
  76802. /**
  76803. * An event triggered when the control has been disposed
  76804. */
  76805. onDisposeObservable: BABYLON.Observable<Control>;
  76806. /**
  76807. * Get the hosting AdvancedDynamicTexture
  76808. */
  76809. get host(): AdvancedDynamicTexture;
  76810. /** Gets or set information about font offsets (used to render and align text) */
  76811. get fontOffset(): {
  76812. ascent: number;
  76813. height: number;
  76814. descent: number;
  76815. };
  76816. set fontOffset(offset: {
  76817. ascent: number;
  76818. height: number;
  76819. descent: number;
  76820. });
  76821. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76822. get alpha(): number;
  76823. set alpha(value: number);
  76824. /**
  76825. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76826. */
  76827. get isHighlighted(): boolean;
  76828. set isHighlighted(value: boolean);
  76829. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76830. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76831. */
  76832. get scaleX(): number;
  76833. set scaleX(value: number);
  76834. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76835. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76836. */
  76837. get scaleY(): number;
  76838. set scaleY(value: number);
  76839. /** Gets or sets the rotation angle (0 by default)
  76840. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76841. */
  76842. get rotation(): number;
  76843. set rotation(value: number);
  76844. /** Gets or sets the transformation center on Y axis (0 by default)
  76845. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76846. */
  76847. get transformCenterY(): number;
  76848. set transformCenterY(value: number);
  76849. /** Gets or sets the transformation center on X axis (0 by default)
  76850. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76851. */
  76852. get transformCenterX(): number;
  76853. set transformCenterX(value: number);
  76854. /**
  76855. * Gets or sets the horizontal alignment
  76856. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76857. */
  76858. get horizontalAlignment(): number;
  76859. set horizontalAlignment(value: number);
  76860. /**
  76861. * Gets or sets the vertical alignment
  76862. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76863. */
  76864. get verticalAlignment(): number;
  76865. set verticalAlignment(value: number);
  76866. /**
  76867. * Gets or sets a fixed ratio for this control.
  76868. * When different from 0, the ratio is used to compute the "second" dimension.
  76869. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76870. * second dimension is computed as first dimension * fixedRatio
  76871. */
  76872. fixedRatio: number;
  76873. private _fixedRatioMasterIsWidth;
  76874. /**
  76875. * Gets or sets control width
  76876. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76877. */
  76878. get width(): string | number;
  76879. set width(value: string | number);
  76880. /**
  76881. * Gets or sets the control width in pixel
  76882. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76883. */
  76884. get widthInPixels(): number;
  76885. set widthInPixels(value: number);
  76886. /**
  76887. * Gets or sets control height
  76888. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76889. */
  76890. get height(): string | number;
  76891. set height(value: string | number);
  76892. /**
  76893. * Gets or sets control height in pixel
  76894. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76895. */
  76896. get heightInPixels(): number;
  76897. set heightInPixels(value: number);
  76898. /** Gets or set font family */
  76899. get fontFamily(): string;
  76900. set fontFamily(value: string);
  76901. /** Gets or sets font style */
  76902. get fontStyle(): string;
  76903. set fontStyle(value: string);
  76904. /** Gets or sets font weight */
  76905. get fontWeight(): string;
  76906. set fontWeight(value: string);
  76907. /**
  76908. * Gets or sets style
  76909. * @see https://doc.babylonjs.com/how_to/gui#styles
  76910. */
  76911. get style(): BABYLON.Nullable<Style>;
  76912. set style(value: BABYLON.Nullable<Style>);
  76913. /** @hidden */
  76914. get _isFontSizeInPercentage(): boolean;
  76915. /** Gets or sets font size in pixels */
  76916. get fontSizeInPixels(): number;
  76917. set fontSizeInPixels(value: number);
  76918. /** Gets or sets font size */
  76919. get fontSize(): string | number;
  76920. set fontSize(value: string | number);
  76921. /** Gets or sets foreground color */
  76922. get color(): string;
  76923. set color(value: string);
  76924. /** Gets or sets z index which is used to reorder controls on the z axis */
  76925. get zIndex(): number;
  76926. set zIndex(value: number);
  76927. /** Gets or sets a boolean indicating if the control can be rendered */
  76928. get notRenderable(): boolean;
  76929. set notRenderable(value: boolean);
  76930. /** Gets or sets a boolean indicating if the control is visible */
  76931. get isVisible(): boolean;
  76932. set isVisible(value: boolean);
  76933. /** Gets a boolean indicating that the control needs to update its rendering */
  76934. get isDirty(): boolean;
  76935. /**
  76936. * Gets the current linked mesh (or null if none)
  76937. */
  76938. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76939. /**
  76940. * Gets or sets a value indicating the padding to use on the left of the control
  76941. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76942. */
  76943. get paddingLeft(): string | number;
  76944. set paddingLeft(value: string | number);
  76945. /**
  76946. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76947. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76948. */
  76949. get paddingLeftInPixels(): number;
  76950. set paddingLeftInPixels(value: number);
  76951. /**
  76952. * Gets or sets a value indicating the padding to use on the right of the control
  76953. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76954. */
  76955. get paddingRight(): string | number;
  76956. set paddingRight(value: string | number);
  76957. /**
  76958. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76959. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76960. */
  76961. get paddingRightInPixels(): number;
  76962. set paddingRightInPixels(value: number);
  76963. /**
  76964. * Gets or sets a value indicating the padding to use on the top of the control
  76965. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76966. */
  76967. get paddingTop(): string | number;
  76968. set paddingTop(value: string | number);
  76969. /**
  76970. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76971. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76972. */
  76973. get paddingTopInPixels(): number;
  76974. set paddingTopInPixels(value: number);
  76975. /**
  76976. * Gets or sets a value indicating the padding to use on the bottom of the control
  76977. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76978. */
  76979. get paddingBottom(): string | number;
  76980. set paddingBottom(value: string | number);
  76981. /**
  76982. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76983. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76984. */
  76985. get paddingBottomInPixels(): number;
  76986. set paddingBottomInPixels(value: number);
  76987. /**
  76988. * Gets or sets a value indicating the left coordinate of the control
  76989. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76990. */
  76991. get left(): string | number;
  76992. set left(value: string | number);
  76993. /**
  76994. * Gets or sets a value indicating the left coordinate in pixels of the control
  76995. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76996. */
  76997. get leftInPixels(): number;
  76998. set leftInPixels(value: number);
  76999. /**
  77000. * Gets or sets a value indicating the top coordinate of the control
  77001. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77002. */
  77003. get top(): string | number;
  77004. set top(value: string | number);
  77005. /**
  77006. * Gets or sets a value indicating the top coordinate in pixels of the control
  77007. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77008. */
  77009. get topInPixels(): number;
  77010. set topInPixels(value: number);
  77011. /**
  77012. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77013. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77014. */
  77015. get linkOffsetX(): string | number;
  77016. set linkOffsetX(value: string | number);
  77017. /**
  77018. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77019. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77020. */
  77021. get linkOffsetXInPixels(): number;
  77022. set linkOffsetXInPixels(value: number);
  77023. /**
  77024. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77025. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77026. */
  77027. get linkOffsetY(): string | number;
  77028. set linkOffsetY(value: string | number);
  77029. /**
  77030. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77031. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77032. */
  77033. get linkOffsetYInPixels(): number;
  77034. set linkOffsetYInPixels(value: number);
  77035. /** Gets the center coordinate on X axis */
  77036. get centerX(): number;
  77037. /** Gets the center coordinate on Y axis */
  77038. get centerY(): number;
  77039. /** Gets or sets if control is Enabled*/
  77040. get isEnabled(): boolean;
  77041. set isEnabled(value: boolean);
  77042. /** Gets or sets background color of control if it's disabled*/
  77043. get disabledColor(): string;
  77044. set disabledColor(value: string);
  77045. /** Gets or sets front color of control if it's disabled*/
  77046. get disabledColorItem(): string;
  77047. set disabledColorItem(value: string);
  77048. /**
  77049. * Creates a new control
  77050. * @param name defines the name of the control
  77051. */
  77052. constructor(
  77053. /** defines the name of the control */
  77054. name?: string | undefined);
  77055. /** @hidden */
  77056. protected _getTypeName(): string;
  77057. /**
  77058. * Gets the first ascendant in the hierarchy of the given type
  77059. * @param className defines the required type
  77060. * @returns the ascendant or null if not found
  77061. */
  77062. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77063. /** @hidden */
  77064. _resetFontCache(): void;
  77065. /**
  77066. * Determines if a container is an ascendant of the current control
  77067. * @param container defines the container to look for
  77068. * @returns true if the container is one of the ascendant of the control
  77069. */
  77070. isAscendant(container: Control): boolean;
  77071. /**
  77072. * Gets coordinates in local control space
  77073. * @param globalCoordinates defines the coordinates to transform
  77074. * @returns the new coordinates in local space
  77075. */
  77076. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77077. /**
  77078. * Gets coordinates in local control space
  77079. * @param globalCoordinates defines the coordinates to transform
  77080. * @param result defines the target vector2 where to store the result
  77081. * @returns the current control
  77082. */
  77083. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77084. /**
  77085. * Gets coordinates in parent local control space
  77086. * @param globalCoordinates defines the coordinates to transform
  77087. * @returns the new coordinates in parent local space
  77088. */
  77089. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77090. /**
  77091. * Move the current control to a vector3 position projected onto the screen.
  77092. * @param position defines the target position
  77093. * @param scene defines the hosting scene
  77094. */
  77095. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77096. /**
  77097. * Will store all controls that have this control as ascendant in a given array
  77098. * @param results defines the array where to store the descendants
  77099. * @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
  77100. * @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
  77101. */
  77102. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77103. /**
  77104. * Will return all controls that have this control as ascendant
  77105. * @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
  77106. * @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
  77107. * @return all child controls
  77108. */
  77109. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77110. /**
  77111. * Link current control with a target mesh
  77112. * @param mesh defines the mesh to link with
  77113. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77114. */
  77115. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77116. /** @hidden */
  77117. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77118. /** @hidden */
  77119. _offsetLeft(offset: number): void;
  77120. /** @hidden */
  77121. _offsetTop(offset: number): void;
  77122. /** @hidden */
  77123. _markMatrixAsDirty(): void;
  77124. /** @hidden */
  77125. _flagDescendantsAsMatrixDirty(): void;
  77126. /** @hidden */
  77127. _intersectsRect(rect: Measure): boolean;
  77128. /** @hidden */
  77129. protected invalidateRect(): void;
  77130. /** @hidden */
  77131. _markAsDirty(force?: boolean): void;
  77132. /** @hidden */
  77133. _markAllAsDirty(): void;
  77134. /** @hidden */
  77135. _link(host: AdvancedDynamicTexture): void;
  77136. /** @hidden */
  77137. protected _transform(context?: CanvasRenderingContext2D): void;
  77138. /** @hidden */
  77139. _renderHighlight(context: CanvasRenderingContext2D): void;
  77140. /** @hidden */
  77141. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77142. /** @hidden */
  77143. protected _applyStates(context: CanvasRenderingContext2D): void;
  77144. /** @hidden */
  77145. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77146. /** @hidden */
  77147. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77148. protected _evaluateClippingState(parentMeasure: Measure): void;
  77149. /** @hidden */
  77150. _measure(): void;
  77151. /** @hidden */
  77152. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77153. /** @hidden */
  77154. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77155. /** @hidden */
  77156. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77157. /** @hidden */
  77158. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77159. private static _ClipMeasure;
  77160. private _tmpMeasureA;
  77161. private _clip;
  77162. /** @hidden */
  77163. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77164. /** @hidden */
  77165. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77166. /**
  77167. * Tests if a given coordinates belong to the current control
  77168. * @param x defines x coordinate to test
  77169. * @param y defines y coordinate to test
  77170. * @returns true if the coordinates are inside the control
  77171. */
  77172. contains(x: number, y: number): boolean;
  77173. /** @hidden */
  77174. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77175. /** @hidden */
  77176. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77177. /** @hidden */
  77178. _onPointerEnter(target: Control): boolean;
  77179. /** @hidden */
  77180. _onPointerOut(target: Control, force?: boolean): void;
  77181. /** @hidden */
  77182. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77183. /** @hidden */
  77184. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77185. /** @hidden */
  77186. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77187. /** @hidden */
  77188. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77189. /** @hidden */
  77190. _onCanvasBlur(): void;
  77191. /** @hidden */
  77192. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77193. private _prepareFont;
  77194. /** Releases associated resources */
  77195. dispose(): void;
  77196. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77197. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77198. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77199. private static _VERTICAL_ALIGNMENT_TOP;
  77200. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77201. private static _VERTICAL_ALIGNMENT_CENTER;
  77202. /** HORIZONTAL_ALIGNMENT_LEFT */
  77203. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77204. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77205. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77206. /** HORIZONTAL_ALIGNMENT_CENTER */
  77207. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77208. /** VERTICAL_ALIGNMENT_TOP */
  77209. static get VERTICAL_ALIGNMENT_TOP(): number;
  77210. /** VERTICAL_ALIGNMENT_BOTTOM */
  77211. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77212. /** VERTICAL_ALIGNMENT_CENTER */
  77213. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77214. private static _FontHeightSizes;
  77215. /** @hidden */
  77216. static _GetFontOffset(font: string): {
  77217. ascent: number;
  77218. height: number;
  77219. descent: number;
  77220. };
  77221. /**
  77222. * Creates a stack panel that can be used to render headers
  77223. * @param control defines the control to associate with the header
  77224. * @param text defines the text of the header
  77225. * @param size defines the size of the header
  77226. * @param options defines options used to configure the header
  77227. * @returns a new StackPanel
  77228. * @ignore
  77229. * @hidden
  77230. */
  77231. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77232. isHorizontal: boolean;
  77233. controlFirst: boolean;
  77234. }) => any;
  77235. /** @hidden */
  77236. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77237. }
  77238. }
  77239. declare module BABYLON.GUI {
  77240. /**
  77241. * Root class for 2D containers
  77242. * @see https://doc.babylonjs.com/how_to/gui#containers
  77243. */
  77244. export class Container extends Control {
  77245. name?: string | undefined;
  77246. /** @hidden */
  77247. _children: Control[];
  77248. /** @hidden */
  77249. protected _measureForChildren: Measure;
  77250. /** @hidden */
  77251. protected _background: string;
  77252. /** @hidden */
  77253. protected _adaptWidthToChildren: boolean;
  77254. /** @hidden */
  77255. protected _adaptHeightToChildren: boolean;
  77256. /**
  77257. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77258. */
  77259. logLayoutCycleErrors: boolean;
  77260. /**
  77261. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77262. */
  77263. maxLayoutCycle: number;
  77264. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77265. get adaptHeightToChildren(): boolean;
  77266. set adaptHeightToChildren(value: boolean);
  77267. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77268. get adaptWidthToChildren(): boolean;
  77269. set adaptWidthToChildren(value: boolean);
  77270. /** Gets or sets background color */
  77271. get background(): string;
  77272. set background(value: string);
  77273. /** Gets the list of children */
  77274. get children(): Control[];
  77275. /**
  77276. * Creates a new Container
  77277. * @param name defines the name of the container
  77278. */
  77279. constructor(name?: string | undefined);
  77280. protected _getTypeName(): string;
  77281. _flagDescendantsAsMatrixDirty(): void;
  77282. /**
  77283. * Gets a child using its name
  77284. * @param name defines the child name to look for
  77285. * @returns the child control if found
  77286. */
  77287. getChildByName(name: string): BABYLON.Nullable<Control>;
  77288. /**
  77289. * Gets a child using its type and its name
  77290. * @param name defines the child name to look for
  77291. * @param type defines the child type to look for
  77292. * @returns the child control if found
  77293. */
  77294. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77295. /**
  77296. * Search for a specific control in children
  77297. * @param control defines the control to look for
  77298. * @returns true if the control is in child list
  77299. */
  77300. containsControl(control: Control): boolean;
  77301. /**
  77302. * Adds a new control to the current container
  77303. * @param control defines the control to add
  77304. * @returns the current container
  77305. */
  77306. addControl(control: BABYLON.Nullable<Control>): Container;
  77307. /**
  77308. * Removes all controls from the current container
  77309. * @returns the current container
  77310. */
  77311. clearControls(): Container;
  77312. /**
  77313. * Removes a control from the current container
  77314. * @param control defines the control to remove
  77315. * @returns the current container
  77316. */
  77317. removeControl(control: Control): Container;
  77318. /** @hidden */
  77319. _reOrderControl(control: Control): void;
  77320. /** @hidden */
  77321. _offsetLeft(offset: number): void;
  77322. /** @hidden */
  77323. _offsetTop(offset: number): void;
  77324. /** @hidden */
  77325. _markAllAsDirty(): void;
  77326. /** @hidden */
  77327. protected _localDraw(context: CanvasRenderingContext2D): void;
  77328. /** @hidden */
  77329. _link(host: AdvancedDynamicTexture): void;
  77330. /** @hidden */
  77331. protected _beforeLayout(): void;
  77332. /** @hidden */
  77333. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77334. /** @hidden */
  77335. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77336. protected _postMeasure(): void;
  77337. /** @hidden */
  77338. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77339. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77340. /** @hidden */
  77341. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77342. /** @hidden */
  77343. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77344. /** Releases associated resources */
  77345. dispose(): void;
  77346. }
  77347. }
  77348. declare module BABYLON.GUI {
  77349. /** Class used to create rectangle container */
  77350. export class Rectangle extends Container {
  77351. name?: string | undefined;
  77352. private _thickness;
  77353. private _cornerRadius;
  77354. /** Gets or sets border thickness */
  77355. get thickness(): number;
  77356. set thickness(value: number);
  77357. /** Gets or sets the corner radius angle */
  77358. get cornerRadius(): number;
  77359. set cornerRadius(value: number);
  77360. /**
  77361. * Creates a new Rectangle
  77362. * @param name defines the control name
  77363. */
  77364. constructor(name?: string | undefined);
  77365. protected _getTypeName(): string;
  77366. protected _localDraw(context: CanvasRenderingContext2D): void;
  77367. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77368. private _drawRoundedRect;
  77369. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77370. }
  77371. }
  77372. declare module BABYLON.GUI {
  77373. /**
  77374. * Enum that determines the text-wrapping mode to use.
  77375. */
  77376. export enum TextWrapping {
  77377. /**
  77378. * Clip the text when it's larger than Control.width; this is the default mode.
  77379. */
  77380. Clip = 0,
  77381. /**
  77382. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77383. */
  77384. WordWrap = 1,
  77385. /**
  77386. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77387. */
  77388. Ellipsis = 2
  77389. }
  77390. /**
  77391. * Class used to create text block control
  77392. */
  77393. export class TextBlock extends Control {
  77394. /**
  77395. * Defines the name of the control
  77396. */
  77397. name?: string | undefined;
  77398. private _text;
  77399. private _textWrapping;
  77400. private _textHorizontalAlignment;
  77401. private _textVerticalAlignment;
  77402. private _lines;
  77403. private _resizeToFit;
  77404. private _lineSpacing;
  77405. private _outlineWidth;
  77406. private _outlineColor;
  77407. /**
  77408. * An event triggered after the text is changed
  77409. */
  77410. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77411. /**
  77412. * An event triggered after the text was broken up into lines
  77413. */
  77414. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77415. /**
  77416. * Function used to split a string into words. By default, a string is split at each space character found
  77417. */
  77418. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77419. /**
  77420. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77421. */
  77422. get lines(): any[];
  77423. /**
  77424. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77425. */
  77426. get resizeToFit(): boolean;
  77427. /**
  77428. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77429. */
  77430. set resizeToFit(value: boolean);
  77431. /**
  77432. * Gets or sets a boolean indicating if text must be wrapped
  77433. */
  77434. get textWrapping(): TextWrapping | boolean;
  77435. /**
  77436. * Gets or sets a boolean indicating if text must be wrapped
  77437. */
  77438. set textWrapping(value: TextWrapping | boolean);
  77439. /**
  77440. * Gets or sets text to display
  77441. */
  77442. get text(): string;
  77443. /**
  77444. * Gets or sets text to display
  77445. */
  77446. set text(value: string);
  77447. /**
  77448. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77449. */
  77450. get textHorizontalAlignment(): number;
  77451. /**
  77452. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77453. */
  77454. set textHorizontalAlignment(value: number);
  77455. /**
  77456. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77457. */
  77458. get textVerticalAlignment(): number;
  77459. /**
  77460. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77461. */
  77462. set textVerticalAlignment(value: number);
  77463. /**
  77464. * Gets or sets line spacing value
  77465. */
  77466. set lineSpacing(value: string | number);
  77467. /**
  77468. * Gets or sets line spacing value
  77469. */
  77470. get lineSpacing(): string | number;
  77471. /**
  77472. * Gets or sets outlineWidth of the text to display
  77473. */
  77474. get outlineWidth(): number;
  77475. /**
  77476. * Gets or sets outlineWidth of the text to display
  77477. */
  77478. set outlineWidth(value: number);
  77479. /**
  77480. * Gets or sets outlineColor of the text to display
  77481. */
  77482. get outlineColor(): string;
  77483. /**
  77484. * Gets or sets outlineColor of the text to display
  77485. */
  77486. set outlineColor(value: string);
  77487. /**
  77488. * Creates a new TextBlock object
  77489. * @param name defines the name of the control
  77490. * @param text defines the text to display (emptry string by default)
  77491. */
  77492. constructor(
  77493. /**
  77494. * Defines the name of the control
  77495. */
  77496. name?: string | undefined, text?: string);
  77497. protected _getTypeName(): string;
  77498. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77499. private _drawText;
  77500. /** @hidden */
  77501. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77502. protected _applyStates(context: CanvasRenderingContext2D): void;
  77503. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77504. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77505. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77506. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77507. protected _renderLines(context: CanvasRenderingContext2D): void;
  77508. /**
  77509. * Given a width constraint applied on the text block, find the expected height
  77510. * @returns expected height
  77511. */
  77512. computeExpectedHeight(): number;
  77513. dispose(): void;
  77514. }
  77515. }
  77516. declare module BABYLON.GUI {
  77517. /**
  77518. * Class used to create 2D images
  77519. */
  77520. export class Image extends Control {
  77521. name?: string | undefined;
  77522. private _workingCanvas;
  77523. private _domImage;
  77524. private _imageWidth;
  77525. private _imageHeight;
  77526. private _loaded;
  77527. private _stretch;
  77528. private _source;
  77529. private _autoScale;
  77530. private _sourceLeft;
  77531. private _sourceTop;
  77532. private _sourceWidth;
  77533. private _sourceHeight;
  77534. private _svgAttributesComputationCompleted;
  77535. private _isSVG;
  77536. private _cellWidth;
  77537. private _cellHeight;
  77538. private _cellId;
  77539. private _populateNinePatchSlicesFromImage;
  77540. private _sliceLeft;
  77541. private _sliceRight;
  77542. private _sliceTop;
  77543. private _sliceBottom;
  77544. private _detectPointerOnOpaqueOnly;
  77545. private _imageDataCache;
  77546. /**
  77547. * BABYLON.Observable notified when the content is loaded
  77548. */
  77549. onImageLoadedObservable: BABYLON.Observable<Image>;
  77550. /**
  77551. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77552. */
  77553. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77554. /**
  77555. * Gets a boolean indicating that the content is loaded
  77556. */
  77557. get isLoaded(): boolean;
  77558. /**
  77559. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77560. */
  77561. get populateNinePatchSlicesFromImage(): boolean;
  77562. set populateNinePatchSlicesFromImage(value: boolean);
  77563. /**
  77564. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77565. * Beware using this as this will comsume more memory as the image has to be stored twice
  77566. */
  77567. get detectPointerOnOpaqueOnly(): boolean;
  77568. set detectPointerOnOpaqueOnly(value: boolean);
  77569. /**
  77570. * Gets or sets the left value for slicing (9-patch)
  77571. */
  77572. get sliceLeft(): number;
  77573. set sliceLeft(value: number);
  77574. /**
  77575. * Gets or sets the right value for slicing (9-patch)
  77576. */
  77577. get sliceRight(): number;
  77578. set sliceRight(value: number);
  77579. /**
  77580. * Gets or sets the top value for slicing (9-patch)
  77581. */
  77582. get sliceTop(): number;
  77583. set sliceTop(value: number);
  77584. /**
  77585. * Gets or sets the bottom value for slicing (9-patch)
  77586. */
  77587. get sliceBottom(): number;
  77588. set sliceBottom(value: number);
  77589. /**
  77590. * Gets or sets the left coordinate in the source image
  77591. */
  77592. get sourceLeft(): number;
  77593. set sourceLeft(value: number);
  77594. /**
  77595. * Gets or sets the top coordinate in the source image
  77596. */
  77597. get sourceTop(): number;
  77598. set sourceTop(value: number);
  77599. /**
  77600. * Gets or sets the width to capture in the source image
  77601. */
  77602. get sourceWidth(): number;
  77603. set sourceWidth(value: number);
  77604. /**
  77605. * Gets or sets the height to capture in the source image
  77606. */
  77607. get sourceHeight(): number;
  77608. set sourceHeight(value: number);
  77609. /** Indicates if the format of the image is SVG */
  77610. get isSVG(): boolean;
  77611. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77612. get svgAttributesComputationCompleted(): boolean;
  77613. /**
  77614. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77615. * @see https://doc.babylonjs.com/how_to/gui#image
  77616. */
  77617. get autoScale(): boolean;
  77618. set autoScale(value: boolean);
  77619. /** Gets or sets the streching mode used by the image */
  77620. get stretch(): number;
  77621. set stretch(value: number);
  77622. /** @hidden */
  77623. _rotate90(n: number, preserveProperties?: boolean): Image;
  77624. private _handleRotationForSVGImage;
  77625. private _rotate90SourceProperties;
  77626. /**
  77627. * Gets or sets the internal DOM image used to render the control
  77628. */
  77629. set domImage(value: HTMLImageElement);
  77630. get domImage(): HTMLImageElement;
  77631. private _onImageLoaded;
  77632. private _extractNinePatchSliceDataFromImage;
  77633. /**
  77634. * Gets or sets image source url
  77635. */
  77636. set source(value: BABYLON.Nullable<string>);
  77637. /**
  77638. * Checks for svg document with icon id present
  77639. */
  77640. private _svgCheck;
  77641. /**
  77642. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77643. * given external svg file and icon id
  77644. */
  77645. private _getSVGAttribs;
  77646. /**
  77647. * Gets or sets the cell width to use when animation sheet is enabled
  77648. * @see https://doc.babylonjs.com/how_to/gui#image
  77649. */
  77650. get cellWidth(): number;
  77651. set cellWidth(value: number);
  77652. /**
  77653. * Gets or sets the cell height to use when animation sheet is enabled
  77654. * @see https://doc.babylonjs.com/how_to/gui#image
  77655. */
  77656. get cellHeight(): number;
  77657. set cellHeight(value: number);
  77658. /**
  77659. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77660. * @see https://doc.babylonjs.com/how_to/gui#image
  77661. */
  77662. get cellId(): number;
  77663. set cellId(value: number);
  77664. /**
  77665. * Creates a new Image
  77666. * @param name defines the control name
  77667. * @param url defines the image url
  77668. */
  77669. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77670. /**
  77671. * Tests if a given coordinates belong to the current control
  77672. * @param x defines x coordinate to test
  77673. * @param y defines y coordinate to test
  77674. * @returns true if the coordinates are inside the control
  77675. */
  77676. contains(x: number, y: number): boolean;
  77677. protected _getTypeName(): string;
  77678. /** Force the control to synchronize with its content */
  77679. synchronizeSizeWithContent(): void;
  77680. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77681. private _prepareWorkingCanvasForOpaqueDetection;
  77682. private _drawImage;
  77683. _draw(context: CanvasRenderingContext2D): void;
  77684. private _renderCornerPatch;
  77685. private _renderNinePatch;
  77686. dispose(): void;
  77687. /** STRETCH_NONE */
  77688. static readonly STRETCH_NONE: number;
  77689. /** STRETCH_FILL */
  77690. static readonly STRETCH_FILL: number;
  77691. /** STRETCH_UNIFORM */
  77692. static readonly STRETCH_UNIFORM: number;
  77693. /** STRETCH_EXTEND */
  77694. static readonly STRETCH_EXTEND: number;
  77695. /** NINE_PATCH */
  77696. static readonly STRETCH_NINE_PATCH: number;
  77697. }
  77698. }
  77699. declare module BABYLON.GUI {
  77700. /**
  77701. * Class used to create 2D buttons
  77702. */
  77703. export class Button extends Rectangle {
  77704. name?: string | undefined;
  77705. /**
  77706. * Function called to generate a pointer enter animation
  77707. */
  77708. pointerEnterAnimation: () => void;
  77709. /**
  77710. * Function called to generate a pointer out animation
  77711. */
  77712. pointerOutAnimation: () => void;
  77713. /**
  77714. * Function called to generate a pointer down animation
  77715. */
  77716. pointerDownAnimation: () => void;
  77717. /**
  77718. * Function called to generate a pointer up animation
  77719. */
  77720. pointerUpAnimation: () => void;
  77721. /**
  77722. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77723. */
  77724. delegatePickingToChildren: boolean;
  77725. private _image;
  77726. /**
  77727. * Returns the image part of the button (if any)
  77728. */
  77729. get image(): BABYLON.Nullable<Image>;
  77730. private _textBlock;
  77731. /**
  77732. * Returns the image part of the button (if any)
  77733. */
  77734. get textBlock(): BABYLON.Nullable<TextBlock>;
  77735. /**
  77736. * Creates a new Button
  77737. * @param name defines the name of the button
  77738. */
  77739. constructor(name?: string | undefined);
  77740. protected _getTypeName(): string;
  77741. /** @hidden */
  77742. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77743. /** @hidden */
  77744. _onPointerEnter(target: Control): boolean;
  77745. /** @hidden */
  77746. _onPointerOut(target: Control, force?: boolean): void;
  77747. /** @hidden */
  77748. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77749. /** @hidden */
  77750. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77751. /**
  77752. * Creates a new button made with an image and a text
  77753. * @param name defines the name of the button
  77754. * @param text defines the text of the button
  77755. * @param imageUrl defines the url of the image
  77756. * @returns a new Button
  77757. */
  77758. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77759. /**
  77760. * Creates a new button made with an image
  77761. * @param name defines the name of the button
  77762. * @param imageUrl defines the url of the image
  77763. * @returns a new Button
  77764. */
  77765. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77766. /**
  77767. * Creates a new button made with a text
  77768. * @param name defines the name of the button
  77769. * @param text defines the text of the button
  77770. * @returns a new Button
  77771. */
  77772. static CreateSimpleButton(name: string, text: string): Button;
  77773. /**
  77774. * Creates a new button made with an image and a centered text
  77775. * @param name defines the name of the button
  77776. * @param text defines the text of the button
  77777. * @param imageUrl defines the url of the image
  77778. * @returns a new Button
  77779. */
  77780. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77781. }
  77782. }
  77783. declare module BABYLON.GUI {
  77784. /**
  77785. * Class used to create a 2D stack panel container
  77786. */
  77787. export class StackPanel extends Container {
  77788. name?: string | undefined;
  77789. private _isVertical;
  77790. private _manualWidth;
  77791. private _manualHeight;
  77792. private _doNotTrackManualChanges;
  77793. /**
  77794. * Gets or sets a boolean indicating that layou warnings should be ignored
  77795. */
  77796. ignoreLayoutWarnings: boolean;
  77797. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77798. get isVertical(): boolean;
  77799. set isVertical(value: boolean);
  77800. /**
  77801. * Gets or sets panel width.
  77802. * This value should not be set when in horizontal mode as it will be computed automatically
  77803. */
  77804. set width(value: string | number);
  77805. get width(): string | number;
  77806. /**
  77807. * Gets or sets panel height.
  77808. * This value should not be set when in vertical mode as it will be computed automatically
  77809. */
  77810. set height(value: string | number);
  77811. get height(): string | number;
  77812. /**
  77813. * Creates a new StackPanel
  77814. * @param name defines control name
  77815. */
  77816. constructor(name?: string | undefined);
  77817. protected _getTypeName(): string;
  77818. /** @hidden */
  77819. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77820. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77821. protected _postMeasure(): void;
  77822. }
  77823. }
  77824. declare module BABYLON.GUI {
  77825. /**
  77826. * Class used to represent a 2D checkbox
  77827. */
  77828. export class Checkbox extends Control {
  77829. name?: string | undefined;
  77830. private _isChecked;
  77831. private _background;
  77832. private _checkSizeRatio;
  77833. private _thickness;
  77834. /** Gets or sets border thickness */
  77835. get thickness(): number;
  77836. set thickness(value: number);
  77837. /**
  77838. * BABYLON.Observable raised when isChecked property changes
  77839. */
  77840. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77841. /** Gets or sets a value indicating the ratio between overall size and check size */
  77842. get checkSizeRatio(): number;
  77843. set checkSizeRatio(value: number);
  77844. /** Gets or sets background color */
  77845. get background(): string;
  77846. set background(value: string);
  77847. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77848. get isChecked(): boolean;
  77849. set isChecked(value: boolean);
  77850. /**
  77851. * Creates a new CheckBox
  77852. * @param name defines the control name
  77853. */
  77854. constructor(name?: string | undefined);
  77855. protected _getTypeName(): string;
  77856. /** @hidden */
  77857. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77858. /** @hidden */
  77859. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77860. /**
  77861. * Utility function to easily create a checkbox with a header
  77862. * @param title defines the label to use for the header
  77863. * @param onValueChanged defines the callback to call when value changes
  77864. * @returns a StackPanel containing the checkbox and a textBlock
  77865. */
  77866. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77867. }
  77868. }
  77869. declare module BABYLON.GUI {
  77870. /**
  77871. * Class used to store key control properties
  77872. */
  77873. export class KeyPropertySet {
  77874. /** Width */
  77875. width?: string;
  77876. /** Height */
  77877. height?: string;
  77878. /** Left padding */
  77879. paddingLeft?: string;
  77880. /** Right padding */
  77881. paddingRight?: string;
  77882. /** Top padding */
  77883. paddingTop?: string;
  77884. /** Bottom padding */
  77885. paddingBottom?: string;
  77886. /** Foreground color */
  77887. color?: string;
  77888. /** Background color */
  77889. background?: string;
  77890. }
  77891. /**
  77892. * Class used to create virtual keyboard
  77893. */
  77894. export class VirtualKeyboard extends StackPanel {
  77895. /** BABYLON.Observable raised when a key is pressed */
  77896. onKeyPressObservable: BABYLON.Observable<string>;
  77897. /** Gets or sets default key button width */
  77898. defaultButtonWidth: string;
  77899. /** Gets or sets default key button height */
  77900. defaultButtonHeight: string;
  77901. /** Gets or sets default key button left padding */
  77902. defaultButtonPaddingLeft: string;
  77903. /** Gets or sets default key button right padding */
  77904. defaultButtonPaddingRight: string;
  77905. /** Gets or sets default key button top padding */
  77906. defaultButtonPaddingTop: string;
  77907. /** Gets or sets default key button bottom padding */
  77908. defaultButtonPaddingBottom: string;
  77909. /** Gets or sets default key button foreground color */
  77910. defaultButtonColor: string;
  77911. /** Gets or sets default key button background color */
  77912. defaultButtonBackground: string;
  77913. /** Gets or sets shift button foreground color */
  77914. shiftButtonColor: string;
  77915. /** Gets or sets shift button thickness*/
  77916. selectedShiftThickness: number;
  77917. /** Gets shift key state */
  77918. shiftState: number;
  77919. protected _getTypeName(): string;
  77920. private _createKey;
  77921. /**
  77922. * Adds a new row of keys
  77923. * @param keys defines the list of keys to add
  77924. * @param propertySets defines the associated property sets
  77925. */
  77926. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77927. /**
  77928. * Set the shift key to a specific state
  77929. * @param shiftState defines the new shift state
  77930. */
  77931. applyShiftState(shiftState: number): void;
  77932. private _currentlyConnectedInputText;
  77933. private _connectedInputTexts;
  77934. private _onKeyPressObserver;
  77935. /** Gets the input text control currently attached to the keyboard */
  77936. get connectedInputText(): BABYLON.Nullable<InputText>;
  77937. /**
  77938. * Connects the keyboard with an input text control
  77939. *
  77940. * @param input defines the target control
  77941. */
  77942. connect(input: InputText): void;
  77943. /**
  77944. * Disconnects the keyboard from connected InputText controls
  77945. *
  77946. * @param input optionally defines a target control, otherwise all are disconnected
  77947. */
  77948. disconnect(input?: InputText): void;
  77949. private _removeConnectedInputObservables;
  77950. /**
  77951. * Release all resources
  77952. */
  77953. dispose(): void;
  77954. /**
  77955. * Creates a new keyboard using a default layout
  77956. *
  77957. * @param name defines control name
  77958. * @returns a new VirtualKeyboard
  77959. */
  77960. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77961. }
  77962. }
  77963. declare module BABYLON.GUI {
  77964. /**
  77965. * Class used to create input text control
  77966. */
  77967. export class InputText extends Control implements IFocusableControl {
  77968. name?: string | undefined;
  77969. private _text;
  77970. private _placeholderText;
  77971. private _background;
  77972. private _focusedBackground;
  77973. private _focusedColor;
  77974. private _placeholderColor;
  77975. private _thickness;
  77976. private _margin;
  77977. private _autoStretchWidth;
  77978. private _maxWidth;
  77979. private _isFocused;
  77980. private _blinkTimeout;
  77981. private _blinkIsEven;
  77982. private _cursorOffset;
  77983. private _scrollLeft;
  77984. private _textWidth;
  77985. private _clickedCoordinate;
  77986. private _deadKey;
  77987. private _addKey;
  77988. private _currentKey;
  77989. private _isTextHighlightOn;
  77990. private _textHighlightColor;
  77991. private _highligherOpacity;
  77992. private _highlightedText;
  77993. private _startHighlightIndex;
  77994. private _endHighlightIndex;
  77995. private _cursorIndex;
  77996. private _onFocusSelectAll;
  77997. private _isPointerDown;
  77998. private _onClipboardObserver;
  77999. private _onPointerDblTapObserver;
  78000. /** @hidden */
  78001. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78002. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78003. promptMessage: string;
  78004. /** Force disable prompt on mobile device */
  78005. disableMobilePrompt: boolean;
  78006. /** BABYLON.Observable raised when the text changes */
  78007. onTextChangedObservable: BABYLON.Observable<InputText>;
  78008. /** BABYLON.Observable raised just before an entered character is to be added */
  78009. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78010. /** BABYLON.Observable raised when the control gets the focus */
  78011. onFocusObservable: BABYLON.Observable<InputText>;
  78012. /** BABYLON.Observable raised when the control loses the focus */
  78013. onBlurObservable: BABYLON.Observable<InputText>;
  78014. /**Observable raised when the text is highlighted */
  78015. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78016. /**Observable raised when copy event is triggered */
  78017. onTextCopyObservable: BABYLON.Observable<InputText>;
  78018. /** BABYLON.Observable raised when cut event is triggered */
  78019. onTextCutObservable: BABYLON.Observable<InputText>;
  78020. /** BABYLON.Observable raised when paste event is triggered */
  78021. onTextPasteObservable: BABYLON.Observable<InputText>;
  78022. /** BABYLON.Observable raised when a key event was processed */
  78023. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78024. /** Gets or sets the maximum width allowed by the control */
  78025. get maxWidth(): string | number;
  78026. /** Gets the maximum width allowed by the control in pixels */
  78027. get maxWidthInPixels(): number;
  78028. set maxWidth(value: string | number);
  78029. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78030. get highligherOpacity(): number;
  78031. set highligherOpacity(value: number);
  78032. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78033. get onFocusSelectAll(): boolean;
  78034. set onFocusSelectAll(value: boolean);
  78035. /** Gets or sets the text hightlight color */
  78036. get textHighlightColor(): string;
  78037. set textHighlightColor(value: string);
  78038. /** Gets or sets control margin */
  78039. get margin(): string;
  78040. /** Gets control margin in pixels */
  78041. get marginInPixels(): number;
  78042. set margin(value: string);
  78043. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78044. get autoStretchWidth(): boolean;
  78045. set autoStretchWidth(value: boolean);
  78046. /** Gets or sets border thickness */
  78047. get thickness(): number;
  78048. set thickness(value: number);
  78049. /** Gets or sets the background color when focused */
  78050. get focusedBackground(): string;
  78051. set focusedBackground(value: string);
  78052. /** Gets or sets the background color when focused */
  78053. get focusedColor(): string;
  78054. set focusedColor(value: string);
  78055. /** Gets or sets the background color */
  78056. get background(): string;
  78057. set background(value: string);
  78058. /** Gets or sets the placeholder color */
  78059. get placeholderColor(): string;
  78060. set placeholderColor(value: string);
  78061. /** Gets or sets the text displayed when the control is empty */
  78062. get placeholderText(): string;
  78063. set placeholderText(value: string);
  78064. /** Gets or sets the dead key flag */
  78065. get deadKey(): boolean;
  78066. set deadKey(flag: boolean);
  78067. /** Gets or sets the highlight text */
  78068. get highlightedText(): string;
  78069. set highlightedText(text: string);
  78070. /** Gets or sets if the current key should be added */
  78071. get addKey(): boolean;
  78072. set addKey(flag: boolean);
  78073. /** Gets or sets the value of the current key being entered */
  78074. get currentKey(): string;
  78075. set currentKey(key: string);
  78076. /** Gets or sets the text displayed in the control */
  78077. get text(): string;
  78078. set text(value: string);
  78079. /** Gets or sets control width */
  78080. get width(): string | number;
  78081. set width(value: string | number);
  78082. /**
  78083. * Creates a new InputText
  78084. * @param name defines the control name
  78085. * @param text defines the text of the control
  78086. */
  78087. constructor(name?: string | undefined, text?: string);
  78088. /** @hidden */
  78089. onBlur(): void;
  78090. /** @hidden */
  78091. onFocus(): void;
  78092. protected _getTypeName(): string;
  78093. /**
  78094. * Function called to get the list of controls that should not steal the focus from this control
  78095. * @returns an array of controls
  78096. */
  78097. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78098. /** @hidden */
  78099. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78100. /** @hidden */
  78101. private _updateValueFromCursorIndex;
  78102. /** @hidden */
  78103. private _processDblClick;
  78104. /** @hidden */
  78105. private _selectAllText;
  78106. /**
  78107. * Handles the keyboard event
  78108. * @param evt Defines the KeyboardEvent
  78109. */
  78110. processKeyboard(evt: KeyboardEvent): void;
  78111. /** @hidden */
  78112. private _onCopyText;
  78113. /** @hidden */
  78114. private _onCutText;
  78115. /** @hidden */
  78116. private _onPasteText;
  78117. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78118. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78119. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78120. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78121. protected _beforeRenderText(text: string): string;
  78122. dispose(): void;
  78123. }
  78124. }
  78125. declare module BABYLON.GUI {
  78126. /**
  78127. * Class used to create a 2D grid container
  78128. */
  78129. export class Grid extends Container {
  78130. name?: string | undefined;
  78131. private _rowDefinitions;
  78132. private _columnDefinitions;
  78133. private _cells;
  78134. private _childControls;
  78135. /**
  78136. * Gets the number of columns
  78137. */
  78138. get columnCount(): number;
  78139. /**
  78140. * Gets the number of rows
  78141. */
  78142. get rowCount(): number;
  78143. /** Gets the list of children */
  78144. get children(): Control[];
  78145. /** Gets the list of cells (e.g. the containers) */
  78146. get cells(): {
  78147. [key: string]: Container;
  78148. };
  78149. /**
  78150. * Gets the definition of a specific row
  78151. * @param index defines the index of the row
  78152. * @returns the row definition
  78153. */
  78154. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78155. /**
  78156. * Gets the definition of a specific column
  78157. * @param index defines the index of the column
  78158. * @returns the column definition
  78159. */
  78160. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78161. /**
  78162. * Adds a new row to the grid
  78163. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78164. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78165. * @returns the current grid
  78166. */
  78167. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78168. /**
  78169. * Adds a new column to the grid
  78170. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78171. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78172. * @returns the current grid
  78173. */
  78174. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78175. /**
  78176. * Update a row definition
  78177. * @param index defines the index of the row to update
  78178. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78179. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78180. * @returns the current grid
  78181. */
  78182. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78183. /**
  78184. * Update a column definition
  78185. * @param index defines the index of the column to update
  78186. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78187. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78188. * @returns the current grid
  78189. */
  78190. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78191. /**
  78192. * Gets the list of children stored in a specific cell
  78193. * @param row defines the row to check
  78194. * @param column defines the column to check
  78195. * @returns the list of controls
  78196. */
  78197. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78198. /**
  78199. * Gets a string representing the child cell info (row x column)
  78200. * @param child defines the control to get info from
  78201. * @returns a string containing the child cell info (row x column)
  78202. */
  78203. getChildCellInfo(child: Control): string;
  78204. private _removeCell;
  78205. private _offsetCell;
  78206. /**
  78207. * Remove a column definition at specified index
  78208. * @param index defines the index of the column to remove
  78209. * @returns the current grid
  78210. */
  78211. removeColumnDefinition(index: number): Grid;
  78212. /**
  78213. * Remove a row definition at specified index
  78214. * @param index defines the index of the row to remove
  78215. * @returns the current grid
  78216. */
  78217. removeRowDefinition(index: number): Grid;
  78218. /**
  78219. * Adds a new control to the current grid
  78220. * @param control defines the control to add
  78221. * @param row defines the row where to add the control (0 by default)
  78222. * @param column defines the column where to add the control (0 by default)
  78223. * @returns the current grid
  78224. */
  78225. addControl(control: Control, row?: number, column?: number): Grid;
  78226. /**
  78227. * Removes a control from the current container
  78228. * @param control defines the control to remove
  78229. * @returns the current container
  78230. */
  78231. removeControl(control: Control): Container;
  78232. /**
  78233. * Creates a new Grid
  78234. * @param name defines control name
  78235. */
  78236. constructor(name?: string | undefined);
  78237. protected _getTypeName(): string;
  78238. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78239. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78240. _flagDescendantsAsMatrixDirty(): void;
  78241. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78242. /** Releases associated resources */
  78243. dispose(): void;
  78244. }
  78245. }
  78246. declare module BABYLON.GUI {
  78247. /** Class used to create color pickers */
  78248. export class ColorPicker extends Control {
  78249. name?: string | undefined;
  78250. private static _Epsilon;
  78251. private _colorWheelCanvas;
  78252. private _value;
  78253. private _tmpColor;
  78254. private _pointerStartedOnSquare;
  78255. private _pointerStartedOnWheel;
  78256. private _squareLeft;
  78257. private _squareTop;
  78258. private _squareSize;
  78259. private _h;
  78260. private _s;
  78261. private _v;
  78262. private _lastPointerDownID;
  78263. /**
  78264. * BABYLON.Observable raised when the value changes
  78265. */
  78266. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78267. /** Gets or sets the color of the color picker */
  78268. get value(): BABYLON.Color3;
  78269. set value(value: BABYLON.Color3);
  78270. /**
  78271. * Gets or sets control width
  78272. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78273. */
  78274. get width(): string | number;
  78275. set width(value: string | number);
  78276. /**
  78277. * Gets or sets control height
  78278. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78279. */
  78280. get height(): string | number;
  78281. /** Gets or sets control height */
  78282. set height(value: string | number);
  78283. /** Gets or sets control size */
  78284. get size(): string | number;
  78285. set size(value: string | number);
  78286. /**
  78287. * Creates a new ColorPicker
  78288. * @param name defines the control name
  78289. */
  78290. constructor(name?: string | undefined);
  78291. protected _getTypeName(): string;
  78292. /** @hidden */
  78293. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78294. private _updateSquareProps;
  78295. private _drawGradientSquare;
  78296. private _drawCircle;
  78297. private _createColorWheelCanvas;
  78298. /** @hidden */
  78299. _draw(context: CanvasRenderingContext2D): void;
  78300. private _pointerIsDown;
  78301. private _updateValueFromPointer;
  78302. private _isPointOnSquare;
  78303. private _isPointOnWheel;
  78304. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78305. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78306. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78307. _onCanvasBlur(): void;
  78308. /**
  78309. * This function expands the color picker by creating a color picker dialog with manual
  78310. * color value input and the ability to save colors into an array to be used later in
  78311. * subsequent launches of the dialogue.
  78312. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78313. * @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.
  78314. * @returns picked color as a hex string and the saved colors array as hex strings.
  78315. */
  78316. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78317. pickerWidth?: string;
  78318. pickerHeight?: string;
  78319. headerHeight?: string;
  78320. lastColor?: string;
  78321. swatchLimit?: number;
  78322. numSwatchesPerLine?: number;
  78323. savedColors?: Array<string>;
  78324. }): Promise<{
  78325. savedColors?: string[];
  78326. pickedColor: string;
  78327. }>;
  78328. }
  78329. }
  78330. declare module BABYLON.GUI {
  78331. /** Class used to create 2D ellipse containers */
  78332. export class Ellipse extends Container {
  78333. name?: string | undefined;
  78334. private _thickness;
  78335. /** Gets or sets border thickness */
  78336. get thickness(): number;
  78337. set thickness(value: number);
  78338. /**
  78339. * Creates a new Ellipse
  78340. * @param name defines the control name
  78341. */
  78342. constructor(name?: string | undefined);
  78343. protected _getTypeName(): string;
  78344. protected _localDraw(context: CanvasRenderingContext2D): void;
  78345. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78346. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78347. }
  78348. }
  78349. declare module BABYLON.GUI {
  78350. /**
  78351. * Class used to create a password control
  78352. */
  78353. export class InputPassword extends InputText {
  78354. protected _beforeRenderText(text: string): string;
  78355. }
  78356. }
  78357. declare module BABYLON.GUI {
  78358. /** Class used to render 2D lines */
  78359. export class Line extends Control {
  78360. name?: string | undefined;
  78361. private _lineWidth;
  78362. private _x1;
  78363. private _y1;
  78364. private _x2;
  78365. private _y2;
  78366. private _dash;
  78367. private _connectedControl;
  78368. private _connectedControlDirtyObserver;
  78369. /** Gets or sets the dash pattern */
  78370. get dash(): Array<number>;
  78371. set dash(value: Array<number>);
  78372. /** Gets or sets the control connected with the line end */
  78373. get connectedControl(): Control;
  78374. set connectedControl(value: Control);
  78375. /** Gets or sets start coordinates on X axis */
  78376. get x1(): string | number;
  78377. set x1(value: string | number);
  78378. /** Gets or sets start coordinates on Y axis */
  78379. get y1(): string | number;
  78380. set y1(value: string | number);
  78381. /** Gets or sets end coordinates on X axis */
  78382. get x2(): string | number;
  78383. set x2(value: string | number);
  78384. /** Gets or sets end coordinates on Y axis */
  78385. get y2(): string | number;
  78386. set y2(value: string | number);
  78387. /** Gets or sets line width */
  78388. get lineWidth(): number;
  78389. set lineWidth(value: number);
  78390. /** Gets or sets horizontal alignment */
  78391. set horizontalAlignment(value: number);
  78392. /** Gets or sets vertical alignment */
  78393. set verticalAlignment(value: number);
  78394. private get _effectiveX2();
  78395. private get _effectiveY2();
  78396. /**
  78397. * Creates a new Line
  78398. * @param name defines the control name
  78399. */
  78400. constructor(name?: string | undefined);
  78401. protected _getTypeName(): string;
  78402. _draw(context: CanvasRenderingContext2D): void;
  78403. _measure(): void;
  78404. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78405. /**
  78406. * Move one end of the line given 3D cartesian coordinates.
  78407. * @param position Targeted world position
  78408. * @param scene BABYLON.Scene
  78409. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78410. */
  78411. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78412. /**
  78413. * Move one end of the line to a position in screen absolute space.
  78414. * @param projectedPosition Position in screen absolute space (X, Y)
  78415. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78416. */
  78417. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78418. }
  78419. }
  78420. declare module BABYLON.GUI {
  78421. /**
  78422. * Class used to store a point for a MultiLine object.
  78423. * The point can be pure 2D coordinates, a mesh or a control
  78424. */
  78425. export class MultiLinePoint {
  78426. private _multiLine;
  78427. private _x;
  78428. private _y;
  78429. private _control;
  78430. private _mesh;
  78431. private _controlObserver;
  78432. private _meshObserver;
  78433. /** @hidden */
  78434. _point: BABYLON.Vector2;
  78435. /**
  78436. * Creates a new MultiLinePoint
  78437. * @param multiLine defines the source MultiLine object
  78438. */
  78439. constructor(multiLine: MultiLine);
  78440. /** Gets or sets x coordinate */
  78441. get x(): string | number;
  78442. set x(value: string | number);
  78443. /** Gets or sets y coordinate */
  78444. get y(): string | number;
  78445. set y(value: string | number);
  78446. /** Gets or sets the control associated with this point */
  78447. get control(): BABYLON.Nullable<Control>;
  78448. set control(value: BABYLON.Nullable<Control>);
  78449. /** Gets or sets the mesh associated with this point */
  78450. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78451. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78452. /** Resets links */
  78453. resetLinks(): void;
  78454. /**
  78455. * Gets a translation vector
  78456. * @returns the translation vector
  78457. */
  78458. translate(): BABYLON.Vector2;
  78459. private _translatePoint;
  78460. /** Release associated resources */
  78461. dispose(): void;
  78462. }
  78463. }
  78464. declare module BABYLON.GUI {
  78465. /**
  78466. * Class used to create multi line control
  78467. */
  78468. export class MultiLine extends Control {
  78469. name?: string | undefined;
  78470. private _lineWidth;
  78471. private _dash;
  78472. private _points;
  78473. private _minX;
  78474. private _minY;
  78475. private _maxX;
  78476. private _maxY;
  78477. /**
  78478. * Creates a new MultiLine
  78479. * @param name defines the control name
  78480. */
  78481. constructor(name?: string | undefined);
  78482. /** Gets or sets dash pattern */
  78483. get dash(): Array<number>;
  78484. set dash(value: Array<number>);
  78485. /**
  78486. * Gets point stored at specified index
  78487. * @param index defines the index to look for
  78488. * @returns the requested point if found
  78489. */
  78490. getAt(index: number): MultiLinePoint;
  78491. /** Function called when a point is updated */
  78492. onPointUpdate: () => void;
  78493. /**
  78494. * Adds new points to the point collection
  78495. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78496. * @returns the list of created MultiLinePoint
  78497. */
  78498. add(...items: (AbstractMesh | Control | {
  78499. x: string | number;
  78500. y: string | number;
  78501. })[]): MultiLinePoint[];
  78502. /**
  78503. * Adds a new point to the point collection
  78504. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78505. * @returns the created MultiLinePoint
  78506. */
  78507. push(item?: (AbstractMesh | Control | {
  78508. x: string | number;
  78509. y: string | number;
  78510. })): MultiLinePoint;
  78511. /**
  78512. * Remove a specific value or point from the active point collection
  78513. * @param value defines the value or point to remove
  78514. */
  78515. remove(value: number | MultiLinePoint): void;
  78516. /**
  78517. * Resets this object to initial state (no point)
  78518. */
  78519. reset(): void;
  78520. /**
  78521. * Resets all links
  78522. */
  78523. resetLinks(): void;
  78524. /** Gets or sets line width */
  78525. get lineWidth(): number;
  78526. set lineWidth(value: number);
  78527. set horizontalAlignment(value: number);
  78528. set verticalAlignment(value: number);
  78529. protected _getTypeName(): string;
  78530. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78531. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78532. _measure(): void;
  78533. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78534. dispose(): void;
  78535. }
  78536. }
  78537. declare module BABYLON.GUI {
  78538. /**
  78539. * Class used to create radio button controls
  78540. */
  78541. export class RadioButton extends Control {
  78542. name?: string | undefined;
  78543. private _isChecked;
  78544. private _background;
  78545. private _checkSizeRatio;
  78546. private _thickness;
  78547. /** Gets or sets border thickness */
  78548. get thickness(): number;
  78549. set thickness(value: number);
  78550. /** Gets or sets group name */
  78551. group: string;
  78552. /** BABYLON.Observable raised when isChecked is changed */
  78553. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78554. /** Gets or sets a value indicating the ratio between overall size and check size */
  78555. get checkSizeRatio(): number;
  78556. set checkSizeRatio(value: number);
  78557. /** Gets or sets background color */
  78558. get background(): string;
  78559. set background(value: string);
  78560. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78561. get isChecked(): boolean;
  78562. set isChecked(value: boolean);
  78563. /**
  78564. * Creates a new RadioButton
  78565. * @param name defines the control name
  78566. */
  78567. constructor(name?: string | undefined);
  78568. protected _getTypeName(): string;
  78569. _draw(context: CanvasRenderingContext2D): void;
  78570. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78571. /**
  78572. * Utility function to easily create a radio button with a header
  78573. * @param title defines the label to use for the header
  78574. * @param group defines the group to use for the radio button
  78575. * @param isChecked defines the initial state of the radio button
  78576. * @param onValueChanged defines the callback to call when value changes
  78577. * @returns a StackPanel containing the radio button and a textBlock
  78578. */
  78579. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78580. }
  78581. }
  78582. declare module BABYLON.GUI {
  78583. /**
  78584. * Class used to create slider controls
  78585. */
  78586. export class BaseSlider extends Control {
  78587. name?: string | undefined;
  78588. protected _thumbWidth: ValueAndUnit;
  78589. private _minimum;
  78590. private _maximum;
  78591. private _value;
  78592. private _isVertical;
  78593. protected _barOffset: ValueAndUnit;
  78594. private _isThumbClamped;
  78595. protected _displayThumb: boolean;
  78596. private _step;
  78597. private _lastPointerDownID;
  78598. protected _effectiveBarOffset: number;
  78599. protected _renderLeft: number;
  78600. protected _renderTop: number;
  78601. protected _renderWidth: number;
  78602. protected _renderHeight: number;
  78603. protected _backgroundBoxLength: number;
  78604. protected _backgroundBoxThickness: number;
  78605. protected _effectiveThumbThickness: number;
  78606. /** BABYLON.Observable raised when the sldier value changes */
  78607. onValueChangedObservable: BABYLON.Observable<number>;
  78608. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78609. get displayThumb(): boolean;
  78610. set displayThumb(value: boolean);
  78611. /** Gets or sets a step to apply to values (0 by default) */
  78612. get step(): number;
  78613. set step(value: number);
  78614. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78615. get barOffset(): string | number;
  78616. /** Gets main bar offset in pixels*/
  78617. get barOffsetInPixels(): number;
  78618. set barOffset(value: string | number);
  78619. /** Gets or sets thumb width */
  78620. get thumbWidth(): string | number;
  78621. /** Gets thumb width in pixels */
  78622. get thumbWidthInPixels(): number;
  78623. set thumbWidth(value: string | number);
  78624. /** Gets or sets minimum value */
  78625. get minimum(): number;
  78626. set minimum(value: number);
  78627. /** Gets or sets maximum value */
  78628. get maximum(): number;
  78629. set maximum(value: number);
  78630. /** Gets or sets current value */
  78631. get value(): number;
  78632. set value(value: number);
  78633. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78634. get isVertical(): boolean;
  78635. set isVertical(value: boolean);
  78636. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78637. get isThumbClamped(): boolean;
  78638. set isThumbClamped(value: boolean);
  78639. /**
  78640. * Creates a new BaseSlider
  78641. * @param name defines the control name
  78642. */
  78643. constructor(name?: string | undefined);
  78644. protected _getTypeName(): string;
  78645. protected _getThumbPosition(): number;
  78646. protected _getThumbThickness(type: string): number;
  78647. protected _prepareRenderingData(type: string): void;
  78648. private _pointerIsDown;
  78649. /** @hidden */
  78650. protected _updateValueFromPointer(x: number, y: number): void;
  78651. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78652. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78653. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78654. _onCanvasBlur(): void;
  78655. }
  78656. }
  78657. declare module BABYLON.GUI {
  78658. /**
  78659. * Class used to create slider controls
  78660. */
  78661. export class Slider extends BaseSlider {
  78662. name?: string | undefined;
  78663. private _background;
  78664. private _borderColor;
  78665. private _isThumbCircle;
  78666. protected _displayValueBar: boolean;
  78667. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78668. get displayValueBar(): boolean;
  78669. set displayValueBar(value: boolean);
  78670. /** Gets or sets border color */
  78671. get borderColor(): string;
  78672. set borderColor(value: string);
  78673. /** Gets or sets background color */
  78674. get background(): string;
  78675. set background(value: string);
  78676. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78677. get isThumbCircle(): boolean;
  78678. set isThumbCircle(value: boolean);
  78679. /**
  78680. * Creates a new Slider
  78681. * @param name defines the control name
  78682. */
  78683. constructor(name?: string | undefined);
  78684. protected _getTypeName(): string;
  78685. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78686. }
  78687. }
  78688. declare module BABYLON.GUI {
  78689. /** Class used to create a RadioGroup
  78690. * which contains groups of radio buttons
  78691. */
  78692. export class SelectorGroup {
  78693. /** name of SelectorGroup */
  78694. name: string;
  78695. private _groupPanel;
  78696. private _selectors;
  78697. private _groupHeader;
  78698. /**
  78699. * Creates a new SelectorGroup
  78700. * @param name of group, used as a group heading
  78701. */
  78702. constructor(
  78703. /** name of SelectorGroup */
  78704. name: string);
  78705. /** Gets the groupPanel of the SelectorGroup */
  78706. get groupPanel(): StackPanel;
  78707. /** Gets the selectors array */
  78708. get selectors(): StackPanel[];
  78709. /** Gets and sets the group header */
  78710. get header(): string;
  78711. set header(label: string);
  78712. /** @hidden */
  78713. private _addGroupHeader;
  78714. /** @hidden*/
  78715. _getSelector(selectorNb: number): StackPanel | undefined;
  78716. /** Removes the selector at the given position
  78717. * @param selectorNb the position of the selector within the group
  78718. */
  78719. removeSelector(selectorNb: number): void;
  78720. }
  78721. /** Class used to create a CheckboxGroup
  78722. * which contains groups of checkbox buttons
  78723. */
  78724. export class CheckboxGroup extends SelectorGroup {
  78725. /** Adds a checkbox as a control
  78726. * @param text is the label for the selector
  78727. * @param func is the function called when the Selector is checked
  78728. * @param checked is true when Selector is checked
  78729. */
  78730. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78731. /** @hidden */
  78732. _setSelectorLabel(selectorNb: number, label: string): void;
  78733. /** @hidden */
  78734. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78735. /** @hidden */
  78736. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78737. /** @hidden */
  78738. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78739. }
  78740. /** Class used to create a RadioGroup
  78741. * which contains groups of radio buttons
  78742. */
  78743. export class RadioGroup extends SelectorGroup {
  78744. private _selectNb;
  78745. /** Adds a radio button as a control
  78746. * @param label is the label for the selector
  78747. * @param func is the function called when the Selector is checked
  78748. * @param checked is true when Selector is checked
  78749. */
  78750. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78751. /** @hidden */
  78752. _setSelectorLabel(selectorNb: number, label: string): void;
  78753. /** @hidden */
  78754. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78755. /** @hidden */
  78756. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78757. /** @hidden */
  78758. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78759. }
  78760. /** Class used to create a SliderGroup
  78761. * which contains groups of slider buttons
  78762. */
  78763. export class SliderGroup extends SelectorGroup {
  78764. /**
  78765. * Adds a slider to the SelectorGroup
  78766. * @param label is the label for the SliderBar
  78767. * @param func is the function called when the Slider moves
  78768. * @param unit is a string describing the units used, eg degrees or metres
  78769. * @param min is the minimum value for the Slider
  78770. * @param max is the maximum value for the Slider
  78771. * @param value is the start value for the Slider between min and max
  78772. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78773. */
  78774. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78775. /** @hidden */
  78776. _setSelectorLabel(selectorNb: number, label: string): void;
  78777. /** @hidden */
  78778. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78779. /** @hidden */
  78780. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78781. /** @hidden */
  78782. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78783. }
  78784. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78785. * @see https://doc.babylonjs.com/how_to/selector
  78786. */
  78787. export class SelectionPanel extends Rectangle {
  78788. /** name of SelectionPanel */
  78789. name: string;
  78790. /** an array of SelectionGroups */
  78791. groups: SelectorGroup[];
  78792. private _panel;
  78793. private _buttonColor;
  78794. private _buttonBackground;
  78795. private _headerColor;
  78796. private _barColor;
  78797. private _barHeight;
  78798. private _spacerHeight;
  78799. private _labelColor;
  78800. private _groups;
  78801. private _bars;
  78802. /**
  78803. * Creates a new SelectionPanel
  78804. * @param name of SelectionPanel
  78805. * @param groups is an array of SelectionGroups
  78806. */
  78807. constructor(
  78808. /** name of SelectionPanel */
  78809. name: string,
  78810. /** an array of SelectionGroups */
  78811. groups?: SelectorGroup[]);
  78812. protected _getTypeName(): string;
  78813. /** Gets or sets the headerColor */
  78814. get headerColor(): string;
  78815. set headerColor(color: string);
  78816. private _setHeaderColor;
  78817. /** Gets or sets the button color */
  78818. get buttonColor(): string;
  78819. set buttonColor(color: string);
  78820. private _setbuttonColor;
  78821. /** Gets or sets the label color */
  78822. get labelColor(): string;
  78823. set labelColor(color: string);
  78824. private _setLabelColor;
  78825. /** Gets or sets the button background */
  78826. get buttonBackground(): string;
  78827. set buttonBackground(color: string);
  78828. private _setButtonBackground;
  78829. /** Gets or sets the color of separator bar */
  78830. get barColor(): string;
  78831. set barColor(color: string);
  78832. private _setBarColor;
  78833. /** Gets or sets the height of separator bar */
  78834. get barHeight(): string;
  78835. set barHeight(value: string);
  78836. private _setBarHeight;
  78837. /** Gets or sets the height of spacers*/
  78838. get spacerHeight(): string;
  78839. set spacerHeight(value: string);
  78840. private _setSpacerHeight;
  78841. /** Adds a bar between groups */
  78842. private _addSpacer;
  78843. /** Add a group to the selection panel
  78844. * @param group is the selector group to add
  78845. */
  78846. addGroup(group: SelectorGroup): void;
  78847. /** Remove the group from the given position
  78848. * @param groupNb is the position of the group in the list
  78849. */
  78850. removeGroup(groupNb: number): void;
  78851. /** Change a group header label
  78852. * @param label is the new group header label
  78853. * @param groupNb is the number of the group to relabel
  78854. * */
  78855. setHeaderName(label: string, groupNb: number): void;
  78856. /** Change selector label to the one given
  78857. * @param label is the new selector label
  78858. * @param groupNb is the number of the groupcontaining the selector
  78859. * @param selectorNb is the number of the selector within a group to relabel
  78860. * */
  78861. relabel(label: string, groupNb: number, selectorNb: number): void;
  78862. /** For a given group position remove the selector at the given position
  78863. * @param groupNb is the number of the group to remove the selector from
  78864. * @param selectorNb is the number of the selector within the group
  78865. */
  78866. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78867. /** For a given group position of correct type add a checkbox button
  78868. * @param groupNb is the number of the group to remove the selector from
  78869. * @param label is the label for the selector
  78870. * @param func is the function called when the Selector is checked
  78871. * @param checked is true when Selector is checked
  78872. */
  78873. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78874. /** For a given group position of correct type add a radio button
  78875. * @param groupNb is the number of the group to remove the selector from
  78876. * @param label is the label for the selector
  78877. * @param func is the function called when the Selector is checked
  78878. * @param checked is true when Selector is checked
  78879. */
  78880. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78881. /**
  78882. * For a given slider group add a slider
  78883. * @param groupNb is the number of the group to add the slider to
  78884. * @param label is the label for the Slider
  78885. * @param func is the function called when the Slider moves
  78886. * @param unit is a string describing the units used, eg degrees or metres
  78887. * @param min is the minimum value for the Slider
  78888. * @param max is the maximum value for the Slider
  78889. * @param value is the start value for the Slider between min and max
  78890. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78891. */
  78892. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78893. }
  78894. }
  78895. declare module BABYLON.GUI {
  78896. /**
  78897. * Class used to hold a the container for ScrollViewer
  78898. * @hidden
  78899. */
  78900. export class _ScrollViewerWindow extends Container {
  78901. parentClientWidth: number;
  78902. parentClientHeight: number;
  78903. private _freezeControls;
  78904. private _parentMeasure;
  78905. private _oldLeft;
  78906. private _oldTop;
  78907. get freezeControls(): boolean;
  78908. set freezeControls(value: boolean);
  78909. private _bucketWidth;
  78910. private _bucketHeight;
  78911. private _buckets;
  78912. private _bucketLen;
  78913. get bucketWidth(): number;
  78914. get bucketHeight(): number;
  78915. setBucketSizes(width: number, height: number): void;
  78916. private _useBuckets;
  78917. private _makeBuckets;
  78918. private _dispatchInBuckets;
  78919. private _updateMeasures;
  78920. private _updateChildrenMeasures;
  78921. private _restoreMeasures;
  78922. /**
  78923. * Creates a new ScrollViewerWindow
  78924. * @param name of ScrollViewerWindow
  78925. */
  78926. constructor(name?: string);
  78927. protected _getTypeName(): string;
  78928. /** @hidden */
  78929. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78930. /** @hidden */
  78931. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78932. private _scrollChildren;
  78933. private _scrollChildrenWithBuckets;
  78934. /** @hidden */
  78935. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78936. protected _postMeasure(): void;
  78937. }
  78938. }
  78939. declare module BABYLON.GUI {
  78940. /**
  78941. * Class used to create slider controls
  78942. */
  78943. export class ScrollBar extends BaseSlider {
  78944. name?: string | undefined;
  78945. private _background;
  78946. private _borderColor;
  78947. private _tempMeasure;
  78948. /** Gets or sets border color */
  78949. get borderColor(): string;
  78950. set borderColor(value: string);
  78951. /** Gets or sets background color */
  78952. get background(): string;
  78953. set background(value: string);
  78954. /**
  78955. * Creates a new Slider
  78956. * @param name defines the control name
  78957. */
  78958. constructor(name?: string | undefined);
  78959. protected _getTypeName(): string;
  78960. protected _getThumbThickness(): number;
  78961. _draw(context: CanvasRenderingContext2D): void;
  78962. private _first;
  78963. private _originX;
  78964. private _originY;
  78965. /** @hidden */
  78966. protected _updateValueFromPointer(x: number, y: number): void;
  78967. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78968. }
  78969. }
  78970. declare module BABYLON.GUI {
  78971. /**
  78972. * Class used to create slider controls
  78973. */
  78974. export class ImageScrollBar extends BaseSlider {
  78975. name?: string | undefined;
  78976. private _backgroundBaseImage;
  78977. private _backgroundImage;
  78978. private _thumbImage;
  78979. private _thumbBaseImage;
  78980. private _thumbLength;
  78981. private _thumbHeight;
  78982. private _barImageHeight;
  78983. private _tempMeasure;
  78984. /** Number of 90° rotation to apply on the images when in vertical mode */
  78985. num90RotationInVerticalMode: number;
  78986. /**
  78987. * Gets or sets the image used to render the background for horizontal bar
  78988. */
  78989. get backgroundImage(): Image;
  78990. set backgroundImage(value: Image);
  78991. /**
  78992. * Gets or sets the image used to render the thumb
  78993. */
  78994. get thumbImage(): Image;
  78995. set thumbImage(value: Image);
  78996. /**
  78997. * Gets or sets the length of the thumb
  78998. */
  78999. get thumbLength(): number;
  79000. set thumbLength(value: number);
  79001. /**
  79002. * Gets or sets the height of the thumb
  79003. */
  79004. get thumbHeight(): number;
  79005. set thumbHeight(value: number);
  79006. /**
  79007. * Gets or sets the height of the bar image
  79008. */
  79009. get barImageHeight(): number;
  79010. set barImageHeight(value: number);
  79011. /**
  79012. * Creates a new ImageScrollBar
  79013. * @param name defines the control name
  79014. */
  79015. constructor(name?: string | undefined);
  79016. protected _getTypeName(): string;
  79017. protected _getThumbThickness(): number;
  79018. _draw(context: CanvasRenderingContext2D): void;
  79019. private _first;
  79020. private _originX;
  79021. private _originY;
  79022. /** @hidden */
  79023. protected _updateValueFromPointer(x: number, y: number): void;
  79024. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79025. }
  79026. }
  79027. declare module BABYLON.GUI {
  79028. /**
  79029. * Class used to hold a viewer window and sliders in a grid
  79030. */
  79031. export class ScrollViewer extends Rectangle {
  79032. private _grid;
  79033. private _horizontalBarSpace;
  79034. private _verticalBarSpace;
  79035. private _dragSpace;
  79036. private _horizontalBar;
  79037. private _verticalBar;
  79038. private _barColor;
  79039. private _barBackground;
  79040. private _barImage;
  79041. private _horizontalBarImage;
  79042. private _verticalBarImage;
  79043. private _barBackgroundImage;
  79044. private _horizontalBarBackgroundImage;
  79045. private _verticalBarBackgroundImage;
  79046. private _barSize;
  79047. private _window;
  79048. private _pointerIsOver;
  79049. private _wheelPrecision;
  79050. private _onWheelObserver;
  79051. private _clientWidth;
  79052. private _clientHeight;
  79053. private _useImageBar;
  79054. private _thumbLength;
  79055. private _thumbHeight;
  79056. private _barImageHeight;
  79057. private _horizontalBarImageHeight;
  79058. private _verticalBarImageHeight;
  79059. private _oldWindowContentsWidth;
  79060. private _oldWindowContentsHeight;
  79061. /**
  79062. * Gets the horizontal scrollbar
  79063. */
  79064. get horizontalBar(): ScrollBar | ImageScrollBar;
  79065. /**
  79066. * Gets the vertical scrollbar
  79067. */
  79068. get verticalBar(): ScrollBar | ImageScrollBar;
  79069. /**
  79070. * Adds a new control to the current container
  79071. * @param control defines the control to add
  79072. * @returns the current container
  79073. */
  79074. addControl(control: BABYLON.Nullable<Control>): Container;
  79075. /**
  79076. * Removes a control from the current container
  79077. * @param control defines the control to remove
  79078. * @returns the current container
  79079. */
  79080. removeControl(control: Control): Container;
  79081. /** Gets the list of children */
  79082. get children(): Control[];
  79083. _flagDescendantsAsMatrixDirty(): void;
  79084. /**
  79085. * Freezes or unfreezes the controls in the window.
  79086. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79087. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79088. */
  79089. get freezeControls(): boolean;
  79090. set freezeControls(value: boolean);
  79091. /** Gets the bucket width */
  79092. get bucketWidth(): number;
  79093. /** Gets the bucket height */
  79094. get bucketHeight(): number;
  79095. /**
  79096. * Sets the bucket sizes.
  79097. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79098. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79099. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79100. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79101. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79102. * used), that's why it is not enabled by default.
  79103. * @param width width of the bucket
  79104. * @param height height of the bucket
  79105. */
  79106. setBucketSizes(width: number, height: number): void;
  79107. private _forceHorizontalBar;
  79108. private _forceVerticalBar;
  79109. /**
  79110. * Forces the horizontal scroll bar to be displayed
  79111. */
  79112. get forceHorizontalBar(): boolean;
  79113. set forceHorizontalBar(value: boolean);
  79114. /**
  79115. * Forces the vertical scroll bar to be displayed
  79116. */
  79117. get forceVerticalBar(): boolean;
  79118. set forceVerticalBar(value: boolean);
  79119. /**
  79120. * Creates a new ScrollViewer
  79121. * @param name of ScrollViewer
  79122. */
  79123. constructor(name?: string, isImageBased?: boolean);
  79124. /** Reset the scroll viewer window to initial size */
  79125. resetWindow(): void;
  79126. protected _getTypeName(): string;
  79127. private _buildClientSizes;
  79128. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79129. protected _postMeasure(): void;
  79130. /**
  79131. * Gets or sets the mouse wheel precision
  79132. * from 0 to 1 with a default value of 0.05
  79133. * */
  79134. get wheelPrecision(): number;
  79135. set wheelPrecision(value: number);
  79136. /** Gets or sets the scroll bar container background color */
  79137. get scrollBackground(): string;
  79138. set scrollBackground(color: string);
  79139. /** Gets or sets the bar color */
  79140. get barColor(): string;
  79141. set barColor(color: string);
  79142. /** Gets or sets the bar image */
  79143. get thumbImage(): Image;
  79144. set thumbImage(value: Image);
  79145. /** Gets or sets the horizontal bar image */
  79146. get horizontalThumbImage(): Image;
  79147. set horizontalThumbImage(value: Image);
  79148. /** Gets or sets the vertical bar image */
  79149. get verticalThumbImage(): Image;
  79150. set verticalThumbImage(value: Image);
  79151. /** Gets or sets the size of the bar */
  79152. get barSize(): number;
  79153. set barSize(value: number);
  79154. /** Gets or sets the length of the thumb */
  79155. get thumbLength(): number;
  79156. set thumbLength(value: number);
  79157. /** Gets or sets the height of the thumb */
  79158. get thumbHeight(): number;
  79159. set thumbHeight(value: number);
  79160. /** Gets or sets the height of the bar image */
  79161. get barImageHeight(): number;
  79162. set barImageHeight(value: number);
  79163. /** Gets or sets the height of the horizontal bar image */
  79164. get horizontalBarImageHeight(): number;
  79165. set horizontalBarImageHeight(value: number);
  79166. /** Gets or sets the height of the vertical bar image */
  79167. get verticalBarImageHeight(): number;
  79168. set verticalBarImageHeight(value: number);
  79169. /** Gets or sets the bar background */
  79170. get barBackground(): string;
  79171. set barBackground(color: string);
  79172. /** Gets or sets the bar background image */
  79173. get barImage(): Image;
  79174. set barImage(value: Image);
  79175. /** Gets or sets the horizontal bar background image */
  79176. get horizontalBarImage(): Image;
  79177. set horizontalBarImage(value: Image);
  79178. /** Gets or sets the vertical bar background image */
  79179. get verticalBarImage(): Image;
  79180. set verticalBarImage(value: Image);
  79181. private _setWindowPosition;
  79182. /** @hidden */
  79183. private _updateScroller;
  79184. _link(host: AdvancedDynamicTexture): void;
  79185. /** @hidden */
  79186. private _addBar;
  79187. /** @hidden */
  79188. private _attachWheel;
  79189. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79190. /** Releases associated resources */
  79191. dispose(): void;
  79192. }
  79193. }
  79194. declare module BABYLON.GUI {
  79195. /** Class used to render a grid */
  79196. export class DisplayGrid extends Control {
  79197. name?: string | undefined;
  79198. private _cellWidth;
  79199. private _cellHeight;
  79200. private _minorLineTickness;
  79201. private _minorLineColor;
  79202. private _majorLineTickness;
  79203. private _majorLineColor;
  79204. private _majorLineFrequency;
  79205. private _background;
  79206. private _displayMajorLines;
  79207. private _displayMinorLines;
  79208. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79209. get displayMinorLines(): boolean;
  79210. set displayMinorLines(value: boolean);
  79211. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79212. get displayMajorLines(): boolean;
  79213. set displayMajorLines(value: boolean);
  79214. /** Gets or sets background color (Black by default) */
  79215. get background(): string;
  79216. set background(value: string);
  79217. /** Gets or sets the width of each cell (20 by default) */
  79218. get cellWidth(): number;
  79219. set cellWidth(value: number);
  79220. /** Gets or sets the height of each cell (20 by default) */
  79221. get cellHeight(): number;
  79222. set cellHeight(value: number);
  79223. /** Gets or sets the tickness of minor lines (1 by default) */
  79224. get minorLineTickness(): number;
  79225. set minorLineTickness(value: number);
  79226. /** Gets or sets the color of minor lines (DarkGray by default) */
  79227. get minorLineColor(): string;
  79228. set minorLineColor(value: string);
  79229. /** Gets or sets the tickness of major lines (2 by default) */
  79230. get majorLineTickness(): number;
  79231. set majorLineTickness(value: number);
  79232. /** Gets or sets the color of major lines (White by default) */
  79233. get majorLineColor(): string;
  79234. set majorLineColor(value: string);
  79235. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79236. get majorLineFrequency(): number;
  79237. set majorLineFrequency(value: number);
  79238. /**
  79239. * Creates a new GridDisplayRectangle
  79240. * @param name defines the control name
  79241. */
  79242. constructor(name?: string | undefined);
  79243. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79244. protected _getTypeName(): string;
  79245. }
  79246. }
  79247. declare module BABYLON.GUI {
  79248. /**
  79249. * Class used to create slider controls based on images
  79250. */
  79251. export class ImageBasedSlider extends BaseSlider {
  79252. name?: string | undefined;
  79253. private _backgroundImage;
  79254. private _thumbImage;
  79255. private _valueBarImage;
  79256. private _tempMeasure;
  79257. get displayThumb(): boolean;
  79258. set displayThumb(value: boolean);
  79259. /**
  79260. * Gets or sets the image used to render the background
  79261. */
  79262. get backgroundImage(): Image;
  79263. set backgroundImage(value: Image);
  79264. /**
  79265. * Gets or sets the image used to render the value bar
  79266. */
  79267. get valueBarImage(): Image;
  79268. set valueBarImage(value: Image);
  79269. /**
  79270. * Gets or sets the image used to render the thumb
  79271. */
  79272. get thumbImage(): Image;
  79273. set thumbImage(value: Image);
  79274. /**
  79275. * Creates a new ImageBasedSlider
  79276. * @param name defines the control name
  79277. */
  79278. constructor(name?: string | undefined);
  79279. protected _getTypeName(): string;
  79280. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79281. }
  79282. }
  79283. declare module BABYLON.GUI {
  79284. /**
  79285. * Forcing an export so that this code will execute
  79286. * @hidden
  79287. */
  79288. const name = "Statics";
  79289. }
  79290. declare module BABYLON.GUI {
  79291. /**
  79292. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79293. */
  79294. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79295. /**
  79296. * Define the instrumented AdvancedDynamicTexture.
  79297. */
  79298. texture: AdvancedDynamicTexture;
  79299. private _captureRenderTime;
  79300. private _renderTime;
  79301. private _captureLayoutTime;
  79302. private _layoutTime;
  79303. private _onBeginRenderObserver;
  79304. private _onEndRenderObserver;
  79305. private _onBeginLayoutObserver;
  79306. private _onEndLayoutObserver;
  79307. /**
  79308. * Gets the perf counter used to capture render time
  79309. */
  79310. get renderTimeCounter(): BABYLON.PerfCounter;
  79311. /**
  79312. * Gets the perf counter used to capture layout time
  79313. */
  79314. get layoutTimeCounter(): BABYLON.PerfCounter;
  79315. /**
  79316. * Enable or disable the render time capture
  79317. */
  79318. get captureRenderTime(): boolean;
  79319. set captureRenderTime(value: boolean);
  79320. /**
  79321. * Enable or disable the layout time capture
  79322. */
  79323. get captureLayoutTime(): boolean;
  79324. set captureLayoutTime(value: boolean);
  79325. /**
  79326. * Instantiates a new advanced dynamic texture instrumentation.
  79327. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79328. * @param texture Defines the AdvancedDynamicTexture to instrument
  79329. */
  79330. constructor(
  79331. /**
  79332. * Define the instrumented AdvancedDynamicTexture.
  79333. */
  79334. texture: AdvancedDynamicTexture);
  79335. /**
  79336. * Dispose and release associated resources.
  79337. */
  79338. dispose(): void;
  79339. }
  79340. }
  79341. declare module BABYLON.GUI {
  79342. /**
  79343. * Class used to load GUI via XML.
  79344. */
  79345. export class XmlLoader {
  79346. private _nodes;
  79347. private _nodeTypes;
  79348. private _isLoaded;
  79349. private _objectAttributes;
  79350. private _parentClass;
  79351. /**
  79352. * Create a new xml loader
  79353. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79354. */
  79355. constructor(parentClass?: null);
  79356. private _getChainElement;
  79357. private _getClassAttribute;
  79358. private _createGuiElement;
  79359. private _parseGrid;
  79360. private _parseElement;
  79361. private _prepareSourceElement;
  79362. private _parseElementsFromSource;
  79363. private _parseXml;
  79364. /**
  79365. * Gets if the loading has finished.
  79366. * @returns whether the loading has finished or not
  79367. */
  79368. isLoaded(): boolean;
  79369. /**
  79370. * Gets a loaded node / control by id.
  79371. * @param id the Controls id set in the xml
  79372. * @returns element of type Control
  79373. */
  79374. getNodeById(id: string): any;
  79375. /**
  79376. * Gets all loaded nodes / controls
  79377. * @returns Array of controls
  79378. */
  79379. getNodes(): any;
  79380. /**
  79381. * Initiates the xml layout loading
  79382. * @param xmlFile defines the xml layout to load
  79383. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79384. * @param callback defines the callback called on layout load.
  79385. */
  79386. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79387. }
  79388. }
  79389. declare module BABYLON.GUI {
  79390. /**
  79391. * Class used to create containers for controls
  79392. */
  79393. export class Container3D extends Control3D {
  79394. private _blockLayout;
  79395. /**
  79396. * Gets the list of child controls
  79397. */
  79398. protected _children: Control3D[];
  79399. /**
  79400. * Gets the list of child controls
  79401. */
  79402. get children(): Array<Control3D>;
  79403. /**
  79404. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79405. * This is helpful to optimize layout operation when adding multiple children in a row
  79406. */
  79407. get blockLayout(): boolean;
  79408. set blockLayout(value: boolean);
  79409. /**
  79410. * Creates a new container
  79411. * @param name defines the container name
  79412. */
  79413. constructor(name?: string);
  79414. /**
  79415. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79416. * @returns the current container
  79417. */
  79418. updateLayout(): Container3D;
  79419. /**
  79420. * Gets a boolean indicating if the given control is in the children of this control
  79421. * @param control defines the control to check
  79422. * @returns true if the control is in the child list
  79423. */
  79424. containsControl(control: Control3D): boolean;
  79425. /**
  79426. * Adds a control to the children of this control
  79427. * @param control defines the control to add
  79428. * @returns the current container
  79429. */
  79430. addControl(control: Control3D): Container3D;
  79431. /**
  79432. * This function will be called everytime a new control is added
  79433. */
  79434. protected _arrangeChildren(): void;
  79435. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79436. /**
  79437. * Removes a control from the children of this control
  79438. * @param control defines the control to remove
  79439. * @returns the current container
  79440. */
  79441. removeControl(control: Control3D): Container3D;
  79442. protected _getTypeName(): string;
  79443. /**
  79444. * Releases all associated resources
  79445. */
  79446. dispose(): void;
  79447. /** Control rotation will remain unchanged */
  79448. static readonly UNSET_ORIENTATION: number;
  79449. /** Control will rotate to make it look at sphere central axis */
  79450. static readonly FACEORIGIN_ORIENTATION: number;
  79451. /** Control will rotate to make it look back at sphere central axis */
  79452. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79453. /** Control will rotate to look at z axis (0, 0, 1) */
  79454. static readonly FACEFORWARD_ORIENTATION: number;
  79455. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79456. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79457. }
  79458. }
  79459. declare module BABYLON.GUI {
  79460. /**
  79461. * Class used to manage 3D user interface
  79462. * @see https://doc.babylonjs.com/how_to/gui3d
  79463. */
  79464. export class GUI3DManager implements BABYLON.IDisposable {
  79465. private _scene;
  79466. private _sceneDisposeObserver;
  79467. private _utilityLayer;
  79468. private _rootContainer;
  79469. private _pointerObserver;
  79470. private _pointerOutObserver;
  79471. /** @hidden */
  79472. _lastPickedControl: Control3D;
  79473. /** @hidden */
  79474. _lastControlOver: {
  79475. [pointerId: number]: Control3D;
  79476. };
  79477. /** @hidden */
  79478. _lastControlDown: {
  79479. [pointerId: number]: Control3D;
  79480. };
  79481. /**
  79482. * BABYLON.Observable raised when the point picked by the pointer events changed
  79483. */
  79484. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79485. /** @hidden */
  79486. _sharedMaterials: {
  79487. [key: string]: BABYLON.Material;
  79488. };
  79489. /** Gets the hosting scene */
  79490. get scene(): BABYLON.Scene;
  79491. /** Gets associated utility layer */
  79492. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79493. /**
  79494. * Creates a new GUI3DManager
  79495. * @param scene
  79496. */
  79497. constructor(scene?: BABYLON.Scene);
  79498. private _handlePointerOut;
  79499. private _doPicking;
  79500. /**
  79501. * Gets the root container
  79502. */
  79503. get rootContainer(): Container3D;
  79504. /**
  79505. * Gets a boolean indicating if the given control is in the root child list
  79506. * @param control defines the control to check
  79507. * @returns true if the control is in the root child list
  79508. */
  79509. containsControl(control: Control3D): boolean;
  79510. /**
  79511. * Adds a control to the root child list
  79512. * @param control defines the control to add
  79513. * @returns the current manager
  79514. */
  79515. addControl(control: Control3D): GUI3DManager;
  79516. /**
  79517. * Removes a control from the root child list
  79518. * @param control defines the control to remove
  79519. * @returns the current container
  79520. */
  79521. removeControl(control: Control3D): GUI3DManager;
  79522. /**
  79523. * Releases all associated resources
  79524. */
  79525. dispose(): void;
  79526. }
  79527. }
  79528. declare module BABYLON.GUI {
  79529. /**
  79530. * Class used to transport BABYLON.Vector3 information for pointer events
  79531. */
  79532. export class Vector3WithInfo extends BABYLON.Vector3 {
  79533. /** defines the current mouse button index */
  79534. buttonIndex: number;
  79535. /**
  79536. * Creates a new Vector3WithInfo
  79537. * @param source defines the vector3 data to transport
  79538. * @param buttonIndex defines the current mouse button index
  79539. */
  79540. constructor(source: BABYLON.Vector3,
  79541. /** defines the current mouse button index */
  79542. buttonIndex?: number);
  79543. }
  79544. }
  79545. declare module BABYLON.GUI {
  79546. /**
  79547. * Class used as base class for controls
  79548. */
  79549. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79550. /** Defines the control name */
  79551. name?: string | undefined;
  79552. /** @hidden */
  79553. _host: GUI3DManager;
  79554. private _node;
  79555. private _downCount;
  79556. private _enterCount;
  79557. private _downPointerIds;
  79558. private _isVisible;
  79559. /** Gets or sets the control position in world space */
  79560. get position(): BABYLON.Vector3;
  79561. set position(value: BABYLON.Vector3);
  79562. /** Gets or sets the control scaling in world space */
  79563. get scaling(): BABYLON.Vector3;
  79564. set scaling(value: BABYLON.Vector3);
  79565. /** Callback used to start pointer enter animation */
  79566. pointerEnterAnimation: () => void;
  79567. /** Callback used to start pointer out animation */
  79568. pointerOutAnimation: () => void;
  79569. /** Callback used to start pointer down animation */
  79570. pointerDownAnimation: () => void;
  79571. /** Callback used to start pointer up animation */
  79572. pointerUpAnimation: () => void;
  79573. /**
  79574. * An event triggered when the pointer move over the control
  79575. */
  79576. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79577. /**
  79578. * An event triggered when the pointer move out of the control
  79579. */
  79580. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79581. /**
  79582. * An event triggered when the pointer taps the control
  79583. */
  79584. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79585. /**
  79586. * An event triggered when pointer is up
  79587. */
  79588. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79589. /**
  79590. * An event triggered when a control is clicked on (with a mouse)
  79591. */
  79592. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79593. /**
  79594. * An event triggered when pointer enters the control
  79595. */
  79596. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79597. /**
  79598. * Gets or sets the parent container
  79599. */
  79600. parent: BABYLON.Nullable<Container3D>;
  79601. private _behaviors;
  79602. /**
  79603. * Gets the list of attached behaviors
  79604. * @see https://doc.babylonjs.com/features/behaviour
  79605. */
  79606. get behaviors(): BABYLON.Behavior<Control3D>[];
  79607. /**
  79608. * Attach a behavior to the control
  79609. * @see https://doc.babylonjs.com/features/behaviour
  79610. * @param behavior defines the behavior to attach
  79611. * @returns the current control
  79612. */
  79613. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79614. /**
  79615. * Remove an attached behavior
  79616. * @see https://doc.babylonjs.com/features/behaviour
  79617. * @param behavior defines the behavior to attach
  79618. * @returns the current control
  79619. */
  79620. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79621. /**
  79622. * Gets an attached behavior by name
  79623. * @param name defines the name of the behavior to look for
  79624. * @see https://doc.babylonjs.com/features/behaviour
  79625. * @returns null if behavior was not found else the requested behavior
  79626. */
  79627. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79628. /** Gets or sets a boolean indicating if the control is visible */
  79629. get isVisible(): boolean;
  79630. set isVisible(value: boolean);
  79631. /**
  79632. * Creates a new control
  79633. * @param name defines the control name
  79634. */
  79635. constructor(
  79636. /** Defines the control name */
  79637. name?: string | undefined);
  79638. /**
  79639. * Gets a string representing the class name
  79640. */
  79641. get typeName(): string;
  79642. /**
  79643. * Get the current class name of the control.
  79644. * @returns current class name
  79645. */
  79646. getClassName(): string;
  79647. protected _getTypeName(): string;
  79648. /**
  79649. * Gets the transform node used by this control
  79650. */
  79651. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79652. /**
  79653. * Gets the mesh used to render this control
  79654. */
  79655. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79656. /**
  79657. * Link the control as child of the given node
  79658. * @param node defines the node to link to. Use null to unlink the control
  79659. * @returns the current control
  79660. */
  79661. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79662. /** @hidden **/
  79663. _prepareNode(scene: BABYLON.Scene): void;
  79664. /**
  79665. * Node creation.
  79666. * Can be overriden by children
  79667. * @param scene defines the scene where the node must be attached
  79668. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79669. */
  79670. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79671. /**
  79672. * Affect a material to the given mesh
  79673. * @param mesh defines the mesh which will represent the control
  79674. */
  79675. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79676. /** @hidden */
  79677. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79678. /** @hidden */
  79679. _onPointerEnter(target: Control3D): boolean;
  79680. /** @hidden */
  79681. _onPointerOut(target: Control3D): void;
  79682. /** @hidden */
  79683. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79684. /** @hidden */
  79685. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79686. /** @hidden */
  79687. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79688. /** @hidden */
  79689. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79690. /** @hidden */
  79691. _disposeNode(): void;
  79692. /**
  79693. * Releases all associated resources
  79694. */
  79695. dispose(): void;
  79696. }
  79697. }
  79698. declare module BABYLON.GUI {
  79699. /**
  79700. * Class used as a root to all buttons
  79701. */
  79702. export class AbstractButton3D extends Control3D {
  79703. /**
  79704. * Creates a new button
  79705. * @param name defines the control name
  79706. */
  79707. constructor(name?: string);
  79708. protected _getTypeName(): string;
  79709. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79710. }
  79711. }
  79712. declare module BABYLON.GUI {
  79713. /**
  79714. * Class used to create a button in 3D
  79715. */
  79716. export class Button3D extends AbstractButton3D {
  79717. /** @hidden */
  79718. protected _currentMaterial: BABYLON.Material;
  79719. private _facadeTexture;
  79720. private _content;
  79721. private _contentResolution;
  79722. private _contentScaleRatio;
  79723. /**
  79724. * Gets or sets the texture resolution used to render content (512 by default)
  79725. */
  79726. get contentResolution(): BABYLON.int;
  79727. set contentResolution(value: BABYLON.int);
  79728. /**
  79729. * Gets or sets the texture scale ratio used to render content (2 by default)
  79730. */
  79731. get contentScaleRatio(): number;
  79732. set contentScaleRatio(value: number);
  79733. protected _disposeFacadeTexture(): void;
  79734. protected _resetContent(): void;
  79735. /**
  79736. * Creates a new button
  79737. * @param name defines the control name
  79738. */
  79739. constructor(name?: string);
  79740. /**
  79741. * Gets or sets the GUI 2D content used to display the button's facade
  79742. */
  79743. get content(): Control;
  79744. set content(value: Control);
  79745. /**
  79746. * Apply the facade texture (created from the content property).
  79747. * This function can be overloaded by child classes
  79748. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79749. */
  79750. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79751. protected _getTypeName(): string;
  79752. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79753. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79754. /**
  79755. * Releases all associated resources
  79756. */
  79757. dispose(): void;
  79758. }
  79759. }
  79760. declare module BABYLON.GUI {
  79761. /**
  79762. * Abstract class used to create a container panel deployed on the surface of a volume
  79763. */
  79764. export abstract class VolumeBasedPanel extends Container3D {
  79765. private _columns;
  79766. private _rows;
  79767. private _rowThenColum;
  79768. private _orientation;
  79769. protected _cellWidth: number;
  79770. protected _cellHeight: number;
  79771. /**
  79772. * Gets or sets the distance between elements
  79773. */
  79774. margin: number;
  79775. /**
  79776. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79777. * | Value | Type | Description |
  79778. * | ----- | ----------------------------------- | ----------- |
  79779. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79780. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79781. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79782. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79783. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79784. */
  79785. get orientation(): number;
  79786. set orientation(value: number);
  79787. /**
  79788. * Gets or sets the number of columns requested (10 by default).
  79789. * The panel will automatically compute the number of rows based on number of child controls.
  79790. */
  79791. get columns(): BABYLON.int;
  79792. set columns(value: BABYLON.int);
  79793. /**
  79794. * Gets or sets a the number of rows requested.
  79795. * The panel will automatically compute the number of columns based on number of child controls.
  79796. */
  79797. get rows(): BABYLON.int;
  79798. set rows(value: BABYLON.int);
  79799. /**
  79800. * Creates new VolumeBasedPanel
  79801. */
  79802. constructor();
  79803. protected _arrangeChildren(): void;
  79804. /** Child classes must implement this function to provide correct control positioning */
  79805. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79806. /** Child classes can implement this function to provide additional processing */
  79807. protected _finalProcessing(): void;
  79808. }
  79809. }
  79810. declare module BABYLON.GUI {
  79811. /**
  79812. * Class used to create a container panel deployed on the surface of a cylinder
  79813. */
  79814. export class CylinderPanel extends VolumeBasedPanel {
  79815. private _radius;
  79816. /**
  79817. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79818. */
  79819. get radius(): BABYLON.float;
  79820. set radius(value: BABYLON.float);
  79821. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79822. private _cylindricalMapping;
  79823. }
  79824. }
  79825. declare module BABYLON.GUI {
  79826. /** @hidden */
  79827. export var fluentVertexShader: {
  79828. name: string;
  79829. shader: string;
  79830. };
  79831. }
  79832. declare module BABYLON.GUI {
  79833. /** @hidden */
  79834. export var fluentPixelShader: {
  79835. name: string;
  79836. shader: string;
  79837. };
  79838. }
  79839. declare module BABYLON.GUI {
  79840. /** @hidden */
  79841. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79842. INNERGLOW: boolean;
  79843. BORDER: boolean;
  79844. HOVERLIGHT: boolean;
  79845. TEXTURE: boolean;
  79846. constructor();
  79847. }
  79848. /**
  79849. * Class used to render controls with fluent desgin
  79850. */
  79851. export class FluentMaterial extends BABYLON.PushMaterial {
  79852. /**
  79853. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79854. */
  79855. innerGlowColorIntensity: number;
  79856. /**
  79857. * Gets or sets the inner glow color (white by default)
  79858. */
  79859. innerGlowColor: BABYLON.Color3;
  79860. /**
  79861. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79862. */
  79863. albedoColor: BABYLON.Color3;
  79864. /**
  79865. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79866. */
  79867. renderBorders: boolean;
  79868. /**
  79869. * Gets or sets border width (default is 0.5)
  79870. */
  79871. borderWidth: number;
  79872. /**
  79873. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79874. */
  79875. edgeSmoothingValue: number;
  79876. /**
  79877. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79878. */
  79879. borderMinValue: number;
  79880. /**
  79881. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79882. */
  79883. renderHoverLight: boolean;
  79884. /**
  79885. * Gets or sets the radius used to render the hover light (default is 1.0)
  79886. */
  79887. hoverRadius: number;
  79888. /**
  79889. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79890. */
  79891. hoverColor: BABYLON.Color4;
  79892. /**
  79893. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79894. */
  79895. hoverPosition: BABYLON.Vector3;
  79896. private _albedoTexture;
  79897. /** Gets or sets the texture to use for albedo color */
  79898. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79899. /**
  79900. * Creates a new Fluent material
  79901. * @param name defines the name of the material
  79902. * @param scene defines the hosting scene
  79903. */
  79904. constructor(name: string, scene: BABYLON.Scene);
  79905. needAlphaBlending(): boolean;
  79906. needAlphaTesting(): boolean;
  79907. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79908. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79909. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79910. getActiveTextures(): BABYLON.BaseTexture[];
  79911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79912. dispose(forceDisposeEffect?: boolean): void;
  79913. clone(name: string): FluentMaterial;
  79914. serialize(): any;
  79915. getClassName(): string;
  79916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79917. }
  79918. }
  79919. declare module BABYLON.GUI {
  79920. /**
  79921. * Class used to create a holographic button in 3D
  79922. */
  79923. export class HolographicButton extends Button3D {
  79924. private _backPlate;
  79925. private _textPlate;
  79926. private _frontPlate;
  79927. private _text;
  79928. private _imageUrl;
  79929. private _shareMaterials;
  79930. private _frontMaterial;
  79931. private _backMaterial;
  79932. private _plateMaterial;
  79933. private _pickedPointObserver;
  79934. private _tooltipFade;
  79935. private _tooltipTextBlock;
  79936. private _tooltipTexture;
  79937. private _tooltipMesh;
  79938. private _tooltipHoverObserver;
  79939. private _tooltipOutObserver;
  79940. private _disposeTooltip;
  79941. /**
  79942. * Rendering ground id of all the mesh in the button
  79943. */
  79944. set renderingGroupId(id: number);
  79945. get renderingGroupId(): number;
  79946. /**
  79947. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79948. */
  79949. set tooltipText(text: BABYLON.Nullable<string>);
  79950. get tooltipText(): BABYLON.Nullable<string>;
  79951. /**
  79952. * Gets or sets text for the button
  79953. */
  79954. get text(): string;
  79955. set text(value: string);
  79956. /**
  79957. * Gets or sets the image url for the button
  79958. */
  79959. get imageUrl(): string;
  79960. set imageUrl(value: string);
  79961. /**
  79962. * Gets the back material used by this button
  79963. */
  79964. get backMaterial(): FluentMaterial;
  79965. /**
  79966. * Gets the front material used by this button
  79967. */
  79968. get frontMaterial(): FluentMaterial;
  79969. /**
  79970. * Gets the plate material used by this button
  79971. */
  79972. get plateMaterial(): BABYLON.StandardMaterial;
  79973. /**
  79974. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79975. */
  79976. get shareMaterials(): boolean;
  79977. /**
  79978. * Creates a new button
  79979. * @param name defines the control name
  79980. */
  79981. constructor(name?: string, shareMaterials?: boolean);
  79982. protected _getTypeName(): string;
  79983. private _rebuildContent;
  79984. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79985. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79986. private _createBackMaterial;
  79987. private _createFrontMaterial;
  79988. private _createPlateMaterial;
  79989. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79990. /**
  79991. * Releases all associated resources
  79992. */
  79993. dispose(): void;
  79994. }
  79995. }
  79996. declare module BABYLON.GUI {
  79997. /**
  79998. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79999. */
  80000. export class MeshButton3D extends Button3D {
  80001. /** @hidden */
  80002. protected _currentMesh: BABYLON.Mesh;
  80003. /**
  80004. * Creates a new 3D button based on a mesh
  80005. * @param mesh mesh to become a 3D button
  80006. * @param name defines the control name
  80007. */
  80008. constructor(mesh: BABYLON.Mesh, name?: string);
  80009. protected _getTypeName(): string;
  80010. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80011. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80012. }
  80013. }
  80014. declare module BABYLON.GUI {
  80015. /**
  80016. * Class used to create a container panel deployed on the surface of a plane
  80017. */
  80018. export class PlanePanel extends VolumeBasedPanel {
  80019. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80020. }
  80021. }
  80022. declare module BABYLON.GUI {
  80023. /**
  80024. * Class used to create a container panel where items get randomized planar mapping
  80025. */
  80026. export class ScatterPanel extends VolumeBasedPanel {
  80027. private _iteration;
  80028. /**
  80029. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80030. */
  80031. get iteration(): BABYLON.float;
  80032. set iteration(value: BABYLON.float);
  80033. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80034. private _scatterMapping;
  80035. protected _finalProcessing(): void;
  80036. }
  80037. }
  80038. declare module BABYLON.GUI {
  80039. /**
  80040. * Class used to create a container panel deployed on the surface of a sphere
  80041. */
  80042. export class SpherePanel extends VolumeBasedPanel {
  80043. private _radius;
  80044. /**
  80045. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80046. */
  80047. get radius(): BABYLON.float;
  80048. set radius(value: BABYLON.float);
  80049. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80050. private _sphericalMapping;
  80051. }
  80052. }
  80053. declare module BABYLON.GUI {
  80054. /**
  80055. * Class used to create a stack panel in 3D on XY plane
  80056. */
  80057. export class StackPanel3D extends Container3D {
  80058. private _isVertical;
  80059. /**
  80060. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80061. */
  80062. get isVertical(): boolean;
  80063. set isVertical(value: boolean);
  80064. /**
  80065. * Gets or sets the distance between elements
  80066. */
  80067. margin: number;
  80068. /**
  80069. * Creates new StackPanel
  80070. * @param isVertical
  80071. */
  80072. constructor(isVertical?: boolean);
  80073. protected _arrangeChildren(): void;
  80074. }
  80075. }
  80076. declare module BABYLON {
  80077. /**
  80078. * Configuration for glTF validation
  80079. */
  80080. export interface IGLTFValidationConfiguration {
  80081. /**
  80082. * The url of the glTF validator.
  80083. */
  80084. url: string;
  80085. }
  80086. /**
  80087. * glTF validation
  80088. */
  80089. export class GLTFValidation {
  80090. /**
  80091. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80092. */
  80093. static Configuration: IGLTFValidationConfiguration;
  80094. private static _LoadScriptPromise;
  80095. /**
  80096. * Validate a glTF asset using the glTF-Validator.
  80097. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80098. * @param rootUrl The root url for the glTF
  80099. * @param fileName The file name for the glTF
  80100. * @param getExternalResource The callback to get external resources for the glTF validator
  80101. * @returns A promise that resolves with the glTF validation results once complete
  80102. */
  80103. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80104. }
  80105. }
  80106. declare module BABYLON {
  80107. /**
  80108. * Mode that determines the coordinate system to use.
  80109. */
  80110. export enum GLTFLoaderCoordinateSystemMode {
  80111. /**
  80112. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80113. */
  80114. AUTO = 0,
  80115. /**
  80116. * Sets the useRightHandedSystem flag on the scene.
  80117. */
  80118. FORCE_RIGHT_HANDED = 1
  80119. }
  80120. /**
  80121. * Mode that determines what animations will start.
  80122. */
  80123. export enum GLTFLoaderAnimationStartMode {
  80124. /**
  80125. * No animation will start.
  80126. */
  80127. NONE = 0,
  80128. /**
  80129. * The first animation will start.
  80130. */
  80131. FIRST = 1,
  80132. /**
  80133. * All animations will start.
  80134. */
  80135. ALL = 2
  80136. }
  80137. /**
  80138. * Interface that contains the data for the glTF asset.
  80139. */
  80140. export interface IGLTFLoaderData {
  80141. /**
  80142. * The object that represents the glTF JSON.
  80143. */
  80144. json: Object;
  80145. /**
  80146. * The BIN chunk of a binary glTF.
  80147. */
  80148. bin: Nullable<IDataBuffer>;
  80149. }
  80150. /**
  80151. * Interface for extending the loader.
  80152. */
  80153. export interface IGLTFLoaderExtension {
  80154. /**
  80155. * The name of this extension.
  80156. */
  80157. readonly name: string;
  80158. /**
  80159. * Defines whether this extension is enabled.
  80160. */
  80161. enabled: boolean;
  80162. /**
  80163. * Defines the order of this extension.
  80164. * The loader sorts the extensions using these values when loading.
  80165. */
  80166. order?: number;
  80167. }
  80168. /**
  80169. * Loader state.
  80170. */
  80171. export enum GLTFLoaderState {
  80172. /**
  80173. * The asset is loading.
  80174. */
  80175. LOADING = 0,
  80176. /**
  80177. * The asset is ready for rendering.
  80178. */
  80179. READY = 1,
  80180. /**
  80181. * The asset is completely loaded.
  80182. */
  80183. COMPLETE = 2
  80184. }
  80185. /** @hidden */
  80186. export interface IImportMeshAsyncOutput {
  80187. meshes: AbstractMesh[];
  80188. particleSystems: IParticleSystem[];
  80189. skeletons: Skeleton[];
  80190. animationGroups: AnimationGroup[];
  80191. lights: Light[];
  80192. transformNodes: TransformNode[];
  80193. }
  80194. /** @hidden */
  80195. export interface IGLTFLoader extends IDisposable {
  80196. readonly state: Nullable<GLTFLoaderState>;
  80197. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80198. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80199. }
  80200. /**
  80201. * File loader for loading glTF files into a scene.
  80202. */
  80203. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80204. /** @hidden */
  80205. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80206. /** @hidden */
  80207. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80208. /**
  80209. * Raised when the asset has been parsed
  80210. */
  80211. onParsedObservable: Observable<IGLTFLoaderData>;
  80212. private _onParsedObserver;
  80213. /**
  80214. * Raised when the asset has been parsed
  80215. */
  80216. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80217. /**
  80218. * 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.
  80219. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80220. * Defaults to true.
  80221. * @hidden
  80222. */
  80223. static IncrementalLoading: boolean;
  80224. /**
  80225. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80226. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80227. * @hidden
  80228. */
  80229. static HomogeneousCoordinates: boolean;
  80230. /**
  80231. * The coordinate system mode. Defaults to AUTO.
  80232. */
  80233. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80234. /**
  80235. * The animation start mode. Defaults to FIRST.
  80236. */
  80237. animationStartMode: GLTFLoaderAnimationStartMode;
  80238. /**
  80239. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80240. */
  80241. compileMaterials: boolean;
  80242. /**
  80243. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80244. */
  80245. useClipPlane: boolean;
  80246. /**
  80247. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80248. */
  80249. compileShadowGenerators: boolean;
  80250. /**
  80251. * Defines if the Alpha blended materials are only applied as coverage.
  80252. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80253. * If true, no extra effects are applied to transparent pixels.
  80254. */
  80255. transparencyAsCoverage: boolean;
  80256. /**
  80257. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80258. * Enabling will disable offline support and glTF validator.
  80259. * Defaults to false.
  80260. */
  80261. useRangeRequests: boolean;
  80262. /**
  80263. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80264. */
  80265. createInstances: boolean;
  80266. /**
  80267. * 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.
  80268. */
  80269. alwaysComputeBoundingBox: boolean;
  80270. /**
  80271. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80272. */
  80273. loadAllMaterials: boolean;
  80274. /**
  80275. * Function called before loading a url referenced by the asset.
  80276. */
  80277. preprocessUrlAsync: (url: string) => Promise<string>;
  80278. /**
  80279. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80280. * 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, ...)
  80281. */
  80282. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80283. private _onMeshLoadedObserver;
  80284. /**
  80285. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80286. * 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, ...)
  80287. */
  80288. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80289. /**
  80290. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80291. */
  80292. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80293. private _onTextureLoadedObserver;
  80294. /**
  80295. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80296. */
  80297. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80298. /**
  80299. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80300. */
  80301. readonly onMaterialLoadedObservable: Observable<Material>;
  80302. private _onMaterialLoadedObserver;
  80303. /**
  80304. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80305. */
  80306. set onMaterialLoaded(callback: (material: Material) => void);
  80307. /**
  80308. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80309. */
  80310. readonly onCameraLoadedObservable: Observable<Camera>;
  80311. private _onCameraLoadedObserver;
  80312. /**
  80313. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80314. */
  80315. set onCameraLoaded(callback: (camera: Camera) => void);
  80316. /**
  80317. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80318. * For assets with LODs, raised when all of the LODs are complete.
  80319. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80320. */
  80321. readonly onCompleteObservable: Observable<void>;
  80322. private _onCompleteObserver;
  80323. /**
  80324. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80325. * For assets with LODs, raised when all of the LODs are complete.
  80326. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80327. */
  80328. set onComplete(callback: () => void);
  80329. /**
  80330. * Observable raised when an error occurs.
  80331. */
  80332. readonly onErrorObservable: Observable<any>;
  80333. private _onErrorObserver;
  80334. /**
  80335. * Callback raised when an error occurs.
  80336. */
  80337. set onError(callback: (reason: any) => void);
  80338. /**
  80339. * Observable raised after the loader is disposed.
  80340. */
  80341. readonly onDisposeObservable: Observable<void>;
  80342. private _onDisposeObserver;
  80343. /**
  80344. * Callback raised after the loader is disposed.
  80345. */
  80346. set onDispose(callback: () => void);
  80347. /**
  80348. * Observable raised after a loader extension is created.
  80349. * Set additional options for a loader extension in this event.
  80350. */
  80351. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80352. private _onExtensionLoadedObserver;
  80353. /**
  80354. * Callback raised after a loader extension is created.
  80355. */
  80356. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80357. /**
  80358. * Defines if the loader logging is enabled.
  80359. */
  80360. get loggingEnabled(): boolean;
  80361. set loggingEnabled(value: boolean);
  80362. /**
  80363. * Defines if the loader should capture performance counters.
  80364. */
  80365. get capturePerformanceCounters(): boolean;
  80366. set capturePerformanceCounters(value: boolean);
  80367. /**
  80368. * Defines if the loader should validate the asset.
  80369. */
  80370. validate: boolean;
  80371. /**
  80372. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80373. */
  80374. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80375. private _onValidatedObserver;
  80376. /**
  80377. * Callback raised after a loader extension is created.
  80378. */
  80379. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80380. private _loader;
  80381. private _progressCallback?;
  80382. private _requests;
  80383. private static magicBase64Encoded;
  80384. /**
  80385. * Name of the loader ("gltf")
  80386. */
  80387. name: string;
  80388. /** @hidden */
  80389. extensions: ISceneLoaderPluginExtensions;
  80390. /**
  80391. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80392. */
  80393. dispose(): void;
  80394. /** @hidden */
  80395. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80396. /** @hidden */
  80397. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80398. /** @hidden */
  80399. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80400. meshes: AbstractMesh[];
  80401. particleSystems: IParticleSystem[];
  80402. skeletons: Skeleton[];
  80403. animationGroups: AnimationGroup[];
  80404. }>;
  80405. /** @hidden */
  80406. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80407. /** @hidden */
  80408. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80409. /** @hidden */
  80410. canDirectLoad(data: string): boolean;
  80411. /** @hidden */
  80412. directLoad(scene: Scene, data: string): Promise<any>;
  80413. /**
  80414. * The callback that allows custom handling of the root url based on the response url.
  80415. * @param rootUrl the original root url
  80416. * @param responseURL the response url if available
  80417. * @returns the new root url
  80418. */
  80419. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80420. /** @hidden */
  80421. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80422. /**
  80423. * The loader state or null if the loader is not active.
  80424. */
  80425. get loaderState(): Nullable<GLTFLoaderState>;
  80426. /**
  80427. * Returns a promise that resolves when the asset is completely loaded.
  80428. * @returns a promise that resolves when the asset is completely loaded.
  80429. */
  80430. whenCompleteAsync(): Promise<void>;
  80431. /** @hidden */
  80432. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80433. /** @hidden */
  80434. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80435. private _onProgress;
  80436. private _validate;
  80437. private _getLoader;
  80438. private _parseJson;
  80439. private _unpackBinaryAsync;
  80440. private _unpackBinaryV1Async;
  80441. private _unpackBinaryV2Async;
  80442. private static _parseVersion;
  80443. private static _compareVersion;
  80444. private static readonly _logSpaces;
  80445. private _logIndentLevel;
  80446. private _loggingEnabled;
  80447. /** @hidden */
  80448. _log: (message: string) => void;
  80449. /** @hidden */
  80450. _logOpen(message: string): void;
  80451. /** @hidden */
  80452. _logClose(): void;
  80453. private _logEnabled;
  80454. private _logDisabled;
  80455. private _capturePerformanceCounters;
  80456. /** @hidden */
  80457. _startPerformanceCounter: (counterName: string) => void;
  80458. /** @hidden */
  80459. _endPerformanceCounter: (counterName: string) => void;
  80460. private _startPerformanceCounterEnabled;
  80461. private _startPerformanceCounterDisabled;
  80462. private _endPerformanceCounterEnabled;
  80463. private _endPerformanceCounterDisabled;
  80464. }
  80465. }
  80466. declare module BABYLON.GLTF1 {
  80467. /**
  80468. * Enums
  80469. * @hidden
  80470. */
  80471. export enum EComponentType {
  80472. BYTE = 5120,
  80473. UNSIGNED_BYTE = 5121,
  80474. SHORT = 5122,
  80475. UNSIGNED_SHORT = 5123,
  80476. FLOAT = 5126
  80477. }
  80478. /** @hidden */
  80479. export enum EShaderType {
  80480. FRAGMENT = 35632,
  80481. VERTEX = 35633
  80482. }
  80483. /** @hidden */
  80484. export enum EParameterType {
  80485. BYTE = 5120,
  80486. UNSIGNED_BYTE = 5121,
  80487. SHORT = 5122,
  80488. UNSIGNED_SHORT = 5123,
  80489. INT = 5124,
  80490. UNSIGNED_INT = 5125,
  80491. FLOAT = 5126,
  80492. FLOAT_VEC2 = 35664,
  80493. FLOAT_VEC3 = 35665,
  80494. FLOAT_VEC4 = 35666,
  80495. INT_VEC2 = 35667,
  80496. INT_VEC3 = 35668,
  80497. INT_VEC4 = 35669,
  80498. BOOL = 35670,
  80499. BOOL_VEC2 = 35671,
  80500. BOOL_VEC3 = 35672,
  80501. BOOL_VEC4 = 35673,
  80502. FLOAT_MAT2 = 35674,
  80503. FLOAT_MAT3 = 35675,
  80504. FLOAT_MAT4 = 35676,
  80505. SAMPLER_2D = 35678
  80506. }
  80507. /** @hidden */
  80508. export enum ETextureWrapMode {
  80509. CLAMP_TO_EDGE = 33071,
  80510. MIRRORED_REPEAT = 33648,
  80511. REPEAT = 10497
  80512. }
  80513. /** @hidden */
  80514. export enum ETextureFilterType {
  80515. NEAREST = 9728,
  80516. LINEAR = 9728,
  80517. NEAREST_MIPMAP_NEAREST = 9984,
  80518. LINEAR_MIPMAP_NEAREST = 9985,
  80519. NEAREST_MIPMAP_LINEAR = 9986,
  80520. LINEAR_MIPMAP_LINEAR = 9987
  80521. }
  80522. /** @hidden */
  80523. export enum ETextureFormat {
  80524. ALPHA = 6406,
  80525. RGB = 6407,
  80526. RGBA = 6408,
  80527. LUMINANCE = 6409,
  80528. LUMINANCE_ALPHA = 6410
  80529. }
  80530. /** @hidden */
  80531. export enum ECullingType {
  80532. FRONT = 1028,
  80533. BACK = 1029,
  80534. FRONT_AND_BACK = 1032
  80535. }
  80536. /** @hidden */
  80537. export enum EBlendingFunction {
  80538. ZERO = 0,
  80539. ONE = 1,
  80540. SRC_COLOR = 768,
  80541. ONE_MINUS_SRC_COLOR = 769,
  80542. DST_COLOR = 774,
  80543. ONE_MINUS_DST_COLOR = 775,
  80544. SRC_ALPHA = 770,
  80545. ONE_MINUS_SRC_ALPHA = 771,
  80546. DST_ALPHA = 772,
  80547. ONE_MINUS_DST_ALPHA = 773,
  80548. CONSTANT_COLOR = 32769,
  80549. ONE_MINUS_CONSTANT_COLOR = 32770,
  80550. CONSTANT_ALPHA = 32771,
  80551. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80552. SRC_ALPHA_SATURATE = 776
  80553. }
  80554. /** @hidden */
  80555. export interface IGLTFProperty {
  80556. extensions?: {
  80557. [key: string]: any;
  80558. };
  80559. extras?: Object;
  80560. }
  80561. /** @hidden */
  80562. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80563. name?: string;
  80564. }
  80565. /** @hidden */
  80566. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80567. bufferView: string;
  80568. byteOffset: number;
  80569. byteStride: number;
  80570. count: number;
  80571. type: string;
  80572. componentType: EComponentType;
  80573. max?: number[];
  80574. min?: number[];
  80575. name?: string;
  80576. }
  80577. /** @hidden */
  80578. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80579. buffer: string;
  80580. byteOffset: number;
  80581. byteLength: number;
  80582. byteStride: number;
  80583. target?: number;
  80584. }
  80585. /** @hidden */
  80586. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80587. uri: string;
  80588. byteLength?: number;
  80589. type?: string;
  80590. }
  80591. /** @hidden */
  80592. export interface IGLTFShader extends IGLTFChildRootProperty {
  80593. uri: string;
  80594. type: EShaderType;
  80595. }
  80596. /** @hidden */
  80597. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80598. attributes: string[];
  80599. fragmentShader: string;
  80600. vertexShader: string;
  80601. }
  80602. /** @hidden */
  80603. export interface IGLTFTechniqueParameter {
  80604. type: number;
  80605. count?: number;
  80606. semantic?: string;
  80607. node?: string;
  80608. value?: number | boolean | string | Array<any>;
  80609. source?: string;
  80610. babylonValue?: any;
  80611. }
  80612. /** @hidden */
  80613. export interface IGLTFTechniqueCommonProfile {
  80614. lightingModel: string;
  80615. texcoordBindings: Object;
  80616. parameters?: Array<any>;
  80617. }
  80618. /** @hidden */
  80619. export interface IGLTFTechniqueStatesFunctions {
  80620. blendColor?: number[];
  80621. blendEquationSeparate?: number[];
  80622. blendFuncSeparate?: number[];
  80623. colorMask: boolean[];
  80624. cullFace: number[];
  80625. }
  80626. /** @hidden */
  80627. export interface IGLTFTechniqueStates {
  80628. enable: number[];
  80629. functions: IGLTFTechniqueStatesFunctions;
  80630. }
  80631. /** @hidden */
  80632. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80633. parameters: {
  80634. [key: string]: IGLTFTechniqueParameter;
  80635. };
  80636. program: string;
  80637. attributes: {
  80638. [key: string]: string;
  80639. };
  80640. uniforms: {
  80641. [key: string]: string;
  80642. };
  80643. states: IGLTFTechniqueStates;
  80644. }
  80645. /** @hidden */
  80646. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80647. technique?: string;
  80648. values: string[];
  80649. }
  80650. /** @hidden */
  80651. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80652. attributes: {
  80653. [key: string]: string;
  80654. };
  80655. indices: string;
  80656. material: string;
  80657. mode?: number;
  80658. }
  80659. /** @hidden */
  80660. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80661. primitives: IGLTFMeshPrimitive[];
  80662. }
  80663. /** @hidden */
  80664. export interface IGLTFImage extends IGLTFChildRootProperty {
  80665. uri: string;
  80666. }
  80667. /** @hidden */
  80668. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80669. magFilter?: number;
  80670. minFilter?: number;
  80671. wrapS?: number;
  80672. wrapT?: number;
  80673. }
  80674. /** @hidden */
  80675. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80676. sampler: string;
  80677. source: string;
  80678. format?: ETextureFormat;
  80679. internalFormat?: ETextureFormat;
  80680. target?: number;
  80681. type?: number;
  80682. babylonTexture?: Texture;
  80683. }
  80684. /** @hidden */
  80685. export interface IGLTFAmbienLight {
  80686. color?: number[];
  80687. }
  80688. /** @hidden */
  80689. export interface IGLTFDirectionalLight {
  80690. color?: number[];
  80691. }
  80692. /** @hidden */
  80693. export interface IGLTFPointLight {
  80694. color?: number[];
  80695. constantAttenuation?: number;
  80696. linearAttenuation?: number;
  80697. quadraticAttenuation?: number;
  80698. }
  80699. /** @hidden */
  80700. export interface IGLTFSpotLight {
  80701. color?: number[];
  80702. constantAttenuation?: number;
  80703. fallOfAngle?: number;
  80704. fallOffExponent?: number;
  80705. linearAttenuation?: number;
  80706. quadraticAttenuation?: number;
  80707. }
  80708. /** @hidden */
  80709. export interface IGLTFLight extends IGLTFChildRootProperty {
  80710. type: string;
  80711. }
  80712. /** @hidden */
  80713. export interface IGLTFCameraOrthographic {
  80714. xmag: number;
  80715. ymag: number;
  80716. zfar: number;
  80717. znear: number;
  80718. }
  80719. /** @hidden */
  80720. export interface IGLTFCameraPerspective {
  80721. aspectRatio: number;
  80722. yfov: number;
  80723. zfar: number;
  80724. znear: number;
  80725. }
  80726. /** @hidden */
  80727. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80728. type: string;
  80729. }
  80730. /** @hidden */
  80731. export interface IGLTFAnimationChannelTarget {
  80732. id: string;
  80733. path: string;
  80734. }
  80735. /** @hidden */
  80736. export interface IGLTFAnimationChannel {
  80737. sampler: string;
  80738. target: IGLTFAnimationChannelTarget;
  80739. }
  80740. /** @hidden */
  80741. export interface IGLTFAnimationSampler {
  80742. input: string;
  80743. output: string;
  80744. interpolation?: string;
  80745. }
  80746. /** @hidden */
  80747. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80748. channels?: IGLTFAnimationChannel[];
  80749. parameters?: {
  80750. [key: string]: string;
  80751. };
  80752. samplers?: {
  80753. [key: string]: IGLTFAnimationSampler;
  80754. };
  80755. }
  80756. /** @hidden */
  80757. export interface IGLTFNodeInstanceSkin {
  80758. skeletons: string[];
  80759. skin: string;
  80760. meshes: string[];
  80761. }
  80762. /** @hidden */
  80763. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80764. bindShapeMatrix: number[];
  80765. inverseBindMatrices: string;
  80766. jointNames: string[];
  80767. babylonSkeleton?: Skeleton;
  80768. }
  80769. /** @hidden */
  80770. export interface IGLTFNode extends IGLTFChildRootProperty {
  80771. camera?: string;
  80772. children: string[];
  80773. skin?: string;
  80774. jointName?: string;
  80775. light?: string;
  80776. matrix: number[];
  80777. mesh?: string;
  80778. meshes?: string[];
  80779. rotation?: number[];
  80780. scale?: number[];
  80781. translation?: number[];
  80782. babylonNode?: Node;
  80783. }
  80784. /** @hidden */
  80785. export interface IGLTFScene extends IGLTFChildRootProperty {
  80786. nodes: string[];
  80787. }
  80788. /** @hidden */
  80789. export interface IGLTFRuntime {
  80790. extensions: {
  80791. [key: string]: any;
  80792. };
  80793. accessors: {
  80794. [key: string]: IGLTFAccessor;
  80795. };
  80796. buffers: {
  80797. [key: string]: IGLTFBuffer;
  80798. };
  80799. bufferViews: {
  80800. [key: string]: IGLTFBufferView;
  80801. };
  80802. meshes: {
  80803. [key: string]: IGLTFMesh;
  80804. };
  80805. lights: {
  80806. [key: string]: IGLTFLight;
  80807. };
  80808. cameras: {
  80809. [key: string]: IGLTFCamera;
  80810. };
  80811. nodes: {
  80812. [key: string]: IGLTFNode;
  80813. };
  80814. images: {
  80815. [key: string]: IGLTFImage;
  80816. };
  80817. textures: {
  80818. [key: string]: IGLTFTexture;
  80819. };
  80820. shaders: {
  80821. [key: string]: IGLTFShader;
  80822. };
  80823. programs: {
  80824. [key: string]: IGLTFProgram;
  80825. };
  80826. samplers: {
  80827. [key: string]: IGLTFSampler;
  80828. };
  80829. techniques: {
  80830. [key: string]: IGLTFTechnique;
  80831. };
  80832. materials: {
  80833. [key: string]: IGLTFMaterial;
  80834. };
  80835. animations: {
  80836. [key: string]: IGLTFAnimation;
  80837. };
  80838. skins: {
  80839. [key: string]: IGLTFSkins;
  80840. };
  80841. currentScene?: Object;
  80842. scenes: {
  80843. [key: string]: IGLTFScene;
  80844. };
  80845. extensionsUsed: string[];
  80846. extensionsRequired?: string[];
  80847. buffersCount: number;
  80848. shaderscount: number;
  80849. scene: Scene;
  80850. rootUrl: string;
  80851. loadedBufferCount: number;
  80852. loadedBufferViews: {
  80853. [name: string]: ArrayBufferView;
  80854. };
  80855. loadedShaderCount: number;
  80856. importOnlyMeshes: boolean;
  80857. importMeshesNames?: string[];
  80858. dummyNodes: Node[];
  80859. forAssetContainer: boolean;
  80860. }
  80861. /** @hidden */
  80862. export interface INodeToRoot {
  80863. bone: Bone;
  80864. node: IGLTFNode;
  80865. id: string;
  80866. }
  80867. /** @hidden */
  80868. export interface IJointNode {
  80869. node: IGLTFNode;
  80870. id: string;
  80871. }
  80872. }
  80873. declare module BABYLON.GLTF1 {
  80874. /**
  80875. * Utils functions for GLTF
  80876. * @hidden
  80877. */
  80878. export class GLTFUtils {
  80879. /**
  80880. * Sets the given "parameter" matrix
  80881. * @param scene: the Scene object
  80882. * @param source: the source node where to pick the matrix
  80883. * @param parameter: the GLTF technique parameter
  80884. * @param uniformName: the name of the shader's uniform
  80885. * @param shaderMaterial: the shader material
  80886. */
  80887. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80888. /**
  80889. * Sets the given "parameter" matrix
  80890. * @param shaderMaterial: the shader material
  80891. * @param uniform: the name of the shader's uniform
  80892. * @param value: the value of the uniform
  80893. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80894. */
  80895. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80896. /**
  80897. * Returns the wrap mode of the texture
  80898. * @param mode: the mode value
  80899. */
  80900. static GetWrapMode(mode: number): number;
  80901. /**
  80902. * Returns the byte stride giving an accessor
  80903. * @param accessor: the GLTF accessor objet
  80904. */
  80905. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80906. /**
  80907. * Returns the texture filter mode giving a mode value
  80908. * @param mode: the filter mode value
  80909. */
  80910. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80911. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80912. /**
  80913. * Returns a buffer from its accessor
  80914. * @param gltfRuntime: the GLTF runtime
  80915. * @param accessor: the GLTF accessor
  80916. */
  80917. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80918. /**
  80919. * Decodes a buffer view into a string
  80920. * @param view: the buffer view
  80921. */
  80922. static DecodeBufferToText(view: ArrayBufferView): string;
  80923. /**
  80924. * Returns the default material of gltf. Related to
  80925. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80926. * @param scene: the Babylon.js scene
  80927. */
  80928. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80929. private static _DefaultMaterial;
  80930. }
  80931. }
  80932. declare module BABYLON.GLTF1 {
  80933. /**
  80934. * Implementation of the base glTF spec
  80935. * @hidden
  80936. */
  80937. export class GLTFLoaderBase {
  80938. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80939. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80940. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80941. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80942. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80943. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80944. }
  80945. /**
  80946. * glTF V1 Loader
  80947. * @hidden
  80948. */
  80949. export class GLTFLoader implements IGLTFLoader {
  80950. static Extensions: {
  80951. [name: string]: GLTFLoaderExtension;
  80952. };
  80953. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80954. state: Nullable<GLTFLoaderState>;
  80955. dispose(): void;
  80956. private _importMeshAsync;
  80957. /**
  80958. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80959. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80960. * @param scene the scene the meshes should be added to
  80961. * @param forAssetContainer defines if the entities must be stored in the scene
  80962. * @param data gltf data containing information of the meshes in a loaded file
  80963. * @param rootUrl root url to load from
  80964. * @param onProgress event that fires when loading progress has occured
  80965. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80966. */
  80967. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80968. private _loadAsync;
  80969. /**
  80970. * Imports all objects from a loaded gltf file and adds them to the scene
  80971. * @param scene the scene the objects should be added to
  80972. * @param data gltf data containing information of the meshes in a loaded file
  80973. * @param rootUrl root url to load from
  80974. * @param onProgress event that fires when loading progress has occured
  80975. * @returns a promise which completes when objects have been loaded to the scene
  80976. */
  80977. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80978. private _loadShadersAsync;
  80979. private _loadBuffersAsync;
  80980. private _createNodes;
  80981. }
  80982. /** @hidden */
  80983. export abstract class GLTFLoaderExtension {
  80984. private _name;
  80985. constructor(name: string);
  80986. get name(): string;
  80987. /**
  80988. * Defines an override for loading the runtime
  80989. * Return true to stop further extensions from loading the runtime
  80990. */
  80991. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80992. /**
  80993. * Defines an onverride for creating gltf runtime
  80994. * Return true to stop further extensions from creating the runtime
  80995. */
  80996. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80997. /**
  80998. * Defines an override for loading buffers
  80999. * Return true to stop further extensions from loading this buffer
  81000. */
  81001. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81002. /**
  81003. * Defines an override for loading texture buffers
  81004. * Return true to stop further extensions from loading this texture data
  81005. */
  81006. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81007. /**
  81008. * Defines an override for creating textures
  81009. * Return true to stop further extensions from loading this texture
  81010. */
  81011. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81012. /**
  81013. * Defines an override for loading shader strings
  81014. * Return true to stop further extensions from loading this shader data
  81015. */
  81016. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81017. /**
  81018. * Defines an override for loading materials
  81019. * Return true to stop further extensions from loading this material
  81020. */
  81021. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81022. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81023. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81024. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81025. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81026. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81027. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81028. private static LoadTextureBufferAsync;
  81029. private static CreateTextureAsync;
  81030. private static ApplyExtensions;
  81031. }
  81032. }
  81033. declare module BABYLON.GLTF1 {
  81034. /** @hidden */
  81035. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81036. private _bin;
  81037. constructor();
  81038. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81039. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81040. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81041. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81042. }
  81043. }
  81044. declare module BABYLON.GLTF1 {
  81045. /** @hidden */
  81046. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81047. constructor();
  81048. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81049. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81050. private _loadTexture;
  81051. }
  81052. }
  81053. declare module BABYLON.GLTF2.Loader {
  81054. /**
  81055. * Loader interface with an index field.
  81056. */
  81057. export interface IArrayItem {
  81058. /**
  81059. * The index of this item in the array.
  81060. */
  81061. index: number;
  81062. }
  81063. /**
  81064. * Loader interface with additional members.
  81065. */
  81066. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81067. /** @hidden */
  81068. _data?: Promise<ArrayBufferView>;
  81069. /** @hidden */
  81070. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81071. }
  81072. /**
  81073. * Loader interface with additional members.
  81074. */
  81075. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81076. }
  81077. /** @hidden */
  81078. export interface _IAnimationSamplerData {
  81079. input: Float32Array;
  81080. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81081. output: Float32Array;
  81082. }
  81083. /**
  81084. * Loader interface with additional members.
  81085. */
  81086. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81087. /** @hidden */
  81088. _data?: Promise<_IAnimationSamplerData>;
  81089. }
  81090. /**
  81091. * Loader interface with additional members.
  81092. */
  81093. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81094. channels: IAnimationChannel[];
  81095. samplers: IAnimationSampler[];
  81096. /** @hidden */
  81097. _babylonAnimationGroup?: AnimationGroup;
  81098. }
  81099. /**
  81100. * Loader interface with additional members.
  81101. */
  81102. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81103. /** @hidden */
  81104. _data?: Promise<ArrayBufferView>;
  81105. }
  81106. /**
  81107. * Loader interface with additional members.
  81108. */
  81109. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81110. /** @hidden */
  81111. _data?: Promise<ArrayBufferView>;
  81112. /** @hidden */
  81113. _babylonBuffer?: Promise<Buffer>;
  81114. }
  81115. /**
  81116. * Loader interface with additional members.
  81117. */
  81118. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81119. }
  81120. /**
  81121. * Loader interface with additional members.
  81122. */
  81123. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81124. /** @hidden */
  81125. _data?: Promise<ArrayBufferView>;
  81126. }
  81127. /**
  81128. * Loader interface with additional members.
  81129. */
  81130. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81131. }
  81132. /**
  81133. * Loader interface with additional members.
  81134. */
  81135. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81136. }
  81137. /**
  81138. * Loader interface with additional members.
  81139. */
  81140. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81141. baseColorTexture?: ITextureInfo;
  81142. metallicRoughnessTexture?: ITextureInfo;
  81143. }
  81144. /**
  81145. * Loader interface with additional members.
  81146. */
  81147. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81148. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81149. normalTexture?: IMaterialNormalTextureInfo;
  81150. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81151. emissiveTexture?: ITextureInfo;
  81152. /** @hidden */
  81153. _data?: {
  81154. [babylonDrawMode: number]: {
  81155. babylonMaterial: Material;
  81156. babylonMeshes: AbstractMesh[];
  81157. promise: Promise<void>;
  81158. };
  81159. };
  81160. }
  81161. /**
  81162. * Loader interface with additional members.
  81163. */
  81164. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81165. primitives: IMeshPrimitive[];
  81166. }
  81167. /**
  81168. * Loader interface with additional members.
  81169. */
  81170. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81171. /** @hidden */
  81172. _instanceData?: {
  81173. babylonSourceMesh: Mesh;
  81174. promise: Promise<any>;
  81175. };
  81176. }
  81177. /**
  81178. * Loader interface with additional members.
  81179. */
  81180. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81181. /**
  81182. * The parent glTF node.
  81183. */
  81184. parent?: INode;
  81185. /** @hidden */
  81186. _babylonTransformNode?: TransformNode;
  81187. /** @hidden */
  81188. _primitiveBabylonMeshes?: AbstractMesh[];
  81189. /** @hidden */
  81190. _babylonBones?: Bone[];
  81191. /** @hidden */
  81192. _numMorphTargets?: number;
  81193. }
  81194. /** @hidden */
  81195. export interface _ISamplerData {
  81196. noMipMaps: boolean;
  81197. samplingMode: number;
  81198. wrapU: number;
  81199. wrapV: number;
  81200. }
  81201. /**
  81202. * Loader interface with additional members.
  81203. */
  81204. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81205. /** @hidden */
  81206. _data?: _ISamplerData;
  81207. }
  81208. /**
  81209. * Loader interface with additional members.
  81210. */
  81211. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81212. }
  81213. /**
  81214. * Loader interface with additional members.
  81215. */
  81216. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81217. /** @hidden */
  81218. _data?: {
  81219. babylonSkeleton: Skeleton;
  81220. promise: Promise<void>;
  81221. };
  81222. }
  81223. /**
  81224. * Loader interface with additional members.
  81225. */
  81226. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81227. }
  81228. /**
  81229. * Loader interface with additional members.
  81230. */
  81231. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81232. }
  81233. /**
  81234. * Loader interface with additional members.
  81235. */
  81236. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81237. accessors?: IAccessor[];
  81238. animations?: IAnimation[];
  81239. buffers?: IBuffer[];
  81240. bufferViews?: IBufferView[];
  81241. cameras?: ICamera[];
  81242. images?: IImage[];
  81243. materials?: IMaterial[];
  81244. meshes?: IMesh[];
  81245. nodes?: INode[];
  81246. samplers?: ISampler[];
  81247. scenes?: IScene[];
  81248. skins?: ISkin[];
  81249. textures?: ITexture[];
  81250. }
  81251. }
  81252. declare module BABYLON.GLTF2 {
  81253. /**
  81254. * Interface for a glTF loader extension.
  81255. */
  81256. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81257. /**
  81258. * Called after the loader state changes to LOADING.
  81259. */
  81260. onLoading?(): void;
  81261. /**
  81262. * Called after the loader state changes to READY.
  81263. */
  81264. onReady?(): void;
  81265. /**
  81266. * Define this method to modify the default behavior when loading scenes.
  81267. * @param context The context when loading the asset
  81268. * @param scene The glTF scene property
  81269. * @returns A promise that resolves when the load is complete or null if not handled
  81270. */
  81271. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81272. /**
  81273. * Define this method to modify the default behavior when loading nodes.
  81274. * @param context The context when loading the asset
  81275. * @param node The glTF node property
  81276. * @param assign A function called synchronously after parsing the glTF properties
  81277. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81278. */
  81279. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81280. /**
  81281. * Define this method to modify the default behavior when loading cameras.
  81282. * @param context The context when loading the asset
  81283. * @param camera The glTF camera property
  81284. * @param assign A function called synchronously after parsing the glTF properties
  81285. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81286. */
  81287. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81288. /**
  81289. * @hidden
  81290. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81291. * @param context The context when loading the asset
  81292. * @param primitive The glTF mesh primitive property
  81293. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81294. */
  81295. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81296. /**
  81297. * @hidden
  81298. * Define this method to modify the default behavior when loading data for mesh primitives.
  81299. * @param context The context when loading the asset
  81300. * @param name The mesh name when loading the asset
  81301. * @param node The glTF node when loading the asset
  81302. * @param mesh The glTF mesh when loading the asset
  81303. * @param primitive The glTF mesh primitive property
  81304. * @param assign A function called synchronously after parsing the glTF properties
  81305. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81306. */
  81307. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81308. /**
  81309. * @hidden
  81310. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81311. * @param context The context when loading the asset
  81312. * @param material The glTF material property
  81313. * @param assign A function called synchronously after parsing the glTF properties
  81314. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81315. */
  81316. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81317. /**
  81318. * Define this method to modify the default behavior when creating materials.
  81319. * @param context The context when loading the asset
  81320. * @param material The glTF material property
  81321. * @param babylonDrawMode The draw mode for the Babylon material
  81322. * @returns The Babylon material or null if not handled
  81323. */
  81324. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81325. /**
  81326. * Define this method to modify the default behavior when loading material properties.
  81327. * @param context The context when loading the asset
  81328. * @param material The glTF material property
  81329. * @param babylonMaterial The Babylon material
  81330. * @returns A promise that resolves when the load is complete or null if not handled
  81331. */
  81332. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81333. /**
  81334. * Define this method to modify the default behavior when loading texture infos.
  81335. * @param context The context when loading the asset
  81336. * @param textureInfo The glTF texture info property
  81337. * @param assign A function called synchronously after parsing the glTF properties
  81338. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81339. */
  81340. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81341. /**
  81342. * @hidden
  81343. * Define this method to modify the default behavior when loading textures.
  81344. * @param context The context when loading the asset
  81345. * @param texture The glTF texture property
  81346. * @param assign A function called synchronously after parsing the glTF properties
  81347. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81348. */
  81349. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81350. /**
  81351. * Define this method to modify the default behavior when loading animations.
  81352. * @param context The context when loading the asset
  81353. * @param animation The glTF animation property
  81354. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81355. */
  81356. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81357. /**
  81358. * @hidden
  81359. * Define this method to modify the default behavior when loading skins.
  81360. * @param context The context when loading the asset
  81361. * @param node The glTF node property
  81362. * @param skin The glTF skin property
  81363. * @returns A promise that resolves when the load is complete or null if not handled
  81364. */
  81365. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81366. /**
  81367. * @hidden
  81368. * Define this method to modify the default behavior when loading uris.
  81369. * @param context The context when loading the asset
  81370. * @param property The glTF property associated with the uri
  81371. * @param uri The uri to load
  81372. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81373. */
  81374. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81375. /**
  81376. * Define this method to modify the default behavior when loading buffer views.
  81377. * @param context The context when loading the asset
  81378. * @param bufferView The glTF buffer view property
  81379. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81380. */
  81381. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81382. /**
  81383. * Define this method to modify the default behavior when loading buffers.
  81384. * @param context The context when loading the asset
  81385. * @param buffer The glTF buffer property
  81386. * @param byteOffset The byte offset to load
  81387. * @param byteLength The byte length to load
  81388. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81389. */
  81390. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81391. }
  81392. }
  81393. declare module BABYLON.GLTF2 {
  81394. /**
  81395. * Helper class for working with arrays when loading the glTF asset
  81396. */
  81397. export class ArrayItem {
  81398. /**
  81399. * Gets an item from the given array.
  81400. * @param context The context when loading the asset
  81401. * @param array The array to get the item from
  81402. * @param index The index to the array
  81403. * @returns The array item
  81404. */
  81405. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81406. /**
  81407. * Assign an `index` field to each item of the given array.
  81408. * @param array The array of items
  81409. */
  81410. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81411. }
  81412. /**
  81413. * The glTF 2.0 loader
  81414. */
  81415. export class GLTFLoader implements IGLTFLoader {
  81416. /** @hidden */
  81417. _completePromises: Promise<any>[];
  81418. /** @hidden */
  81419. _forAssetContainer: boolean;
  81420. /** Storage */
  81421. _babylonLights: Light[];
  81422. /** @hidden */
  81423. _disableInstancedMesh: number;
  81424. private _disposed;
  81425. private _parent;
  81426. private _state;
  81427. private _extensions;
  81428. private _rootUrl;
  81429. private _fileName;
  81430. private _uniqueRootUrl;
  81431. private _gltf;
  81432. private _bin;
  81433. private _babylonScene;
  81434. private _rootBabylonMesh;
  81435. private _defaultBabylonMaterialData;
  81436. private static _RegisteredExtensions;
  81437. /**
  81438. * The default glTF sampler.
  81439. */
  81440. static readonly DefaultSampler: ISampler;
  81441. /**
  81442. * Registers a loader extension.
  81443. * @param name The name of the loader extension.
  81444. * @param factory The factory function that creates the loader extension.
  81445. */
  81446. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81447. /**
  81448. * Unregisters a loader extension.
  81449. * @param name The name of the loader extension.
  81450. * @returns A boolean indicating whether the extension has been unregistered
  81451. */
  81452. static UnregisterExtension(name: string): boolean;
  81453. /**
  81454. * The loader state.
  81455. */
  81456. get state(): Nullable<GLTFLoaderState>;
  81457. /**
  81458. * The object that represents the glTF JSON.
  81459. */
  81460. get gltf(): IGLTF;
  81461. /**
  81462. * The BIN chunk of a binary glTF.
  81463. */
  81464. get bin(): Nullable<IDataBuffer>;
  81465. /**
  81466. * The parent file loader.
  81467. */
  81468. get parent(): GLTFFileLoader;
  81469. /**
  81470. * The Babylon scene when loading the asset.
  81471. */
  81472. get babylonScene(): Scene;
  81473. /**
  81474. * The root Babylon mesh when loading the asset.
  81475. */
  81476. get rootBabylonMesh(): Mesh;
  81477. /** @hidden */
  81478. constructor(parent: GLTFFileLoader);
  81479. /** @hidden */
  81480. dispose(): void;
  81481. /** @hidden */
  81482. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81483. /** @hidden */
  81484. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81485. private _loadAsync;
  81486. private _loadData;
  81487. private _setupData;
  81488. private _loadExtensions;
  81489. private _checkExtensions;
  81490. private _setState;
  81491. private _createRootNode;
  81492. /**
  81493. * Loads a glTF scene.
  81494. * @param context The context when loading the asset
  81495. * @param scene The glTF scene property
  81496. * @returns A promise that resolves when the load is complete
  81497. */
  81498. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81499. private _forEachPrimitive;
  81500. private _getMeshes;
  81501. private _getTransformNodes;
  81502. private _getSkeletons;
  81503. private _getAnimationGroups;
  81504. private _startAnimations;
  81505. /**
  81506. * Loads a glTF node.
  81507. * @param context The context when loading the asset
  81508. * @param node The glTF node property
  81509. * @param assign A function called synchronously after parsing the glTF properties
  81510. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81511. */
  81512. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81513. private _loadMeshAsync;
  81514. /**
  81515. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81516. * @param context The context when loading the asset
  81517. * @param name The mesh name when loading the asset
  81518. * @param node The glTF node when loading the asset
  81519. * @param mesh The glTF mesh when loading the asset
  81520. * @param primitive The glTF mesh primitive property
  81521. * @param assign A function called synchronously after parsing the glTF properties
  81522. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81523. */
  81524. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81525. private _loadVertexDataAsync;
  81526. private _createMorphTargets;
  81527. private _loadMorphTargetsAsync;
  81528. private _loadMorphTargetVertexDataAsync;
  81529. private static _LoadTransform;
  81530. private _loadSkinAsync;
  81531. private _loadBones;
  81532. private _loadBone;
  81533. private _loadSkinInverseBindMatricesDataAsync;
  81534. private _updateBoneMatrices;
  81535. private _getNodeMatrix;
  81536. /**
  81537. * Loads a glTF camera.
  81538. * @param context The context when loading the asset
  81539. * @param camera The glTF camera property
  81540. * @param assign A function called synchronously after parsing the glTF properties
  81541. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81542. */
  81543. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81544. private _loadAnimationsAsync;
  81545. /**
  81546. * Loads a glTF animation.
  81547. * @param context The context when loading the asset
  81548. * @param animation The glTF animation property
  81549. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81550. */
  81551. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81552. /**
  81553. * @hidden Loads a glTF animation channel.
  81554. * @param context The context when loading the asset
  81555. * @param animationContext The context of the animation when loading the asset
  81556. * @param animation The glTF animation property
  81557. * @param channel The glTF animation channel property
  81558. * @param babylonAnimationGroup The babylon animation group property
  81559. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81560. * @returns A void promise when the channel load is complete
  81561. */
  81562. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81563. private _loadAnimationSamplerAsync;
  81564. private _loadBufferAsync;
  81565. /**
  81566. * Loads a glTF buffer view.
  81567. * @param context The context when loading the asset
  81568. * @param bufferView The glTF buffer view property
  81569. * @returns A promise that resolves with the loaded data when the load is complete
  81570. */
  81571. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81572. private _loadAccessorAsync;
  81573. /** @hidden */
  81574. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81575. private _loadIndicesAccessorAsync;
  81576. private _loadVertexBufferViewAsync;
  81577. private _loadVertexAccessorAsync;
  81578. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81579. /** @hidden */
  81580. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81581. private _createDefaultMaterial;
  81582. /**
  81583. * Creates a Babylon material from a glTF material.
  81584. * @param context The context when loading the asset
  81585. * @param material The glTF material property
  81586. * @param babylonDrawMode The draw mode for the Babylon material
  81587. * @returns The Babylon material
  81588. */
  81589. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81590. /**
  81591. * Loads properties from a glTF material into a Babylon material.
  81592. * @param context The context when loading the asset
  81593. * @param material The glTF material property
  81594. * @param babylonMaterial The Babylon material
  81595. * @returns A promise that resolves when the load is complete
  81596. */
  81597. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81598. /**
  81599. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81600. * @param context The context when loading the asset
  81601. * @param material The glTF material property
  81602. * @param babylonMaterial The Babylon material
  81603. * @returns A promise that resolves when the load is complete
  81604. */
  81605. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81606. /**
  81607. * Loads the alpha properties from a glTF material into a Babylon material.
  81608. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81609. * @param context The context when loading the asset
  81610. * @param material The glTF material property
  81611. * @param babylonMaterial The Babylon material
  81612. */
  81613. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81614. /**
  81615. * Loads a glTF texture info.
  81616. * @param context The context when loading the asset
  81617. * @param textureInfo The glTF texture info property
  81618. * @param assign A function called synchronously after parsing the glTF properties
  81619. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81620. */
  81621. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81622. /** @hidden */
  81623. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81624. /** @hidden */
  81625. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81626. private _loadSampler;
  81627. /**
  81628. * Loads a glTF image.
  81629. * @param context The context when loading the asset
  81630. * @param image The glTF image property
  81631. * @returns A promise that resolves with the loaded data when the load is complete
  81632. */
  81633. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81634. /**
  81635. * Loads a glTF uri.
  81636. * @param context The context when loading the asset
  81637. * @param property The glTF property associated with the uri
  81638. * @param uri The base64 or relative uri
  81639. * @returns A promise that resolves with the loaded data when the load is complete
  81640. */
  81641. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81642. /**
  81643. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81644. * @param babylonObject the Babylon object with metadata
  81645. * @param pointer the JSON pointer
  81646. */
  81647. static AddPointerMetadata(babylonObject: {
  81648. metadata: any;
  81649. }, pointer: string): void;
  81650. private static _GetTextureWrapMode;
  81651. private static _GetTextureSamplingMode;
  81652. private static _GetTypedArrayConstructor;
  81653. private static _GetTypedArray;
  81654. private static _GetNumComponents;
  81655. private static _ValidateUri;
  81656. /** @hidden */
  81657. static _GetDrawMode(context: string, mode: number | undefined): number;
  81658. private _compileMaterialsAsync;
  81659. private _compileShadowGeneratorsAsync;
  81660. private _forEachExtensions;
  81661. private _applyExtensions;
  81662. private _extensionsOnLoading;
  81663. private _extensionsOnReady;
  81664. private _extensionsLoadSceneAsync;
  81665. private _extensionsLoadNodeAsync;
  81666. private _extensionsLoadCameraAsync;
  81667. private _extensionsLoadVertexDataAsync;
  81668. private _extensionsLoadMeshPrimitiveAsync;
  81669. private _extensionsLoadMaterialAsync;
  81670. private _extensionsCreateMaterial;
  81671. private _extensionsLoadMaterialPropertiesAsync;
  81672. private _extensionsLoadTextureInfoAsync;
  81673. private _extensionsLoadTextureAsync;
  81674. private _extensionsLoadAnimationAsync;
  81675. private _extensionsLoadSkinAsync;
  81676. private _extensionsLoadUriAsync;
  81677. private _extensionsLoadBufferViewAsync;
  81678. private _extensionsLoadBufferAsync;
  81679. /**
  81680. * Helper method called by a loader extension to load an glTF extension.
  81681. * @param context The context when loading the asset
  81682. * @param property The glTF property to load the extension from
  81683. * @param extensionName The name of the extension to load
  81684. * @param actionAsync The action to run
  81685. * @returns The promise returned by actionAsync or null if the extension does not exist
  81686. */
  81687. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81688. /**
  81689. * Helper method called by a loader extension to load a glTF extra.
  81690. * @param context The context when loading the asset
  81691. * @param property The glTF property to load the extra from
  81692. * @param extensionName The name of the extension to load
  81693. * @param actionAsync The action to run
  81694. * @returns The promise returned by actionAsync or null if the extra does not exist
  81695. */
  81696. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81697. /**
  81698. * Checks for presence of an extension.
  81699. * @param name The name of the extension to check
  81700. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81701. */
  81702. isExtensionUsed(name: string): boolean;
  81703. /**
  81704. * Increments the indentation level and logs a message.
  81705. * @param message The message to log
  81706. */
  81707. logOpen(message: string): void;
  81708. /**
  81709. * Decrements the indentation level.
  81710. */
  81711. logClose(): void;
  81712. /**
  81713. * Logs a message
  81714. * @param message The message to log
  81715. */
  81716. log(message: string): void;
  81717. /**
  81718. * Starts a performance counter.
  81719. * @param counterName The name of the performance counter
  81720. */
  81721. startPerformanceCounter(counterName: string): void;
  81722. /**
  81723. * Ends a performance counter.
  81724. * @param counterName The name of the performance counter
  81725. */
  81726. endPerformanceCounter(counterName: string): void;
  81727. }
  81728. }
  81729. declare module BABYLON.GLTF2.Loader.Extensions {
  81730. /** @hidden */
  81731. interface IEXTLightsImageBased_LightImageBased {
  81732. _babylonTexture?: BaseTexture;
  81733. _loaded?: Promise<void>;
  81734. }
  81735. /**
  81736. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81737. */
  81738. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81739. /**
  81740. * The name of this extension.
  81741. */
  81742. readonly name: string;
  81743. /**
  81744. * Defines whether this extension is enabled.
  81745. */
  81746. enabled: boolean;
  81747. private _loader;
  81748. private _lights?;
  81749. /** @hidden */
  81750. constructor(loader: GLTFLoader);
  81751. /** @hidden */
  81752. dispose(): void;
  81753. /** @hidden */
  81754. onLoading(): void;
  81755. /** @hidden */
  81756. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81757. private _loadLightAsync;
  81758. }
  81759. }
  81760. declare module BABYLON.GLTF2.Loader.Extensions {
  81761. /**
  81762. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81763. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81764. * !!! Experimental Extension Subject to Changes !!!
  81765. */
  81766. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81767. /**
  81768. * The name of this extension.
  81769. */
  81770. readonly name: string;
  81771. /**
  81772. * Defines whether this extension is enabled.
  81773. */
  81774. enabled: boolean;
  81775. private _loader;
  81776. /** @hidden */
  81777. constructor(loader: GLTFLoader);
  81778. /** @hidden */
  81779. dispose(): void;
  81780. /** @hidden */
  81781. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81782. }
  81783. }
  81784. declare module BABYLON.GLTF2.Loader.Extensions {
  81785. /**
  81786. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81787. */
  81788. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81789. /** The name of this extension. */
  81790. readonly name: string;
  81791. /** Defines whether this extension is enabled. */
  81792. enabled: boolean;
  81793. private _loader;
  81794. /** @hidden */
  81795. constructor(loader: GLTFLoader);
  81796. /** @hidden */
  81797. dispose(): void;
  81798. /** @hidden */
  81799. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81800. }
  81801. }
  81802. declare module BABYLON.GLTF2.Loader.Extensions {
  81803. /**
  81804. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81805. */
  81806. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81807. /**
  81808. * The name of this extension.
  81809. */
  81810. readonly name: string;
  81811. /**
  81812. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81813. */
  81814. dracoCompression?: DracoCompression;
  81815. /**
  81816. * Defines whether this extension is enabled.
  81817. */
  81818. enabled: boolean;
  81819. private _loader;
  81820. /** @hidden */
  81821. constructor(loader: GLTFLoader);
  81822. /** @hidden */
  81823. dispose(): void;
  81824. /** @hidden */
  81825. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81826. }
  81827. }
  81828. declare module BABYLON.GLTF2.Loader.Extensions {
  81829. /**
  81830. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81831. */
  81832. export class KHR_lights implements IGLTFLoaderExtension {
  81833. /**
  81834. * The name of this extension.
  81835. */
  81836. readonly name: string;
  81837. /**
  81838. * Defines whether this extension is enabled.
  81839. */
  81840. enabled: boolean;
  81841. private _loader;
  81842. private _lights?;
  81843. /** @hidden */
  81844. constructor(loader: GLTFLoader);
  81845. /** @hidden */
  81846. dispose(): void;
  81847. /** @hidden */
  81848. onLoading(): void;
  81849. /** @hidden */
  81850. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81851. }
  81852. }
  81853. declare module BABYLON.GLTF2.Loader.Extensions {
  81854. /**
  81855. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81856. */
  81857. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81858. /**
  81859. * The name of this extension.
  81860. */
  81861. readonly name: string;
  81862. /**
  81863. * Defines whether this extension is enabled.
  81864. */
  81865. enabled: boolean;
  81866. /**
  81867. * Defines a number that determines the order the extensions are applied.
  81868. */
  81869. order: number;
  81870. private _loader;
  81871. /** @hidden */
  81872. constructor(loader: GLTFLoader);
  81873. /** @hidden */
  81874. dispose(): void;
  81875. /** @hidden */
  81876. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81877. private _loadSpecularGlossinessPropertiesAsync;
  81878. }
  81879. }
  81880. declare module BABYLON.GLTF2.Loader.Extensions {
  81881. /**
  81882. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81883. */
  81884. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81885. /**
  81886. * The name of this extension.
  81887. */
  81888. readonly name: string;
  81889. /**
  81890. * Defines whether this extension is enabled.
  81891. */
  81892. enabled: boolean;
  81893. /**
  81894. * Defines a number that determines the order the extensions are applied.
  81895. */
  81896. order: number;
  81897. private _loader;
  81898. /** @hidden */
  81899. constructor(loader: GLTFLoader);
  81900. /** @hidden */
  81901. dispose(): void;
  81902. /** @hidden */
  81903. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81904. private _loadUnlitPropertiesAsync;
  81905. }
  81906. }
  81907. declare module BABYLON.GLTF2.Loader.Extensions {
  81908. /**
  81909. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81910. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81911. * !!! Experimental Extension Subject to Changes !!!
  81912. */
  81913. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81914. /**
  81915. * The name of this extension.
  81916. */
  81917. readonly name: string;
  81918. /**
  81919. * Defines whether this extension is enabled.
  81920. */
  81921. enabled: boolean;
  81922. /**
  81923. * Defines a number that determines the order the extensions are applied.
  81924. */
  81925. order: number;
  81926. private _loader;
  81927. /** @hidden */
  81928. constructor(loader: GLTFLoader);
  81929. /** @hidden */
  81930. dispose(): void;
  81931. /** @hidden */
  81932. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81933. private _loadClearCoatPropertiesAsync;
  81934. }
  81935. }
  81936. declare module BABYLON.GLTF2.Loader.Extensions {
  81937. /**
  81938. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81939. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81940. * !!! Experimental Extension Subject to Changes !!!
  81941. */
  81942. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81943. /**
  81944. * The name of this extension.
  81945. */
  81946. readonly name: string;
  81947. /**
  81948. * Defines whether this extension is enabled.
  81949. */
  81950. enabled: boolean;
  81951. /**
  81952. * Defines a number that determines the order the extensions are applied.
  81953. */
  81954. order: number;
  81955. private _loader;
  81956. /** @hidden */
  81957. constructor(loader: GLTFLoader);
  81958. /** @hidden */
  81959. dispose(): void;
  81960. /** @hidden */
  81961. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81962. private _loadSheenPropertiesAsync;
  81963. }
  81964. }
  81965. declare module BABYLON.GLTF2.Loader.Extensions {
  81966. /**
  81967. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81968. * !!! Experimental Extension Subject to Changes !!!
  81969. */
  81970. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81971. /**
  81972. * The name of this extension.
  81973. */
  81974. readonly name: string;
  81975. /**
  81976. * Defines whether this extension is enabled.
  81977. */
  81978. enabled: boolean;
  81979. /**
  81980. * Defines a number that determines the order the extensions are applied.
  81981. */
  81982. order: number;
  81983. private _loader;
  81984. /** @hidden */
  81985. constructor(loader: GLTFLoader);
  81986. /** @hidden */
  81987. dispose(): void;
  81988. /** @hidden */
  81989. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81990. private _loadSpecularPropertiesAsync;
  81991. }
  81992. }
  81993. declare module BABYLON.GLTF2.Loader.Extensions {
  81994. /**
  81995. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81996. * !!! Experimental Extension Subject to Changes !!!
  81997. */
  81998. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81999. /**
  82000. * Default ior Value from the spec.
  82001. */
  82002. private static readonly _DEFAULT_IOR;
  82003. /**
  82004. * The name of this extension.
  82005. */
  82006. readonly name: string;
  82007. /**
  82008. * Defines whether this extension is enabled.
  82009. */
  82010. enabled: boolean;
  82011. /**
  82012. * Defines a number that determines the order the extensions are applied.
  82013. */
  82014. order: number;
  82015. private _loader;
  82016. /** @hidden */
  82017. constructor(loader: GLTFLoader);
  82018. /** @hidden */
  82019. dispose(): void;
  82020. /** @hidden */
  82021. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82022. private _loadIorPropertiesAsync;
  82023. }
  82024. }
  82025. declare module BABYLON.GLTF2.Loader.Extensions {
  82026. /**
  82027. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82028. * !!! Experimental Extension Subject to Changes !!!
  82029. */
  82030. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82031. /**
  82032. * The name of this extension.
  82033. */
  82034. readonly name: string;
  82035. /**
  82036. * Defines whether this extension is enabled.
  82037. */
  82038. enabled: boolean;
  82039. private _loader;
  82040. private _variants?;
  82041. /** @hidden */
  82042. constructor(loader: GLTFLoader);
  82043. /** @hidden */
  82044. dispose(): void;
  82045. /**
  82046. * Gets the list of available variant names for this asset.
  82047. * @param rootMesh The glTF root mesh
  82048. * @returns the list of all the variant names for this model
  82049. */
  82050. static GetAvailableVariants(rootMesh: Mesh): string[];
  82051. /**
  82052. * Gets the list of available variant names for this asset.
  82053. * @param rootMesh The glTF root mesh
  82054. * @returns the list of all the variant names for this model
  82055. */
  82056. getAvailableVariants(rootMesh: Mesh): string[];
  82057. /**
  82058. * Select a variant given a variant name or a list of variant names.
  82059. * @param rootMesh The glTF root mesh
  82060. * @param variantName The variant name(s) to select.
  82061. */
  82062. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82063. /**
  82064. * Select a variant given a variant name or a list of variant names.
  82065. * @param rootMesh The glTF root mesh
  82066. * @param variantName The variant name(s) to select.
  82067. */
  82068. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82069. /**
  82070. * Reset back to the original before selecting a variant.
  82071. * @param rootMesh The glTF root mesh
  82072. */
  82073. static Reset(rootMesh: Mesh): void;
  82074. /**
  82075. * Reset back to the original before selecting a variant.
  82076. * @param rootMesh The glTF root mesh
  82077. */
  82078. reset(rootMesh: Mesh): void;
  82079. /**
  82080. * Gets the last selected variant name(s) or null if original.
  82081. * @param rootMesh The glTF root mesh
  82082. * @returns The selected variant name(s).
  82083. */
  82084. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82085. /**
  82086. * Gets the last selected variant name(s) or null if original.
  82087. * @param rootMesh The glTF root mesh
  82088. * @returns The selected variant name(s).
  82089. */
  82090. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82091. private static _GetExtensionMetadata;
  82092. /** @hidden */
  82093. onLoading(): void;
  82094. /** @hidden */
  82095. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82096. }
  82097. }
  82098. declare module BABYLON.GLTF2.Loader.Extensions {
  82099. /**
  82100. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82101. * !!! Experimental Extension Subject to Changes !!!
  82102. */
  82103. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82104. /**
  82105. * The name of this extension.
  82106. */
  82107. readonly name: string;
  82108. /**
  82109. * Defines whether this extension is enabled.
  82110. */
  82111. enabled: boolean;
  82112. /**
  82113. * Defines a number that determines the order the extensions are applied.
  82114. */
  82115. order: number;
  82116. private _loader;
  82117. /** @hidden */
  82118. constructor(loader: GLTFLoader);
  82119. /** @hidden */
  82120. dispose(): void;
  82121. /** @hidden */
  82122. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82123. private _loadTransparentPropertiesAsync;
  82124. }
  82125. }
  82126. declare module BABYLON.GLTF2.Loader.Extensions {
  82127. /**
  82128. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82129. */
  82130. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82131. /**
  82132. * The name of this extension.
  82133. */
  82134. readonly name: string;
  82135. /**
  82136. * Defines whether this extension is enabled.
  82137. */
  82138. enabled: boolean;
  82139. /** @hidden */
  82140. constructor(loader: GLTFLoader);
  82141. /** @hidden */
  82142. dispose(): void;
  82143. }
  82144. }
  82145. declare module BABYLON.GLTF2.Loader.Extensions {
  82146. /**
  82147. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82148. * !!! Experimental Extension Subject to Changes !!!
  82149. */
  82150. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82151. /** The name of this extension. */
  82152. readonly name: string;
  82153. /** Defines whether this extension is enabled. */
  82154. enabled: boolean;
  82155. private _loader;
  82156. /** @hidden */
  82157. constructor(loader: GLTFLoader);
  82158. /** @hidden */
  82159. dispose(): void;
  82160. /** @hidden */
  82161. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82162. }
  82163. }
  82164. declare module BABYLON.GLTF2.Loader.Extensions {
  82165. /**
  82166. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82167. */
  82168. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82169. /**
  82170. * The name of this extension.
  82171. */
  82172. readonly name: string;
  82173. /**
  82174. * Defines whether this extension is enabled.
  82175. */
  82176. enabled: boolean;
  82177. private _loader;
  82178. /** @hidden */
  82179. constructor(loader: GLTFLoader);
  82180. /** @hidden */
  82181. dispose(): void;
  82182. /** @hidden */
  82183. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82184. }
  82185. }
  82186. declare module BABYLON.GLTF2.Loader.Extensions {
  82187. /**
  82188. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82189. * !!! Experimental Extension Subject to Changes !!!
  82190. */
  82191. export class KHR_xmp implements IGLTFLoaderExtension {
  82192. /**
  82193. * The name of this extension.
  82194. */
  82195. readonly name: string;
  82196. /**
  82197. * Defines whether this extension is enabled.
  82198. */
  82199. enabled: boolean;
  82200. /**
  82201. * Defines a number that determines the order the extensions are applied.
  82202. */
  82203. order: number;
  82204. private _loader;
  82205. /** @hidden */
  82206. constructor(loader: GLTFLoader);
  82207. /** @hidden */
  82208. dispose(): void;
  82209. /**
  82210. * Called after the loader state changes to LOADING.
  82211. */
  82212. onLoading(): void;
  82213. }
  82214. }
  82215. declare module BABYLON.GLTF2.Loader.Extensions {
  82216. /**
  82217. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82218. */
  82219. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82220. /**
  82221. * The name of this extension.
  82222. */
  82223. readonly name: string;
  82224. /**
  82225. * Defines whether this extension is enabled.
  82226. */
  82227. enabled: boolean;
  82228. private _loader;
  82229. private _clips;
  82230. private _emitters;
  82231. /** @hidden */
  82232. constructor(loader: GLTFLoader);
  82233. /** @hidden */
  82234. dispose(): void;
  82235. /** @hidden */
  82236. onLoading(): void;
  82237. /** @hidden */
  82238. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82239. /** @hidden */
  82240. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82241. /** @hidden */
  82242. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82243. private _loadClipAsync;
  82244. private _loadEmitterAsync;
  82245. private _getEventAction;
  82246. private _loadAnimationEventAsync;
  82247. }
  82248. }
  82249. declare module BABYLON.GLTF2.Loader.Extensions {
  82250. /**
  82251. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82252. */
  82253. export class MSFT_lod implements IGLTFLoaderExtension {
  82254. /**
  82255. * The name of this extension.
  82256. */
  82257. readonly name: string;
  82258. /**
  82259. * Defines whether this extension is enabled.
  82260. */
  82261. enabled: boolean;
  82262. /**
  82263. * Defines a number that determines the order the extensions are applied.
  82264. */
  82265. order: number;
  82266. /**
  82267. * Maximum number of LODs to load, starting from the lowest LOD.
  82268. */
  82269. maxLODsToLoad: number;
  82270. /**
  82271. * Observable raised when all node LODs of one level are loaded.
  82272. * The event data is the index of the loaded LOD starting from zero.
  82273. * Dispose the loader to cancel the loading of the next level of LODs.
  82274. */
  82275. onNodeLODsLoadedObservable: Observable<number>;
  82276. /**
  82277. * Observable raised when all material LODs of one level are loaded.
  82278. * The event data is the index of the loaded LOD starting from zero.
  82279. * Dispose the loader to cancel the loading of the next level of LODs.
  82280. */
  82281. onMaterialLODsLoadedObservable: Observable<number>;
  82282. private _loader;
  82283. private _bufferLODs;
  82284. private _nodeIndexLOD;
  82285. private _nodeSignalLODs;
  82286. private _nodePromiseLODs;
  82287. private _nodeBufferLODs;
  82288. private _materialIndexLOD;
  82289. private _materialSignalLODs;
  82290. private _materialPromiseLODs;
  82291. private _materialBufferLODs;
  82292. /** @hidden */
  82293. constructor(loader: GLTFLoader);
  82294. /** @hidden */
  82295. dispose(): void;
  82296. /** @hidden */
  82297. onReady(): void;
  82298. /** @hidden */
  82299. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82300. /** @hidden */
  82301. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82302. /** @hidden */
  82303. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82304. /** @hidden */
  82305. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82306. /** @hidden */
  82307. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82308. private _loadBufferLOD;
  82309. /**
  82310. * Gets an array of LOD properties from lowest to highest.
  82311. */
  82312. private _getLODs;
  82313. private _disposeTransformNode;
  82314. private _disposeMaterials;
  82315. }
  82316. }
  82317. declare module BABYLON.GLTF2.Loader.Extensions {
  82318. /** @hidden */
  82319. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82320. readonly name: string;
  82321. enabled: boolean;
  82322. private _loader;
  82323. constructor(loader: GLTFLoader);
  82324. dispose(): void;
  82325. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82326. }
  82327. }
  82328. declare module BABYLON.GLTF2.Loader.Extensions {
  82329. /** @hidden */
  82330. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82331. readonly name: string;
  82332. enabled: boolean;
  82333. private _loader;
  82334. constructor(loader: GLTFLoader);
  82335. dispose(): void;
  82336. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82337. }
  82338. }
  82339. declare module BABYLON.GLTF2.Loader.Extensions {
  82340. /**
  82341. * Store glTF extras (if present) in BJS objects' metadata
  82342. */
  82343. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82344. /**
  82345. * The name of this extension.
  82346. */
  82347. readonly name: string;
  82348. /**
  82349. * Defines whether this extension is enabled.
  82350. */
  82351. enabled: boolean;
  82352. private _loader;
  82353. private _assignExtras;
  82354. /** @hidden */
  82355. constructor(loader: GLTFLoader);
  82356. /** @hidden */
  82357. dispose(): void;
  82358. /** @hidden */
  82359. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82360. /** @hidden */
  82361. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82362. /** @hidden */
  82363. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82364. }
  82365. }
  82366. declare module BABYLON {
  82367. /**
  82368. * Class reading and parsing the MTL file bundled with the obj file.
  82369. */
  82370. export class MTLFileLoader {
  82371. /**
  82372. * Invert Y-Axis of referenced textures on load
  82373. */
  82374. static INVERT_TEXTURE_Y: boolean;
  82375. /**
  82376. * All material loaded from the mtl will be set here
  82377. */
  82378. materials: StandardMaterial[];
  82379. /**
  82380. * This function will read the mtl file and create each material described inside
  82381. * This function could be improve by adding :
  82382. * -some component missing (Ni, Tf...)
  82383. * -including the specific options available
  82384. *
  82385. * @param scene defines the scene the material will be created in
  82386. * @param data defines the mtl data to parse
  82387. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82388. * @param forAssetContainer defines if the material should be registered in the scene
  82389. */
  82390. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82391. /**
  82392. * Gets the texture for the material.
  82393. *
  82394. * If the material is imported from input file,
  82395. * We sanitize the url to ensure it takes the textre from aside the material.
  82396. *
  82397. * @param rootUrl The root url to load from
  82398. * @param value The value stored in the mtl
  82399. * @return The Texture
  82400. */
  82401. private static _getTexture;
  82402. }
  82403. }
  82404. declare module BABYLON {
  82405. /**
  82406. * Options for loading OBJ/MTL files
  82407. */
  82408. type MeshLoadOptions = {
  82409. /**
  82410. * Defines if UVs are optimized by default during load.
  82411. */
  82412. OptimizeWithUV: boolean;
  82413. /**
  82414. * Defines custom scaling of UV coordinates of loaded meshes.
  82415. */
  82416. UVScaling: Vector2;
  82417. /**
  82418. * Invert model on y-axis (does a model scaling inversion)
  82419. */
  82420. InvertY: boolean;
  82421. /**
  82422. * Invert Y-Axis of referenced textures on load
  82423. */
  82424. InvertTextureY: boolean;
  82425. /**
  82426. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82427. */
  82428. ImportVertexColors: boolean;
  82429. /**
  82430. * Compute the normals for the model, even if normals are present in the file.
  82431. */
  82432. ComputeNormals: boolean;
  82433. /**
  82434. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82435. */
  82436. SkipMaterials: boolean;
  82437. /**
  82438. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82439. */
  82440. MaterialLoadingFailsSilently: boolean;
  82441. };
  82442. /**
  82443. * OBJ file type loader.
  82444. * This is a babylon scene loader plugin.
  82445. */
  82446. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82447. /**
  82448. * Defines if UVs are optimized by default during load.
  82449. */
  82450. static OPTIMIZE_WITH_UV: boolean;
  82451. /**
  82452. * Invert model on y-axis (does a model scaling inversion)
  82453. */
  82454. static INVERT_Y: boolean;
  82455. /**
  82456. * Invert Y-Axis of referenced textures on load
  82457. */
  82458. static get INVERT_TEXTURE_Y(): boolean;
  82459. static set INVERT_TEXTURE_Y(value: boolean);
  82460. /**
  82461. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82462. */
  82463. static IMPORT_VERTEX_COLORS: boolean;
  82464. /**
  82465. * Compute the normals for the model, even if normals are present in the file.
  82466. */
  82467. static COMPUTE_NORMALS: boolean;
  82468. /**
  82469. * Defines custom scaling of UV coordinates of loaded meshes.
  82470. */
  82471. static UV_SCALING: Vector2;
  82472. /**
  82473. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82474. */
  82475. static SKIP_MATERIALS: boolean;
  82476. /**
  82477. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82478. *
  82479. * Defaults to true for backwards compatibility.
  82480. */
  82481. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82482. /**
  82483. * Defines the name of the plugin.
  82484. */
  82485. name: string;
  82486. /**
  82487. * Defines the extension the plugin is able to load.
  82488. */
  82489. extensions: string;
  82490. /** @hidden */
  82491. obj: RegExp;
  82492. /** @hidden */
  82493. group: RegExp;
  82494. /** @hidden */
  82495. mtllib: RegExp;
  82496. /** @hidden */
  82497. usemtl: RegExp;
  82498. /** @hidden */
  82499. smooth: RegExp;
  82500. /** @hidden */
  82501. vertexPattern: RegExp;
  82502. /** @hidden */
  82503. normalPattern: RegExp;
  82504. /** @hidden */
  82505. uvPattern: RegExp;
  82506. /** @hidden */
  82507. facePattern1: RegExp;
  82508. /** @hidden */
  82509. facePattern2: RegExp;
  82510. /** @hidden */
  82511. facePattern3: RegExp;
  82512. /** @hidden */
  82513. facePattern4: RegExp;
  82514. /** @hidden */
  82515. facePattern5: RegExp;
  82516. private _forAssetContainer;
  82517. private _meshLoadOptions;
  82518. /**
  82519. * Creates loader for .OBJ files
  82520. *
  82521. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82522. */
  82523. constructor(meshLoadOptions?: MeshLoadOptions);
  82524. private static get currentMeshLoadOptions();
  82525. /**
  82526. * Calls synchronously the MTL file attached to this obj.
  82527. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82528. * Without this function materials are not displayed in the first frame (but displayed after).
  82529. * In consequence it is impossible to get material information in your HTML file
  82530. *
  82531. * @param url The URL of the MTL file
  82532. * @param rootUrl
  82533. * @param onSuccess Callback function to be called when the MTL file is loaded
  82534. * @private
  82535. */
  82536. private _loadMTL;
  82537. /**
  82538. * Instantiates a OBJ file loader plugin.
  82539. * @returns the created plugin
  82540. */
  82541. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82542. /**
  82543. * If the data string can be loaded directly.
  82544. *
  82545. * @param data string containing the file data
  82546. * @returns if the data can be loaded directly
  82547. */
  82548. canDirectLoad(data: string): boolean;
  82549. /**
  82550. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82551. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82552. * @param scene the scene the meshes should be added to
  82553. * @param data the OBJ data to load
  82554. * @param rootUrl root url to load from
  82555. * @param onProgress event that fires when loading progress has occured
  82556. * @param fileName Defines the name of the file to load
  82557. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82558. */
  82559. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82560. meshes: AbstractMesh[];
  82561. particleSystems: IParticleSystem[];
  82562. skeletons: Skeleton[];
  82563. animationGroups: AnimationGroup[];
  82564. }>;
  82565. /**
  82566. * Imports all objects from the loaded OBJ data and adds them to the scene
  82567. * @param scene the scene the objects should be added to
  82568. * @param data the OBJ data to load
  82569. * @param rootUrl root url to load from
  82570. * @param onProgress event that fires when loading progress has occured
  82571. * @param fileName Defines the name of the file to load
  82572. * @returns a promise which completes when objects have been loaded to the scene
  82573. */
  82574. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82575. /**
  82576. * Load into an asset container.
  82577. * @param scene The scene to load into
  82578. * @param data The data to import
  82579. * @param rootUrl The root url for scene and resources
  82580. * @param onProgress The callback when the load progresses
  82581. * @param fileName Defines the name of the file to load
  82582. * @returns The loaded asset container
  82583. */
  82584. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82585. /**
  82586. * Read the OBJ file and create an Array of meshes.
  82587. * Each mesh contains all information given by the OBJ and the MTL file.
  82588. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82589. *
  82590. * @param meshesNames
  82591. * @param scene Scene The scene where are displayed the data
  82592. * @param data String The content of the obj file
  82593. * @param rootUrl String The path to the folder
  82594. * @returns Array<AbstractMesh>
  82595. * @private
  82596. */
  82597. private _parseSolid;
  82598. }
  82599. }
  82600. declare module BABYLON {
  82601. /**
  82602. * STL file type loader.
  82603. * This is a babylon scene loader plugin.
  82604. */
  82605. export class STLFileLoader implements ISceneLoaderPlugin {
  82606. /** @hidden */
  82607. solidPattern: RegExp;
  82608. /** @hidden */
  82609. facetsPattern: RegExp;
  82610. /** @hidden */
  82611. normalPattern: RegExp;
  82612. /** @hidden */
  82613. vertexPattern: RegExp;
  82614. /**
  82615. * Defines the name of the plugin.
  82616. */
  82617. name: string;
  82618. /**
  82619. * Defines the extensions the stl loader is able to load.
  82620. * force data to come in as an ArrayBuffer
  82621. * we'll convert to string if it looks like it's an ASCII .stl
  82622. */
  82623. extensions: ISceneLoaderPluginExtensions;
  82624. /**
  82625. * Import meshes into a scene.
  82626. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82627. * @param scene The scene to import into
  82628. * @param data The data to import
  82629. * @param rootUrl The root url for scene and resources
  82630. * @param meshes The meshes array to import into
  82631. * @param particleSystems The particle systems array to import into
  82632. * @param skeletons The skeletons array to import into
  82633. * @param onError The callback when import fails
  82634. * @returns True if successful or false otherwise
  82635. */
  82636. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82637. /**
  82638. * Load into a scene.
  82639. * @param scene The scene to load into
  82640. * @param data The data to import
  82641. * @param rootUrl The root url for scene and resources
  82642. * @param onError The callback when import fails
  82643. * @returns true if successful or false otherwise
  82644. */
  82645. load(scene: Scene, data: any, rootUrl: string): boolean;
  82646. /**
  82647. * Load into an asset container.
  82648. * @param scene The scene to load into
  82649. * @param data The data to import
  82650. * @param rootUrl The root url for scene and resources
  82651. * @param onError The callback when import fails
  82652. * @returns The loaded asset container
  82653. */
  82654. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82655. private _isBinary;
  82656. private _parseBinary;
  82657. private _parseASCII;
  82658. }
  82659. }
  82660. declare module BABYLON {
  82661. /**
  82662. * Class for generating OBJ data from a Babylon scene.
  82663. */
  82664. export class OBJExport {
  82665. /**
  82666. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82667. * @param mesh defines the list of meshes to serialize
  82668. * @param materials defines if materials should be exported
  82669. * @param matlibname defines the name of the associated mtl file
  82670. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82671. * @returns the OBJ content
  82672. */
  82673. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82674. /**
  82675. * Exports the material(s) of a mesh in .MTL file format (text)
  82676. * @param mesh defines the mesh to extract the material from
  82677. * @returns the mtl content
  82678. */
  82679. static MTL(mesh: Mesh): string;
  82680. }
  82681. }
  82682. declare module BABYLON {
  82683. /** @hidden */
  82684. export var __IGLTFExporterExtension: number;
  82685. /**
  82686. * Interface for extending the exporter
  82687. * @hidden
  82688. */
  82689. export interface IGLTFExporterExtension {
  82690. /**
  82691. * The name of this extension
  82692. */
  82693. readonly name: string;
  82694. /**
  82695. * Defines whether this extension is enabled
  82696. */
  82697. enabled: boolean;
  82698. /**
  82699. * Defines whether this extension is required
  82700. */
  82701. required: boolean;
  82702. }
  82703. }
  82704. declare module BABYLON.GLTF2.Exporter {
  82705. /** @hidden */
  82706. export var __IGLTFExporterExtensionV2: number;
  82707. /**
  82708. * Interface for a glTF exporter extension
  82709. * @hidden
  82710. */
  82711. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82712. /**
  82713. * Define this method to modify the default behavior before exporting a texture
  82714. * @param context The context when loading the asset
  82715. * @param babylonTexture The Babylon.js texture
  82716. * @param mimeType The mime-type of the generated image
  82717. * @returns A promise that resolves with the exported texture
  82718. */
  82719. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82720. /**
  82721. * Define this method to get notified when a texture info is created
  82722. * @param context The context when loading the asset
  82723. * @param textureInfo The glTF texture info
  82724. * @param babylonTexture The Babylon.js texture
  82725. */
  82726. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82727. /**
  82728. * Define this method to modify the default behavior when exporting texture info
  82729. * @param context The context when loading the asset
  82730. * @param meshPrimitive glTF mesh primitive
  82731. * @param babylonSubMesh Babylon submesh
  82732. * @param binaryWriter glTF serializer binary writer instance
  82733. * @returns nullable IMeshPrimitive promise
  82734. */
  82735. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82736. /**
  82737. * Define this method to modify the default behavior when exporting a node
  82738. * @param context The context when exporting the node
  82739. * @param node glTF node
  82740. * @param babylonNode BabylonJS node
  82741. * @returns nullable INode promise
  82742. */
  82743. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82744. [key: number]: number;
  82745. }): Promise<Nullable<INode>>;
  82746. /**
  82747. * Define this method to modify the default behavior when exporting a material
  82748. * @param material glTF material
  82749. * @param babylonMaterial BabylonJS material
  82750. * @returns nullable IMaterial promise
  82751. */
  82752. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82753. /**
  82754. * Define this method to return additional textures to export from a material
  82755. * @param material glTF material
  82756. * @param babylonMaterial BabylonJS material
  82757. * @returns List of textures
  82758. */
  82759. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82760. /** Gets a boolean indicating that this extension was used */
  82761. wasUsed: boolean;
  82762. /** Gets a boolean indicating that this extension is required for the file to work */
  82763. required: boolean;
  82764. /**
  82765. * Called after the exporter state changes to EXPORTING
  82766. */
  82767. onExporting?(): void;
  82768. }
  82769. }
  82770. declare module BABYLON.GLTF2.Exporter {
  82771. /**
  82772. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82773. * @hidden
  82774. */
  82775. export class _GLTFMaterialExporter {
  82776. /**
  82777. * Represents the dielectric specular values for R, G and B
  82778. */
  82779. private static readonly _DielectricSpecular;
  82780. /**
  82781. * Allows the maximum specular power to be defined for material calculations
  82782. */
  82783. private static readonly _MaxSpecularPower;
  82784. /**
  82785. * Mapping to store textures
  82786. */
  82787. private _textureMap;
  82788. /**
  82789. * Numeric tolerance value
  82790. */
  82791. private static readonly _Epsilon;
  82792. /**
  82793. * Reference to the glTF Exporter
  82794. */
  82795. private _exporter;
  82796. constructor(exporter: _Exporter);
  82797. /**
  82798. * Specifies if two colors are approximately equal in value
  82799. * @param color1 first color to compare to
  82800. * @param color2 second color to compare to
  82801. * @param epsilon threshold value
  82802. */
  82803. private static FuzzyEquals;
  82804. /**
  82805. * Gets the materials from a Babylon scene and converts them to glTF materials
  82806. * @param scene babylonjs scene
  82807. * @param mimeType texture mime type
  82808. * @param images array of images
  82809. * @param textures array of textures
  82810. * @param materials array of materials
  82811. * @param imageData mapping of texture names to base64 textures
  82812. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82813. */
  82814. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82815. /**
  82816. * Makes a copy of the glTF material without the texture parameters
  82817. * @param originalMaterial original glTF material
  82818. * @returns glTF material without texture parameters
  82819. */
  82820. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82821. /**
  82822. * Specifies if the material has any texture parameters present
  82823. * @param material glTF Material
  82824. * @returns boolean specifying if texture parameters are present
  82825. */
  82826. _hasTexturesPresent(material: IMaterial): boolean;
  82827. /**
  82828. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82829. * @param babylonStandardMaterial
  82830. * @returns glTF Metallic Roughness Material representation
  82831. */
  82832. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82833. /**
  82834. * Computes the metallic factor
  82835. * @param diffuse diffused value
  82836. * @param specular specular value
  82837. * @param oneMinusSpecularStrength one minus the specular strength
  82838. * @returns metallic value
  82839. */
  82840. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82841. /**
  82842. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82843. * @param glTFMaterial glTF material
  82844. * @param babylonMaterial Babylon material
  82845. */
  82846. private static _SetAlphaMode;
  82847. /**
  82848. * Converts a Babylon Standard Material to a glTF Material
  82849. * @param babylonStandardMaterial BJS Standard Material
  82850. * @param mimeType mime type to use for the textures
  82851. * @param images array of glTF image interfaces
  82852. * @param textures array of glTF texture interfaces
  82853. * @param materials array of glTF material interfaces
  82854. * @param imageData map of image file name to data
  82855. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82856. */
  82857. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82858. private _finishMaterial;
  82859. /**
  82860. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82861. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82862. * @param mimeType mime type to use for the textures
  82863. * @param images array of glTF image interfaces
  82864. * @param textures array of glTF texture interfaces
  82865. * @param materials array of glTF material interfaces
  82866. * @param imageData map of image file name to data
  82867. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82868. */
  82869. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82870. /**
  82871. * Converts an image typed array buffer to a base64 image
  82872. * @param buffer typed array buffer
  82873. * @param width width of the image
  82874. * @param height height of the image
  82875. * @param mimeType mimetype of the image
  82876. * @returns base64 image string
  82877. */
  82878. private _createBase64FromCanvasAsync;
  82879. /**
  82880. * Generates a white texture based on the specified width and height
  82881. * @param width width of the texture in pixels
  82882. * @param height height of the texture in pixels
  82883. * @param scene babylonjs scene
  82884. * @returns white texture
  82885. */
  82886. private _createWhiteTexture;
  82887. /**
  82888. * 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
  82889. * @param texture1 first texture to resize
  82890. * @param texture2 second texture to resize
  82891. * @param scene babylonjs scene
  82892. * @returns resized textures or null
  82893. */
  82894. private _resizeTexturesToSameDimensions;
  82895. /**
  82896. * Converts an array of pixels to a Float32Array
  82897. * Throws an error if the pixel format is not supported
  82898. * @param pixels - array buffer containing pixel values
  82899. * @returns Float32 of pixels
  82900. */
  82901. private _convertPixelArrayToFloat32;
  82902. /**
  82903. * Convert Specular Glossiness Textures to Metallic Roughness
  82904. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82905. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82906. * @param diffuseTexture texture used to store diffuse information
  82907. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82908. * @param factors specular glossiness material factors
  82909. * @param mimeType the mime type to use for the texture
  82910. * @returns pbr metallic roughness interface or null
  82911. */
  82912. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82913. /**
  82914. * Converts specular glossiness material properties to metallic roughness
  82915. * @param specularGlossiness interface with specular glossiness material properties
  82916. * @returns interface with metallic roughness material properties
  82917. */
  82918. private _convertSpecularGlossinessToMetallicRoughness;
  82919. /**
  82920. * Calculates the surface reflectance, independent of lighting conditions
  82921. * @param color Color source to calculate brightness from
  82922. * @returns number representing the perceived brightness, or zero if color is undefined
  82923. */
  82924. private _getPerceivedBrightness;
  82925. /**
  82926. * Returns the maximum color component value
  82927. * @param color
  82928. * @returns maximum color component value, or zero if color is null or undefined
  82929. */
  82930. private _getMaxComponent;
  82931. /**
  82932. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82933. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82934. * @param mimeType mime type to use for the textures
  82935. * @param images array of glTF image interfaces
  82936. * @param textures array of glTF texture interfaces
  82937. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82938. * @param imageData map of image file name to data
  82939. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82940. * @returns glTF PBR Metallic Roughness factors
  82941. */
  82942. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82943. private _getGLTFTextureSampler;
  82944. private _getGLTFTextureWrapMode;
  82945. private _getGLTFTextureWrapModesSampler;
  82946. /**
  82947. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82948. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82949. * @param mimeType mime type to use for the textures
  82950. * @param images array of glTF image interfaces
  82951. * @param textures array of glTF texture interfaces
  82952. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82953. * @param imageData map of image file name to data
  82954. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82955. * @returns glTF PBR Metallic Roughness factors
  82956. */
  82957. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82958. /**
  82959. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82960. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82961. * @param mimeType mime type to use for the textures
  82962. * @param images array of glTF image interfaces
  82963. * @param textures array of glTF texture interfaces
  82964. * @param materials array of glTF material interfaces
  82965. * @param imageData map of image file name to data
  82966. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82967. */
  82968. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82969. private setMetallicRoughnessPbrMaterial;
  82970. private getPixelsFromTexture;
  82971. /**
  82972. * Extracts a texture from a Babylon texture into file data and glTF data
  82973. * @param babylonTexture Babylon texture to extract
  82974. * @param mimeType Mime Type of the babylonTexture
  82975. * @return glTF texture info, or null if the texture format is not supported
  82976. */
  82977. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82978. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82979. /**
  82980. * Builds a texture from base64 string
  82981. * @param base64Texture base64 texture string
  82982. * @param baseTextureName Name to use for the texture
  82983. * @param mimeType image mime type for the texture
  82984. * @param images array of images
  82985. * @param textures array of textures
  82986. * @param imageData map of image data
  82987. * @returns glTF texture info, or null if the texture format is not supported
  82988. */
  82989. private _getTextureInfoFromBase64;
  82990. }
  82991. }
  82992. declare module BABYLON {
  82993. /**
  82994. * Class for holding and downloading glTF file data
  82995. */
  82996. export class GLTFData {
  82997. /**
  82998. * Object which contains the file name as the key and its data as the value
  82999. */
  83000. glTFFiles: {
  83001. [fileName: string]: string | Blob;
  83002. };
  83003. /**
  83004. * Initializes the glTF file object
  83005. */
  83006. constructor();
  83007. /**
  83008. * Downloads the glTF data as files based on their names and data
  83009. */
  83010. downloadFiles(): void;
  83011. }
  83012. }
  83013. declare module BABYLON {
  83014. /**
  83015. * Holds a collection of exporter options and parameters
  83016. */
  83017. export interface IExportOptions {
  83018. /**
  83019. * Function which indicates whether a babylon node should be exported or not
  83020. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83021. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83022. */
  83023. shouldExportNode?(node: Node): boolean;
  83024. /**
  83025. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83026. * @param metadata source metadata to read from
  83027. * @returns the data to store to glTF node extras
  83028. */
  83029. metadataSelector?(metadata: any): any;
  83030. /**
  83031. * The sample rate to bake animation curves
  83032. */
  83033. animationSampleRate?: number;
  83034. /**
  83035. * Begin serialization without waiting for the scene to be ready
  83036. */
  83037. exportWithoutWaitingForScene?: boolean;
  83038. /**
  83039. * Indicates if coordinate system swapping root nodes should be included in export
  83040. */
  83041. includeCoordinateSystemConversionNodes?: boolean;
  83042. }
  83043. /**
  83044. * Class for generating glTF data from a Babylon scene.
  83045. */
  83046. export class GLTF2Export {
  83047. /**
  83048. * Exports the geometry of the scene to .gltf file format asynchronously
  83049. * @param scene Babylon scene with scene hierarchy information
  83050. * @param filePrefix File prefix to use when generating the glTF file
  83051. * @param options Exporter options
  83052. * @returns Returns an object with a .gltf file and associates texture names
  83053. * as keys and their data and paths as values
  83054. */
  83055. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83056. private static _PreExportAsync;
  83057. private static _PostExportAsync;
  83058. /**
  83059. * Exports the geometry of the scene to .glb file format asychronously
  83060. * @param scene Babylon scene with scene hierarchy information
  83061. * @param filePrefix File prefix to use when generating glb file
  83062. * @param options Exporter options
  83063. * @returns Returns an object with a .glb filename as key and data as value
  83064. */
  83065. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83066. }
  83067. }
  83068. declare module BABYLON.GLTF2.Exporter {
  83069. /**
  83070. * @hidden
  83071. */
  83072. export class _GLTFUtilities {
  83073. /**
  83074. * Creates a buffer view based on the supplied arguments
  83075. * @param bufferIndex index value of the specified buffer
  83076. * @param byteOffset byte offset value
  83077. * @param byteLength byte length of the bufferView
  83078. * @param byteStride byte distance between conequential elements
  83079. * @param name name of the buffer view
  83080. * @returns bufferView for glTF
  83081. */
  83082. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83083. /**
  83084. * Creates an accessor based on the supplied arguments
  83085. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83086. * @param name The name of the accessor
  83087. * @param type The type of the accessor
  83088. * @param componentType The datatype of components in the attribute
  83089. * @param count The number of attributes referenced by this accessor
  83090. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83091. * @param min Minimum value of each component in this attribute
  83092. * @param max Maximum value of each component in this attribute
  83093. * @returns accessor for glTF
  83094. */
  83095. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83096. /**
  83097. * Calculates the minimum and maximum values of an array of position floats
  83098. * @param positions Positions array of a mesh
  83099. * @param vertexStart Starting vertex offset to calculate min and max values
  83100. * @param vertexCount Number of vertices to check for min and max values
  83101. * @returns min number array and max number array
  83102. */
  83103. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83104. min: number[];
  83105. max: number[];
  83106. };
  83107. /**
  83108. * Converts a new right-handed Vector3
  83109. * @param vector vector3 array
  83110. * @returns right-handed Vector3
  83111. */
  83112. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83113. /**
  83114. * Converts a Vector3 to right-handed
  83115. * @param vector Vector3 to convert to right-handed
  83116. */
  83117. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83118. /**
  83119. * Converts a three element number array to right-handed
  83120. * @param vector number array to convert to right-handed
  83121. */
  83122. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83123. /**
  83124. * Converts a new right-handed Vector3
  83125. * @param vector vector3 array
  83126. * @returns right-handed Vector3
  83127. */
  83128. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83129. /**
  83130. * Converts a Vector3 to right-handed
  83131. * @param vector Vector3 to convert to right-handed
  83132. */
  83133. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83134. /**
  83135. * Converts a three element number array to right-handed
  83136. * @param vector number array to convert to right-handed
  83137. */
  83138. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83139. /**
  83140. * Converts a Vector4 to right-handed
  83141. * @param vector Vector4 to convert to right-handed
  83142. */
  83143. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83144. /**
  83145. * Converts a Vector4 to right-handed
  83146. * @param vector Vector4 to convert to right-handed
  83147. */
  83148. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83149. /**
  83150. * Converts a Quaternion to right-handed
  83151. * @param quaternion Source quaternion to convert to right-handed
  83152. */
  83153. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83154. /**
  83155. * Converts a Quaternion to right-handed
  83156. * @param quaternion Source quaternion to convert to right-handed
  83157. */
  83158. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83159. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83160. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83161. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83162. }
  83163. }
  83164. declare module BABYLON.GLTF2.Exporter {
  83165. /**
  83166. * Converts Babylon Scene into glTF 2.0.
  83167. * @hidden
  83168. */
  83169. export class _Exporter {
  83170. /**
  83171. * Stores the glTF to export
  83172. */
  83173. _glTF: IGLTF;
  83174. /**
  83175. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83176. */
  83177. _bufferViews: IBufferView[];
  83178. /**
  83179. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83180. */
  83181. _accessors: IAccessor[];
  83182. /**
  83183. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83184. */
  83185. _nodes: INode[];
  83186. /**
  83187. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83188. */
  83189. private _scenes;
  83190. /**
  83191. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83192. */
  83193. private _meshes;
  83194. /**
  83195. * Stores all the generated material information, which represents the appearance of each primitive
  83196. */
  83197. _materials: IMaterial[];
  83198. _materialMap: {
  83199. [materialID: number]: number;
  83200. };
  83201. /**
  83202. * Stores all the generated texture information, which is referenced by glTF materials
  83203. */
  83204. _textures: ITexture[];
  83205. /**
  83206. * Stores all the generated image information, which is referenced by glTF textures
  83207. */
  83208. _images: IImage[];
  83209. /**
  83210. * Stores all the texture samplers
  83211. */
  83212. _samplers: ISampler[];
  83213. /**
  83214. * Stores all the generated glTF skins
  83215. */
  83216. _skins: ISkin[];
  83217. /**
  83218. * Stores all the generated animation samplers, which is referenced by glTF animations
  83219. */
  83220. /**
  83221. * Stores the animations for glTF models
  83222. */
  83223. private _animations;
  83224. /**
  83225. * Stores the total amount of bytes stored in the glTF buffer
  83226. */
  83227. private _totalByteLength;
  83228. /**
  83229. * Stores a reference to the Babylon scene containing the source geometry and material information
  83230. */
  83231. _babylonScene: Scene;
  83232. /**
  83233. * Stores a map of the image data, where the key is the file name and the value
  83234. * is the image data
  83235. */
  83236. _imageData: {
  83237. [fileName: string]: {
  83238. data: Uint8Array;
  83239. mimeType: ImageMimeType;
  83240. };
  83241. };
  83242. /**
  83243. * Stores a map of the unique id of a node to its index in the node array
  83244. */
  83245. _nodeMap: {
  83246. [key: number]: number;
  83247. };
  83248. /**
  83249. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83250. */
  83251. _convertToRightHandedSystem: boolean;
  83252. /**
  83253. * Specifies if a Babylon node should be converted to right-handed on export
  83254. */
  83255. _convertToRightHandedSystemMap: {
  83256. [nodeId: number]: boolean;
  83257. };
  83258. _includeCoordinateSystemConversionNodes: boolean;
  83259. /**
  83260. * Baked animation sample rate
  83261. */
  83262. private _animationSampleRate;
  83263. private _options;
  83264. private _localEngine;
  83265. _glTFMaterialExporter: _GLTFMaterialExporter;
  83266. private _extensions;
  83267. private static _ExtensionNames;
  83268. private static _ExtensionFactories;
  83269. private _applyExtension;
  83270. private _applyExtensions;
  83271. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83272. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83273. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83274. [key: number]: number;
  83275. }): Promise<Nullable<INode>>;
  83276. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83277. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83278. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83279. private _forEachExtensions;
  83280. private _extensionsOnExporting;
  83281. /**
  83282. * Load glTF serializer extensions
  83283. */
  83284. private _loadExtensions;
  83285. /**
  83286. * Creates a glTF Exporter instance, which can accept optional exporter options
  83287. * @param babylonScene Babylon scene object
  83288. * @param options Options to modify the behavior of the exporter
  83289. */
  83290. constructor(babylonScene: Scene, options?: IExportOptions);
  83291. dispose(): void;
  83292. /**
  83293. * Registers a glTF exporter extension
  83294. * @param name Name of the extension to export
  83295. * @param factory The factory function that creates the exporter extension
  83296. */
  83297. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83298. /**
  83299. * Un-registers an exporter extension
  83300. * @param name The name fo the exporter extension
  83301. * @returns A boolean indicating whether the extension has been un-registered
  83302. */
  83303. static UnregisterExtension(name: string): boolean;
  83304. /**
  83305. * Lazy load a local engine
  83306. */
  83307. _getLocalEngine(): Engine;
  83308. private reorderIndicesBasedOnPrimitiveMode;
  83309. /**
  83310. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83311. * clock-wise during export to glTF
  83312. * @param submesh BabylonJS submesh
  83313. * @param primitiveMode Primitive mode of the mesh
  83314. * @param sideOrientation the winding order of the submesh
  83315. * @param vertexBufferKind The type of vertex attribute
  83316. * @param meshAttributeArray The vertex attribute data
  83317. * @param byteOffset The offset to the binary data
  83318. * @param binaryWriter The binary data for the glTF file
  83319. * @param convertToRightHandedSystem Converts the values to right-handed
  83320. */
  83321. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83322. /**
  83323. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83324. * clock-wise during export to glTF
  83325. * @param submesh BabylonJS submesh
  83326. * @param primitiveMode Primitive mode of the mesh
  83327. * @param sideOrientation the winding order of the submesh
  83328. * @param vertexBufferKind The type of vertex attribute
  83329. * @param meshAttributeArray The vertex attribute data
  83330. * @param byteOffset The offset to the binary data
  83331. * @param binaryWriter The binary data for the glTF file
  83332. * @param convertToRightHandedSystem Converts the values to right-handed
  83333. */
  83334. private reorderTriangleFillMode;
  83335. /**
  83336. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83337. * clock-wise during export to glTF
  83338. * @param submesh BabylonJS submesh
  83339. * @param primitiveMode Primitive mode of the mesh
  83340. * @param sideOrientation the winding order of the submesh
  83341. * @param vertexBufferKind The type of vertex attribute
  83342. * @param meshAttributeArray The vertex attribute data
  83343. * @param byteOffset The offset to the binary data
  83344. * @param binaryWriter The binary data for the glTF file
  83345. * @param convertToRightHandedSystem Converts the values to right-handed
  83346. */
  83347. private reorderTriangleStripDrawMode;
  83348. /**
  83349. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83350. * clock-wise during export to glTF
  83351. * @param submesh BabylonJS submesh
  83352. * @param primitiveMode Primitive mode of the mesh
  83353. * @param sideOrientation the winding order of the submesh
  83354. * @param vertexBufferKind The type of vertex attribute
  83355. * @param meshAttributeArray The vertex attribute data
  83356. * @param byteOffset The offset to the binary data
  83357. * @param binaryWriter The binary data for the glTF file
  83358. * @param convertToRightHandedSystem Converts the values to right-handed
  83359. */
  83360. private reorderTriangleFanMode;
  83361. /**
  83362. * Writes the vertex attribute data to binary
  83363. * @param vertices The vertices to write to the binary writer
  83364. * @param byteOffset The offset into the binary writer to overwrite binary data
  83365. * @param vertexAttributeKind The vertex attribute type
  83366. * @param meshAttributeArray The vertex attribute data
  83367. * @param binaryWriter The writer containing the binary data
  83368. * @param convertToRightHandedSystem Converts the values to right-handed
  83369. */
  83370. private writeVertexAttributeData;
  83371. /**
  83372. * Writes mesh attribute data to a data buffer
  83373. * Returns the bytelength of the data
  83374. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83375. * @param meshAttributeArray Array containing the attribute data
  83376. * @param byteStride Specifies the space between data
  83377. * @param binaryWriter The buffer to write the binary data to
  83378. * @param convertToRightHandedSystem Converts the values to right-handed
  83379. */
  83380. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83381. /**
  83382. * Writes mesh attribute data to a data buffer
  83383. * Returns the bytelength of the data
  83384. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83385. * @param meshAttributeArray Array containing the attribute data
  83386. * @param byteStride Specifies the space between data
  83387. * @param binaryWriter The buffer to write the binary data to
  83388. * @param convertToRightHandedSystem Converts the values to right-handed
  83389. */
  83390. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  83391. /**
  83392. * Generates glTF json data
  83393. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83394. * @param glTFPrefix Text to use when prefixing a glTF file
  83395. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83396. * @returns json data as string
  83397. */
  83398. private generateJSON;
  83399. /**
  83400. * Generates data for .gltf and .bin files based on the glTF prefix string
  83401. * @param glTFPrefix Text to use when prefixing a glTF file
  83402. * @param dispose Dispose the exporter
  83403. * @returns GLTFData with glTF file data
  83404. */
  83405. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83406. /**
  83407. * Creates a binary buffer for glTF
  83408. * @returns array buffer for binary data
  83409. */
  83410. private _generateBinaryAsync;
  83411. /**
  83412. * Pads the number to a multiple of 4
  83413. * @param num number to pad
  83414. * @returns padded number
  83415. */
  83416. private _getPadding;
  83417. /**
  83418. * @hidden
  83419. */
  83420. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83421. /**
  83422. * Sets the TRS for each node
  83423. * @param node glTF Node for storing the transformation data
  83424. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83425. * @param convertToRightHandedSystem Converts the values to right-handed
  83426. */
  83427. private setNodeTransformation;
  83428. private getVertexBufferFromMesh;
  83429. /**
  83430. * Creates a bufferview based on the vertices type for the Babylon mesh
  83431. * @param kind Indicates the type of vertices data
  83432. * @param componentType Indicates the numerical type used to store the data
  83433. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83434. * @param binaryWriter The buffer to write the bufferview data to
  83435. * @param convertToRightHandedSystem Converts the values to right-handed
  83436. */
  83437. private createBufferViewKind;
  83438. /**
  83439. * Creates a bufferview based on the vertices type for the Babylon mesh
  83440. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  83441. * @param babylonMorphTarget the morph target to be exported
  83442. * @param binaryWriter The buffer to write the bufferview data to
  83443. * @param convertToRightHandedSystem Converts the values to right-handed
  83444. */
  83445. private setMorphTargetAttributes;
  83446. /**
  83447. * The primitive mode of the Babylon mesh
  83448. * @param babylonMesh The BabylonJS mesh
  83449. */
  83450. private getMeshPrimitiveMode;
  83451. /**
  83452. * Sets the primitive mode of the glTF mesh primitive
  83453. * @param meshPrimitive glTF mesh primitive
  83454. * @param primitiveMode The primitive mode
  83455. */
  83456. private setPrimitiveMode;
  83457. /**
  83458. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83459. * @param meshPrimitive glTF mesh primitive
  83460. * @param attributeKind vertex attribute
  83461. * @returns boolean specifying if uv coordinates are present
  83462. */
  83463. private setAttributeKind;
  83464. /**
  83465. * Sets data for the primitive attributes of each submesh
  83466. * @param mesh glTF Mesh object to store the primitive attribute information
  83467. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83468. * @param binaryWriter Buffer to write the attribute data to
  83469. * @param convertToRightHandedSystem Converts the values to right-handed
  83470. */
  83471. private setPrimitiveAttributesAsync;
  83472. /**
  83473. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83474. * @param node The node to check
  83475. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83476. */
  83477. private isBabylonCoordinateSystemConvertingNode;
  83478. /**
  83479. * Creates a glTF scene based on the array of meshes
  83480. * Returns the the total byte offset
  83481. * @param babylonScene Babylon scene to get the mesh data from
  83482. * @param binaryWriter Buffer to write binary data to
  83483. */
  83484. private createSceneAsync;
  83485. /**
  83486. * Creates a mapping of Node unique id to node index and handles animations
  83487. * @param babylonScene Babylon Scene
  83488. * @param nodes Babylon transform nodes
  83489. * @param binaryWriter Buffer to write binary data to
  83490. * @returns Node mapping of unique id to index
  83491. */
  83492. private createNodeMapAndAnimationsAsync;
  83493. /**
  83494. * Creates a glTF node from a Babylon mesh
  83495. * @param babylonMesh Source Babylon mesh
  83496. * @param binaryWriter Buffer for storing geometry data
  83497. * @param convertToRightHandedSystem Converts the values to right-handed
  83498. * @param nodeMap Node mapping of unique id to glTF node index
  83499. * @returns glTF node
  83500. */
  83501. private createNodeAsync;
  83502. /**
  83503. * Creates a glTF skin from a Babylon skeleton
  83504. * @param babylonScene Babylon Scene
  83505. * @param nodes Babylon transform nodes
  83506. * @param binaryWriter Buffer to write binary data to
  83507. * @returns Node mapping of unique id to index
  83508. */
  83509. private createSkinsAsync;
  83510. }
  83511. /**
  83512. * @hidden
  83513. *
  83514. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83515. */
  83516. export class _BinaryWriter {
  83517. /**
  83518. * Array buffer which stores all binary data
  83519. */
  83520. private _arrayBuffer;
  83521. /**
  83522. * View of the array buffer
  83523. */
  83524. private _dataView;
  83525. /**
  83526. * byte offset of data in array buffer
  83527. */
  83528. private _byteOffset;
  83529. /**
  83530. * Initialize binary writer with an initial byte length
  83531. * @param byteLength Initial byte length of the array buffer
  83532. */
  83533. constructor(byteLength: number);
  83534. /**
  83535. * Resize the array buffer to the specified byte length
  83536. * @param byteLength
  83537. */
  83538. private resizeBuffer;
  83539. /**
  83540. * Get an array buffer with the length of the byte offset
  83541. * @returns ArrayBuffer resized to the byte offset
  83542. */
  83543. getArrayBuffer(): ArrayBuffer;
  83544. /**
  83545. * Get the byte offset of the array buffer
  83546. * @returns byte offset
  83547. */
  83548. getByteOffset(): number;
  83549. /**
  83550. * Stores an UInt8 in the array buffer
  83551. * @param entry
  83552. * @param byteOffset If defined, specifies where to set the value as an offset.
  83553. */
  83554. setUInt8(entry: number, byteOffset?: number): void;
  83555. /**
  83556. * Stores an UInt16 in the array buffer
  83557. * @param entry
  83558. * @param byteOffset If defined, specifies where to set the value as an offset.
  83559. */
  83560. setUInt16(entry: number, byteOffset?: number): void;
  83561. /**
  83562. * Gets an UInt32 in the array buffer
  83563. * @param entry
  83564. * @param byteOffset If defined, specifies where to set the value as an offset.
  83565. */
  83566. getUInt32(byteOffset: number): number;
  83567. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83568. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83569. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83570. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83571. /**
  83572. * Stores a Float32 in the array buffer
  83573. * @param entry
  83574. */
  83575. setFloat32(entry: number, byteOffset?: number): void;
  83576. /**
  83577. * Stores an UInt32 in the array buffer
  83578. * @param entry
  83579. * @param byteOffset If defined, specifies where to set the value as an offset.
  83580. */
  83581. setUInt32(entry: number, byteOffset?: number): void;
  83582. }
  83583. }
  83584. declare module BABYLON.GLTF2.Exporter {
  83585. /**
  83586. * @hidden
  83587. * Interface to store animation data.
  83588. */
  83589. export interface _IAnimationData {
  83590. /**
  83591. * Keyframe data.
  83592. */
  83593. inputs: number[];
  83594. /**
  83595. * Value data.
  83596. */
  83597. outputs: number[][];
  83598. /**
  83599. * Animation interpolation data.
  83600. */
  83601. samplerInterpolation: AnimationSamplerInterpolation;
  83602. /**
  83603. * Minimum keyframe value.
  83604. */
  83605. inputsMin: number;
  83606. /**
  83607. * Maximum keyframe value.
  83608. */
  83609. inputsMax: number;
  83610. }
  83611. /**
  83612. * @hidden
  83613. */
  83614. export interface _IAnimationInfo {
  83615. /**
  83616. * The target channel for the animation
  83617. */
  83618. animationChannelTargetPath: AnimationChannelTargetPath;
  83619. /**
  83620. * The glTF accessor type for the data.
  83621. */
  83622. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  83623. /**
  83624. * Specifies if quaternions should be used.
  83625. */
  83626. useQuaternion: boolean;
  83627. }
  83628. /**
  83629. * @hidden
  83630. * Utility class for generating glTF animation data from BabylonJS.
  83631. */
  83632. export class _GLTFAnimation {
  83633. /**
  83634. * @ignore
  83635. *
  83636. * Creates glTF channel animation from BabylonJS animation.
  83637. * @param babylonTransformNode - BabylonJS mesh.
  83638. * @param animation - animation.
  83639. * @param animationChannelTargetPath - The target animation channel.
  83640. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83641. * @param useQuaternion - Specifies if quaternions are used.
  83642. * @returns nullable IAnimationData
  83643. */
  83644. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83645. private static _DeduceAnimationInfo;
  83646. /**
  83647. * @ignore
  83648. * Create node animations from the transform node animations
  83649. * @param babylonNode
  83650. * @param runtimeGLTFAnimation
  83651. * @param idleGLTFAnimations
  83652. * @param nodeMap
  83653. * @param nodes
  83654. * @param binaryWriter
  83655. * @param bufferViews
  83656. * @param accessors
  83657. * @param convertToRightHandedSystem
  83658. * @param animationSampleRate
  83659. */
  83660. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83661. [key: number]: number;
  83662. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83663. /**
  83664. * @ignore
  83665. * Create individual morph animations from the mesh's morph target animation tracks
  83666. * @param babylonNode
  83667. * @param runtimeGLTFAnimation
  83668. * @param idleGLTFAnimations
  83669. * @param nodeMap
  83670. * @param nodes
  83671. * @param binaryWriter
  83672. * @param bufferViews
  83673. * @param accessors
  83674. * @param convertToRightHandedSystem
  83675. * @param animationSampleRate
  83676. */
  83677. static _CreateMorphTargetAnimationFromMorphTargets(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83678. [key: number]: number;
  83679. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83680. /**
  83681. * @ignore
  83682. * Create node and morph animations from the animation groups
  83683. * @param babylonScene
  83684. * @param glTFAnimations
  83685. * @param nodeMap
  83686. * @param nodes
  83687. * @param binaryWriter
  83688. * @param bufferViews
  83689. * @param accessors
  83690. * @param convertToRightHandedSystemMap
  83691. * @param animationSampleRate
  83692. */
  83693. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83694. [key: number]: number;
  83695. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83696. [nodeId: number]: boolean;
  83697. }, animationSampleRate: number): void;
  83698. private static AddAnimation;
  83699. /**
  83700. * Create a baked animation
  83701. * @param babylonTransformNode BabylonJS mesh
  83702. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83703. * @param animationChannelTargetPath animation target channel
  83704. * @param minFrame minimum animation frame
  83705. * @param maxFrame maximum animation frame
  83706. * @param fps frames per second of the animation
  83707. * @param inputs input key frames of the animation
  83708. * @param outputs output key frame data of the animation
  83709. * @param convertToRightHandedSystem converts the values to right-handed
  83710. * @param useQuaternion specifies if quaternions should be used
  83711. */
  83712. private static _CreateBakedAnimation;
  83713. private static _ConvertFactorToVector3OrQuaternion;
  83714. private static _SetInterpolatedValue;
  83715. /**
  83716. * Creates linear animation from the animation key frames
  83717. * @param babylonTransformNode BabylonJS mesh
  83718. * @param animation BabylonJS animation
  83719. * @param animationChannelTargetPath The target animation channel
  83720. * @param frameDelta The difference between the last and first frame of the animation
  83721. * @param inputs Array to store the key frame times
  83722. * @param outputs Array to store the key frame data
  83723. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83724. * @param useQuaternion Specifies if quaternions are used in the animation
  83725. */
  83726. private static _CreateLinearOrStepAnimation;
  83727. /**
  83728. * Creates cubic spline animation from the animation key frames
  83729. * @param babylonTransformNode BabylonJS mesh
  83730. * @param animation BabylonJS animation
  83731. * @param animationChannelTargetPath The target animation channel
  83732. * @param frameDelta The difference between the last and first frame of the animation
  83733. * @param inputs Array to store the key frame times
  83734. * @param outputs Array to store the key frame data
  83735. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83736. * @param useQuaternion Specifies if quaternions are used in the animation
  83737. */
  83738. private static _CreateCubicSplineAnimation;
  83739. private static _GetBasePositionRotationOrScale;
  83740. /**
  83741. * Adds a key frame value
  83742. * @param keyFrame
  83743. * @param animation
  83744. * @param outputs
  83745. * @param animationChannelTargetPath
  83746. * @param basePositionRotationOrScale
  83747. * @param convertToRightHandedSystem
  83748. * @param useQuaternion
  83749. */
  83750. private static _AddKeyframeValue;
  83751. /**
  83752. * Determine the interpolation based on the key frames
  83753. * @param keyFrames
  83754. * @param animationChannelTargetPath
  83755. * @param useQuaternion
  83756. */
  83757. private static _DeduceInterpolation;
  83758. /**
  83759. * Adds an input tangent or output tangent to the output data
  83760. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83761. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83762. * @param outputs The animation data by keyframe
  83763. * @param animationChannelTargetPath The target animation channel
  83764. * @param interpolation The interpolation type
  83765. * @param keyFrame The key frame with the animation data
  83766. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83767. * @param useQuaternion Specifies if quaternions are used
  83768. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83769. */
  83770. private static AddSplineTangent;
  83771. /**
  83772. * Get the minimum and maximum key frames' frame values
  83773. * @param keyFrames animation key frames
  83774. * @returns the minimum and maximum key frame value
  83775. */
  83776. private static calculateMinMaxKeyFrames;
  83777. }
  83778. }
  83779. declare module BABYLON.GLTF2.Exporter {
  83780. /** @hidden */
  83781. export var textureTransformPixelShader: {
  83782. name: string;
  83783. shader: string;
  83784. };
  83785. }
  83786. declare module BABYLON.GLTF2.Exporter.Extensions {
  83787. /**
  83788. * @hidden
  83789. */
  83790. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83791. private _recordedTextures;
  83792. /** Name of this extension */
  83793. readonly name: string;
  83794. /** Defines whether this extension is enabled */
  83795. enabled: boolean;
  83796. /** Defines whether this extension is required */
  83797. required: boolean;
  83798. /** Reference to the glTF exporter */
  83799. private _wasUsed;
  83800. constructor(exporter: _Exporter);
  83801. dispose(): void;
  83802. /** @hidden */
  83803. get wasUsed(): boolean;
  83804. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83805. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83806. /**
  83807. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83808. * @param babylonTexture
  83809. * @param offset
  83810. * @param rotation
  83811. * @param scale
  83812. * @param scene
  83813. */
  83814. private _textureTransformTextureAsync;
  83815. }
  83816. }
  83817. declare module BABYLON.GLTF2.Exporter.Extensions {
  83818. /**
  83819. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83820. */
  83821. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83822. /** The name of this extension. */
  83823. readonly name: string;
  83824. /** Defines whether this extension is enabled. */
  83825. enabled: boolean;
  83826. /** Defines whether this extension is required */
  83827. required: boolean;
  83828. /** Reference to the glTF exporter */
  83829. private _exporter;
  83830. private _lights;
  83831. /** @hidden */
  83832. constructor(exporter: _Exporter);
  83833. /** @hidden */
  83834. dispose(): void;
  83835. /** @hidden */
  83836. get wasUsed(): boolean;
  83837. /** @hidden */
  83838. onExporting(): void;
  83839. /**
  83840. * Define this method to modify the default behavior when exporting a node
  83841. * @param context The context when exporting the node
  83842. * @param node glTF node
  83843. * @param babylonNode BabylonJS node
  83844. * @param nodeMap Node mapping of unique id to glTF node index
  83845. * @returns nullable INode promise
  83846. */
  83847. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83848. [key: number]: number;
  83849. }): Promise<Nullable<INode>>;
  83850. }
  83851. }
  83852. declare module BABYLON.GLTF2.Exporter.Extensions {
  83853. /**
  83854. * @hidden
  83855. */
  83856. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83857. /** Name of this extension */
  83858. readonly name: string;
  83859. /** Defines whether this extension is enabled */
  83860. enabled: boolean;
  83861. /** Defines whether this extension is required */
  83862. required: boolean;
  83863. /** Reference to the glTF exporter */
  83864. private _textureInfos;
  83865. private _exportedTextures;
  83866. private _wasUsed;
  83867. constructor(exporter: _Exporter);
  83868. dispose(): void;
  83869. /** @hidden */
  83870. get wasUsed(): boolean;
  83871. private _getTextureIndex;
  83872. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83873. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83874. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83875. }
  83876. }
  83877. declare module BABYLON.GLTF2.Exporter.Extensions {
  83878. /**
  83879. * @hidden
  83880. */
  83881. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83882. /** Name of this extension */
  83883. readonly name: string;
  83884. /** Defines whether this extension is enabled */
  83885. enabled: boolean;
  83886. /** Defines whether this extension is required */
  83887. required: boolean;
  83888. private _wasUsed;
  83889. constructor(exporter: _Exporter);
  83890. /** @hidden */
  83891. get wasUsed(): boolean;
  83892. dispose(): void;
  83893. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83894. }
  83895. }
  83896. declare module BABYLON {
  83897. /**
  83898. * Class for generating STL data from a Babylon scene.
  83899. */
  83900. export class STLExport {
  83901. /**
  83902. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83903. * @param meshes list defines the mesh to serialize
  83904. * @param download triggers the automatic download of the file.
  83905. * @param fileName changes the downloads fileName.
  83906. * @param binary changes the STL to a binary type.
  83907. * @param isLittleEndian toggle for binary type exporter.
  83908. * @returns the STL as UTF8 string
  83909. */
  83910. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83911. }
  83912. }
  83913. declare module "babylonjs-gltf2interface" {
  83914. export = BABYLON.GLTF2;
  83915. }
  83916. /**
  83917. * Module for glTF 2.0 Interface
  83918. */
  83919. declare module BABYLON.GLTF2 {
  83920. /**
  83921. * The datatype of the components in the attribute
  83922. */
  83923. const enum AccessorComponentType {
  83924. /**
  83925. * Byte
  83926. */
  83927. BYTE = 5120,
  83928. /**
  83929. * Unsigned Byte
  83930. */
  83931. UNSIGNED_BYTE = 5121,
  83932. /**
  83933. * Short
  83934. */
  83935. SHORT = 5122,
  83936. /**
  83937. * Unsigned Short
  83938. */
  83939. UNSIGNED_SHORT = 5123,
  83940. /**
  83941. * Unsigned Int
  83942. */
  83943. UNSIGNED_INT = 5125,
  83944. /**
  83945. * Float
  83946. */
  83947. FLOAT = 5126,
  83948. }
  83949. /**
  83950. * Specifies if the attirbute is a scalar, vector, or matrix
  83951. */
  83952. const enum AccessorType {
  83953. /**
  83954. * Scalar
  83955. */
  83956. SCALAR = "SCALAR",
  83957. /**
  83958. * Vector2
  83959. */
  83960. VEC2 = "VEC2",
  83961. /**
  83962. * Vector3
  83963. */
  83964. VEC3 = "VEC3",
  83965. /**
  83966. * Vector4
  83967. */
  83968. VEC4 = "VEC4",
  83969. /**
  83970. * Matrix2x2
  83971. */
  83972. MAT2 = "MAT2",
  83973. /**
  83974. * Matrix3x3
  83975. */
  83976. MAT3 = "MAT3",
  83977. /**
  83978. * Matrix4x4
  83979. */
  83980. MAT4 = "MAT4",
  83981. }
  83982. /**
  83983. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83984. */
  83985. const enum AnimationChannelTargetPath {
  83986. /**
  83987. * Translation
  83988. */
  83989. TRANSLATION = "translation",
  83990. /**
  83991. * Rotation
  83992. */
  83993. ROTATION = "rotation",
  83994. /**
  83995. * Scale
  83996. */
  83997. SCALE = "scale",
  83998. /**
  83999. * Weights
  84000. */
  84001. WEIGHTS = "weights",
  84002. }
  84003. /**
  84004. * Interpolation algorithm
  84005. */
  84006. const enum AnimationSamplerInterpolation {
  84007. /**
  84008. * The animated values are linearly interpolated between keyframes
  84009. */
  84010. LINEAR = "LINEAR",
  84011. /**
  84012. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84013. */
  84014. STEP = "STEP",
  84015. /**
  84016. * The animation's interpolation is computed using a cubic spline with specified tangents
  84017. */
  84018. CUBICSPLINE = "CUBICSPLINE",
  84019. }
  84020. /**
  84021. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84022. */
  84023. const enum CameraType {
  84024. /**
  84025. * A perspective camera containing properties to create a perspective projection matrix
  84026. */
  84027. PERSPECTIVE = "perspective",
  84028. /**
  84029. * An orthographic camera containing properties to create an orthographic projection matrix
  84030. */
  84031. ORTHOGRAPHIC = "orthographic",
  84032. }
  84033. /**
  84034. * The mime-type of the image
  84035. */
  84036. const enum ImageMimeType {
  84037. /**
  84038. * JPEG Mime-type
  84039. */
  84040. JPEG = "image/jpeg",
  84041. /**
  84042. * PNG Mime-type
  84043. */
  84044. PNG = "image/png",
  84045. }
  84046. /**
  84047. * The alpha rendering mode of the material
  84048. */
  84049. const enum MaterialAlphaMode {
  84050. /**
  84051. * The alpha value is ignored and the rendered output is fully opaque
  84052. */
  84053. OPAQUE = "OPAQUE",
  84054. /**
  84055. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84056. */
  84057. MASK = "MASK",
  84058. /**
  84059. * 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)
  84060. */
  84061. BLEND = "BLEND",
  84062. }
  84063. /**
  84064. * The type of the primitives to render
  84065. */
  84066. const enum MeshPrimitiveMode {
  84067. /**
  84068. * Points
  84069. */
  84070. POINTS = 0,
  84071. /**
  84072. * Lines
  84073. */
  84074. LINES = 1,
  84075. /**
  84076. * Line Loop
  84077. */
  84078. LINE_LOOP = 2,
  84079. /**
  84080. * Line Strip
  84081. */
  84082. LINE_STRIP = 3,
  84083. /**
  84084. * Triangles
  84085. */
  84086. TRIANGLES = 4,
  84087. /**
  84088. * Triangle Strip
  84089. */
  84090. TRIANGLE_STRIP = 5,
  84091. /**
  84092. * Triangle Fan
  84093. */
  84094. TRIANGLE_FAN = 6,
  84095. }
  84096. /**
  84097. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84098. */
  84099. const enum TextureMagFilter {
  84100. /**
  84101. * Nearest
  84102. */
  84103. NEAREST = 9728,
  84104. /**
  84105. * Linear
  84106. */
  84107. LINEAR = 9729,
  84108. }
  84109. /**
  84110. * Minification filter. All valid values correspond to WebGL enums
  84111. */
  84112. const enum TextureMinFilter {
  84113. /**
  84114. * Nearest
  84115. */
  84116. NEAREST = 9728,
  84117. /**
  84118. * Linear
  84119. */
  84120. LINEAR = 9729,
  84121. /**
  84122. * Nearest Mip-Map Nearest
  84123. */
  84124. NEAREST_MIPMAP_NEAREST = 9984,
  84125. /**
  84126. * Linear Mipmap Nearest
  84127. */
  84128. LINEAR_MIPMAP_NEAREST = 9985,
  84129. /**
  84130. * Nearest Mipmap Linear
  84131. */
  84132. NEAREST_MIPMAP_LINEAR = 9986,
  84133. /**
  84134. * Linear Mipmap Linear
  84135. */
  84136. LINEAR_MIPMAP_LINEAR = 9987,
  84137. }
  84138. /**
  84139. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84140. */
  84141. const enum TextureWrapMode {
  84142. /**
  84143. * Clamp to Edge
  84144. */
  84145. CLAMP_TO_EDGE = 33071,
  84146. /**
  84147. * Mirrored Repeat
  84148. */
  84149. MIRRORED_REPEAT = 33648,
  84150. /**
  84151. * Repeat
  84152. */
  84153. REPEAT = 10497,
  84154. }
  84155. /**
  84156. * glTF Property
  84157. */
  84158. interface IProperty {
  84159. /**
  84160. * Dictionary object with extension-specific objects
  84161. */
  84162. extensions?: {
  84163. [key: string]: any;
  84164. };
  84165. /**
  84166. * Application-Specific data
  84167. */
  84168. extras?: any;
  84169. }
  84170. /**
  84171. * glTF Child of Root Property
  84172. */
  84173. interface IChildRootProperty extends IProperty {
  84174. /**
  84175. * The user-defined name of this object
  84176. */
  84177. name?: string;
  84178. }
  84179. /**
  84180. * Indices of those attributes that deviate from their initialization value
  84181. */
  84182. interface IAccessorSparseIndices extends IProperty {
  84183. /**
  84184. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84185. */
  84186. bufferView: number;
  84187. /**
  84188. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84189. */
  84190. byteOffset?: number;
  84191. /**
  84192. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84193. */
  84194. componentType: AccessorComponentType;
  84195. }
  84196. /**
  84197. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84198. */
  84199. interface IAccessorSparseValues extends IProperty {
  84200. /**
  84201. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84202. */
  84203. bufferView: number;
  84204. /**
  84205. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84206. */
  84207. byteOffset?: number;
  84208. }
  84209. /**
  84210. * Sparse storage of attributes that deviate from their initialization value
  84211. */
  84212. interface IAccessorSparse extends IProperty {
  84213. /**
  84214. * The number of attributes encoded in this sparse accessor
  84215. */
  84216. count: number;
  84217. /**
  84218. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84219. */
  84220. indices: IAccessorSparseIndices;
  84221. /**
  84222. * 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
  84223. */
  84224. values: IAccessorSparseValues;
  84225. }
  84226. /**
  84227. * 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
  84228. */
  84229. interface IAccessor extends IChildRootProperty {
  84230. /**
  84231. * The index of the bufferview
  84232. */
  84233. bufferView?: number;
  84234. /**
  84235. * The offset relative to the start of the bufferView in bytes
  84236. */
  84237. byteOffset?: number;
  84238. /**
  84239. * The datatype of components in the attribute
  84240. */
  84241. componentType: AccessorComponentType;
  84242. /**
  84243. * Specifies whether integer data values should be normalized
  84244. */
  84245. normalized?: boolean;
  84246. /**
  84247. * The number of attributes referenced by this accessor
  84248. */
  84249. count: number;
  84250. /**
  84251. * Specifies if the attribute is a scalar, vector, or matrix
  84252. */
  84253. type: AccessorType;
  84254. /**
  84255. * Maximum value of each component in this attribute
  84256. */
  84257. max?: number[];
  84258. /**
  84259. * Minimum value of each component in this attribute
  84260. */
  84261. min?: number[];
  84262. /**
  84263. * Sparse storage of attributes that deviate from their initialization value
  84264. */
  84265. sparse?: IAccessorSparse;
  84266. }
  84267. /**
  84268. * Targets an animation's sampler at a node's property
  84269. */
  84270. interface IAnimationChannel extends IProperty {
  84271. /**
  84272. * The index of a sampler in this animation used to compute the value for the target
  84273. */
  84274. sampler: number;
  84275. /**
  84276. * The index of the node and TRS property to target
  84277. */
  84278. target: IAnimationChannelTarget;
  84279. }
  84280. /**
  84281. * The index of the node and TRS property that an animation channel targets
  84282. */
  84283. interface IAnimationChannelTarget extends IProperty {
  84284. /**
  84285. * The index of the node to target
  84286. */
  84287. node: number;
  84288. /**
  84289. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84290. */
  84291. path: AnimationChannelTargetPath;
  84292. }
  84293. /**
  84294. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84295. */
  84296. interface IAnimationSampler extends IProperty {
  84297. /**
  84298. * The index of an accessor containing keyframe input values, e.g., time
  84299. */
  84300. input: number;
  84301. /**
  84302. * Interpolation algorithm
  84303. */
  84304. interpolation?: AnimationSamplerInterpolation;
  84305. /**
  84306. * The index of an accessor, containing keyframe output values
  84307. */
  84308. output: number;
  84309. }
  84310. /**
  84311. * A keyframe animation
  84312. */
  84313. interface IAnimation extends IChildRootProperty {
  84314. /**
  84315. * An array of channels, each of which targets an animation's sampler at a node's property
  84316. */
  84317. channels: IAnimationChannel[];
  84318. /**
  84319. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84320. */
  84321. samplers: IAnimationSampler[];
  84322. }
  84323. /**
  84324. * Metadata about the glTF asset
  84325. */
  84326. interface IAsset extends IChildRootProperty {
  84327. /**
  84328. * A copyright message suitable for display to credit the content creator
  84329. */
  84330. copyright?: string;
  84331. /**
  84332. * Tool that generated this glTF model. Useful for debugging
  84333. */
  84334. generator?: string;
  84335. /**
  84336. * The glTF version that this asset targets
  84337. */
  84338. version: string;
  84339. /**
  84340. * The minimum glTF version that this asset targets
  84341. */
  84342. minVersion?: string;
  84343. }
  84344. /**
  84345. * A buffer points to binary geometry, animation, or skins
  84346. */
  84347. interface IBuffer extends IChildRootProperty {
  84348. /**
  84349. * 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
  84350. */
  84351. uri?: string;
  84352. /**
  84353. * The length of the buffer in bytes
  84354. */
  84355. byteLength: number;
  84356. }
  84357. /**
  84358. * A view into a buffer generally representing a subset of the buffer
  84359. */
  84360. interface IBufferView extends IChildRootProperty {
  84361. /**
  84362. * The index of the buffer
  84363. */
  84364. buffer: number;
  84365. /**
  84366. * The offset into the buffer in bytes
  84367. */
  84368. byteOffset?: number;
  84369. /**
  84370. * The lenth of the bufferView in bytes
  84371. */
  84372. byteLength: number;
  84373. /**
  84374. * The stride, in bytes
  84375. */
  84376. byteStride?: number;
  84377. }
  84378. /**
  84379. * An orthographic camera containing properties to create an orthographic projection matrix
  84380. */
  84381. interface ICameraOrthographic extends IProperty {
  84382. /**
  84383. * The floating-point horizontal magnification of the view. Must not be zero
  84384. */
  84385. xmag: number;
  84386. /**
  84387. * The floating-point vertical magnification of the view. Must not be zero
  84388. */
  84389. ymag: number;
  84390. /**
  84391. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84392. */
  84393. zfar: number;
  84394. /**
  84395. * The floating-point distance to the near clipping plane
  84396. */
  84397. znear: number;
  84398. }
  84399. /**
  84400. * A perspective camera containing properties to create a perspective projection matrix
  84401. */
  84402. interface ICameraPerspective extends IProperty {
  84403. /**
  84404. * The floating-point aspect ratio of the field of view
  84405. */
  84406. aspectRatio?: number;
  84407. /**
  84408. * The floating-point vertical field of view in radians
  84409. */
  84410. yfov: number;
  84411. /**
  84412. * The floating-point distance to the far clipping plane
  84413. */
  84414. zfar?: number;
  84415. /**
  84416. * The floating-point distance to the near clipping plane
  84417. */
  84418. znear: number;
  84419. }
  84420. /**
  84421. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84422. */
  84423. interface ICamera extends IChildRootProperty {
  84424. /**
  84425. * An orthographic camera containing properties to create an orthographic projection matrix
  84426. */
  84427. orthographic?: ICameraOrthographic;
  84428. /**
  84429. * A perspective camera containing properties to create a perspective projection matrix
  84430. */
  84431. perspective?: ICameraPerspective;
  84432. /**
  84433. * Specifies if the camera uses a perspective or orthographic projection
  84434. */
  84435. type: CameraType;
  84436. }
  84437. /**
  84438. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84439. */
  84440. interface IImage extends IChildRootProperty {
  84441. /**
  84442. * 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
  84443. */
  84444. uri?: string;
  84445. /**
  84446. * The image's MIME type
  84447. */
  84448. mimeType?: ImageMimeType;
  84449. /**
  84450. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84451. */
  84452. bufferView?: number;
  84453. }
  84454. /**
  84455. * Material Normal Texture Info
  84456. */
  84457. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84458. /**
  84459. * The scalar multiplier applied to each normal vector of the normal texture
  84460. */
  84461. scale?: number;
  84462. }
  84463. /**
  84464. * Material Occlusion Texture Info
  84465. */
  84466. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84467. /**
  84468. * A scalar multiplier controlling the amount of occlusion applied
  84469. */
  84470. strength?: number;
  84471. }
  84472. /**
  84473. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84474. */
  84475. interface IMaterialPbrMetallicRoughness {
  84476. /**
  84477. * The material's base color factor
  84478. */
  84479. baseColorFactor?: number[];
  84480. /**
  84481. * The base color texture
  84482. */
  84483. baseColorTexture?: ITextureInfo;
  84484. /**
  84485. * The metalness of the material
  84486. */
  84487. metallicFactor?: number;
  84488. /**
  84489. * The roughness of the material
  84490. */
  84491. roughnessFactor?: number;
  84492. /**
  84493. * The metallic-roughness texture
  84494. */
  84495. metallicRoughnessTexture?: ITextureInfo;
  84496. }
  84497. /**
  84498. * The material appearance of a primitive
  84499. */
  84500. interface IMaterial extends IChildRootProperty {
  84501. /**
  84502. * 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
  84503. */
  84504. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84505. /**
  84506. * The normal map texture
  84507. */
  84508. normalTexture?: IMaterialNormalTextureInfo;
  84509. /**
  84510. * The occlusion map texture
  84511. */
  84512. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84513. /**
  84514. * The emissive map texture
  84515. */
  84516. emissiveTexture?: ITextureInfo;
  84517. /**
  84518. * 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
  84519. */
  84520. emissiveFactor?: number[];
  84521. /**
  84522. * The alpha rendering mode of the material
  84523. */
  84524. alphaMode?: MaterialAlphaMode;
  84525. /**
  84526. * The alpha cutoff value of the material
  84527. */
  84528. alphaCutoff?: number;
  84529. /**
  84530. * Specifies whether the material is double sided
  84531. */
  84532. doubleSided?: boolean;
  84533. }
  84534. /**
  84535. * Geometry to be rendered with the given material
  84536. */
  84537. interface IMeshPrimitive extends IProperty {
  84538. /**
  84539. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84540. */
  84541. attributes: {
  84542. [name: string]: number;
  84543. };
  84544. /**
  84545. * The index of the accessor that contains the indices
  84546. */
  84547. indices?: number;
  84548. /**
  84549. * The index of the material to apply to this primitive when rendering
  84550. */
  84551. material?: number;
  84552. /**
  84553. * The type of primitives to render. All valid values correspond to WebGL enums
  84554. */
  84555. mode?: MeshPrimitiveMode;
  84556. /**
  84557. * 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
  84558. */
  84559. targets?: {
  84560. [name: string]: number;
  84561. }[];
  84562. }
  84563. /**
  84564. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84565. */
  84566. interface IMesh extends IChildRootProperty {
  84567. /**
  84568. * An array of primitives, each defining geometry to be rendered with a material
  84569. */
  84570. primitives: IMeshPrimitive[];
  84571. /**
  84572. * Array of weights to be applied to the Morph Targets
  84573. */
  84574. weights?: number[];
  84575. }
  84576. /**
  84577. * A node in the node hierarchy
  84578. */
  84579. interface INode extends IChildRootProperty {
  84580. /**
  84581. * The index of the camera referenced by this node
  84582. */
  84583. camera?: number;
  84584. /**
  84585. * The indices of this node's children
  84586. */
  84587. children?: number[];
  84588. /**
  84589. * The index of the skin referenced by this node
  84590. */
  84591. skin?: number;
  84592. /**
  84593. * A floating-point 4x4 transformation matrix stored in column-major order
  84594. */
  84595. matrix?: number[];
  84596. /**
  84597. * The index of the mesh in this node
  84598. */
  84599. mesh?: number;
  84600. /**
  84601. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84602. */
  84603. rotation?: number[];
  84604. /**
  84605. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84606. */
  84607. scale?: number[];
  84608. /**
  84609. * The node's translation along the x, y, and z axes
  84610. */
  84611. translation?: number[];
  84612. /**
  84613. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84614. */
  84615. weights?: number[];
  84616. }
  84617. /**
  84618. * Texture sampler properties for filtering and wrapping modes
  84619. */
  84620. interface ISampler extends IChildRootProperty {
  84621. /**
  84622. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84623. */
  84624. magFilter?: TextureMagFilter;
  84625. /**
  84626. * Minification filter. All valid values correspond to WebGL enums
  84627. */
  84628. minFilter?: TextureMinFilter;
  84629. /**
  84630. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84631. */
  84632. wrapS?: TextureWrapMode;
  84633. /**
  84634. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84635. */
  84636. wrapT?: TextureWrapMode;
  84637. }
  84638. /**
  84639. * The root nodes of a scene
  84640. */
  84641. interface IScene extends IChildRootProperty {
  84642. /**
  84643. * The indices of each root node
  84644. */
  84645. nodes: number[];
  84646. }
  84647. /**
  84648. * Joints and matrices defining a skin
  84649. */
  84650. interface ISkin extends IChildRootProperty {
  84651. /**
  84652. * 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
  84653. */
  84654. inverseBindMatrices?: number;
  84655. /**
  84656. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84657. */
  84658. skeleton?: number;
  84659. /**
  84660. * 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)
  84661. */
  84662. joints: number[];
  84663. }
  84664. /**
  84665. * A texture and its sampler
  84666. */
  84667. interface ITexture extends IChildRootProperty {
  84668. /**
  84669. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84670. */
  84671. sampler?: number;
  84672. /**
  84673. * The index of the image used by this texture
  84674. */
  84675. source: number;
  84676. }
  84677. /**
  84678. * Reference to a texture
  84679. */
  84680. interface ITextureInfo extends IProperty {
  84681. /**
  84682. * The index of the texture
  84683. */
  84684. index: number;
  84685. /**
  84686. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84687. */
  84688. texCoord?: number;
  84689. }
  84690. /**
  84691. * The root object for a glTF asset
  84692. */
  84693. interface IGLTF extends IProperty {
  84694. /**
  84695. * An array of accessors. An accessor is a typed view into a bufferView
  84696. */
  84697. accessors?: IAccessor[];
  84698. /**
  84699. * An array of keyframe animations
  84700. */
  84701. animations?: IAnimation[];
  84702. /**
  84703. * Metadata about the glTF asset
  84704. */
  84705. asset: IAsset;
  84706. /**
  84707. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84708. */
  84709. buffers?: IBuffer[];
  84710. /**
  84711. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84712. */
  84713. bufferViews?: IBufferView[];
  84714. /**
  84715. * An array of cameras
  84716. */
  84717. cameras?: ICamera[];
  84718. /**
  84719. * Names of glTF extensions used somewhere in this asset
  84720. */
  84721. extensionsUsed?: string[];
  84722. /**
  84723. * Names of glTF extensions required to properly load this asset
  84724. */
  84725. extensionsRequired?: string[];
  84726. /**
  84727. * An array of images. An image defines data used to create a texture
  84728. */
  84729. images?: IImage[];
  84730. /**
  84731. * An array of materials. A material defines the appearance of a primitive
  84732. */
  84733. materials?: IMaterial[];
  84734. /**
  84735. * An array of meshes. A mesh is a set of primitives to be rendered
  84736. */
  84737. meshes?: IMesh[];
  84738. /**
  84739. * An array of nodes
  84740. */
  84741. nodes?: INode[];
  84742. /**
  84743. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84744. */
  84745. samplers?: ISampler[];
  84746. /**
  84747. * The index of the default scene
  84748. */
  84749. scene?: number;
  84750. /**
  84751. * An array of scenes
  84752. */
  84753. scenes?: IScene[];
  84754. /**
  84755. * An array of skins. A skin is defined by joints and matrices
  84756. */
  84757. skins?: ISkin[];
  84758. /**
  84759. * An array of textures
  84760. */
  84761. textures?: ITexture[];
  84762. }
  84763. /**
  84764. * The glTF validation results
  84765. * @ignore
  84766. */
  84767. interface IGLTFValidationResults {
  84768. info: {
  84769. generator: string;
  84770. hasAnimations: boolean;
  84771. hasDefaultScene: boolean;
  84772. hasMaterials: boolean;
  84773. hasMorphTargets: boolean;
  84774. hasSkins: boolean;
  84775. hasTextures: boolean;
  84776. maxAttributesUsed: number;
  84777. primitivesCount: number
  84778. };
  84779. issues: {
  84780. messages: Array<string>;
  84781. numErrors: number;
  84782. numHints: number;
  84783. numInfos: number;
  84784. numWarnings: number;
  84785. truncated: boolean
  84786. };
  84787. mimeType: string;
  84788. uri: string;
  84789. validatedAt: string;
  84790. validatorVersion: string;
  84791. }
  84792. /**
  84793. * The glTF validation options
  84794. */
  84795. interface IGLTFValidationOptions {
  84796. /** Uri to use */
  84797. uri?: string;
  84798. /** Function used to load external resources */
  84799. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84800. /** Boolean indicating that we need to validate accessor data */
  84801. validateAccessorData?: boolean;
  84802. /** max number of issues allowed */
  84803. maxIssues?: number;
  84804. /** Ignored issues */
  84805. ignoredIssues?: Array<string>;
  84806. /** Value to override severy settings */
  84807. severityOverrides?: Object;
  84808. }
  84809. /**
  84810. * The glTF validator object
  84811. * @ignore
  84812. */
  84813. interface IGLTFValidator {
  84814. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84815. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84816. }
  84817. /**
  84818. * Interfaces from the EXT_lights_image_based extension
  84819. */
  84820. /** @hidden */
  84821. interface IEXTLightsImageBased_LightReferenceImageBased {
  84822. light: number;
  84823. }
  84824. /** @hidden */
  84825. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84826. intensity: number;
  84827. rotation: number[];
  84828. specularImageSize: number;
  84829. specularImages: number[][];
  84830. irradianceCoefficients: number[][];
  84831. }
  84832. /** @hidden */
  84833. interface IEXTLightsImageBased {
  84834. lights: IEXTLightsImageBased_LightImageBased[];
  84835. }
  84836. /**
  84837. * Interfaces from the EXT_mesh_gpu_instancing extension
  84838. * !!! Experimental Extension Subject to Changes !!!
  84839. */
  84840. /** @hidden */
  84841. interface IEXTMeshGpuInstancing {
  84842. mesh?: number;
  84843. attributes: { [name: string]: number };
  84844. }
  84845. /**
  84846. * Interfaces from the KHR_draco_mesh_compression extension
  84847. */
  84848. /** @hidden */
  84849. interface IKHRDracoMeshCompression {
  84850. bufferView: number;
  84851. attributes: { [name: string]: number };
  84852. }
  84853. /**
  84854. * Interfaces from the KHR_lights_punctual extension
  84855. */
  84856. /** @hidden */
  84857. const enum IKHRLightsPunctual_LightType {
  84858. DIRECTIONAL = "directional",
  84859. POINT = "point",
  84860. SPOT = "spot"
  84861. }
  84862. /** @hidden */
  84863. interface IKHRLightsPunctual_LightReference {
  84864. light: number;
  84865. }
  84866. /** @hidden */
  84867. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84868. type: IKHRLightsPunctual_LightType;
  84869. color?: number[];
  84870. intensity?: number;
  84871. range?: number;
  84872. spot?: {
  84873. innerConeAngle?: number;
  84874. outerConeAngle?: number;
  84875. };
  84876. }
  84877. /** @hidden */
  84878. interface IKHRLightsPunctual {
  84879. lights: IKHRLightsPunctual_Light[];
  84880. }
  84881. /**
  84882. * Interfaces from the KHR_materials_clearcoat extension
  84883. * !!! Experimental Extension Subject to Changes !!!
  84884. */
  84885. /** @hidden */
  84886. interface IKHRMaterialsClearcoat {
  84887. clearcoatFactor: number;
  84888. clearcoatTexture: ITextureInfo;
  84889. clearcoatRoughnessFactor: number;
  84890. clearcoatRoughnessTexture: ITextureInfo;
  84891. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84892. }
  84893. /**
  84894. * Interfaces from the KHR_materials_ior extension
  84895. * !!! Experimental Extension Subject to Changes !!!
  84896. */
  84897. /** @hidden */
  84898. interface IKHRMaterialsIor {
  84899. ior: number;
  84900. }
  84901. /**
  84902. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84903. */
  84904. /** @hidden */
  84905. interface IKHRMaterialsPbrSpecularGlossiness {
  84906. diffuseFactor: number[];
  84907. diffuseTexture: ITextureInfo;
  84908. specularFactor: number[];
  84909. glossinessFactor: number;
  84910. specularGlossinessTexture: ITextureInfo;
  84911. }
  84912. /**
  84913. * Interfaces from the KHR_materials_sheen extension
  84914. * !!! Experimental Extension Subject to Changes !!!
  84915. */
  84916. /** @hidden */
  84917. interface IKHRMaterialsSheen {
  84918. sheenColorFactor?: number[];
  84919. sheenTexture?: ITextureInfo;
  84920. sheenRoughnessFactor?: number;
  84921. }
  84922. /**
  84923. * Interfaces from the KHR_materials_specular extension
  84924. * !!! Experimental Extension Subject to Changes !!!
  84925. */
  84926. /** @hidden */
  84927. interface IKHRMaterialsSpecular {
  84928. specularFactor: number;
  84929. specularColorFactor: number[];
  84930. specularTexture: ITextureInfo;
  84931. }
  84932. /**
  84933. * Interfaces from the KHR_materials_transmission extension
  84934. * !!! Experimental Extension Subject to Changes !!!
  84935. */
  84936. /** @hidden */
  84937. interface IKHRMaterialsTransmission {
  84938. transmissionFactor?: number;
  84939. transmissionTexture?: ITextureInfo;
  84940. }
  84941. /**
  84942. * Interfaces from the KHR_materials_variants extension
  84943. * !!! Experimental Extension Subject to Changes !!!
  84944. */
  84945. /** @hidden */
  84946. interface IKHRMaterialVariants_Mapping extends IProperty {
  84947. mapping: Array<{
  84948. variants: number[];
  84949. material: number;
  84950. }>;
  84951. }
  84952. /** @hidden */
  84953. interface IKHRMaterialVariants_Variant extends IProperty {
  84954. name: string;
  84955. }
  84956. /** @hidden */
  84957. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  84958. variants: Array<IKHRMaterialVariants_Variant>;
  84959. }
  84960. /**
  84961. * Interfaces from the KHR_texture_basisu extension
  84962. * !!! Experimental Extension Subject to Changes !!!
  84963. */
  84964. /** @hidden */
  84965. interface IKHRTextureBasisU {
  84966. source: number;
  84967. }
  84968. /**
  84969. * Interfaces from the EXT_texture_webp extension
  84970. */
  84971. /** @hidden */
  84972. interface IEXTTextureWebP {
  84973. source: number;
  84974. }
  84975. /**
  84976. * Interfaces from the KHR_texture_transform extension
  84977. */
  84978. /** @hidden */
  84979. interface IKHRTextureTransform {
  84980. offset?: number[];
  84981. rotation?: number;
  84982. scale?: number[];
  84983. texCoord?: number;
  84984. }
  84985. /**
  84986. * Interfaces from the KHR_xmp extension
  84987. * !!! Experimental Extension Subject to Changes !!!
  84988. */
  84989. /** @hidden */
  84990. interface IKHRXmp_Data {
  84991. [key: string]: unknown;
  84992. }
  84993. /** @hidden */
  84994. interface IKHRXmp_Gltf {
  84995. packets: IKHRXmp_Data[];
  84996. }
  84997. /** @hidden */
  84998. interface IKHRXmp_Node {
  84999. packet: number;
  85000. }
  85001. /**
  85002. * Interfaces from the MSFT_audio_emitter extension
  85003. */
  85004. /** @hidden */
  85005. interface IMSFTAudioEmitter_ClipReference {
  85006. clip: number;
  85007. weight?: number;
  85008. }
  85009. /** @hidden */
  85010. interface IMSFTAudioEmitter_EmittersReference {
  85011. emitters: number[];
  85012. }
  85013. /** @hidden */
  85014. const enum IMSFTAudioEmitter_DistanceModel {
  85015. linear = "linear",
  85016. inverse = "inverse",
  85017. exponential = "exponential",
  85018. }
  85019. /** @hidden */
  85020. interface IMSFTAudioEmitter_Emitter {
  85021. name?: string;
  85022. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85023. refDistance?: number;
  85024. maxDistance?: number;
  85025. rolloffFactor?: number;
  85026. innerAngle?: number;
  85027. outerAngle?: number;
  85028. loop?: boolean;
  85029. volume?: number;
  85030. clips: IMSFTAudioEmitter_ClipReference[];
  85031. }
  85032. /** @hidden */
  85033. const enum IMSFTAudioEmitter_AudioMimeType {
  85034. WAV = "audio/wav",
  85035. }
  85036. /** @hidden */
  85037. interface IMSFTAudioEmitter_Clip extends IProperty {
  85038. uri?: string;
  85039. bufferView?: number;
  85040. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85041. }
  85042. /** @hidden */
  85043. const enum IMSFTAudioEmitter_AnimationEventAction {
  85044. play = "play",
  85045. pause = "pause",
  85046. stop = "stop",
  85047. }
  85048. /** @hidden */
  85049. interface IMSFTAudioEmitter_AnimationEvent {
  85050. action: IMSFTAudioEmitter_AnimationEventAction;
  85051. emitter: number;
  85052. time: number;
  85053. startOffset?: number;
  85054. }
  85055. /**
  85056. * Interfaces from the MSFT_lod extension
  85057. */
  85058. /** @hidden */
  85059. interface IMSFTLOD {
  85060. ids: number[];
  85061. }
  85062. }
  85063. declare module BABYLON {
  85064. /** @hidden */
  85065. export var cellPixelShader: {
  85066. name: string;
  85067. shader: string;
  85068. };
  85069. }
  85070. declare module BABYLON {
  85071. /** @hidden */
  85072. export var cellVertexShader: {
  85073. name: string;
  85074. shader: string;
  85075. };
  85076. }
  85077. declare module BABYLON {
  85078. export class CellMaterial extends BABYLON.PushMaterial {
  85079. private _diffuseTexture;
  85080. diffuseTexture: BABYLON.BaseTexture;
  85081. diffuseColor: BABYLON.Color3;
  85082. _computeHighLevel: boolean;
  85083. computeHighLevel: boolean;
  85084. private _disableLighting;
  85085. disableLighting: boolean;
  85086. private _maxSimultaneousLights;
  85087. maxSimultaneousLights: number;
  85088. constructor(name: string, scene: BABYLON.Scene);
  85089. needAlphaBlending(): boolean;
  85090. needAlphaTesting(): boolean;
  85091. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85092. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85093. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85094. getAnimatables(): BABYLON.IAnimatable[];
  85095. getActiveTextures(): BABYLON.BaseTexture[];
  85096. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85097. dispose(forceDisposeEffect?: boolean): void;
  85098. getClassName(): string;
  85099. clone(name: string): CellMaterial;
  85100. serialize(): any;
  85101. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85102. }
  85103. }
  85104. declare module BABYLON {
  85105. export class CustomShaderStructure {
  85106. FragmentStore: string;
  85107. VertexStore: string;
  85108. constructor();
  85109. }
  85110. export class ShaderSpecialParts {
  85111. constructor();
  85112. Fragment_Begin: string;
  85113. Fragment_Definitions: string;
  85114. Fragment_MainBegin: string;
  85115. Fragment_Custom_Diffuse: string;
  85116. Fragment_Before_Lights: string;
  85117. Fragment_Before_Fog: string;
  85118. Fragment_Custom_Alpha: string;
  85119. Fragment_Before_FragColor: string;
  85120. Vertex_Begin: string;
  85121. Vertex_Definitions: string;
  85122. Vertex_MainBegin: string;
  85123. Vertex_Before_PositionUpdated: string;
  85124. Vertex_Before_NormalUpdated: string;
  85125. Vertex_After_WorldPosComputed: string;
  85126. Vertex_MainEnd: string;
  85127. }
  85128. export class CustomMaterial extends BABYLON.StandardMaterial {
  85129. static ShaderIndexer: number;
  85130. CustomParts: ShaderSpecialParts;
  85131. _isCreatedShader: boolean;
  85132. _createdShaderName: string;
  85133. _customUniform: string[];
  85134. _newUniforms: string[];
  85135. _newUniformInstances: {
  85136. [name: string]: any;
  85137. };
  85138. _newSamplerInstances: {
  85139. [name: string]: BABYLON.Texture;
  85140. };
  85141. _customAttributes: string[];
  85142. FragmentShader: string;
  85143. VertexShader: string;
  85144. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85145. ReviewUniform(name: string, arr: string[]): string[];
  85146. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85147. constructor(name: string, scene: BABYLON.Scene);
  85148. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85149. AddAttribute(name: string): CustomMaterial;
  85150. Fragment_Begin(shaderPart: string): CustomMaterial;
  85151. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85152. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85153. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85154. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85155. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85156. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85157. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85158. Vertex_Begin(shaderPart: string): CustomMaterial;
  85159. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85160. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85161. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85162. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85163. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85164. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85165. }
  85166. }
  85167. declare module BABYLON {
  85168. export class ShaderAlebdoParts {
  85169. constructor();
  85170. Fragment_Begin: string;
  85171. Fragment_Definitions: string;
  85172. Fragment_MainBegin: string;
  85173. Fragment_Custom_Albedo: string;
  85174. Fragment_Before_Lights: string;
  85175. Fragment_Custom_MetallicRoughness: string;
  85176. Fragment_Custom_MicroSurface: string;
  85177. Fragment_Before_Fog: string;
  85178. Fragment_Custom_Alpha: string;
  85179. Fragment_Before_FragColor: string;
  85180. Vertex_Begin: string;
  85181. Vertex_Definitions: string;
  85182. Vertex_MainBegin: string;
  85183. Vertex_Before_PositionUpdated: string;
  85184. Vertex_Before_NormalUpdated: string;
  85185. Vertex_After_WorldPosComputed: string;
  85186. Vertex_MainEnd: string;
  85187. }
  85188. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85189. static ShaderIndexer: number;
  85190. CustomParts: ShaderAlebdoParts;
  85191. _isCreatedShader: boolean;
  85192. _createdShaderName: string;
  85193. _customUniform: string[];
  85194. _newUniforms: string[];
  85195. _newUniformInstances: {
  85196. [name: string]: any;
  85197. };
  85198. _newSamplerInstances: {
  85199. [name: string]: BABYLON.Texture;
  85200. };
  85201. _customAttributes: string[];
  85202. FragmentShader: string;
  85203. VertexShader: string;
  85204. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85205. ReviewUniform(name: string, arr: string[]): string[];
  85206. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85207. constructor(name: string, scene: BABYLON.Scene);
  85208. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85209. AddAttribute(name: string): PBRCustomMaterial;
  85210. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85211. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85212. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85213. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85214. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85215. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85216. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85217. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85218. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85219. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85220. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85221. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85222. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85223. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85224. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85225. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85226. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85227. }
  85228. }
  85229. declare module BABYLON {
  85230. /** @hidden */
  85231. export var firePixelShader: {
  85232. name: string;
  85233. shader: string;
  85234. };
  85235. }
  85236. declare module BABYLON {
  85237. /** @hidden */
  85238. export var fireVertexShader: {
  85239. name: string;
  85240. shader: string;
  85241. };
  85242. }
  85243. declare module BABYLON {
  85244. export class FireMaterial extends BABYLON.PushMaterial {
  85245. private _diffuseTexture;
  85246. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85247. private _distortionTexture;
  85248. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85249. private _opacityTexture;
  85250. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85251. diffuseColor: BABYLON.Color3;
  85252. speed: number;
  85253. private _scaledDiffuse;
  85254. private _lastTime;
  85255. constructor(name: string, scene: BABYLON.Scene);
  85256. needAlphaBlending(): boolean;
  85257. needAlphaTesting(): boolean;
  85258. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85259. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85260. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85261. getAnimatables(): BABYLON.IAnimatable[];
  85262. getActiveTextures(): BABYLON.BaseTexture[];
  85263. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85264. getClassName(): string;
  85265. dispose(forceDisposeEffect?: boolean): void;
  85266. clone(name: string): FireMaterial;
  85267. serialize(): any;
  85268. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85269. }
  85270. }
  85271. declare module BABYLON {
  85272. /** @hidden */
  85273. export var furPixelShader: {
  85274. name: string;
  85275. shader: string;
  85276. };
  85277. }
  85278. declare module BABYLON {
  85279. /** @hidden */
  85280. export var furVertexShader: {
  85281. name: string;
  85282. shader: string;
  85283. };
  85284. }
  85285. declare module BABYLON {
  85286. export class FurMaterial extends BABYLON.PushMaterial {
  85287. private _diffuseTexture;
  85288. diffuseTexture: BABYLON.BaseTexture;
  85289. private _heightTexture;
  85290. heightTexture: BABYLON.BaseTexture;
  85291. diffuseColor: BABYLON.Color3;
  85292. furLength: number;
  85293. furAngle: number;
  85294. furColor: BABYLON.Color3;
  85295. furOffset: number;
  85296. furSpacing: number;
  85297. furGravity: BABYLON.Vector3;
  85298. furSpeed: number;
  85299. furDensity: number;
  85300. furOcclusion: number;
  85301. furTexture: BABYLON.DynamicTexture;
  85302. private _disableLighting;
  85303. disableLighting: boolean;
  85304. private _maxSimultaneousLights;
  85305. maxSimultaneousLights: number;
  85306. highLevelFur: boolean;
  85307. _meshes: BABYLON.AbstractMesh[];
  85308. private _furTime;
  85309. constructor(name: string, scene: BABYLON.Scene);
  85310. get furTime(): number;
  85311. set furTime(furTime: number);
  85312. needAlphaBlending(): boolean;
  85313. needAlphaTesting(): boolean;
  85314. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85315. updateFur(): void;
  85316. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85317. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85318. getAnimatables(): BABYLON.IAnimatable[];
  85319. getActiveTextures(): BABYLON.BaseTexture[];
  85320. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85321. dispose(forceDisposeEffect?: boolean): void;
  85322. clone(name: string): FurMaterial;
  85323. serialize(): any;
  85324. getClassName(): string;
  85325. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85326. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85327. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85328. }
  85329. }
  85330. declare module BABYLON {
  85331. /** @hidden */
  85332. export var gradientPixelShader: {
  85333. name: string;
  85334. shader: string;
  85335. };
  85336. }
  85337. declare module BABYLON {
  85338. /** @hidden */
  85339. export var gradientVertexShader: {
  85340. name: string;
  85341. shader: string;
  85342. };
  85343. }
  85344. declare module BABYLON {
  85345. export class GradientMaterial extends BABYLON.PushMaterial {
  85346. private _maxSimultaneousLights;
  85347. maxSimultaneousLights: number;
  85348. topColor: BABYLON.Color3;
  85349. topColorAlpha: number;
  85350. bottomColor: BABYLON.Color3;
  85351. bottomColorAlpha: number;
  85352. offset: number;
  85353. scale: number;
  85354. smoothness: number;
  85355. private _disableLighting;
  85356. disableLighting: boolean;
  85357. constructor(name: string, scene: BABYLON.Scene);
  85358. needAlphaBlending(): boolean;
  85359. needAlphaTesting(): boolean;
  85360. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85361. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85362. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85363. getAnimatables(): BABYLON.IAnimatable[];
  85364. dispose(forceDisposeEffect?: boolean): void;
  85365. clone(name: string): GradientMaterial;
  85366. serialize(): any;
  85367. getClassName(): string;
  85368. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85369. }
  85370. }
  85371. declare module BABYLON {
  85372. /** @hidden */
  85373. export var gridPixelShader: {
  85374. name: string;
  85375. shader: string;
  85376. };
  85377. }
  85378. declare module BABYLON {
  85379. /** @hidden */
  85380. export var gridVertexShader: {
  85381. name: string;
  85382. shader: string;
  85383. };
  85384. }
  85385. declare module BABYLON {
  85386. /**
  85387. * The grid materials allows you to wrap any shape with a grid.
  85388. * Colors are customizable.
  85389. */
  85390. export class GridMaterial extends BABYLON.PushMaterial {
  85391. /**
  85392. * Main color of the grid (e.g. between lines)
  85393. */
  85394. mainColor: BABYLON.Color3;
  85395. /**
  85396. * Color of the grid lines.
  85397. */
  85398. lineColor: BABYLON.Color3;
  85399. /**
  85400. * The scale of the grid compared to unit.
  85401. */
  85402. gridRatio: number;
  85403. /**
  85404. * Allows setting an offset for the grid lines.
  85405. */
  85406. gridOffset: BABYLON.Vector3;
  85407. /**
  85408. * The frequency of thicker lines.
  85409. */
  85410. majorUnitFrequency: number;
  85411. /**
  85412. * The visibility of minor units in the grid.
  85413. */
  85414. minorUnitVisibility: number;
  85415. /**
  85416. * The grid opacity outside of the lines.
  85417. */
  85418. opacity: number;
  85419. /**
  85420. * Determine RBG output is premultiplied by alpha value.
  85421. */
  85422. preMultiplyAlpha: boolean;
  85423. private _opacityTexture;
  85424. opacityTexture: BABYLON.BaseTexture;
  85425. private _gridControl;
  85426. /**
  85427. * constructor
  85428. * @param name The name given to the material in order to identify it afterwards.
  85429. * @param scene The scene the material is used in.
  85430. */
  85431. constructor(name: string, scene: BABYLON.Scene);
  85432. /**
  85433. * Returns wehter or not the grid requires alpha blending.
  85434. */
  85435. needAlphaBlending(): boolean;
  85436. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85437. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85438. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85439. /**
  85440. * Dispose the material and its associated resources.
  85441. * @param forceDisposeEffect will also dispose the used effect when true
  85442. */
  85443. dispose(forceDisposeEffect?: boolean): void;
  85444. clone(name: string): GridMaterial;
  85445. serialize(): any;
  85446. getClassName(): string;
  85447. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85448. }
  85449. }
  85450. declare module BABYLON {
  85451. /** @hidden */
  85452. export var lavaPixelShader: {
  85453. name: string;
  85454. shader: string;
  85455. };
  85456. }
  85457. declare module BABYLON {
  85458. /** @hidden */
  85459. export var lavaVertexShader: {
  85460. name: string;
  85461. shader: string;
  85462. };
  85463. }
  85464. declare module BABYLON {
  85465. export class LavaMaterial extends BABYLON.PushMaterial {
  85466. private _diffuseTexture;
  85467. diffuseTexture: BABYLON.BaseTexture;
  85468. noiseTexture: BABYLON.BaseTexture;
  85469. fogColor: BABYLON.Color3;
  85470. speed: number;
  85471. movingSpeed: number;
  85472. lowFrequencySpeed: number;
  85473. fogDensity: number;
  85474. private _lastTime;
  85475. diffuseColor: BABYLON.Color3;
  85476. private _disableLighting;
  85477. disableLighting: boolean;
  85478. private _unlit;
  85479. unlit: boolean;
  85480. private _maxSimultaneousLights;
  85481. maxSimultaneousLights: number;
  85482. private _scaledDiffuse;
  85483. constructor(name: string, scene: BABYLON.Scene);
  85484. needAlphaBlending(): boolean;
  85485. needAlphaTesting(): boolean;
  85486. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85487. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85488. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85489. getAnimatables(): BABYLON.IAnimatable[];
  85490. getActiveTextures(): BABYLON.BaseTexture[];
  85491. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85492. dispose(forceDisposeEffect?: boolean): void;
  85493. clone(name: string): LavaMaterial;
  85494. serialize(): any;
  85495. getClassName(): string;
  85496. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85497. }
  85498. }
  85499. declare module BABYLON {
  85500. /** @hidden */
  85501. export var mixPixelShader: {
  85502. name: string;
  85503. shader: string;
  85504. };
  85505. }
  85506. declare module BABYLON {
  85507. /** @hidden */
  85508. export var mixVertexShader: {
  85509. name: string;
  85510. shader: string;
  85511. };
  85512. }
  85513. declare module BABYLON {
  85514. export class MixMaterial extends BABYLON.PushMaterial {
  85515. /**
  85516. * Mix textures
  85517. */
  85518. private _mixTexture1;
  85519. mixTexture1: BABYLON.BaseTexture;
  85520. private _mixTexture2;
  85521. mixTexture2: BABYLON.BaseTexture;
  85522. /**
  85523. * Diffuse textures
  85524. */
  85525. private _diffuseTexture1;
  85526. diffuseTexture1: BABYLON.Texture;
  85527. private _diffuseTexture2;
  85528. diffuseTexture2: BABYLON.Texture;
  85529. private _diffuseTexture3;
  85530. diffuseTexture3: BABYLON.Texture;
  85531. private _diffuseTexture4;
  85532. diffuseTexture4: BABYLON.Texture;
  85533. private _diffuseTexture5;
  85534. diffuseTexture5: BABYLON.Texture;
  85535. private _diffuseTexture6;
  85536. diffuseTexture6: BABYLON.Texture;
  85537. private _diffuseTexture7;
  85538. diffuseTexture7: BABYLON.Texture;
  85539. private _diffuseTexture8;
  85540. diffuseTexture8: BABYLON.Texture;
  85541. /**
  85542. * Uniforms
  85543. */
  85544. diffuseColor: BABYLON.Color3;
  85545. specularColor: BABYLON.Color3;
  85546. specularPower: number;
  85547. private _disableLighting;
  85548. disableLighting: boolean;
  85549. private _maxSimultaneousLights;
  85550. maxSimultaneousLights: number;
  85551. constructor(name: string, scene: BABYLON.Scene);
  85552. needAlphaBlending(): boolean;
  85553. needAlphaTesting(): boolean;
  85554. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85555. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85556. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85557. getAnimatables(): BABYLON.IAnimatable[];
  85558. getActiveTextures(): BABYLON.BaseTexture[];
  85559. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85560. dispose(forceDisposeEffect?: boolean): void;
  85561. clone(name: string): MixMaterial;
  85562. serialize(): any;
  85563. getClassName(): string;
  85564. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85565. }
  85566. }
  85567. declare module BABYLON {
  85568. /** @hidden */
  85569. export var normalPixelShader: {
  85570. name: string;
  85571. shader: string;
  85572. };
  85573. }
  85574. declare module BABYLON {
  85575. /** @hidden */
  85576. export var normalVertexShader: {
  85577. name: string;
  85578. shader: string;
  85579. };
  85580. }
  85581. declare module BABYLON {
  85582. export class NormalMaterial extends BABYLON.PushMaterial {
  85583. private _diffuseTexture;
  85584. diffuseTexture: BABYLON.BaseTexture;
  85585. diffuseColor: BABYLON.Color3;
  85586. private _disableLighting;
  85587. disableLighting: boolean;
  85588. private _maxSimultaneousLights;
  85589. maxSimultaneousLights: number;
  85590. constructor(name: string, scene: BABYLON.Scene);
  85591. needAlphaBlending(): boolean;
  85592. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85593. needAlphaTesting(): boolean;
  85594. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85595. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85596. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85597. getAnimatables(): BABYLON.IAnimatable[];
  85598. getActiveTextures(): BABYLON.BaseTexture[];
  85599. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85600. dispose(forceDisposeEffect?: boolean): void;
  85601. clone(name: string): NormalMaterial;
  85602. serialize(): any;
  85603. getClassName(): string;
  85604. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85605. }
  85606. }
  85607. declare module BABYLON {
  85608. /** @hidden */
  85609. export var shadowOnlyPixelShader: {
  85610. name: string;
  85611. shader: string;
  85612. };
  85613. }
  85614. declare module BABYLON {
  85615. /** @hidden */
  85616. export var shadowOnlyVertexShader: {
  85617. name: string;
  85618. shader: string;
  85619. };
  85620. }
  85621. declare module BABYLON {
  85622. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85623. private _activeLight;
  85624. private _needAlphaBlending;
  85625. constructor(name: string, scene: BABYLON.Scene);
  85626. shadowColor: BABYLON.Color3;
  85627. needAlphaBlending(): boolean;
  85628. needAlphaTesting(): boolean;
  85629. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85630. get activeLight(): BABYLON.IShadowLight;
  85631. set activeLight(light: BABYLON.IShadowLight);
  85632. private _getFirstShadowLightForMesh;
  85633. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85634. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85635. clone(name: string): ShadowOnlyMaterial;
  85636. serialize(): any;
  85637. getClassName(): string;
  85638. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85639. }
  85640. }
  85641. declare module BABYLON {
  85642. /** @hidden */
  85643. export var simplePixelShader: {
  85644. name: string;
  85645. shader: string;
  85646. };
  85647. }
  85648. declare module BABYLON {
  85649. /** @hidden */
  85650. export var simpleVertexShader: {
  85651. name: string;
  85652. shader: string;
  85653. };
  85654. }
  85655. declare module BABYLON {
  85656. export class SimpleMaterial extends BABYLON.PushMaterial {
  85657. private _diffuseTexture;
  85658. diffuseTexture: BABYLON.BaseTexture;
  85659. diffuseColor: BABYLON.Color3;
  85660. private _disableLighting;
  85661. disableLighting: boolean;
  85662. private _maxSimultaneousLights;
  85663. maxSimultaneousLights: number;
  85664. constructor(name: string, scene: BABYLON.Scene);
  85665. needAlphaBlending(): boolean;
  85666. needAlphaTesting(): boolean;
  85667. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85668. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85669. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85670. getAnimatables(): BABYLON.IAnimatable[];
  85671. getActiveTextures(): BABYLON.BaseTexture[];
  85672. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85673. dispose(forceDisposeEffect?: boolean): void;
  85674. clone(name: string): SimpleMaterial;
  85675. serialize(): any;
  85676. getClassName(): string;
  85677. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85678. }
  85679. }
  85680. declare module BABYLON {
  85681. /** @hidden */
  85682. export var skyPixelShader: {
  85683. name: string;
  85684. shader: string;
  85685. };
  85686. }
  85687. declare module BABYLON {
  85688. /** @hidden */
  85689. export var skyVertexShader: {
  85690. name: string;
  85691. shader: string;
  85692. };
  85693. }
  85694. declare module BABYLON {
  85695. /**
  85696. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85697. * @see https://doc.babylonjs.com/extensions/sky
  85698. */
  85699. export class SkyMaterial extends BABYLON.PushMaterial {
  85700. /**
  85701. * Defines the overall luminance of sky in interval ]0, 1[.
  85702. */
  85703. luminance: number;
  85704. /**
  85705. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85706. */
  85707. turbidity: number;
  85708. /**
  85709. * Defines the sky appearance (light intensity).
  85710. */
  85711. rayleigh: number;
  85712. /**
  85713. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85714. */
  85715. mieCoefficient: number;
  85716. /**
  85717. * Defines the amount of haze particles following the Mie scattering theory.
  85718. */
  85719. mieDirectionalG: number;
  85720. /**
  85721. * Defines the distance of the sun according to the active scene camera.
  85722. */
  85723. distance: number;
  85724. /**
  85725. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85726. * "inclined".
  85727. */
  85728. inclination: number;
  85729. /**
  85730. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85731. * an object direction and a reference direction.
  85732. */
  85733. azimuth: number;
  85734. /**
  85735. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85736. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85737. */
  85738. sunPosition: BABYLON.Vector3;
  85739. /**
  85740. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85741. * .sunPosition property.
  85742. */
  85743. useSunPosition: boolean;
  85744. /**
  85745. * Defines an offset vector used to get a horizon offset.
  85746. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85747. */
  85748. cameraOffset: BABYLON.Vector3;
  85749. private _cameraPosition;
  85750. /**
  85751. * Instantiates a new sky material.
  85752. * This material allows to create dynamic and texture free
  85753. * effects for skyboxes by taking care of the atmosphere state.
  85754. * @see https://doc.babylonjs.com/extensions/sky
  85755. * @param name Define the name of the material in the scene
  85756. * @param scene Define the scene the material belong to
  85757. */
  85758. constructor(name: string, scene: BABYLON.Scene);
  85759. /**
  85760. * Specifies if the material will require alpha blending
  85761. * @returns a boolean specifying if alpha blending is needed
  85762. */
  85763. needAlphaBlending(): boolean;
  85764. /**
  85765. * Specifies if this material should be rendered in alpha test mode
  85766. * @returns false as the sky material doesn't need alpha testing.
  85767. */
  85768. needAlphaTesting(): boolean;
  85769. /**
  85770. * Get the texture used for alpha test purpose.
  85771. * @returns null as the sky material has no texture.
  85772. */
  85773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85774. /**
  85775. * Get if the submesh is ready to be used and all its information available.
  85776. * Child classes can use it to update shaders
  85777. * @param mesh defines the mesh to check
  85778. * @param subMesh defines which submesh to check
  85779. * @param useInstances specifies that instances should be used
  85780. * @returns a boolean indicating that the submesh is ready or not
  85781. */
  85782. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85783. /**
  85784. * Binds the submesh to this material by preparing the effect and shader to draw
  85785. * @param world defines the world transformation matrix
  85786. * @param mesh defines the mesh containing the submesh
  85787. * @param subMesh defines the submesh to bind the material to
  85788. */
  85789. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85790. /**
  85791. * Get the list of animatables in the material.
  85792. * @returns the list of animatables object used in the material
  85793. */
  85794. getAnimatables(): BABYLON.IAnimatable[];
  85795. /**
  85796. * Disposes the material
  85797. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85798. */
  85799. dispose(forceDisposeEffect?: boolean): void;
  85800. /**
  85801. * Makes a duplicate of the material, and gives it a new name
  85802. * @param name defines the new name for the duplicated material
  85803. * @returns the cloned material
  85804. */
  85805. clone(name: string): SkyMaterial;
  85806. /**
  85807. * Serializes this material in a JSON representation
  85808. * @returns the serialized material object
  85809. */
  85810. serialize(): any;
  85811. /**
  85812. * Gets the current class name of the material e.g. "SkyMaterial"
  85813. * Mainly use in serialization.
  85814. * @returns the class name
  85815. */
  85816. getClassName(): string;
  85817. /**
  85818. * Creates a sky material from parsed material data
  85819. * @param source defines the JSON representation of the material
  85820. * @param scene defines the hosting scene
  85821. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85822. * @returns a new sky material
  85823. */
  85824. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85825. }
  85826. }
  85827. declare module BABYLON {
  85828. /** @hidden */
  85829. export var terrainPixelShader: {
  85830. name: string;
  85831. shader: string;
  85832. };
  85833. }
  85834. declare module BABYLON {
  85835. /** @hidden */
  85836. export var terrainVertexShader: {
  85837. name: string;
  85838. shader: string;
  85839. };
  85840. }
  85841. declare module BABYLON {
  85842. export class TerrainMaterial extends BABYLON.PushMaterial {
  85843. private _mixTexture;
  85844. mixTexture: BABYLON.BaseTexture;
  85845. private _diffuseTexture1;
  85846. diffuseTexture1: BABYLON.Texture;
  85847. private _diffuseTexture2;
  85848. diffuseTexture2: BABYLON.Texture;
  85849. private _diffuseTexture3;
  85850. diffuseTexture3: BABYLON.Texture;
  85851. private _bumpTexture1;
  85852. bumpTexture1: BABYLON.Texture;
  85853. private _bumpTexture2;
  85854. bumpTexture2: BABYLON.Texture;
  85855. private _bumpTexture3;
  85856. bumpTexture3: BABYLON.Texture;
  85857. diffuseColor: BABYLON.Color3;
  85858. specularColor: BABYLON.Color3;
  85859. specularPower: number;
  85860. private _disableLighting;
  85861. disableLighting: boolean;
  85862. private _maxSimultaneousLights;
  85863. maxSimultaneousLights: number;
  85864. constructor(name: string, scene: BABYLON.Scene);
  85865. needAlphaBlending(): boolean;
  85866. needAlphaTesting(): boolean;
  85867. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85868. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85869. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85870. getAnimatables(): BABYLON.IAnimatable[];
  85871. getActiveTextures(): BABYLON.BaseTexture[];
  85872. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85873. dispose(forceDisposeEffect?: boolean): void;
  85874. clone(name: string): TerrainMaterial;
  85875. serialize(): any;
  85876. getClassName(): string;
  85877. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85878. }
  85879. }
  85880. declare module BABYLON {
  85881. /** @hidden */
  85882. export var triplanarPixelShader: {
  85883. name: string;
  85884. shader: string;
  85885. };
  85886. }
  85887. declare module BABYLON {
  85888. /** @hidden */
  85889. export var triplanarVertexShader: {
  85890. name: string;
  85891. shader: string;
  85892. };
  85893. }
  85894. declare module BABYLON {
  85895. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85896. mixTexture: BABYLON.BaseTexture;
  85897. private _diffuseTextureX;
  85898. diffuseTextureX: BABYLON.BaseTexture;
  85899. private _diffuseTextureY;
  85900. diffuseTextureY: BABYLON.BaseTexture;
  85901. private _diffuseTextureZ;
  85902. diffuseTextureZ: BABYLON.BaseTexture;
  85903. private _normalTextureX;
  85904. normalTextureX: BABYLON.BaseTexture;
  85905. private _normalTextureY;
  85906. normalTextureY: BABYLON.BaseTexture;
  85907. private _normalTextureZ;
  85908. normalTextureZ: BABYLON.BaseTexture;
  85909. tileSize: number;
  85910. diffuseColor: BABYLON.Color3;
  85911. specularColor: BABYLON.Color3;
  85912. specularPower: number;
  85913. private _disableLighting;
  85914. disableLighting: boolean;
  85915. private _maxSimultaneousLights;
  85916. maxSimultaneousLights: number;
  85917. constructor(name: string, scene: BABYLON.Scene);
  85918. needAlphaBlending(): boolean;
  85919. needAlphaTesting(): boolean;
  85920. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85921. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85922. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85923. getAnimatables(): BABYLON.IAnimatable[];
  85924. getActiveTextures(): BABYLON.BaseTexture[];
  85925. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85926. dispose(forceDisposeEffect?: boolean): void;
  85927. clone(name: string): TriPlanarMaterial;
  85928. serialize(): any;
  85929. getClassName(): string;
  85930. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85931. }
  85932. }
  85933. declare module BABYLON {
  85934. /** @hidden */
  85935. export var waterPixelShader: {
  85936. name: string;
  85937. shader: string;
  85938. };
  85939. }
  85940. declare module BABYLON {
  85941. /** @hidden */
  85942. export var waterVertexShader: {
  85943. name: string;
  85944. shader: string;
  85945. };
  85946. }
  85947. declare module BABYLON {
  85948. export class WaterMaterial extends BABYLON.PushMaterial {
  85949. renderTargetSize: BABYLON.Vector2;
  85950. private _bumpTexture;
  85951. bumpTexture: BABYLON.BaseTexture;
  85952. diffuseColor: BABYLON.Color3;
  85953. specularColor: BABYLON.Color3;
  85954. specularPower: number;
  85955. private _disableLighting;
  85956. disableLighting: boolean;
  85957. private _maxSimultaneousLights;
  85958. maxSimultaneousLights: number;
  85959. /**
  85960. * @param {number}: Represents the wind force
  85961. */
  85962. windForce: number;
  85963. /**
  85964. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85965. */
  85966. windDirection: BABYLON.Vector2;
  85967. /**
  85968. * @param {number}: Wave height, represents the height of the waves
  85969. */
  85970. waveHeight: number;
  85971. /**
  85972. * @param {number}: Bump height, represents the bump height related to the bump map
  85973. */
  85974. bumpHeight: number;
  85975. /**
  85976. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85977. */
  85978. private _bumpSuperimpose;
  85979. bumpSuperimpose: boolean;
  85980. /**
  85981. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85982. */
  85983. private _fresnelSeparate;
  85984. fresnelSeparate: boolean;
  85985. /**
  85986. * @param {boolean}: bump Waves modify the reflection.
  85987. */
  85988. private _bumpAffectsReflection;
  85989. bumpAffectsReflection: boolean;
  85990. /**
  85991. * @param {number}: The water color blended with the refraction (near)
  85992. */
  85993. waterColor: BABYLON.Color3;
  85994. /**
  85995. * @param {number}: The blend factor related to the water color
  85996. */
  85997. colorBlendFactor: number;
  85998. /**
  85999. * @param {number}: The water color blended with the reflection (far)
  86000. */
  86001. waterColor2: BABYLON.Color3;
  86002. /**
  86003. * @param {number}: The blend factor related to the water color (reflection, far)
  86004. */
  86005. colorBlendFactor2: number;
  86006. /**
  86007. * @param {number}: Represents the maximum length of a wave
  86008. */
  86009. waveLength: number;
  86010. /**
  86011. * @param {number}: Defines the waves speed
  86012. */
  86013. waveSpeed: number;
  86014. /**
  86015. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86016. * will avoid calculating useless pixels in the pixel shader of the water material.
  86017. */
  86018. disableClipPlane: boolean;
  86019. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86020. private _mesh;
  86021. private _refractionRTT;
  86022. private _reflectionRTT;
  86023. private _reflectionTransform;
  86024. private _lastTime;
  86025. private _lastDeltaTime;
  86026. private _useLogarithmicDepth;
  86027. private _waitingRenderList;
  86028. private _imageProcessingConfiguration;
  86029. private _imageProcessingObserver;
  86030. /**
  86031. * Gets a boolean indicating that current material needs to register RTT
  86032. */
  86033. get hasRenderTargetTextures(): boolean;
  86034. /**
  86035. * Constructor
  86036. */
  86037. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86038. get useLogarithmicDepth(): boolean;
  86039. set useLogarithmicDepth(value: boolean);
  86040. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86041. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86042. addToRenderList(node: any): void;
  86043. enableRenderTargets(enable: boolean): void;
  86044. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86045. get renderTargetsEnabled(): boolean;
  86046. needAlphaBlending(): boolean;
  86047. needAlphaTesting(): boolean;
  86048. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86049. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86050. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86051. private _createRenderTargets;
  86052. getAnimatables(): BABYLON.IAnimatable[];
  86053. getActiveTextures(): BABYLON.BaseTexture[];
  86054. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86055. dispose(forceDisposeEffect?: boolean): void;
  86056. clone(name: string): WaterMaterial;
  86057. serialize(): any;
  86058. getClassName(): string;
  86059. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86060. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86061. }
  86062. }
  86063. declare module BABYLON {
  86064. /** @hidden */
  86065. export var asciiartPixelShader: {
  86066. name: string;
  86067. shader: string;
  86068. };
  86069. }
  86070. declare module BABYLON {
  86071. /**
  86072. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86073. *
  86074. * It basically takes care rendering the font front the given font size to a texture.
  86075. * This is used later on in the postprocess.
  86076. */
  86077. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86078. private _font;
  86079. private _text;
  86080. private _charSize;
  86081. /**
  86082. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86083. */
  86084. get charSize(): number;
  86085. /**
  86086. * Create a new instance of the Ascii Art FontTexture class
  86087. * @param name the name of the texture
  86088. * @param font the font to use, use the W3C CSS notation
  86089. * @param text the caracter set to use in the rendering.
  86090. * @param scene the scene that owns the texture
  86091. */
  86092. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86093. /**
  86094. * Gets the max char width of a font.
  86095. * @param font the font to use, use the W3C CSS notation
  86096. * @return the max char width
  86097. */
  86098. private getFontWidth;
  86099. /**
  86100. * Gets the max char height of a font.
  86101. * @param font the font to use, use the W3C CSS notation
  86102. * @return the max char height
  86103. */
  86104. private getFontHeight;
  86105. /**
  86106. * Clones the current AsciiArtTexture.
  86107. * @return the clone of the texture.
  86108. */
  86109. clone(): AsciiArtFontTexture;
  86110. /**
  86111. * Parses a json object representing the texture and returns an instance of it.
  86112. * @param source the source JSON representation
  86113. * @param scene the scene to create the texture for
  86114. * @return the parsed texture
  86115. */
  86116. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86117. }
  86118. /**
  86119. * Option available in the Ascii Art Post Process.
  86120. */
  86121. export interface IAsciiArtPostProcessOptions {
  86122. /**
  86123. * The font to use following the w3c font definition.
  86124. */
  86125. font?: string;
  86126. /**
  86127. * The character set to use in the postprocess.
  86128. */
  86129. characterSet?: string;
  86130. /**
  86131. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86132. * This number is defined between 0 and 1;
  86133. */
  86134. mixToTile?: number;
  86135. /**
  86136. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86137. * This number is defined between 0 and 1;
  86138. */
  86139. mixToNormal?: number;
  86140. }
  86141. /**
  86142. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86143. *
  86144. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86145. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86146. */
  86147. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86148. /**
  86149. * The font texture used to render the char in the post process.
  86150. */
  86151. private _asciiArtFontTexture;
  86152. /**
  86153. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86154. * This number is defined between 0 and 1;
  86155. */
  86156. mixToTile: number;
  86157. /**
  86158. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86159. * This number is defined between 0 and 1;
  86160. */
  86161. mixToNormal: number;
  86162. /**
  86163. * Instantiates a new Ascii Art Post Process.
  86164. * @param name the name to give to the postprocess
  86165. * @camera the camera to apply the post process to.
  86166. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86167. */
  86168. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86169. }
  86170. }
  86171. declare module BABYLON {
  86172. /** @hidden */
  86173. export var digitalrainPixelShader: {
  86174. name: string;
  86175. shader: string;
  86176. };
  86177. }
  86178. declare module BABYLON {
  86179. /**
  86180. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86181. *
  86182. * It basically takes care rendering the font front the given font size to a texture.
  86183. * This is used later on in the postprocess.
  86184. */
  86185. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86186. private _font;
  86187. private _text;
  86188. private _charSize;
  86189. /**
  86190. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86191. */
  86192. get charSize(): number;
  86193. /**
  86194. * Create a new instance of the Digital Rain FontTexture class
  86195. * @param name the name of the texture
  86196. * @param font the font to use, use the W3C CSS notation
  86197. * @param text the caracter set to use in the rendering.
  86198. * @param scene the scene that owns the texture
  86199. */
  86200. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86201. /**
  86202. * Gets the max char width of a font.
  86203. * @param font the font to use, use the W3C CSS notation
  86204. * @return the max char width
  86205. */
  86206. private getFontWidth;
  86207. /**
  86208. * Gets the max char height of a font.
  86209. * @param font the font to use, use the W3C CSS notation
  86210. * @return the max char height
  86211. */
  86212. private getFontHeight;
  86213. /**
  86214. * Clones the current DigitalRainFontTexture.
  86215. * @return the clone of the texture.
  86216. */
  86217. clone(): DigitalRainFontTexture;
  86218. /**
  86219. * Parses a json object representing the texture and returns an instance of it.
  86220. * @param source the source JSON representation
  86221. * @param scene the scene to create the texture for
  86222. * @return the parsed texture
  86223. */
  86224. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86225. }
  86226. /**
  86227. * Option available in the Digital Rain Post Process.
  86228. */
  86229. export interface IDigitalRainPostProcessOptions {
  86230. /**
  86231. * The font to use following the w3c font definition.
  86232. */
  86233. font?: string;
  86234. /**
  86235. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86236. * This number is defined between 0 and 1;
  86237. */
  86238. mixToTile?: number;
  86239. /**
  86240. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86241. * This number is defined between 0 and 1;
  86242. */
  86243. mixToNormal?: number;
  86244. }
  86245. /**
  86246. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86247. *
  86248. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86249. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86250. */
  86251. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86252. /**
  86253. * The font texture used to render the char in the post process.
  86254. */
  86255. private _digitalRainFontTexture;
  86256. /**
  86257. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86258. * This number is defined between 0 and 1;
  86259. */
  86260. mixToTile: number;
  86261. /**
  86262. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86263. * This number is defined between 0 and 1;
  86264. */
  86265. mixToNormal: number;
  86266. /**
  86267. * Instantiates a new Digital Rain Post Process.
  86268. * @param name the name to give to the postprocess
  86269. * @camera the camera to apply the post process to.
  86270. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86271. */
  86272. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86273. }
  86274. }
  86275. declare module BABYLON {
  86276. /** @hidden */
  86277. export var brickProceduralTexturePixelShader: {
  86278. name: string;
  86279. shader: string;
  86280. };
  86281. }
  86282. declare module BABYLON {
  86283. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86284. private _numberOfBricksHeight;
  86285. private _numberOfBricksWidth;
  86286. private _jointColor;
  86287. private _brickColor;
  86288. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86289. updateShaderUniforms(): void;
  86290. get numberOfBricksHeight(): number;
  86291. set numberOfBricksHeight(value: number);
  86292. get numberOfBricksWidth(): number;
  86293. set numberOfBricksWidth(value: number);
  86294. get jointColor(): BABYLON.Color3;
  86295. set jointColor(value: BABYLON.Color3);
  86296. get brickColor(): BABYLON.Color3;
  86297. set brickColor(value: BABYLON.Color3);
  86298. /**
  86299. * Serializes this brick procedural texture
  86300. * @returns a serialized brick procedural texture object
  86301. */
  86302. serialize(): any;
  86303. /**
  86304. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86305. * @param parsedTexture defines parsed texture data
  86306. * @param scene defines the current scene
  86307. * @param rootUrl defines the root URL containing brick procedural texture information
  86308. * @returns a parsed Brick Procedural BABYLON.Texture
  86309. */
  86310. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86311. }
  86312. }
  86313. declare module BABYLON {
  86314. /** @hidden */
  86315. export var cloudProceduralTexturePixelShader: {
  86316. name: string;
  86317. shader: string;
  86318. };
  86319. }
  86320. declare module BABYLON {
  86321. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86322. private _skyColor;
  86323. private _cloudColor;
  86324. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86325. updateShaderUniforms(): void;
  86326. get skyColor(): BABYLON.Color4;
  86327. set skyColor(value: BABYLON.Color4);
  86328. get cloudColor(): BABYLON.Color4;
  86329. set cloudColor(value: BABYLON.Color4);
  86330. /**
  86331. * Serializes this cloud procedural texture
  86332. * @returns a serialized cloud procedural texture object
  86333. */
  86334. serialize(): any;
  86335. /**
  86336. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86337. * @param parsedTexture defines parsed texture data
  86338. * @param scene defines the current scene
  86339. * @param rootUrl defines the root URL containing cloud procedural texture information
  86340. * @returns a parsed Cloud Procedural BABYLON.Texture
  86341. */
  86342. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86343. }
  86344. }
  86345. declare module BABYLON {
  86346. /** @hidden */
  86347. export var fireProceduralTexturePixelShader: {
  86348. name: string;
  86349. shader: string;
  86350. };
  86351. }
  86352. declare module BABYLON {
  86353. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86354. private _time;
  86355. private _speed;
  86356. private _autoGenerateTime;
  86357. private _fireColors;
  86358. private _alphaThreshold;
  86359. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86360. updateShaderUniforms(): void;
  86361. render(useCameraPostProcess?: boolean): void;
  86362. static get PurpleFireColors(): BABYLON.Color3[];
  86363. static get GreenFireColors(): BABYLON.Color3[];
  86364. static get RedFireColors(): BABYLON.Color3[];
  86365. static get BlueFireColors(): BABYLON.Color3[];
  86366. get autoGenerateTime(): boolean;
  86367. set autoGenerateTime(value: boolean);
  86368. get fireColors(): BABYLON.Color3[];
  86369. set fireColors(value: BABYLON.Color3[]);
  86370. get time(): number;
  86371. set time(value: number);
  86372. get speed(): BABYLON.Vector2;
  86373. set speed(value: BABYLON.Vector2);
  86374. get alphaThreshold(): number;
  86375. set alphaThreshold(value: number);
  86376. /**
  86377. * Serializes this fire procedural texture
  86378. * @returns a serialized fire procedural texture object
  86379. */
  86380. serialize(): any;
  86381. /**
  86382. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86383. * @param parsedTexture defines parsed texture data
  86384. * @param scene defines the current scene
  86385. * @param rootUrl defines the root URL containing fire procedural texture information
  86386. * @returns a parsed Fire Procedural BABYLON.Texture
  86387. */
  86388. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86389. }
  86390. }
  86391. declare module BABYLON {
  86392. /** @hidden */
  86393. export var grassProceduralTexturePixelShader: {
  86394. name: string;
  86395. shader: string;
  86396. };
  86397. }
  86398. declare module BABYLON {
  86399. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86400. private _grassColors;
  86401. private _groundColor;
  86402. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86403. updateShaderUniforms(): void;
  86404. get grassColors(): BABYLON.Color3[];
  86405. set grassColors(value: BABYLON.Color3[]);
  86406. get groundColor(): BABYLON.Color3;
  86407. set groundColor(value: BABYLON.Color3);
  86408. /**
  86409. * Serializes this grass procedural texture
  86410. * @returns a serialized grass procedural texture object
  86411. */
  86412. serialize(): any;
  86413. /**
  86414. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86415. * @param parsedTexture defines parsed texture data
  86416. * @param scene defines the current scene
  86417. * @param rootUrl defines the root URL containing grass procedural texture information
  86418. * @returns a parsed Grass Procedural BABYLON.Texture
  86419. */
  86420. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86421. }
  86422. }
  86423. declare module BABYLON {
  86424. /** @hidden */
  86425. export var marbleProceduralTexturePixelShader: {
  86426. name: string;
  86427. shader: string;
  86428. };
  86429. }
  86430. declare module BABYLON {
  86431. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86432. private _numberOfTilesHeight;
  86433. private _numberOfTilesWidth;
  86434. private _amplitude;
  86435. private _jointColor;
  86436. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86437. updateShaderUniforms(): void;
  86438. get numberOfTilesHeight(): number;
  86439. set numberOfTilesHeight(value: number);
  86440. get amplitude(): number;
  86441. set amplitude(value: number);
  86442. get numberOfTilesWidth(): number;
  86443. set numberOfTilesWidth(value: number);
  86444. get jointColor(): BABYLON.Color3;
  86445. set jointColor(value: BABYLON.Color3);
  86446. /**
  86447. * Serializes this marble procedural texture
  86448. * @returns a serialized marble procedural texture object
  86449. */
  86450. serialize(): any;
  86451. /**
  86452. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86453. * @param parsedTexture defines parsed texture data
  86454. * @param scene defines the current scene
  86455. * @param rootUrl defines the root URL containing marble procedural texture information
  86456. * @returns a parsed Marble Procedural BABYLON.Texture
  86457. */
  86458. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86459. }
  86460. }
  86461. declare module BABYLON {
  86462. /** @hidden */
  86463. export var normalMapProceduralTexturePixelShader: {
  86464. name: string;
  86465. shader: string;
  86466. };
  86467. }
  86468. declare module BABYLON {
  86469. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86470. private _baseTexture;
  86471. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86472. updateShaderUniforms(): void;
  86473. render(useCameraPostProcess?: boolean): void;
  86474. resize(size: any, generateMipMaps: any): void;
  86475. get baseTexture(): BABYLON.Texture;
  86476. set baseTexture(texture: BABYLON.Texture);
  86477. /**
  86478. * Serializes this normal map procedural texture
  86479. * @returns a serialized normal map procedural texture object
  86480. */
  86481. serialize(): any;
  86482. /**
  86483. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86484. * @param parsedTexture defines parsed texture data
  86485. * @param scene defines the current scene
  86486. * @param rootUrl defines the root URL containing normal map procedural texture information
  86487. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86488. */
  86489. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86490. }
  86491. }
  86492. declare module BABYLON {
  86493. /** @hidden */
  86494. export var perlinNoiseProceduralTexturePixelShader: {
  86495. name: string;
  86496. shader: string;
  86497. };
  86498. }
  86499. declare module BABYLON {
  86500. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86501. time: number;
  86502. timeScale: number;
  86503. translationSpeed: number;
  86504. private _currentTranslation;
  86505. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86506. updateShaderUniforms(): void;
  86507. render(useCameraPostProcess?: boolean): void;
  86508. resize(size: any, generateMipMaps: any): void;
  86509. /**
  86510. * Serializes this perlin noise procedural texture
  86511. * @returns a serialized perlin noise procedural texture object
  86512. */
  86513. serialize(): any;
  86514. /**
  86515. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86516. * @param parsedTexture defines parsed texture data
  86517. * @param scene defines the current scene
  86518. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86519. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86520. */
  86521. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86522. }
  86523. }
  86524. declare module BABYLON {
  86525. /** @hidden */
  86526. export var roadProceduralTexturePixelShader: {
  86527. name: string;
  86528. shader: string;
  86529. };
  86530. }
  86531. declare module BABYLON {
  86532. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86533. private _roadColor;
  86534. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86535. updateShaderUniforms(): void;
  86536. get roadColor(): BABYLON.Color3;
  86537. set roadColor(value: BABYLON.Color3);
  86538. /**
  86539. * Serializes this road procedural texture
  86540. * @returns a serialized road procedural texture object
  86541. */
  86542. serialize(): any;
  86543. /**
  86544. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86545. * @param parsedTexture defines parsed texture data
  86546. * @param scene defines the current scene
  86547. * @param rootUrl defines the root URL containing road procedural texture information
  86548. * @returns a parsed Road Procedural BABYLON.Texture
  86549. */
  86550. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86551. }
  86552. }
  86553. declare module BABYLON {
  86554. /** @hidden */
  86555. export var starfieldProceduralTexturePixelShader: {
  86556. name: string;
  86557. shader: string;
  86558. };
  86559. }
  86560. declare module BABYLON {
  86561. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86562. private _time;
  86563. private _alpha;
  86564. private _beta;
  86565. private _zoom;
  86566. private _formuparam;
  86567. private _stepsize;
  86568. private _tile;
  86569. private _brightness;
  86570. private _darkmatter;
  86571. private _distfading;
  86572. private _saturation;
  86573. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86574. updateShaderUniforms(): void;
  86575. get time(): number;
  86576. set time(value: number);
  86577. get alpha(): number;
  86578. set alpha(value: number);
  86579. get beta(): number;
  86580. set beta(value: number);
  86581. get formuparam(): number;
  86582. set formuparam(value: number);
  86583. get stepsize(): number;
  86584. set stepsize(value: number);
  86585. get zoom(): number;
  86586. set zoom(value: number);
  86587. get tile(): number;
  86588. set tile(value: number);
  86589. get brightness(): number;
  86590. set brightness(value: number);
  86591. get darkmatter(): number;
  86592. set darkmatter(value: number);
  86593. get distfading(): number;
  86594. set distfading(value: number);
  86595. get saturation(): number;
  86596. set saturation(value: number);
  86597. /**
  86598. * Serializes this starfield procedural texture
  86599. * @returns a serialized starfield procedural texture object
  86600. */
  86601. serialize(): any;
  86602. /**
  86603. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86604. * @param parsedTexture defines parsed texture data
  86605. * @param scene defines the current scene
  86606. * @param rootUrl defines the root URL containing startfield procedural texture information
  86607. * @returns a parsed Starfield Procedural BABYLON.Texture
  86608. */
  86609. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86610. }
  86611. }
  86612. declare module BABYLON {
  86613. /** @hidden */
  86614. export var woodProceduralTexturePixelShader: {
  86615. name: string;
  86616. shader: string;
  86617. };
  86618. }
  86619. declare module BABYLON {
  86620. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86621. private _ampScale;
  86622. private _woodColor;
  86623. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86624. updateShaderUniforms(): void;
  86625. get ampScale(): number;
  86626. set ampScale(value: number);
  86627. get woodColor(): BABYLON.Color3;
  86628. set woodColor(value: BABYLON.Color3);
  86629. /**
  86630. * Serializes this wood procedural texture
  86631. * @returns a serialized wood procedural texture object
  86632. */
  86633. serialize(): any;
  86634. /**
  86635. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86636. * @param parsedTexture defines parsed texture data
  86637. * @param scene defines the current scene
  86638. * @param rootUrl defines the root URL containing wood procedural texture information
  86639. * @returns a parsed Wood Procedural BABYLON.Texture
  86640. */
  86641. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86642. }
  86643. }