documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823
  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. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23290. get mimeType(): string | undefined;
  23291. /**
  23292. * Observable triggered once the texture has been loaded.
  23293. */
  23294. onLoadObservable: Observable<Texture>;
  23295. protected _isBlocking: boolean;
  23296. /**
  23297. * Is the texture preventing material to render while loading.
  23298. * If false, a default texture will be used instead of the loading one during the preparation step.
  23299. */
  23300. set isBlocking(value: boolean);
  23301. get isBlocking(): boolean;
  23302. /**
  23303. * Get the current sampling mode associated with the texture.
  23304. */
  23305. get samplingMode(): number;
  23306. /**
  23307. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23308. */
  23309. get invertY(): boolean;
  23310. /**
  23311. * Instantiates a new texture.
  23312. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23313. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23314. * @param url defines the url of the picture to load as a texture
  23315. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23316. * @param noMipmap defines if the texture will require mip maps or not
  23317. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23318. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23319. * @param onLoad defines a callback triggered when the texture has been loaded
  23320. * @param onError defines a callback triggered when an error occurred during the loading session
  23321. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23322. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23323. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23324. * @param mimeType defines an optional mime type information
  23325. */
  23326. 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);
  23327. /**
  23328. * Update the url (and optional buffer) of this texture if url was null during construction.
  23329. * @param url the url of the texture
  23330. * @param buffer the buffer of the texture (defaults to null)
  23331. * @param onLoad callback called when the texture is loaded (defaults to null)
  23332. */
  23333. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23334. /**
  23335. * Finish the loading sequence of a texture flagged as delayed load.
  23336. * @hidden
  23337. */
  23338. delayLoad(): void;
  23339. private _prepareRowForTextureGeneration;
  23340. /**
  23341. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23342. * @returns the transform matrix of the texture.
  23343. */
  23344. getTextureMatrix(uBase?: number): Matrix;
  23345. /**
  23346. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23347. * @returns The reflection texture transform
  23348. */
  23349. getReflectionTextureMatrix(): Matrix;
  23350. /**
  23351. * Clones the texture.
  23352. * @returns the cloned texture
  23353. */
  23354. clone(): Texture;
  23355. /**
  23356. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23357. * @returns The JSON representation of the texture
  23358. */
  23359. serialize(): any;
  23360. /**
  23361. * Get the current class name of the texture useful for serialization or dynamic coding.
  23362. * @returns "Texture"
  23363. */
  23364. getClassName(): string;
  23365. /**
  23366. * Dispose the texture and release its associated resources.
  23367. */
  23368. dispose(): void;
  23369. /**
  23370. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23371. * @param parsedTexture Define the JSON representation of the texture
  23372. * @param scene Define the scene the parsed texture should be instantiated in
  23373. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23374. * @returns The parsed texture if successful
  23375. */
  23376. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23377. /**
  23378. * Creates a texture from its base 64 representation.
  23379. * @param data Define the base64 payload without the data: prefix
  23380. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23381. * @param scene Define the scene the texture should belong to
  23382. * @param noMipmap Forces the texture to not create mip map information if true
  23383. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23384. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23385. * @param onLoad define a callback triggered when the texture has been loaded
  23386. * @param onError define a callback triggered when an error occurred during the loading session
  23387. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23388. * @returns the created texture
  23389. */
  23390. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23391. /**
  23392. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23393. * @param data Define the base64 payload without the data: prefix
  23394. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23395. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23396. * @param scene Define the scene the texture should belong to
  23397. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23398. * @param noMipmap Forces the texture to not create mip map information if true
  23399. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23400. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23401. * @param onLoad define a callback triggered when the texture has been loaded
  23402. * @param onError define a callback triggered when an error occurred during the loading session
  23403. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23404. * @returns the created texture
  23405. */
  23406. 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;
  23407. }
  23408. }
  23409. declare module BABYLON {
  23410. /**
  23411. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23412. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23413. */
  23414. export class PostProcessManager {
  23415. private _scene;
  23416. private _indexBuffer;
  23417. private _vertexBuffers;
  23418. /**
  23419. * Creates a new instance PostProcess
  23420. * @param scene The scene that the post process is associated with.
  23421. */
  23422. constructor(scene: Scene);
  23423. private _prepareBuffers;
  23424. private _buildIndexBuffer;
  23425. /**
  23426. * Rebuilds the vertex buffers of the manager.
  23427. * @hidden
  23428. */
  23429. _rebuild(): void;
  23430. /**
  23431. * Prepares a frame to be run through a post process.
  23432. * @param sourceTexture The input texture to the post procesess. (default: null)
  23433. * @param postProcesses An array of post processes to be run. (default: null)
  23434. * @returns True if the post processes were able to be run.
  23435. * @hidden
  23436. */
  23437. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23438. /**
  23439. * Manually render a set of post processes to a texture.
  23440. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23441. * @param postProcesses An array of post processes to be run.
  23442. * @param targetTexture The target texture to render to.
  23443. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23444. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23445. * @param lodLevel defines which lod of the texture to render to
  23446. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23447. */
  23448. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23449. /**
  23450. * Finalize the result of the output of the postprocesses.
  23451. * @param doNotPresent If true the result will not be displayed to the screen.
  23452. * @param targetTexture The target texture to render to.
  23453. * @param faceIndex The index of the face to bind the target texture to.
  23454. * @param postProcesses The array of post processes to render.
  23455. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23456. * @hidden
  23457. */
  23458. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23459. /**
  23460. * Disposes of the post process manager.
  23461. */
  23462. dispose(): void;
  23463. }
  23464. }
  23465. declare module BABYLON {
  23466. /**
  23467. * This Helps creating a texture that will be created from a camera in your scene.
  23468. * It is basically a dynamic texture that could be used to create special effects for instance.
  23469. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23470. */
  23471. export class RenderTargetTexture extends Texture {
  23472. /**
  23473. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23474. */
  23475. static readonly REFRESHRATE_RENDER_ONCE: number;
  23476. /**
  23477. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23478. */
  23479. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23480. /**
  23481. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23482. * the central point of your effect and can save a lot of performances.
  23483. */
  23484. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23485. /**
  23486. * Use this predicate to dynamically define the list of mesh you want to render.
  23487. * If set, the renderList property will be overwritten.
  23488. */
  23489. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23490. private _renderList;
  23491. /**
  23492. * Use this list to define the list of mesh you want to render.
  23493. */
  23494. get renderList(): Nullable<Array<AbstractMesh>>;
  23495. set renderList(value: Nullable<Array<AbstractMesh>>);
  23496. /**
  23497. * Use this function to overload the renderList array at rendering time.
  23498. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23499. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23500. * the cube (if the RTT is a cube, else layerOrFace=0).
  23501. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23502. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23503. * hold dummy elements!
  23504. */
  23505. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23506. private _hookArray;
  23507. /**
  23508. * Define if particles should be rendered in your texture.
  23509. */
  23510. renderParticles: boolean;
  23511. /**
  23512. * Define if sprites should be rendered in your texture.
  23513. */
  23514. renderSprites: boolean;
  23515. /**
  23516. * Define the camera used to render the texture.
  23517. */
  23518. activeCamera: Nullable<Camera>;
  23519. /**
  23520. * Override the mesh isReady function with your own one.
  23521. */
  23522. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23523. /**
  23524. * Override the render function of the texture with your own one.
  23525. */
  23526. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23527. /**
  23528. * Define if camera post processes should be use while rendering the texture.
  23529. */
  23530. useCameraPostProcesses: boolean;
  23531. /**
  23532. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23533. */
  23534. ignoreCameraViewport: boolean;
  23535. private _postProcessManager;
  23536. private _postProcesses;
  23537. private _resizeObserver;
  23538. /**
  23539. * An event triggered when the texture is unbind.
  23540. */
  23541. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23542. /**
  23543. * An event triggered when the texture is unbind.
  23544. */
  23545. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23546. private _onAfterUnbindObserver;
  23547. /**
  23548. * Set a after unbind callback in the texture.
  23549. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23550. */
  23551. set onAfterUnbind(callback: () => void);
  23552. /**
  23553. * An event triggered before rendering the texture
  23554. */
  23555. onBeforeRenderObservable: Observable<number>;
  23556. private _onBeforeRenderObserver;
  23557. /**
  23558. * Set a before render callback in the texture.
  23559. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23560. */
  23561. set onBeforeRender(callback: (faceIndex: number) => void);
  23562. /**
  23563. * An event triggered after rendering the texture
  23564. */
  23565. onAfterRenderObservable: Observable<number>;
  23566. private _onAfterRenderObserver;
  23567. /**
  23568. * Set a after render callback in the texture.
  23569. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23570. */
  23571. set onAfterRender(callback: (faceIndex: number) => void);
  23572. /**
  23573. * An event triggered after the texture clear
  23574. */
  23575. onClearObservable: Observable<Engine>;
  23576. private _onClearObserver;
  23577. /**
  23578. * Set a clear callback in the texture.
  23579. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23580. */
  23581. set onClear(callback: (Engine: Engine) => void);
  23582. /**
  23583. * An event triggered when the texture is resized.
  23584. */
  23585. onResizeObservable: Observable<RenderTargetTexture>;
  23586. /**
  23587. * Define the clear color of the Render Target if it should be different from the scene.
  23588. */
  23589. clearColor: Color4;
  23590. protected _size: number | {
  23591. width: number;
  23592. height: number;
  23593. layers?: number;
  23594. };
  23595. protected _initialSizeParameter: number | {
  23596. width: number;
  23597. height: number;
  23598. } | {
  23599. ratio: number;
  23600. };
  23601. protected _sizeRatio: Nullable<number>;
  23602. /** @hidden */
  23603. _generateMipMaps: boolean;
  23604. protected _renderingManager: RenderingManager;
  23605. /** @hidden */
  23606. _waitingRenderList?: string[];
  23607. protected _doNotChangeAspectRatio: boolean;
  23608. protected _currentRefreshId: number;
  23609. protected _refreshRate: number;
  23610. protected _textureMatrix: Matrix;
  23611. protected _samples: number;
  23612. protected _renderTargetOptions: RenderTargetCreationOptions;
  23613. /**
  23614. * Gets render target creation options that were used.
  23615. */
  23616. get renderTargetOptions(): RenderTargetCreationOptions;
  23617. protected _onRatioRescale(): void;
  23618. /**
  23619. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23620. * It must define where the camera used to render the texture is set
  23621. */
  23622. boundingBoxPosition: Vector3;
  23623. private _boundingBoxSize;
  23624. /**
  23625. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23626. * When defined, the cubemap will switch to local mode
  23627. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23628. * @example https://www.babylonjs-playground.com/#RNASML
  23629. */
  23630. set boundingBoxSize(value: Vector3);
  23631. get boundingBoxSize(): Vector3;
  23632. /**
  23633. * In case the RTT has been created with a depth texture, get the associated
  23634. * depth texture.
  23635. * Otherwise, return null.
  23636. */
  23637. get depthStencilTexture(): Nullable<InternalTexture>;
  23638. /**
  23639. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23640. * or used a shadow, depth texture...
  23641. * @param name The friendly name of the texture
  23642. * @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)
  23643. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23644. * @param generateMipMaps True if mip maps need to be generated after render.
  23645. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23646. * @param type The type of the buffer in the RTT (int, half float, float...)
  23647. * @param isCube True if a cube texture needs to be created
  23648. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23649. * @param generateDepthBuffer True to generate a depth buffer
  23650. * @param generateStencilBuffer True to generate a stencil buffer
  23651. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23652. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23653. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23654. */
  23655. constructor(name: string, size: number | {
  23656. width: number;
  23657. height: number;
  23658. layers?: number;
  23659. } | {
  23660. ratio: number;
  23661. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23662. /**
  23663. * Creates a depth stencil texture.
  23664. * This is only available in WebGL 2 or with the depth texture extension available.
  23665. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23666. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23667. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23668. */
  23669. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23670. private _processSizeParameter;
  23671. /**
  23672. * Define the number of samples to use in case of MSAA.
  23673. * It defaults to one meaning no MSAA has been enabled.
  23674. */
  23675. get samples(): number;
  23676. set samples(value: number);
  23677. /**
  23678. * Resets the refresh counter of the texture and start bak from scratch.
  23679. * Could be useful to regenerate the texture if it is setup to render only once.
  23680. */
  23681. resetRefreshCounter(): void;
  23682. /**
  23683. * Define the refresh rate of the texture or the rendering frequency.
  23684. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23685. */
  23686. get refreshRate(): number;
  23687. set refreshRate(value: number);
  23688. /**
  23689. * Adds a post process to the render target rendering passes.
  23690. * @param postProcess define the post process to add
  23691. */
  23692. addPostProcess(postProcess: PostProcess): void;
  23693. /**
  23694. * Clear all the post processes attached to the render target
  23695. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23696. */
  23697. clearPostProcesses(dispose?: boolean): void;
  23698. /**
  23699. * Remove one of the post process from the list of attached post processes to the texture
  23700. * @param postProcess define the post process to remove from the list
  23701. */
  23702. removePostProcess(postProcess: PostProcess): void;
  23703. /** @hidden */
  23704. _shouldRender(): boolean;
  23705. /**
  23706. * Gets the actual render size of the texture.
  23707. * @returns the width of the render size
  23708. */
  23709. getRenderSize(): number;
  23710. /**
  23711. * Gets the actual render width of the texture.
  23712. * @returns the width of the render size
  23713. */
  23714. getRenderWidth(): number;
  23715. /**
  23716. * Gets the actual render height of the texture.
  23717. * @returns the height of the render size
  23718. */
  23719. getRenderHeight(): number;
  23720. /**
  23721. * Gets the actual number of layers of the texture.
  23722. * @returns the number of layers
  23723. */
  23724. getRenderLayers(): number;
  23725. /**
  23726. * Get if the texture can be rescaled or not.
  23727. */
  23728. get canRescale(): boolean;
  23729. /**
  23730. * Resize the texture using a ratio.
  23731. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23732. */
  23733. scale(ratio: number): void;
  23734. /**
  23735. * Get the texture reflection matrix used to rotate/transform the reflection.
  23736. * @returns the reflection matrix
  23737. */
  23738. getReflectionTextureMatrix(): Matrix;
  23739. /**
  23740. * Resize the texture to a new desired size.
  23741. * Be carrefull as it will recreate all the data in the new texture.
  23742. * @param size Define the new size. It can be:
  23743. * - a number for squared texture,
  23744. * - an object containing { width: number, height: number }
  23745. * - or an object containing a ratio { ratio: number }
  23746. */
  23747. resize(size: number | {
  23748. width: number;
  23749. height: number;
  23750. } | {
  23751. ratio: number;
  23752. }): void;
  23753. private _defaultRenderListPrepared;
  23754. /**
  23755. * Renders all the objects from the render list into the texture.
  23756. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23757. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23758. */
  23759. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23760. private _bestReflectionRenderTargetDimension;
  23761. private _prepareRenderingManager;
  23762. /**
  23763. * @hidden
  23764. * @param faceIndex face index to bind to if this is a cubetexture
  23765. * @param layer defines the index of the texture to bind in the array
  23766. */
  23767. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23768. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23769. private renderToTarget;
  23770. /**
  23771. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23772. * This allowed control for front to back rendering or reversly depending of the special needs.
  23773. *
  23774. * @param renderingGroupId The rendering group id corresponding to its index
  23775. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23776. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23777. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23778. */
  23779. 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;
  23780. /**
  23781. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23782. *
  23783. * @param renderingGroupId The rendering group id corresponding to its index
  23784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23785. */
  23786. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23787. /**
  23788. * Clones the texture.
  23789. * @returns the cloned texture
  23790. */
  23791. clone(): RenderTargetTexture;
  23792. /**
  23793. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23794. * @returns The JSON representation of the texture
  23795. */
  23796. serialize(): any;
  23797. /**
  23798. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23799. */
  23800. disposeFramebufferObjects(): void;
  23801. /**
  23802. * Dispose the texture and release its associated resources.
  23803. */
  23804. dispose(): void;
  23805. /** @hidden */
  23806. _rebuild(): void;
  23807. /**
  23808. * Clear the info related to rendering groups preventing retention point in material dispose.
  23809. */
  23810. freeRenderingGroups(): void;
  23811. /**
  23812. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23813. * @returns the view count
  23814. */
  23815. getViewCount(): number;
  23816. }
  23817. }
  23818. declare module BABYLON {
  23819. /**
  23820. * Class used to manipulate GUIDs
  23821. */
  23822. export class GUID {
  23823. /**
  23824. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23825. * Be aware Math.random() could cause collisions, but:
  23826. * "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"
  23827. * @returns a pseudo random id
  23828. */
  23829. static RandomId(): string;
  23830. }
  23831. }
  23832. declare module BABYLON {
  23833. /**
  23834. * Options to be used when creating a shadow depth material
  23835. */
  23836. export interface IIOptionShadowDepthMaterial {
  23837. /** Variables in the vertex shader code that need to have their names remapped.
  23838. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23839. * "var_name" should be either: worldPos or vNormalW
  23840. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23841. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23842. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23843. */
  23844. remappedVariables?: string[];
  23845. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23846. standalone?: boolean;
  23847. }
  23848. /**
  23849. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23850. */
  23851. export class ShadowDepthWrapper {
  23852. private _scene;
  23853. private _options?;
  23854. private _baseMaterial;
  23855. private _onEffectCreatedObserver;
  23856. private _subMeshToEffect;
  23857. private _subMeshToDepthEffect;
  23858. private _meshes;
  23859. /** @hidden */
  23860. _matriceNames: any;
  23861. /** Gets the standalone status of the wrapper */
  23862. get standalone(): boolean;
  23863. /** Gets the base material the wrapper is built upon */
  23864. get baseMaterial(): Material;
  23865. /**
  23866. * Instantiate a new shadow depth wrapper.
  23867. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23868. * generate the shadow depth map. For more information, please refer to the documentation:
  23869. * https://doc.babylonjs.com/babylon101/shadows
  23870. * @param baseMaterial Material to wrap
  23871. * @param scene Define the scene the material belongs to
  23872. * @param options Options used to create the wrapper
  23873. */
  23874. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23875. /**
  23876. * Gets the effect to use to generate the depth map
  23877. * @param subMesh subMesh to get the effect for
  23878. * @param shadowGenerator shadow generator to get the effect for
  23879. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23880. */
  23881. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23882. /**
  23883. * Specifies that the submesh is ready to be used for depth rendering
  23884. * @param subMesh submesh to check
  23885. * @param defines the list of defines to take into account when checking the effect
  23886. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23887. * @param useInstances specifies that instances should be used
  23888. * @returns a boolean indicating that the submesh is ready or not
  23889. */
  23890. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23891. /**
  23892. * Disposes the resources
  23893. */
  23894. dispose(): void;
  23895. private _makeEffect;
  23896. }
  23897. }
  23898. declare module BABYLON {
  23899. interface ThinEngine {
  23900. /**
  23901. * Unbind a list of render target textures from the webGL context
  23902. * This is used only when drawBuffer extension or webGL2 are active
  23903. * @param textures defines the render target textures to unbind
  23904. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23905. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23906. */
  23907. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23908. /**
  23909. * Create a multi render target texture
  23910. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23911. * @param size defines the size of the texture
  23912. * @param options defines the creation options
  23913. * @returns the cube texture as an InternalTexture
  23914. */
  23915. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23916. /**
  23917. * Update the sample count for a given multiple render target texture
  23918. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23919. * @param textures defines the textures to update
  23920. * @param samples defines the sample count to set
  23921. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23922. */
  23923. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23924. /**
  23925. * Select a subsets of attachments to draw to.
  23926. * @param attachments gl attachments
  23927. */
  23928. bindAttachments(attachments: number[]): void;
  23929. }
  23930. }
  23931. declare module BABYLON {
  23932. /**
  23933. * Creation options of the multi render target texture.
  23934. */
  23935. export interface IMultiRenderTargetOptions {
  23936. /**
  23937. * Define if the texture needs to create mip maps after render.
  23938. */
  23939. generateMipMaps?: boolean;
  23940. /**
  23941. * Define the types of all the draw buffers we want to create
  23942. */
  23943. types?: number[];
  23944. /**
  23945. * Define the sampling modes of all the draw buffers we want to create
  23946. */
  23947. samplingModes?: number[];
  23948. /**
  23949. * Define if a depth buffer is required
  23950. */
  23951. generateDepthBuffer?: boolean;
  23952. /**
  23953. * Define if a stencil buffer is required
  23954. */
  23955. generateStencilBuffer?: boolean;
  23956. /**
  23957. * Define if a depth texture is required instead of a depth buffer
  23958. */
  23959. generateDepthTexture?: boolean;
  23960. /**
  23961. * Define the number of desired draw buffers
  23962. */
  23963. textureCount?: number;
  23964. /**
  23965. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23966. */
  23967. doNotChangeAspectRatio?: boolean;
  23968. /**
  23969. * Define the default type of the buffers we are creating
  23970. */
  23971. defaultType?: number;
  23972. }
  23973. /**
  23974. * A multi render target, like a render target provides the ability to render to a texture.
  23975. * Unlike the render target, it can render to several draw buffers in one draw.
  23976. * This is specially interesting in deferred rendering or for any effects requiring more than
  23977. * just one color from a single pass.
  23978. */
  23979. export class MultiRenderTarget extends RenderTargetTexture {
  23980. private _internalTextures;
  23981. private _textures;
  23982. private _multiRenderTargetOptions;
  23983. private _count;
  23984. /**
  23985. * Get if draw buffers are currently supported by the used hardware and browser.
  23986. */
  23987. get isSupported(): boolean;
  23988. /**
  23989. * Get the list of textures generated by the multi render target.
  23990. */
  23991. get textures(): Texture[];
  23992. /**
  23993. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23994. */
  23995. get count(): number;
  23996. /**
  23997. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23998. */
  23999. get depthTexture(): Texture;
  24000. /**
  24001. * Set the wrapping mode on U of all the textures we are rendering to.
  24002. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24003. */
  24004. set wrapU(wrap: number);
  24005. /**
  24006. * Set the wrapping mode on V of all the textures we are rendering to.
  24007. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24008. */
  24009. set wrapV(wrap: number);
  24010. /**
  24011. * Instantiate a new multi render target texture.
  24012. * A multi render target, like a render target provides the ability to render to a texture.
  24013. * Unlike the render target, it can render to several draw buffers in one draw.
  24014. * This is specially interesting in deferred rendering or for any effects requiring more than
  24015. * just one color from a single pass.
  24016. * @param name Define the name of the texture
  24017. * @param size Define the size of the buffers to render to
  24018. * @param count Define the number of target we are rendering into
  24019. * @param scene Define the scene the texture belongs to
  24020. * @param options Define the options used to create the multi render target
  24021. */
  24022. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24023. /** @hidden */
  24024. _rebuild(): void;
  24025. private _createInternalTextures;
  24026. private _createTextures;
  24027. /**
  24028. * Define the number of samples used if MSAA is enabled.
  24029. */
  24030. get samples(): number;
  24031. set samples(value: number);
  24032. /**
  24033. * Resize all the textures in the multi render target.
  24034. * Be carrefull as it will recreate all the data in the new texture.
  24035. * @param size Define the new size
  24036. */
  24037. resize(size: any): void;
  24038. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24039. /**
  24040. * Dispose the render targets and their associated resources
  24041. */
  24042. dispose(): void;
  24043. /**
  24044. * Release all the underlying texture used as draw buffers.
  24045. */
  24046. releaseInternalTextures(): void;
  24047. }
  24048. }
  24049. declare module BABYLON {
  24050. /** @hidden */
  24051. export var imageProcessingPixelShader: {
  24052. name: string;
  24053. shader: string;
  24054. };
  24055. }
  24056. declare module BABYLON {
  24057. /**
  24058. * ImageProcessingPostProcess
  24059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24060. */
  24061. export class ImageProcessingPostProcess extends PostProcess {
  24062. /**
  24063. * Default configuration related to image processing available in the PBR Material.
  24064. */
  24065. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24066. /**
  24067. * Gets the image processing configuration used either in this material.
  24068. */
  24069. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24070. /**
  24071. * Sets the Default image processing configuration used either in the this material.
  24072. *
  24073. * If sets to null, the scene one is in use.
  24074. */
  24075. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24076. /**
  24077. * Keep track of the image processing observer to allow dispose and replace.
  24078. */
  24079. private _imageProcessingObserver;
  24080. /**
  24081. * Attaches a new image processing configuration to the PBR Material.
  24082. * @param configuration
  24083. */
  24084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24085. /**
  24086. * If the post process is supported.
  24087. */
  24088. get isSupported(): boolean;
  24089. /**
  24090. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24091. */
  24092. get colorCurves(): Nullable<ColorCurves>;
  24093. /**
  24094. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24095. */
  24096. set colorCurves(value: Nullable<ColorCurves>);
  24097. /**
  24098. * Gets wether the color curves effect is enabled.
  24099. */
  24100. get colorCurvesEnabled(): boolean;
  24101. /**
  24102. * Sets wether the color curves effect is enabled.
  24103. */
  24104. set colorCurvesEnabled(value: boolean);
  24105. /**
  24106. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24107. */
  24108. get colorGradingTexture(): Nullable<BaseTexture>;
  24109. /**
  24110. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24111. */
  24112. set colorGradingTexture(value: Nullable<BaseTexture>);
  24113. /**
  24114. * Gets wether the color grading effect is enabled.
  24115. */
  24116. get colorGradingEnabled(): boolean;
  24117. /**
  24118. * Gets wether the color grading effect is enabled.
  24119. */
  24120. set colorGradingEnabled(value: boolean);
  24121. /**
  24122. * Gets exposure used in the effect.
  24123. */
  24124. get exposure(): number;
  24125. /**
  24126. * Sets exposure used in the effect.
  24127. */
  24128. set exposure(value: number);
  24129. /**
  24130. * Gets wether tonemapping is enabled or not.
  24131. */
  24132. get toneMappingEnabled(): boolean;
  24133. /**
  24134. * Sets wether tonemapping is enabled or not
  24135. */
  24136. set toneMappingEnabled(value: boolean);
  24137. /**
  24138. * Gets the type of tone mapping effect.
  24139. */
  24140. get toneMappingType(): number;
  24141. /**
  24142. * Sets the type of tone mapping effect.
  24143. */
  24144. set toneMappingType(value: number);
  24145. /**
  24146. * Gets contrast used in the effect.
  24147. */
  24148. get contrast(): number;
  24149. /**
  24150. * Sets contrast used in the effect.
  24151. */
  24152. set contrast(value: number);
  24153. /**
  24154. * Gets Vignette stretch size.
  24155. */
  24156. get vignetteStretch(): number;
  24157. /**
  24158. * Sets Vignette stretch size.
  24159. */
  24160. set vignetteStretch(value: number);
  24161. /**
  24162. * Gets Vignette centre X Offset.
  24163. */
  24164. get vignetteCentreX(): number;
  24165. /**
  24166. * Sets Vignette centre X Offset.
  24167. */
  24168. set vignetteCentreX(value: number);
  24169. /**
  24170. * Gets Vignette centre Y Offset.
  24171. */
  24172. get vignetteCentreY(): number;
  24173. /**
  24174. * Sets Vignette centre Y Offset.
  24175. */
  24176. set vignetteCentreY(value: number);
  24177. /**
  24178. * Gets Vignette weight or intensity of the vignette effect.
  24179. */
  24180. get vignetteWeight(): number;
  24181. /**
  24182. * Sets Vignette weight or intensity of the vignette effect.
  24183. */
  24184. set vignetteWeight(value: number);
  24185. /**
  24186. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24187. * if vignetteEnabled is set to true.
  24188. */
  24189. get vignetteColor(): Color4;
  24190. /**
  24191. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24192. * if vignetteEnabled is set to true.
  24193. */
  24194. set vignetteColor(value: Color4);
  24195. /**
  24196. * Gets Camera field of view used by the Vignette effect.
  24197. */
  24198. get vignetteCameraFov(): number;
  24199. /**
  24200. * Sets Camera field of view used by the Vignette effect.
  24201. */
  24202. set vignetteCameraFov(value: number);
  24203. /**
  24204. * Gets the vignette blend mode allowing different kind of effect.
  24205. */
  24206. get vignetteBlendMode(): number;
  24207. /**
  24208. * Sets the vignette blend mode allowing different kind of effect.
  24209. */
  24210. set vignetteBlendMode(value: number);
  24211. /**
  24212. * Gets wether the vignette effect is enabled.
  24213. */
  24214. get vignetteEnabled(): boolean;
  24215. /**
  24216. * Sets wether the vignette effect is enabled.
  24217. */
  24218. set vignetteEnabled(value: boolean);
  24219. private _fromLinearSpace;
  24220. /**
  24221. * Gets wether the input of the processing is in Gamma or Linear Space.
  24222. */
  24223. get fromLinearSpace(): boolean;
  24224. /**
  24225. * Sets wether the input of the processing is in Gamma or Linear Space.
  24226. */
  24227. set fromLinearSpace(value: boolean);
  24228. /**
  24229. * Defines cache preventing GC.
  24230. */
  24231. private _defines;
  24232. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24233. /**
  24234. * "ImageProcessingPostProcess"
  24235. * @returns "ImageProcessingPostProcess"
  24236. */
  24237. getClassName(): string;
  24238. /**
  24239. * @hidden
  24240. */
  24241. _updateParameters(): void;
  24242. dispose(camera?: Camera): void;
  24243. }
  24244. }
  24245. declare module BABYLON {
  24246. /** @hidden */
  24247. export var fibonacci: {
  24248. name: string;
  24249. shader: string;
  24250. };
  24251. }
  24252. declare module BABYLON {
  24253. /** @hidden */
  24254. export var subSurfaceScatteringFunctions: {
  24255. name: string;
  24256. shader: string;
  24257. };
  24258. }
  24259. declare module BABYLON {
  24260. /** @hidden */
  24261. export var diffusionProfile: {
  24262. name: string;
  24263. shader: string;
  24264. };
  24265. }
  24266. declare module BABYLON {
  24267. /** @hidden */
  24268. export var subSurfaceScatteringPixelShader: {
  24269. name: string;
  24270. shader: string;
  24271. };
  24272. }
  24273. declare module BABYLON {
  24274. /**
  24275. * Sub surface scattering post process
  24276. */
  24277. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24278. /**
  24279. * Gets a string identifying the name of the class
  24280. * @returns "SubSurfaceScatteringPostProcess" string
  24281. */
  24282. getClassName(): string;
  24283. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24284. }
  24285. }
  24286. declare module BABYLON {
  24287. /**
  24288. * Interface for defining prepass effects in the prepass post-process pipeline
  24289. */
  24290. export interface PrePassEffectConfiguration {
  24291. /**
  24292. * Post process to attach for this effect
  24293. */
  24294. postProcess: PostProcess;
  24295. /**
  24296. * Is the effect enabled
  24297. */
  24298. enabled: boolean;
  24299. /**
  24300. * Disposes the effect configuration
  24301. */
  24302. dispose(): void;
  24303. /**
  24304. * Disposes the effect configuration
  24305. */
  24306. createPostProcess: () => PostProcess;
  24307. }
  24308. }
  24309. declare module BABYLON {
  24310. /**
  24311. * Contains all parameters needed for the prepass to perform
  24312. * screen space subsurface scattering
  24313. */
  24314. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24315. private _ssDiffusionS;
  24316. private _ssFilterRadii;
  24317. private _ssDiffusionD;
  24318. /**
  24319. * Post process to attach for screen space subsurface scattering
  24320. */
  24321. postProcess: SubSurfaceScatteringPostProcess;
  24322. /**
  24323. * Diffusion profile color for subsurface scattering
  24324. */
  24325. get ssDiffusionS(): number[];
  24326. /**
  24327. * Diffusion profile max color channel value for subsurface scattering
  24328. */
  24329. get ssDiffusionD(): number[];
  24330. /**
  24331. * Diffusion profile filter radius for subsurface scattering
  24332. */
  24333. get ssFilterRadii(): number[];
  24334. /**
  24335. * Is subsurface enabled
  24336. */
  24337. enabled: boolean;
  24338. /**
  24339. * Diffusion profile colors for subsurface scattering
  24340. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24341. * See ...
  24342. * Note that you can only store up to 5 of them
  24343. */
  24344. ssDiffusionProfileColors: Color3[];
  24345. /**
  24346. * Defines the ratio real world => scene units.
  24347. * Used for subsurface scattering
  24348. */
  24349. metersPerUnit: number;
  24350. private _scene;
  24351. /**
  24352. * Builds a subsurface configuration object
  24353. * @param scene The scene
  24354. */
  24355. constructor(scene: Scene);
  24356. /**
  24357. * Adds a new diffusion profile.
  24358. * Useful for more realistic subsurface scattering on diverse materials.
  24359. * @param color The color of the diffusion profile. Should be the average color of the material.
  24360. * @return The index of the diffusion profile for the material subsurface configuration
  24361. */
  24362. addDiffusionProfile(color: Color3): number;
  24363. /**
  24364. * Creates the sss post process
  24365. * @return The created post process
  24366. */
  24367. createPostProcess(): SubSurfaceScatteringPostProcess;
  24368. /**
  24369. * Deletes all diffusion profiles.
  24370. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24371. */
  24372. clearAllDiffusionProfiles(): void;
  24373. /**
  24374. * Disposes this object
  24375. */
  24376. dispose(): void;
  24377. /**
  24378. * @hidden
  24379. * https://zero-radiance.github.io/post/sampling-diffusion/
  24380. *
  24381. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24382. * ------------------------------------------------------------------------------------
  24383. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24384. * PDF[r, phi, s] = r * R[r, phi, s]
  24385. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24386. * ------------------------------------------------------------------------------------
  24387. * We importance sample the color channel with the widest scattering distance.
  24388. */
  24389. getDiffusionProfileParameters(color: Color3): number;
  24390. /**
  24391. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24392. * 'u' is the random number (the value of the CDF): [0, 1).
  24393. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24394. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24395. */
  24396. private _sampleBurleyDiffusionProfile;
  24397. }
  24398. }
  24399. declare module BABYLON {
  24400. /**
  24401. * Renders a pre pass of the scene
  24402. * This means every mesh in the scene will be rendered to a render target texture
  24403. * And then this texture will be composited to the rendering canvas with post processes
  24404. * It is necessary for effects like subsurface scattering or deferred shading
  24405. */
  24406. export class PrePassRenderer {
  24407. /** @hidden */
  24408. static _SceneComponentInitialization: (scene: Scene) => void;
  24409. private _scene;
  24410. private _engine;
  24411. private _isDirty;
  24412. /**
  24413. * Number of textures in the multi render target texture where the scene is directly rendered
  24414. */
  24415. readonly mrtCount: number;
  24416. /**
  24417. * The render target where the scene is directly rendered
  24418. */
  24419. prePassRT: MultiRenderTarget;
  24420. private _mrtTypes;
  24421. private _multiRenderAttachments;
  24422. private _defaultAttachments;
  24423. private _clearAttachments;
  24424. private _postProcesses;
  24425. private readonly _clearColor;
  24426. /**
  24427. * Image processing post process for composition
  24428. */
  24429. imageProcessingPostProcess: ImageProcessingPostProcess;
  24430. /**
  24431. * Configuration for sub surface scattering post process
  24432. */
  24433. subSurfaceConfiguration: SubSurfaceConfiguration;
  24434. /**
  24435. * Should materials render their geometry on the MRT
  24436. */
  24437. materialsShouldRenderGeometry: boolean;
  24438. /**
  24439. * Should materials render the irradiance information on the MRT
  24440. */
  24441. materialsShouldRenderIrradiance: boolean;
  24442. private _enabled;
  24443. /**
  24444. * Indicates if the prepass is enabled
  24445. */
  24446. get enabled(): boolean;
  24447. /**
  24448. * How many samples are used for MSAA of the scene render target
  24449. */
  24450. get samples(): number;
  24451. set samples(n: number);
  24452. /**
  24453. * Instanciates a prepass renderer
  24454. * @param scene The scene
  24455. */
  24456. constructor(scene: Scene);
  24457. private _initializeAttachments;
  24458. private _createCompositionEffect;
  24459. /**
  24460. * Indicates if rendering a prepass is supported
  24461. */
  24462. get isSupported(): boolean;
  24463. /**
  24464. * Sets the proper output textures to draw in the engine.
  24465. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24466. */
  24467. bindAttachmentsForEffect(effect: Effect): void;
  24468. /**
  24469. * @hidden
  24470. */
  24471. _beforeCameraDraw(): void;
  24472. /**
  24473. * @hidden
  24474. */
  24475. _afterCameraDraw(): void;
  24476. private _checkRTSize;
  24477. private _bindFrameBuffer;
  24478. /**
  24479. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24480. */
  24481. clear(): void;
  24482. private _setState;
  24483. private _enable;
  24484. private _disable;
  24485. private _resetPostProcessChain;
  24486. private _bindPostProcessChain;
  24487. /**
  24488. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24489. */
  24490. markAsDirty(): void;
  24491. private _update;
  24492. /**
  24493. * Disposes the prepass renderer.
  24494. */
  24495. dispose(): void;
  24496. }
  24497. }
  24498. declare module BABYLON {
  24499. /**
  24500. * Options for compiling materials.
  24501. */
  24502. export interface IMaterialCompilationOptions {
  24503. /**
  24504. * Defines whether clip planes are enabled.
  24505. */
  24506. clipPlane: boolean;
  24507. /**
  24508. * Defines whether instances are enabled.
  24509. */
  24510. useInstances: boolean;
  24511. }
  24512. /**
  24513. * Options passed when calling customShaderNameResolve
  24514. */
  24515. export interface ICustomShaderNameResolveOptions {
  24516. /**
  24517. * 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
  24518. */
  24519. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24520. }
  24521. /**
  24522. * Base class for the main features of a material in Babylon.js
  24523. */
  24524. export class Material implements IAnimatable {
  24525. /**
  24526. * Returns the triangle fill mode
  24527. */
  24528. static readonly TriangleFillMode: number;
  24529. /**
  24530. * Returns the wireframe mode
  24531. */
  24532. static readonly WireFrameFillMode: number;
  24533. /**
  24534. * Returns the point fill mode
  24535. */
  24536. static readonly PointFillMode: number;
  24537. /**
  24538. * Returns the point list draw mode
  24539. */
  24540. static readonly PointListDrawMode: number;
  24541. /**
  24542. * Returns the line list draw mode
  24543. */
  24544. static readonly LineListDrawMode: number;
  24545. /**
  24546. * Returns the line loop draw mode
  24547. */
  24548. static readonly LineLoopDrawMode: number;
  24549. /**
  24550. * Returns the line strip draw mode
  24551. */
  24552. static readonly LineStripDrawMode: number;
  24553. /**
  24554. * Returns the triangle strip draw mode
  24555. */
  24556. static readonly TriangleStripDrawMode: number;
  24557. /**
  24558. * Returns the triangle fan draw mode
  24559. */
  24560. static readonly TriangleFanDrawMode: number;
  24561. /**
  24562. * Stores the clock-wise side orientation
  24563. */
  24564. static readonly ClockWiseSideOrientation: number;
  24565. /**
  24566. * Stores the counter clock-wise side orientation
  24567. */
  24568. static readonly CounterClockWiseSideOrientation: number;
  24569. /**
  24570. * The dirty texture flag value
  24571. */
  24572. static readonly TextureDirtyFlag: number;
  24573. /**
  24574. * The dirty light flag value
  24575. */
  24576. static readonly LightDirtyFlag: number;
  24577. /**
  24578. * The dirty fresnel flag value
  24579. */
  24580. static readonly FresnelDirtyFlag: number;
  24581. /**
  24582. * The dirty attribute flag value
  24583. */
  24584. static readonly AttributesDirtyFlag: number;
  24585. /**
  24586. * The dirty misc flag value
  24587. */
  24588. static readonly MiscDirtyFlag: number;
  24589. /**
  24590. * The all dirty flag value
  24591. */
  24592. static readonly AllDirtyFlag: number;
  24593. /**
  24594. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24595. */
  24596. static readonly MATERIAL_OPAQUE: number;
  24597. /**
  24598. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24599. */
  24600. static readonly MATERIAL_ALPHATEST: number;
  24601. /**
  24602. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24603. */
  24604. static readonly MATERIAL_ALPHABLEND: number;
  24605. /**
  24606. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24607. * They are also discarded below the alpha cutoff threshold to improve performances.
  24608. */
  24609. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24610. /**
  24611. * The Whiteout method is used to blend normals.
  24612. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24613. */
  24614. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24615. /**
  24616. * The Reoriented Normal Mapping method is used to blend normals.
  24617. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24618. */
  24619. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24620. /**
  24621. * Custom callback helping to override the default shader used in the material.
  24622. */
  24623. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24624. /**
  24625. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24626. */
  24627. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24628. /**
  24629. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24630. * This means that the material can keep using a previous shader while a new one is being compiled.
  24631. * This is mostly used when shader parallel compilation is supported (true by default)
  24632. */
  24633. allowShaderHotSwapping: boolean;
  24634. /**
  24635. * The ID of the material
  24636. */
  24637. id: string;
  24638. /**
  24639. * Gets or sets the unique id of the material
  24640. */
  24641. uniqueId: number;
  24642. /**
  24643. * The name of the material
  24644. */
  24645. name: string;
  24646. /**
  24647. * Gets or sets user defined metadata
  24648. */
  24649. metadata: any;
  24650. /**
  24651. * For internal use only. Please do not use.
  24652. */
  24653. reservedDataStore: any;
  24654. /**
  24655. * Specifies if the ready state should be checked on each call
  24656. */
  24657. checkReadyOnEveryCall: boolean;
  24658. /**
  24659. * Specifies if the ready state should be checked once
  24660. */
  24661. checkReadyOnlyOnce: boolean;
  24662. /**
  24663. * The state of the material
  24664. */
  24665. state: string;
  24666. /**
  24667. * If the material can be rendered to several textures with MRT extension
  24668. */
  24669. get canRenderToMRT(): boolean;
  24670. /**
  24671. * The alpha value of the material
  24672. */
  24673. protected _alpha: number;
  24674. /**
  24675. * List of inspectable custom properties (used by the Inspector)
  24676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24677. */
  24678. inspectableCustomProperties: IInspectable[];
  24679. /**
  24680. * Sets the alpha value of the material
  24681. */
  24682. set alpha(value: number);
  24683. /**
  24684. * Gets the alpha value of the material
  24685. */
  24686. get alpha(): number;
  24687. /**
  24688. * Specifies if back face culling is enabled
  24689. */
  24690. protected _backFaceCulling: boolean;
  24691. /**
  24692. * Sets the back-face culling state
  24693. */
  24694. set backFaceCulling(value: boolean);
  24695. /**
  24696. * Gets the back-face culling state
  24697. */
  24698. get backFaceCulling(): boolean;
  24699. /**
  24700. * Stores the value for side orientation
  24701. */
  24702. sideOrientation: number;
  24703. /**
  24704. * Callback triggered when the material is compiled
  24705. */
  24706. onCompiled: Nullable<(effect: Effect) => void>;
  24707. /**
  24708. * Callback triggered when an error occurs
  24709. */
  24710. onError: Nullable<(effect: Effect, errors: string) => void>;
  24711. /**
  24712. * Callback triggered to get the render target textures
  24713. */
  24714. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24715. /**
  24716. * Gets a boolean indicating that current material needs to register RTT
  24717. */
  24718. get hasRenderTargetTextures(): boolean;
  24719. /**
  24720. * Specifies if the material should be serialized
  24721. */
  24722. doNotSerialize: boolean;
  24723. /**
  24724. * @hidden
  24725. */
  24726. _storeEffectOnSubMeshes: boolean;
  24727. /**
  24728. * Stores the animations for the material
  24729. */
  24730. animations: Nullable<Array<Animation>>;
  24731. /**
  24732. * An event triggered when the material is disposed
  24733. */
  24734. onDisposeObservable: Observable<Material>;
  24735. /**
  24736. * An observer which watches for dispose events
  24737. */
  24738. private _onDisposeObserver;
  24739. private _onUnBindObservable;
  24740. /**
  24741. * Called during a dispose event
  24742. */
  24743. set onDispose(callback: () => void);
  24744. private _onBindObservable;
  24745. /**
  24746. * An event triggered when the material is bound
  24747. */
  24748. get onBindObservable(): Observable<AbstractMesh>;
  24749. /**
  24750. * An observer which watches for bind events
  24751. */
  24752. private _onBindObserver;
  24753. /**
  24754. * Called during a bind event
  24755. */
  24756. set onBind(callback: (Mesh: AbstractMesh) => void);
  24757. /**
  24758. * An event triggered when the material is unbound
  24759. */
  24760. get onUnBindObservable(): Observable<Material>;
  24761. protected _onEffectCreatedObservable: Nullable<Observable<{
  24762. effect: Effect;
  24763. subMesh: Nullable<SubMesh>;
  24764. }>>;
  24765. /**
  24766. * An event triggered when the effect is (re)created
  24767. */
  24768. get onEffectCreatedObservable(): Observable<{
  24769. effect: Effect;
  24770. subMesh: Nullable<SubMesh>;
  24771. }>;
  24772. /**
  24773. * Stores the value of the alpha mode
  24774. */
  24775. private _alphaMode;
  24776. /**
  24777. * Sets the value of the alpha mode.
  24778. *
  24779. * | Value | Type | Description |
  24780. * | --- | --- | --- |
  24781. * | 0 | ALPHA_DISABLE | |
  24782. * | 1 | ALPHA_ADD | |
  24783. * | 2 | ALPHA_COMBINE | |
  24784. * | 3 | ALPHA_SUBTRACT | |
  24785. * | 4 | ALPHA_MULTIPLY | |
  24786. * | 5 | ALPHA_MAXIMIZED | |
  24787. * | 6 | ALPHA_ONEONE | |
  24788. * | 7 | ALPHA_PREMULTIPLIED | |
  24789. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24790. * | 9 | ALPHA_INTERPOLATE | |
  24791. * | 10 | ALPHA_SCREENMODE | |
  24792. *
  24793. */
  24794. set alphaMode(value: number);
  24795. /**
  24796. * Gets the value of the alpha mode
  24797. */
  24798. get alphaMode(): number;
  24799. /**
  24800. * Stores the state of the need depth pre-pass value
  24801. */
  24802. private _needDepthPrePass;
  24803. /**
  24804. * Sets the need depth pre-pass value
  24805. */
  24806. set needDepthPrePass(value: boolean);
  24807. /**
  24808. * Gets the depth pre-pass value
  24809. */
  24810. get needDepthPrePass(): boolean;
  24811. /**
  24812. * Specifies if depth writing should be disabled
  24813. */
  24814. disableDepthWrite: boolean;
  24815. /**
  24816. * Specifies if color writing should be disabled
  24817. */
  24818. disableColorWrite: boolean;
  24819. /**
  24820. * Specifies if depth writing should be forced
  24821. */
  24822. forceDepthWrite: boolean;
  24823. /**
  24824. * Specifies the depth function that should be used. 0 means the default engine function
  24825. */
  24826. depthFunction: number;
  24827. /**
  24828. * Specifies if there should be a separate pass for culling
  24829. */
  24830. separateCullingPass: boolean;
  24831. /**
  24832. * Stores the state specifing if fog should be enabled
  24833. */
  24834. private _fogEnabled;
  24835. /**
  24836. * Sets the state for enabling fog
  24837. */
  24838. set fogEnabled(value: boolean);
  24839. /**
  24840. * Gets the value of the fog enabled state
  24841. */
  24842. get fogEnabled(): boolean;
  24843. /**
  24844. * Stores the size of points
  24845. */
  24846. pointSize: number;
  24847. /**
  24848. * Stores the z offset value
  24849. */
  24850. zOffset: number;
  24851. get wireframe(): boolean;
  24852. /**
  24853. * Sets the state of wireframe mode
  24854. */
  24855. set wireframe(value: boolean);
  24856. /**
  24857. * Gets the value specifying if point clouds are enabled
  24858. */
  24859. get pointsCloud(): boolean;
  24860. /**
  24861. * Sets the state of point cloud mode
  24862. */
  24863. set pointsCloud(value: boolean);
  24864. /**
  24865. * Gets the material fill mode
  24866. */
  24867. get fillMode(): number;
  24868. /**
  24869. * Sets the material fill mode
  24870. */
  24871. set fillMode(value: number);
  24872. /**
  24873. * @hidden
  24874. * Stores the effects for the material
  24875. */
  24876. _effect: Nullable<Effect>;
  24877. /**
  24878. * Specifies if uniform buffers should be used
  24879. */
  24880. private _useUBO;
  24881. /**
  24882. * Stores a reference to the scene
  24883. */
  24884. private _scene;
  24885. /**
  24886. * Stores the fill mode state
  24887. */
  24888. private _fillMode;
  24889. /**
  24890. * Specifies if the depth write state should be cached
  24891. */
  24892. private _cachedDepthWriteState;
  24893. /**
  24894. * Specifies if the color write state should be cached
  24895. */
  24896. private _cachedColorWriteState;
  24897. /**
  24898. * Specifies if the depth function state should be cached
  24899. */
  24900. private _cachedDepthFunctionState;
  24901. /**
  24902. * Stores the uniform buffer
  24903. */
  24904. protected _uniformBuffer: UniformBuffer;
  24905. /** @hidden */
  24906. _indexInSceneMaterialArray: number;
  24907. /** @hidden */
  24908. meshMap: Nullable<{
  24909. [id: string]: AbstractMesh | undefined;
  24910. }>;
  24911. /**
  24912. * Creates a material instance
  24913. * @param name defines the name of the material
  24914. * @param scene defines the scene to reference
  24915. * @param doNotAdd specifies if the material should be added to the scene
  24916. */
  24917. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24918. /**
  24919. * Returns a string representation of the current material
  24920. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24921. * @returns a string with material information
  24922. */
  24923. toString(fullDetails?: boolean): string;
  24924. /**
  24925. * Gets the class name of the material
  24926. * @returns a string with the class name of the material
  24927. */
  24928. getClassName(): string;
  24929. /**
  24930. * Specifies if updates for the material been locked
  24931. */
  24932. get isFrozen(): boolean;
  24933. /**
  24934. * Locks updates for the material
  24935. */
  24936. freeze(): void;
  24937. /**
  24938. * Unlocks updates for the material
  24939. */
  24940. unfreeze(): void;
  24941. /**
  24942. * Specifies if the material is ready to be used
  24943. * @param mesh defines the mesh to check
  24944. * @param useInstances specifies if instances should be used
  24945. * @returns a boolean indicating if the material is ready to be used
  24946. */
  24947. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24948. /**
  24949. * Specifies that the submesh is ready to be used
  24950. * @param mesh defines the mesh to check
  24951. * @param subMesh defines which submesh to check
  24952. * @param useInstances specifies that instances should be used
  24953. * @returns a boolean indicating that the submesh is ready or not
  24954. */
  24955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24956. /**
  24957. * Returns the material effect
  24958. * @returns the effect associated with the material
  24959. */
  24960. getEffect(): Nullable<Effect>;
  24961. /**
  24962. * Returns the current scene
  24963. * @returns a Scene
  24964. */
  24965. getScene(): Scene;
  24966. /**
  24967. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24968. */
  24969. protected _forceAlphaTest: boolean;
  24970. /**
  24971. * The transparency mode of the material.
  24972. */
  24973. protected _transparencyMode: Nullable<number>;
  24974. /**
  24975. * Gets the current transparency mode.
  24976. */
  24977. get transparencyMode(): Nullable<number>;
  24978. /**
  24979. * Sets the transparency mode of the material.
  24980. *
  24981. * | Value | Type | Description |
  24982. * | ----- | ----------------------------------- | ----------- |
  24983. * | 0 | OPAQUE | |
  24984. * | 1 | ALPHATEST | |
  24985. * | 2 | ALPHABLEND | |
  24986. * | 3 | ALPHATESTANDBLEND | |
  24987. *
  24988. */
  24989. set transparencyMode(value: Nullable<number>);
  24990. /**
  24991. * Returns true if alpha blending should be disabled.
  24992. */
  24993. protected get _disableAlphaBlending(): boolean;
  24994. /**
  24995. * Specifies whether or not this material should be rendered in alpha blend mode.
  24996. * @returns a boolean specifying if alpha blending is needed
  24997. */
  24998. needAlphaBlending(): boolean;
  24999. /**
  25000. * Specifies if the mesh will require alpha blending
  25001. * @param mesh defines the mesh to check
  25002. * @returns a boolean specifying if alpha blending is needed for the mesh
  25003. */
  25004. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25005. /**
  25006. * Specifies whether or not this material should be rendered in alpha test mode.
  25007. * @returns a boolean specifying if an alpha test is needed.
  25008. */
  25009. needAlphaTesting(): boolean;
  25010. /**
  25011. * Specifies if material alpha testing should be turned on for the mesh
  25012. * @param mesh defines the mesh to check
  25013. */
  25014. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25015. /**
  25016. * Gets the texture used for the alpha test
  25017. * @returns the texture to use for alpha testing
  25018. */
  25019. getAlphaTestTexture(): Nullable<BaseTexture>;
  25020. /**
  25021. * Marks the material to indicate that it needs to be re-calculated
  25022. */
  25023. markDirty(): void;
  25024. /** @hidden */
  25025. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25026. /**
  25027. * Binds the material to the mesh
  25028. * @param world defines the world transformation matrix
  25029. * @param mesh defines the mesh to bind the material to
  25030. */
  25031. bind(world: Matrix, mesh?: Mesh): void;
  25032. /**
  25033. * Binds the submesh to the material
  25034. * @param world defines the world transformation matrix
  25035. * @param mesh defines the mesh containing the submesh
  25036. * @param subMesh defines the submesh to bind the material to
  25037. */
  25038. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25039. /**
  25040. * Binds the world matrix to the material
  25041. * @param world defines the world transformation matrix
  25042. */
  25043. bindOnlyWorldMatrix(world: Matrix): void;
  25044. /**
  25045. * Binds the scene's uniform buffer to the effect.
  25046. * @param effect defines the effect to bind to the scene uniform buffer
  25047. * @param sceneUbo defines the uniform buffer storing scene data
  25048. */
  25049. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25050. /**
  25051. * Binds the view matrix to the effect
  25052. * @param effect defines the effect to bind the view matrix to
  25053. */
  25054. bindView(effect: Effect): void;
  25055. /**
  25056. * Binds the view projection matrix to the effect
  25057. * @param effect defines the effect to bind the view projection matrix to
  25058. */
  25059. bindViewProjection(effect: Effect): void;
  25060. /**
  25061. * Processes to execute after binding the material to a mesh
  25062. * @param mesh defines the rendered mesh
  25063. */
  25064. protected _afterBind(mesh?: Mesh): void;
  25065. /**
  25066. * Unbinds the material from the mesh
  25067. */
  25068. unbind(): void;
  25069. /**
  25070. * Gets the active textures from the material
  25071. * @returns an array of textures
  25072. */
  25073. getActiveTextures(): BaseTexture[];
  25074. /**
  25075. * Specifies if the material uses a texture
  25076. * @param texture defines the texture to check against the material
  25077. * @returns a boolean specifying if the material uses the texture
  25078. */
  25079. hasTexture(texture: BaseTexture): boolean;
  25080. /**
  25081. * Makes a duplicate of the material, and gives it a new name
  25082. * @param name defines the new name for the duplicated material
  25083. * @returns the cloned material
  25084. */
  25085. clone(name: string): Nullable<Material>;
  25086. /**
  25087. * Gets the meshes bound to the material
  25088. * @returns an array of meshes bound to the material
  25089. */
  25090. getBindedMeshes(): AbstractMesh[];
  25091. /**
  25092. * Force shader compilation
  25093. * @param mesh defines the mesh associated with this material
  25094. * @param onCompiled defines a function to execute once the material is compiled
  25095. * @param options defines the options to configure the compilation
  25096. * @param onError defines a function to execute if the material fails compiling
  25097. */
  25098. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25099. /**
  25100. * Force shader compilation
  25101. * @param mesh defines the mesh that will use this material
  25102. * @param options defines additional options for compiling the shaders
  25103. * @returns a promise that resolves when the compilation completes
  25104. */
  25105. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25106. private static readonly _AllDirtyCallBack;
  25107. private static readonly _ImageProcessingDirtyCallBack;
  25108. private static readonly _TextureDirtyCallBack;
  25109. private static readonly _FresnelDirtyCallBack;
  25110. private static readonly _MiscDirtyCallBack;
  25111. private static readonly _LightsDirtyCallBack;
  25112. private static readonly _AttributeDirtyCallBack;
  25113. private static _FresnelAndMiscDirtyCallBack;
  25114. private static _TextureAndMiscDirtyCallBack;
  25115. private static readonly _DirtyCallbackArray;
  25116. private static readonly _RunDirtyCallBacks;
  25117. /**
  25118. * Marks a define in the material to indicate that it needs to be re-computed
  25119. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25120. */
  25121. markAsDirty(flag: number): void;
  25122. /**
  25123. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25124. * @param func defines a function which checks material defines against the submeshes
  25125. */
  25126. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25127. /**
  25128. * Indicates that the scene should check if the rendering now needs a prepass
  25129. */
  25130. protected _markScenePrePassDirty(): void;
  25131. /**
  25132. * Indicates that we need to re-calculated for all submeshes
  25133. */
  25134. protected _markAllSubMeshesAsAllDirty(): void;
  25135. /**
  25136. * Indicates that image processing needs to be re-calculated for all submeshes
  25137. */
  25138. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25139. /**
  25140. * Indicates that textures need to be re-calculated for all submeshes
  25141. */
  25142. protected _markAllSubMeshesAsTexturesDirty(): void;
  25143. /**
  25144. * Indicates that fresnel needs to be re-calculated for all submeshes
  25145. */
  25146. protected _markAllSubMeshesAsFresnelDirty(): void;
  25147. /**
  25148. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25149. */
  25150. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25151. /**
  25152. * Indicates that lights need to be re-calculated for all submeshes
  25153. */
  25154. protected _markAllSubMeshesAsLightsDirty(): void;
  25155. /**
  25156. * Indicates that attributes need to be re-calculated for all submeshes
  25157. */
  25158. protected _markAllSubMeshesAsAttributesDirty(): void;
  25159. /**
  25160. * Indicates that misc needs to be re-calculated for all submeshes
  25161. */
  25162. protected _markAllSubMeshesAsMiscDirty(): void;
  25163. /**
  25164. * Indicates that textures and misc need to be re-calculated for all submeshes
  25165. */
  25166. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25167. /**
  25168. * Sets the required values to the prepass renderer.
  25169. * @param prePassRenderer defines the prepass renderer to setup.
  25170. * @returns true if the pre pass is needed.
  25171. */
  25172. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25173. /**
  25174. * Disposes the material
  25175. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25176. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25177. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25178. */
  25179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25180. /** @hidden */
  25181. private releaseVertexArrayObject;
  25182. /**
  25183. * Serializes this material
  25184. * @returns the serialized material object
  25185. */
  25186. serialize(): any;
  25187. /**
  25188. * Creates a material from parsed material data
  25189. * @param parsedMaterial defines parsed material data
  25190. * @param scene defines the hosting scene
  25191. * @param rootUrl defines the root URL to use to load textures
  25192. * @returns a new material
  25193. */
  25194. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25195. }
  25196. }
  25197. declare module BABYLON {
  25198. /**
  25199. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25200. * separate meshes. This can be use to improve performances.
  25201. * @see https://doc.babylonjs.com/how_to/multi_materials
  25202. */
  25203. export class MultiMaterial extends Material {
  25204. private _subMaterials;
  25205. /**
  25206. * Gets or Sets the list of Materials used within the multi material.
  25207. * They need to be ordered according to the submeshes order in the associated mesh
  25208. */
  25209. get subMaterials(): Nullable<Material>[];
  25210. set subMaterials(value: Nullable<Material>[]);
  25211. /**
  25212. * Function used to align with Node.getChildren()
  25213. * @returns the list of Materials used within the multi material
  25214. */
  25215. getChildren(): Nullable<Material>[];
  25216. /**
  25217. * Instantiates a new Multi Material
  25218. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25219. * separate meshes. This can be use to improve performances.
  25220. * @see https://doc.babylonjs.com/how_to/multi_materials
  25221. * @param name Define the name in the scene
  25222. * @param scene Define the scene the material belongs to
  25223. */
  25224. constructor(name: string, scene: Scene);
  25225. private _hookArray;
  25226. /**
  25227. * Get one of the submaterial by its index in the submaterials array
  25228. * @param index The index to look the sub material at
  25229. * @returns The Material if the index has been defined
  25230. */
  25231. getSubMaterial(index: number): Nullable<Material>;
  25232. /**
  25233. * Get the list of active textures for the whole sub materials list.
  25234. * @returns All the textures that will be used during the rendering
  25235. */
  25236. getActiveTextures(): BaseTexture[];
  25237. /**
  25238. * Gets the current class name of the material e.g. "MultiMaterial"
  25239. * Mainly use in serialization.
  25240. * @returns the class name
  25241. */
  25242. getClassName(): string;
  25243. /**
  25244. * Checks if the material is ready to render the requested sub mesh
  25245. * @param mesh Define the mesh the submesh belongs to
  25246. * @param subMesh Define the sub mesh to look readyness for
  25247. * @param useInstances Define whether or not the material is used with instances
  25248. * @returns true if ready, otherwise false
  25249. */
  25250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25251. /**
  25252. * Clones the current material and its related sub materials
  25253. * @param name Define the name of the newly cloned material
  25254. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25255. * @returns the cloned material
  25256. */
  25257. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25258. /**
  25259. * Serializes the materials into a JSON representation.
  25260. * @returns the JSON representation
  25261. */
  25262. serialize(): any;
  25263. /**
  25264. * Dispose the material and release its associated resources
  25265. * @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)
  25266. * @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)
  25267. * @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)
  25268. */
  25269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25270. /**
  25271. * Creates a MultiMaterial from parsed MultiMaterial data.
  25272. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25273. * @param scene defines the hosting scene
  25274. * @returns a new MultiMaterial
  25275. */
  25276. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25277. }
  25278. }
  25279. declare module BABYLON {
  25280. /**
  25281. * Defines a subdivision inside a mesh
  25282. */
  25283. export class SubMesh implements ICullable {
  25284. /** the material index to use */
  25285. materialIndex: number;
  25286. /** vertex index start */
  25287. verticesStart: number;
  25288. /** vertices count */
  25289. verticesCount: number;
  25290. /** index start */
  25291. indexStart: number;
  25292. /** indices count */
  25293. indexCount: number;
  25294. /** @hidden */
  25295. _materialDefines: Nullable<MaterialDefines>;
  25296. /** @hidden */
  25297. _materialEffect: Nullable<Effect>;
  25298. /** @hidden */
  25299. _effectOverride: Nullable<Effect>;
  25300. /**
  25301. * Gets material defines used by the effect associated to the sub mesh
  25302. */
  25303. get materialDefines(): Nullable<MaterialDefines>;
  25304. /**
  25305. * Sets material defines used by the effect associated to the sub mesh
  25306. */
  25307. set materialDefines(defines: Nullable<MaterialDefines>);
  25308. /**
  25309. * Gets associated effect
  25310. */
  25311. get effect(): Nullable<Effect>;
  25312. /**
  25313. * Sets associated effect (effect used to render this submesh)
  25314. * @param effect defines the effect to associate with
  25315. * @param defines defines the set of defines used to compile this effect
  25316. */
  25317. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25318. /** @hidden */
  25319. _linesIndexCount: number;
  25320. private _mesh;
  25321. private _renderingMesh;
  25322. private _boundingInfo;
  25323. private _linesIndexBuffer;
  25324. /** @hidden */
  25325. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25326. /** @hidden */
  25327. _trianglePlanes: Plane[];
  25328. /** @hidden */
  25329. _lastColliderTransformMatrix: Nullable<Matrix>;
  25330. /** @hidden */
  25331. _renderId: number;
  25332. /** @hidden */
  25333. _alphaIndex: number;
  25334. /** @hidden */
  25335. _distanceToCamera: number;
  25336. /** @hidden */
  25337. _id: number;
  25338. private _currentMaterial;
  25339. /**
  25340. * Add a new submesh to a mesh
  25341. * @param materialIndex defines the material index to use
  25342. * @param verticesStart defines vertex index start
  25343. * @param verticesCount defines vertices count
  25344. * @param indexStart defines index start
  25345. * @param indexCount defines indices count
  25346. * @param mesh defines the parent mesh
  25347. * @param renderingMesh defines an optional rendering mesh
  25348. * @param createBoundingBox defines if bounding box should be created for this submesh
  25349. * @returns the new submesh
  25350. */
  25351. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25352. /**
  25353. * Creates a new submesh
  25354. * @param materialIndex defines the material index to use
  25355. * @param verticesStart defines vertex index start
  25356. * @param verticesCount defines vertices count
  25357. * @param indexStart defines index start
  25358. * @param indexCount defines indices count
  25359. * @param mesh defines the parent mesh
  25360. * @param renderingMesh defines an optional rendering mesh
  25361. * @param createBoundingBox defines if bounding box should be created for this submesh
  25362. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25363. */
  25364. constructor(
  25365. /** the material index to use */
  25366. materialIndex: number,
  25367. /** vertex index start */
  25368. verticesStart: number,
  25369. /** vertices count */
  25370. verticesCount: number,
  25371. /** index start */
  25372. indexStart: number,
  25373. /** indices count */
  25374. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25375. /**
  25376. * Returns true if this submesh covers the entire parent mesh
  25377. * @ignorenaming
  25378. */
  25379. get IsGlobal(): boolean;
  25380. /**
  25381. * Returns the submesh BoudingInfo object
  25382. * @returns current bounding info (or mesh's one if the submesh is global)
  25383. */
  25384. getBoundingInfo(): BoundingInfo;
  25385. /**
  25386. * Sets the submesh BoundingInfo
  25387. * @param boundingInfo defines the new bounding info to use
  25388. * @returns the SubMesh
  25389. */
  25390. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25391. /**
  25392. * Returns the mesh of the current submesh
  25393. * @return the parent mesh
  25394. */
  25395. getMesh(): AbstractMesh;
  25396. /**
  25397. * Returns the rendering mesh of the submesh
  25398. * @returns the rendering mesh (could be different from parent mesh)
  25399. */
  25400. getRenderingMesh(): Mesh;
  25401. /**
  25402. * Returns the replacement mesh of the submesh
  25403. * @returns the replacement mesh (could be different from parent mesh)
  25404. */
  25405. getReplacementMesh(): Nullable<AbstractMesh>;
  25406. /**
  25407. * Returns the effective mesh of the submesh
  25408. * @returns the effective mesh (could be different from parent mesh)
  25409. */
  25410. getEffectiveMesh(): AbstractMesh;
  25411. /**
  25412. * Returns the submesh material
  25413. * @returns null or the current material
  25414. */
  25415. getMaterial(): Nullable<Material>;
  25416. private _IsMultiMaterial;
  25417. /**
  25418. * Sets a new updated BoundingInfo object to the submesh
  25419. * @param data defines an optional position array to use to determine the bounding info
  25420. * @returns the SubMesh
  25421. */
  25422. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25423. /** @hidden */
  25424. _checkCollision(collider: Collider): boolean;
  25425. /**
  25426. * Updates the submesh BoundingInfo
  25427. * @param world defines the world matrix to use to update the bounding info
  25428. * @returns the submesh
  25429. */
  25430. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25431. /**
  25432. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25433. * @param frustumPlanes defines the frustum planes
  25434. * @returns true if the submesh is intersecting with the frustum
  25435. */
  25436. isInFrustum(frustumPlanes: Plane[]): boolean;
  25437. /**
  25438. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25439. * @param frustumPlanes defines the frustum planes
  25440. * @returns true if the submesh is inside the frustum
  25441. */
  25442. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25443. /**
  25444. * Renders the submesh
  25445. * @param enableAlphaMode defines if alpha needs to be used
  25446. * @returns the submesh
  25447. */
  25448. render(enableAlphaMode: boolean): SubMesh;
  25449. /**
  25450. * @hidden
  25451. */
  25452. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25453. /**
  25454. * Checks if the submesh intersects with a ray
  25455. * @param ray defines the ray to test
  25456. * @returns true is the passed ray intersects the submesh bounding box
  25457. */
  25458. canIntersects(ray: Ray): boolean;
  25459. /**
  25460. * Intersects current submesh with a ray
  25461. * @param ray defines the ray to test
  25462. * @param positions defines mesh's positions array
  25463. * @param indices defines mesh's indices array
  25464. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25465. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25466. * @returns intersection info or null if no intersection
  25467. */
  25468. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25469. /** @hidden */
  25470. private _intersectLines;
  25471. /** @hidden */
  25472. private _intersectUnIndexedLines;
  25473. /** @hidden */
  25474. private _intersectTriangles;
  25475. /** @hidden */
  25476. private _intersectUnIndexedTriangles;
  25477. /** @hidden */
  25478. _rebuild(): void;
  25479. /**
  25480. * Creates a new submesh from the passed mesh
  25481. * @param newMesh defines the new hosting mesh
  25482. * @param newRenderingMesh defines an optional rendering mesh
  25483. * @returns the new submesh
  25484. */
  25485. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25486. /**
  25487. * Release associated resources
  25488. */
  25489. dispose(): void;
  25490. /**
  25491. * Gets the class name
  25492. * @returns the string "SubMesh".
  25493. */
  25494. getClassName(): string;
  25495. /**
  25496. * Creates a new submesh from indices data
  25497. * @param materialIndex the index of the main mesh material
  25498. * @param startIndex the index where to start the copy in the mesh indices array
  25499. * @param indexCount the number of indices to copy then from the startIndex
  25500. * @param mesh the main mesh to create the submesh from
  25501. * @param renderingMesh the optional rendering mesh
  25502. * @returns a new submesh
  25503. */
  25504. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. /**
  25509. * Class used to represent data loading progression
  25510. */
  25511. export class SceneLoaderFlags {
  25512. private static _ForceFullSceneLoadingForIncremental;
  25513. private static _ShowLoadingScreen;
  25514. private static _CleanBoneMatrixWeights;
  25515. private static _loggingLevel;
  25516. /**
  25517. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25518. */
  25519. static get ForceFullSceneLoadingForIncremental(): boolean;
  25520. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25521. /**
  25522. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25523. */
  25524. static get ShowLoadingScreen(): boolean;
  25525. static set ShowLoadingScreen(value: boolean);
  25526. /**
  25527. * Defines the current logging level (while loading the scene)
  25528. * @ignorenaming
  25529. */
  25530. static get loggingLevel(): number;
  25531. static set loggingLevel(value: number);
  25532. /**
  25533. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25534. */
  25535. static get CleanBoneMatrixWeights(): boolean;
  25536. static set CleanBoneMatrixWeights(value: boolean);
  25537. }
  25538. }
  25539. declare module BABYLON {
  25540. /**
  25541. * Class used to store geometry data (vertex buffers + index buffer)
  25542. */
  25543. export class Geometry implements IGetSetVerticesData {
  25544. /**
  25545. * Gets or sets the ID of the geometry
  25546. */
  25547. id: string;
  25548. /**
  25549. * Gets or sets the unique ID of the geometry
  25550. */
  25551. uniqueId: number;
  25552. /**
  25553. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25554. */
  25555. delayLoadState: number;
  25556. /**
  25557. * Gets the file containing the data to load when running in delay load state
  25558. */
  25559. delayLoadingFile: Nullable<string>;
  25560. /**
  25561. * Callback called when the geometry is updated
  25562. */
  25563. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25564. private _scene;
  25565. private _engine;
  25566. private _meshes;
  25567. private _totalVertices;
  25568. /** @hidden */
  25569. _indices: IndicesArray;
  25570. /** @hidden */
  25571. _vertexBuffers: {
  25572. [key: string]: VertexBuffer;
  25573. };
  25574. private _isDisposed;
  25575. private _extend;
  25576. private _boundingBias;
  25577. /** @hidden */
  25578. _delayInfo: Array<string>;
  25579. private _indexBuffer;
  25580. private _indexBufferIsUpdatable;
  25581. /** @hidden */
  25582. _boundingInfo: Nullable<BoundingInfo>;
  25583. /** @hidden */
  25584. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25585. /** @hidden */
  25586. _softwareSkinningFrameId: number;
  25587. private _vertexArrayObjects;
  25588. private _updatable;
  25589. /** @hidden */
  25590. _positions: Nullable<Vector3[]>;
  25591. /**
  25592. * 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
  25593. */
  25594. get boundingBias(): Vector2;
  25595. /**
  25596. * 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
  25597. */
  25598. set boundingBias(value: Vector2);
  25599. /**
  25600. * Static function used to attach a new empty geometry to a mesh
  25601. * @param mesh defines the mesh to attach the geometry to
  25602. * @returns the new Geometry
  25603. */
  25604. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25605. /** Get the list of meshes using this geometry */
  25606. get meshes(): Mesh[];
  25607. /**
  25608. * 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
  25609. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25610. */
  25611. useBoundingInfoFromGeometry: boolean;
  25612. /**
  25613. * Creates a new geometry
  25614. * @param id defines the unique ID
  25615. * @param scene defines the hosting scene
  25616. * @param vertexData defines the VertexData used to get geometry data
  25617. * @param updatable defines if geometry must be updatable (false by default)
  25618. * @param mesh defines the mesh that will be associated with the geometry
  25619. */
  25620. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25621. /**
  25622. * Gets the current extend of the geometry
  25623. */
  25624. get extend(): {
  25625. minimum: Vector3;
  25626. maximum: Vector3;
  25627. };
  25628. /**
  25629. * Gets the hosting scene
  25630. * @returns the hosting Scene
  25631. */
  25632. getScene(): Scene;
  25633. /**
  25634. * Gets the hosting engine
  25635. * @returns the hosting Engine
  25636. */
  25637. getEngine(): Engine;
  25638. /**
  25639. * Defines if the geometry is ready to use
  25640. * @returns true if the geometry is ready to be used
  25641. */
  25642. isReady(): boolean;
  25643. /**
  25644. * Gets a value indicating that the geometry should not be serialized
  25645. */
  25646. get doNotSerialize(): boolean;
  25647. /** @hidden */
  25648. _rebuild(): void;
  25649. /**
  25650. * Affects all geometry data in one call
  25651. * @param vertexData defines the geometry data
  25652. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25653. */
  25654. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25655. /**
  25656. * Set specific vertex data
  25657. * @param kind defines the data kind (Position, normal, etc...)
  25658. * @param data defines the vertex data to use
  25659. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25660. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25661. */
  25662. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25663. /**
  25664. * Removes a specific vertex data
  25665. * @param kind defines the data kind (Position, normal, etc...)
  25666. */
  25667. removeVerticesData(kind: string): void;
  25668. /**
  25669. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25670. * @param buffer defines the vertex buffer to use
  25671. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25672. */
  25673. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25674. /**
  25675. * Update a specific vertex buffer
  25676. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25677. * It will do nothing if the buffer is not updatable
  25678. * @param kind defines the data kind (Position, normal, etc...)
  25679. * @param data defines the data to use
  25680. * @param offset defines the offset in the target buffer where to store the data
  25681. * @param useBytes set to true if the offset is in bytes
  25682. */
  25683. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25684. /**
  25685. * Update a specific vertex buffer
  25686. * This function will create a new buffer if the current one is not updatable
  25687. * @param kind defines the data kind (Position, normal, etc...)
  25688. * @param data defines the data to use
  25689. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25690. */
  25691. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25692. private _updateBoundingInfo;
  25693. /** @hidden */
  25694. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25695. /**
  25696. * Gets total number of vertices
  25697. * @returns the total number of vertices
  25698. */
  25699. getTotalVertices(): number;
  25700. /**
  25701. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25702. * @param kind defines the data kind (Position, normal, etc...)
  25703. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25704. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25705. * @returns a float array containing vertex data
  25706. */
  25707. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25708. /**
  25709. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25710. * @param kind defines the data kind (Position, normal, etc...)
  25711. * @returns true if the vertex buffer with the specified kind is updatable
  25712. */
  25713. isVertexBufferUpdatable(kind: string): boolean;
  25714. /**
  25715. * Gets a specific vertex buffer
  25716. * @param kind defines the data kind (Position, normal, etc...)
  25717. * @returns a VertexBuffer
  25718. */
  25719. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25720. /**
  25721. * Returns all vertex buffers
  25722. * @return an object holding all vertex buffers indexed by kind
  25723. */
  25724. getVertexBuffers(): Nullable<{
  25725. [key: string]: VertexBuffer;
  25726. }>;
  25727. /**
  25728. * Gets a boolean indicating if specific vertex buffer is present
  25729. * @param kind defines the data kind (Position, normal, etc...)
  25730. * @returns true if data is present
  25731. */
  25732. isVerticesDataPresent(kind: string): boolean;
  25733. /**
  25734. * Gets a list of all attached data kinds (Position, normal, etc...)
  25735. * @returns a list of string containing all kinds
  25736. */
  25737. getVerticesDataKinds(): string[];
  25738. /**
  25739. * Update index buffer
  25740. * @param indices defines the indices to store in the index buffer
  25741. * @param offset defines the offset in the target buffer where to store the data
  25742. * @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)
  25743. */
  25744. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25745. /**
  25746. * Creates a new index buffer
  25747. * @param indices defines the indices to store in the index buffer
  25748. * @param totalVertices defines the total number of vertices (could be null)
  25749. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25750. */
  25751. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25752. /**
  25753. * Return the total number of indices
  25754. * @returns the total number of indices
  25755. */
  25756. getTotalIndices(): number;
  25757. /**
  25758. * Gets the index buffer array
  25759. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25760. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25761. * @returns the index buffer array
  25762. */
  25763. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25764. /**
  25765. * Gets the index buffer
  25766. * @return the index buffer
  25767. */
  25768. getIndexBuffer(): Nullable<DataBuffer>;
  25769. /** @hidden */
  25770. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25771. /**
  25772. * Release the associated resources for a specific mesh
  25773. * @param mesh defines the source mesh
  25774. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25775. */
  25776. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25777. /**
  25778. * Apply current geometry to a given mesh
  25779. * @param mesh defines the mesh to apply geometry to
  25780. */
  25781. applyToMesh(mesh: Mesh): void;
  25782. private _updateExtend;
  25783. private _applyToMesh;
  25784. private notifyUpdate;
  25785. /**
  25786. * Load the geometry if it was flagged as delay loaded
  25787. * @param scene defines the hosting scene
  25788. * @param onLoaded defines a callback called when the geometry is loaded
  25789. */
  25790. load(scene: Scene, onLoaded?: () => void): void;
  25791. private _queueLoad;
  25792. /**
  25793. * Invert the geometry to move from a right handed system to a left handed one.
  25794. */
  25795. toLeftHanded(): void;
  25796. /** @hidden */
  25797. _resetPointsArrayCache(): void;
  25798. /** @hidden */
  25799. _generatePointsArray(): boolean;
  25800. /**
  25801. * Gets a value indicating if the geometry is disposed
  25802. * @returns true if the geometry was disposed
  25803. */
  25804. isDisposed(): boolean;
  25805. private _disposeVertexArrayObjects;
  25806. /**
  25807. * Free all associated resources
  25808. */
  25809. dispose(): void;
  25810. /**
  25811. * Clone the current geometry into a new geometry
  25812. * @param id defines the unique ID of the new geometry
  25813. * @returns a new geometry object
  25814. */
  25815. copy(id: string): Geometry;
  25816. /**
  25817. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25818. * @return a JSON representation of the current geometry data (without the vertices data)
  25819. */
  25820. serialize(): any;
  25821. private toNumberArray;
  25822. /**
  25823. * Serialize all vertices data into a JSON oject
  25824. * @returns a JSON representation of the current geometry data
  25825. */
  25826. serializeVerticeData(): any;
  25827. /**
  25828. * Extracts a clone of a mesh geometry
  25829. * @param mesh defines the source mesh
  25830. * @param id defines the unique ID of the new geometry object
  25831. * @returns the new geometry object
  25832. */
  25833. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25834. /**
  25835. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25836. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25837. * Be aware Math.random() could cause collisions, but:
  25838. * "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"
  25839. * @returns a string containing a new GUID
  25840. */
  25841. static RandomId(): string;
  25842. /** @hidden */
  25843. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25844. private static _CleanMatricesWeights;
  25845. /**
  25846. * Create a new geometry from persisted data (Using .babylon file format)
  25847. * @param parsedVertexData defines the persisted data
  25848. * @param scene defines the hosting scene
  25849. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25850. * @returns the new geometry object
  25851. */
  25852. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25853. }
  25854. }
  25855. declare module BABYLON {
  25856. /**
  25857. * Define an interface for all classes that will get and set the data on vertices
  25858. */
  25859. export interface IGetSetVerticesData {
  25860. /**
  25861. * Gets a boolean indicating if specific vertex data is present
  25862. * @param kind defines the vertex data kind to use
  25863. * @returns true is data kind is present
  25864. */
  25865. isVerticesDataPresent(kind: string): boolean;
  25866. /**
  25867. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25868. * @param kind defines the data kind (Position, normal, etc...)
  25869. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25870. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25871. * @returns a float array containing vertex data
  25872. */
  25873. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25874. /**
  25875. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25876. * @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.
  25877. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25878. * @returns the indices array or an empty array if the mesh has no geometry
  25879. */
  25880. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25881. /**
  25882. * Set specific vertex data
  25883. * @param kind defines the data kind (Position, normal, etc...)
  25884. * @param data defines the vertex data to use
  25885. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25886. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25887. */
  25888. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25889. /**
  25890. * Update a specific associated vertex buffer
  25891. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25892. * - VertexBuffer.PositionKind
  25893. * - VertexBuffer.UVKind
  25894. * - VertexBuffer.UV2Kind
  25895. * - VertexBuffer.UV3Kind
  25896. * - VertexBuffer.UV4Kind
  25897. * - VertexBuffer.UV5Kind
  25898. * - VertexBuffer.UV6Kind
  25899. * - VertexBuffer.ColorKind
  25900. * - VertexBuffer.MatricesIndicesKind
  25901. * - VertexBuffer.MatricesIndicesExtraKind
  25902. * - VertexBuffer.MatricesWeightsKind
  25903. * - VertexBuffer.MatricesWeightsExtraKind
  25904. * @param data defines the data source
  25905. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25906. * @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)
  25907. */
  25908. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25909. /**
  25910. * Creates a new index buffer
  25911. * @param indices defines the indices to store in the index buffer
  25912. * @param totalVertices defines the total number of vertices (could be null)
  25913. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25914. */
  25915. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25916. }
  25917. /**
  25918. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25919. */
  25920. export class VertexData {
  25921. /**
  25922. * Mesh side orientation : usually the external or front surface
  25923. */
  25924. static readonly FRONTSIDE: number;
  25925. /**
  25926. * Mesh side orientation : usually the internal or back surface
  25927. */
  25928. static readonly BACKSIDE: number;
  25929. /**
  25930. * Mesh side orientation : both internal and external or front and back surfaces
  25931. */
  25932. static readonly DOUBLESIDE: number;
  25933. /**
  25934. * Mesh side orientation : by default, `FRONTSIDE`
  25935. */
  25936. static readonly DEFAULTSIDE: number;
  25937. /**
  25938. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25939. */
  25940. positions: Nullable<FloatArray>;
  25941. /**
  25942. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25943. */
  25944. normals: Nullable<FloatArray>;
  25945. /**
  25946. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25947. */
  25948. tangents: Nullable<FloatArray>;
  25949. /**
  25950. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25951. */
  25952. uvs: Nullable<FloatArray>;
  25953. /**
  25954. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25955. */
  25956. uvs2: Nullable<FloatArray>;
  25957. /**
  25958. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25959. */
  25960. uvs3: Nullable<FloatArray>;
  25961. /**
  25962. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25963. */
  25964. uvs4: Nullable<FloatArray>;
  25965. /**
  25966. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25967. */
  25968. uvs5: Nullable<FloatArray>;
  25969. /**
  25970. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25971. */
  25972. uvs6: Nullable<FloatArray>;
  25973. /**
  25974. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25975. */
  25976. colors: Nullable<FloatArray>;
  25977. /**
  25978. * 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).
  25979. */
  25980. matricesIndices: Nullable<FloatArray>;
  25981. /**
  25982. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25983. */
  25984. matricesWeights: Nullable<FloatArray>;
  25985. /**
  25986. * An array extending the number of possible indices
  25987. */
  25988. matricesIndicesExtra: Nullable<FloatArray>;
  25989. /**
  25990. * An array extending the number of possible weights when the number of indices is extended
  25991. */
  25992. matricesWeightsExtra: Nullable<FloatArray>;
  25993. /**
  25994. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25995. */
  25996. indices: Nullable<IndicesArray>;
  25997. /**
  25998. * Uses the passed data array to set the set the values for the specified kind of data
  25999. * @param data a linear array of floating numbers
  26000. * @param kind the type of data that is being set, eg positions, colors etc
  26001. */
  26002. set(data: FloatArray, kind: string): void;
  26003. /**
  26004. * Associates the vertexData to the passed Mesh.
  26005. * Sets it as updatable or not (default `false`)
  26006. * @param mesh the mesh the vertexData is applied to
  26007. * @param updatable when used and having the value true allows new data to update the vertexData
  26008. * @returns the VertexData
  26009. */
  26010. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26011. /**
  26012. * Associates the vertexData to the passed Geometry.
  26013. * Sets it as updatable or not (default `false`)
  26014. * @param geometry the geometry the vertexData is applied to
  26015. * @param updatable when used and having the value true allows new data to update the vertexData
  26016. * @returns VertexData
  26017. */
  26018. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26019. /**
  26020. * Updates the associated mesh
  26021. * @param mesh the mesh to be updated
  26022. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26023. * @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
  26024. * @returns VertexData
  26025. */
  26026. updateMesh(mesh: Mesh): VertexData;
  26027. /**
  26028. * Updates the associated geometry
  26029. * @param geometry the geometry to be updated
  26030. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26031. * @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
  26032. * @returns VertexData.
  26033. */
  26034. updateGeometry(geometry: Geometry): VertexData;
  26035. private _applyTo;
  26036. private _update;
  26037. /**
  26038. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26039. * @param matrix the transforming matrix
  26040. * @returns the VertexData
  26041. */
  26042. transform(matrix: Matrix): VertexData;
  26043. /**
  26044. * Merges the passed VertexData into the current one
  26045. * @param other the VertexData to be merged into the current one
  26046. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26047. * @returns the modified VertexData
  26048. */
  26049. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26050. private _mergeElement;
  26051. private _validate;
  26052. /**
  26053. * Serializes the VertexData
  26054. * @returns a serialized object
  26055. */
  26056. serialize(): any;
  26057. /**
  26058. * Extracts the vertexData from a mesh
  26059. * @param mesh the mesh from which to extract the VertexData
  26060. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26061. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26062. * @returns the object VertexData associated to the passed mesh
  26063. */
  26064. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26065. /**
  26066. * Extracts the vertexData from the geometry
  26067. * @param geometry the geometry from which to extract the VertexData
  26068. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26069. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26070. * @returns the object VertexData associated to the passed mesh
  26071. */
  26072. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26073. private static _ExtractFrom;
  26074. /**
  26075. * Creates the VertexData for a Ribbon
  26076. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26077. * * pathArray array of paths, each of which an array of successive Vector3
  26078. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26079. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26080. * * 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
  26081. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26082. * * 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)
  26083. * * 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)
  26084. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26085. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26086. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26087. * @returns the VertexData of the ribbon
  26088. */
  26089. static CreateRibbon(options: {
  26090. pathArray: Vector3[][];
  26091. closeArray?: boolean;
  26092. closePath?: boolean;
  26093. offset?: number;
  26094. sideOrientation?: number;
  26095. frontUVs?: Vector4;
  26096. backUVs?: Vector4;
  26097. invertUV?: boolean;
  26098. uvs?: Vector2[];
  26099. colors?: Color4[];
  26100. }): VertexData;
  26101. /**
  26102. * Creates the VertexData for a box
  26103. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26104. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26105. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26106. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26107. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26108. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26109. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26111. * * 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)
  26112. * * 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)
  26113. * @returns the VertexData of the box
  26114. */
  26115. static CreateBox(options: {
  26116. size?: number;
  26117. width?: number;
  26118. height?: number;
  26119. depth?: number;
  26120. faceUV?: Vector4[];
  26121. faceColors?: Color4[];
  26122. sideOrientation?: number;
  26123. frontUVs?: Vector4;
  26124. backUVs?: Vector4;
  26125. }): VertexData;
  26126. /**
  26127. * Creates the VertexData for a tiled box
  26128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26129. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26130. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26131. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26133. * @returns the VertexData of the box
  26134. */
  26135. static CreateTiledBox(options: {
  26136. pattern?: number;
  26137. width?: number;
  26138. height?: number;
  26139. depth?: number;
  26140. tileSize?: number;
  26141. tileWidth?: number;
  26142. tileHeight?: number;
  26143. alignHorizontal?: number;
  26144. alignVertical?: number;
  26145. faceUV?: Vector4[];
  26146. faceColors?: Color4[];
  26147. sideOrientation?: number;
  26148. }): VertexData;
  26149. /**
  26150. * Creates the VertexData for a tiled plane
  26151. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26152. * * pattern a limited pattern arrangement depending on the number
  26153. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26154. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26155. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26157. * * 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)
  26158. * * 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)
  26159. * @returns the VertexData of the tiled plane
  26160. */
  26161. static CreateTiledPlane(options: {
  26162. pattern?: number;
  26163. tileSize?: number;
  26164. tileWidth?: number;
  26165. tileHeight?: number;
  26166. size?: number;
  26167. width?: number;
  26168. height?: number;
  26169. alignHorizontal?: number;
  26170. alignVertical?: number;
  26171. sideOrientation?: number;
  26172. frontUVs?: Vector4;
  26173. backUVs?: Vector4;
  26174. }): VertexData;
  26175. /**
  26176. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26177. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26178. * * segments sets the number of horizontal strips optional, default 32
  26179. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26180. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26181. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26182. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26183. * * 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
  26184. * * 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
  26185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26186. * * 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)
  26187. * * 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)
  26188. * @returns the VertexData of the ellipsoid
  26189. */
  26190. static CreateSphere(options: {
  26191. segments?: number;
  26192. diameter?: number;
  26193. diameterX?: number;
  26194. diameterY?: number;
  26195. diameterZ?: number;
  26196. arc?: number;
  26197. slice?: number;
  26198. sideOrientation?: number;
  26199. frontUVs?: Vector4;
  26200. backUVs?: Vector4;
  26201. }): VertexData;
  26202. /**
  26203. * Creates the VertexData for a cylinder, cone or prism
  26204. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26205. * * height sets the height (y direction) of the cylinder, optional, default 2
  26206. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26207. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26208. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26209. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26210. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26211. * * 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
  26212. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26213. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26214. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26215. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26216. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26217. * * 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)
  26218. * * 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)
  26219. * @returns the VertexData of the cylinder, cone or prism
  26220. */
  26221. static CreateCylinder(options: {
  26222. height?: number;
  26223. diameterTop?: number;
  26224. diameterBottom?: number;
  26225. diameter?: number;
  26226. tessellation?: number;
  26227. subdivisions?: number;
  26228. arc?: number;
  26229. faceColors?: Color4[];
  26230. faceUV?: Vector4[];
  26231. hasRings?: boolean;
  26232. enclose?: boolean;
  26233. sideOrientation?: number;
  26234. frontUVs?: Vector4;
  26235. backUVs?: Vector4;
  26236. }): VertexData;
  26237. /**
  26238. * Creates the VertexData for a torus
  26239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26240. * * diameter the diameter of the torus, optional default 1
  26241. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26242. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26244. * * 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)
  26245. * * 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)
  26246. * @returns the VertexData of the torus
  26247. */
  26248. static CreateTorus(options: {
  26249. diameter?: number;
  26250. thickness?: number;
  26251. tessellation?: number;
  26252. sideOrientation?: number;
  26253. frontUVs?: Vector4;
  26254. backUVs?: Vector4;
  26255. }): VertexData;
  26256. /**
  26257. * Creates the VertexData of the LineSystem
  26258. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26259. * - lines an array of lines, each line being an array of successive Vector3
  26260. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26261. * @returns the VertexData of the LineSystem
  26262. */
  26263. static CreateLineSystem(options: {
  26264. lines: Vector3[][];
  26265. colors?: Nullable<Color4[][]>;
  26266. }): VertexData;
  26267. /**
  26268. * Create the VertexData for a DashedLines
  26269. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26270. * - points an array successive Vector3
  26271. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26272. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26273. * - dashNb the intended total number of dashes, optional, default 200
  26274. * @returns the VertexData for the DashedLines
  26275. */
  26276. static CreateDashedLines(options: {
  26277. points: Vector3[];
  26278. dashSize?: number;
  26279. gapSize?: number;
  26280. dashNb?: number;
  26281. }): VertexData;
  26282. /**
  26283. * Creates the VertexData for a Ground
  26284. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26285. * - width the width (x direction) of the ground, optional, default 1
  26286. * - height the height (z direction) of the ground, optional, default 1
  26287. * - subdivisions the number of subdivisions per side, optional, default 1
  26288. * @returns the VertexData of the Ground
  26289. */
  26290. static CreateGround(options: {
  26291. width?: number;
  26292. height?: number;
  26293. subdivisions?: number;
  26294. subdivisionsX?: number;
  26295. subdivisionsY?: number;
  26296. }): VertexData;
  26297. /**
  26298. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26299. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26300. * * xmin the ground minimum X coordinate, optional, default -1
  26301. * * zmin the ground minimum Z coordinate, optional, default -1
  26302. * * xmax the ground maximum X coordinate, optional, default 1
  26303. * * zmax the ground maximum Z coordinate, optional, default 1
  26304. * * 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}
  26305. * * 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}
  26306. * @returns the VertexData of the TiledGround
  26307. */
  26308. static CreateTiledGround(options: {
  26309. xmin: number;
  26310. zmin: number;
  26311. xmax: number;
  26312. zmax: number;
  26313. subdivisions?: {
  26314. w: number;
  26315. h: number;
  26316. };
  26317. precision?: {
  26318. w: number;
  26319. h: number;
  26320. };
  26321. }): VertexData;
  26322. /**
  26323. * Creates the VertexData of the Ground designed from a heightmap
  26324. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26325. * * width the width (x direction) of the ground
  26326. * * height the height (z direction) of the ground
  26327. * * subdivisions the number of subdivisions per side
  26328. * * minHeight the minimum altitude on the ground, optional, default 0
  26329. * * maxHeight the maximum altitude on the ground, optional default 1
  26330. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26331. * * buffer the array holding the image color data
  26332. * * bufferWidth the width of image
  26333. * * bufferHeight the height of image
  26334. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26335. * @returns the VertexData of the Ground designed from a heightmap
  26336. */
  26337. static CreateGroundFromHeightMap(options: {
  26338. width: number;
  26339. height: number;
  26340. subdivisions: number;
  26341. minHeight: number;
  26342. maxHeight: number;
  26343. colorFilter: Color3;
  26344. buffer: Uint8Array;
  26345. bufferWidth: number;
  26346. bufferHeight: number;
  26347. alphaFilter: number;
  26348. }): VertexData;
  26349. /**
  26350. * Creates the VertexData for a Plane
  26351. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26352. * * size sets the width and height of the plane to the value of size, optional default 1
  26353. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26354. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26356. * * 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)
  26357. * * 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)
  26358. * @returns the VertexData of the box
  26359. */
  26360. static CreatePlane(options: {
  26361. size?: number;
  26362. width?: number;
  26363. height?: number;
  26364. sideOrientation?: number;
  26365. frontUVs?: Vector4;
  26366. backUVs?: Vector4;
  26367. }): VertexData;
  26368. /**
  26369. * Creates the VertexData of the Disc or regular Polygon
  26370. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26371. * * radius the radius of the disc, optional default 0.5
  26372. * * tessellation the number of polygon sides, optional, default 64
  26373. * * 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
  26374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26375. * * 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)
  26376. * * 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)
  26377. * @returns the VertexData of the box
  26378. */
  26379. static CreateDisc(options: {
  26380. radius?: number;
  26381. tessellation?: number;
  26382. arc?: number;
  26383. sideOrientation?: number;
  26384. frontUVs?: Vector4;
  26385. backUVs?: Vector4;
  26386. }): VertexData;
  26387. /**
  26388. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26389. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26390. * @param polygon a mesh built from polygonTriangulation.build()
  26391. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26392. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26393. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26394. * @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)
  26395. * @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)
  26396. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26397. * @returns the VertexData of the Polygon
  26398. */
  26399. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26400. /**
  26401. * Creates the VertexData of the IcoSphere
  26402. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26403. * * radius the radius of the IcoSphere, optional default 1
  26404. * * radiusX allows stretching in the x direction, optional, default radius
  26405. * * radiusY allows stretching in the y direction, optional, default radius
  26406. * * radiusZ allows stretching in the z direction, optional, default radius
  26407. * * flat when true creates a flat shaded mesh, optional, default true
  26408. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26409. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26410. * * 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)
  26411. * * 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)
  26412. * @returns the VertexData of the IcoSphere
  26413. */
  26414. static CreateIcoSphere(options: {
  26415. radius?: number;
  26416. radiusX?: number;
  26417. radiusY?: number;
  26418. radiusZ?: number;
  26419. flat?: boolean;
  26420. subdivisions?: number;
  26421. sideOrientation?: number;
  26422. frontUVs?: Vector4;
  26423. backUVs?: Vector4;
  26424. }): VertexData;
  26425. /**
  26426. * Creates the VertexData for a Polyhedron
  26427. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26428. * * type provided types are:
  26429. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26430. * * 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)
  26431. * * size the size of the IcoSphere, optional default 1
  26432. * * sizeX allows stretching in the x direction, optional, default size
  26433. * * sizeY allows stretching in the y direction, optional, default size
  26434. * * sizeZ allows stretching in the z direction, optional, default size
  26435. * * 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
  26436. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26437. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26438. * * flat when true creates a flat shaded mesh, optional, default true
  26439. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26441. * * 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)
  26442. * * 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)
  26443. * @returns the VertexData of the Polyhedron
  26444. */
  26445. static CreatePolyhedron(options: {
  26446. type?: number;
  26447. size?: number;
  26448. sizeX?: number;
  26449. sizeY?: number;
  26450. sizeZ?: number;
  26451. custom?: any;
  26452. faceUV?: Vector4[];
  26453. faceColors?: Color4[];
  26454. flat?: boolean;
  26455. sideOrientation?: number;
  26456. frontUVs?: Vector4;
  26457. backUVs?: Vector4;
  26458. }): VertexData;
  26459. /**
  26460. * Creates the VertexData for a TorusKnot
  26461. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26462. * * radius the radius of the torus knot, optional, default 2
  26463. * * tube the thickness of the tube, optional, default 0.5
  26464. * * radialSegments the number of sides on each tube segments, optional, default 32
  26465. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26466. * * p the number of windings around the z axis, optional, default 2
  26467. * * q the number of windings around the x axis, optional, default 3
  26468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26469. * * 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)
  26470. * * 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)
  26471. * @returns the VertexData of the Torus Knot
  26472. */
  26473. static CreateTorusKnot(options: {
  26474. radius?: number;
  26475. tube?: number;
  26476. radialSegments?: number;
  26477. tubularSegments?: number;
  26478. p?: number;
  26479. q?: number;
  26480. sideOrientation?: number;
  26481. frontUVs?: Vector4;
  26482. backUVs?: Vector4;
  26483. }): VertexData;
  26484. /**
  26485. * Compute normals for given positions and indices
  26486. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26487. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26488. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26489. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26490. * * facetNormals : optional array of facet normals (vector3)
  26491. * * facetPositions : optional array of facet positions (vector3)
  26492. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26493. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26494. * * bInfo : optional bounding info, required for facetPartitioning computation
  26495. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26496. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26497. * * useRightHandedSystem: optional boolean to for right handed system computation
  26498. * * depthSort : optional boolean to enable the facet depth sort computation
  26499. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26500. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26501. */
  26502. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26503. facetNormals?: any;
  26504. facetPositions?: any;
  26505. facetPartitioning?: any;
  26506. ratio?: number;
  26507. bInfo?: any;
  26508. bbSize?: Vector3;
  26509. subDiv?: any;
  26510. useRightHandedSystem?: boolean;
  26511. depthSort?: boolean;
  26512. distanceTo?: Vector3;
  26513. depthSortedFacets?: any;
  26514. }): void;
  26515. /** @hidden */
  26516. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26517. /**
  26518. * Applies VertexData created from the imported parameters to the geometry
  26519. * @param parsedVertexData the parsed data from an imported file
  26520. * @param geometry the geometry to apply the VertexData to
  26521. */
  26522. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26523. }
  26524. }
  26525. declare module BABYLON {
  26526. /**
  26527. * Defines a target to use with MorphTargetManager
  26528. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26529. */
  26530. export class MorphTarget implements IAnimatable {
  26531. /** defines the name of the target */
  26532. name: string;
  26533. /**
  26534. * Gets or sets the list of animations
  26535. */
  26536. animations: Animation[];
  26537. private _scene;
  26538. private _positions;
  26539. private _normals;
  26540. private _tangents;
  26541. private _uvs;
  26542. private _influence;
  26543. private _uniqueId;
  26544. /**
  26545. * Observable raised when the influence changes
  26546. */
  26547. onInfluenceChanged: Observable<boolean>;
  26548. /** @hidden */
  26549. _onDataLayoutChanged: Observable<void>;
  26550. /**
  26551. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26552. */
  26553. get influence(): number;
  26554. set influence(influence: number);
  26555. /**
  26556. * Gets or sets the id of the morph Target
  26557. */
  26558. id: string;
  26559. private _animationPropertiesOverride;
  26560. /**
  26561. * Gets or sets the animation properties override
  26562. */
  26563. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26564. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26565. /**
  26566. * Creates a new MorphTarget
  26567. * @param name defines the name of the target
  26568. * @param influence defines the influence to use
  26569. * @param scene defines the scene the morphtarget belongs to
  26570. */
  26571. constructor(
  26572. /** defines the name of the target */
  26573. name: string, influence?: number, scene?: Nullable<Scene>);
  26574. /**
  26575. * Gets the unique ID of this manager
  26576. */
  26577. get uniqueId(): number;
  26578. /**
  26579. * Gets a boolean defining if the target contains position data
  26580. */
  26581. get hasPositions(): boolean;
  26582. /**
  26583. * Gets a boolean defining if the target contains normal data
  26584. */
  26585. get hasNormals(): boolean;
  26586. /**
  26587. * Gets a boolean defining if the target contains tangent data
  26588. */
  26589. get hasTangents(): boolean;
  26590. /**
  26591. * Gets a boolean defining if the target contains texture coordinates data
  26592. */
  26593. get hasUVs(): boolean;
  26594. /**
  26595. * Affects position data to this target
  26596. * @param data defines the position data to use
  26597. */
  26598. setPositions(data: Nullable<FloatArray>): void;
  26599. /**
  26600. * Gets the position data stored in this target
  26601. * @returns a FloatArray containing the position data (or null if not present)
  26602. */
  26603. getPositions(): Nullable<FloatArray>;
  26604. /**
  26605. * Affects normal data to this target
  26606. * @param data defines the normal data to use
  26607. */
  26608. setNormals(data: Nullable<FloatArray>): void;
  26609. /**
  26610. * Gets the normal data stored in this target
  26611. * @returns a FloatArray containing the normal data (or null if not present)
  26612. */
  26613. getNormals(): Nullable<FloatArray>;
  26614. /**
  26615. * Affects tangent data to this target
  26616. * @param data defines the tangent data to use
  26617. */
  26618. setTangents(data: Nullable<FloatArray>): void;
  26619. /**
  26620. * Gets the tangent data stored in this target
  26621. * @returns a FloatArray containing the tangent data (or null if not present)
  26622. */
  26623. getTangents(): Nullable<FloatArray>;
  26624. /**
  26625. * Affects texture coordinates data to this target
  26626. * @param data defines the texture coordinates data to use
  26627. */
  26628. setUVs(data: Nullable<FloatArray>): void;
  26629. /**
  26630. * Gets the texture coordinates data stored in this target
  26631. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26632. */
  26633. getUVs(): Nullable<FloatArray>;
  26634. /**
  26635. * Clone the current target
  26636. * @returns a new MorphTarget
  26637. */
  26638. clone(): MorphTarget;
  26639. /**
  26640. * Serializes the current target into a Serialization object
  26641. * @returns the serialized object
  26642. */
  26643. serialize(): any;
  26644. /**
  26645. * Returns the string "MorphTarget"
  26646. * @returns "MorphTarget"
  26647. */
  26648. getClassName(): string;
  26649. /**
  26650. * Creates a new target from serialized data
  26651. * @param serializationObject defines the serialized data to use
  26652. * @returns a new MorphTarget
  26653. */
  26654. static Parse(serializationObject: any): MorphTarget;
  26655. /**
  26656. * Creates a MorphTarget from mesh data
  26657. * @param mesh defines the source mesh
  26658. * @param name defines the name to use for the new target
  26659. * @param influence defines the influence to attach to the target
  26660. * @returns a new MorphTarget
  26661. */
  26662. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26663. }
  26664. }
  26665. declare module BABYLON {
  26666. /**
  26667. * This class is used to deform meshes using morphing between different targets
  26668. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26669. */
  26670. export class MorphTargetManager {
  26671. private _targets;
  26672. private _targetInfluenceChangedObservers;
  26673. private _targetDataLayoutChangedObservers;
  26674. private _activeTargets;
  26675. private _scene;
  26676. private _influences;
  26677. private _supportsNormals;
  26678. private _supportsTangents;
  26679. private _supportsUVs;
  26680. private _vertexCount;
  26681. private _uniqueId;
  26682. private _tempInfluences;
  26683. /**
  26684. * Gets or sets a boolean indicating if normals must be morphed
  26685. */
  26686. enableNormalMorphing: boolean;
  26687. /**
  26688. * Gets or sets a boolean indicating if tangents must be morphed
  26689. */
  26690. enableTangentMorphing: boolean;
  26691. /**
  26692. * Gets or sets a boolean indicating if UV must be morphed
  26693. */
  26694. enableUVMorphing: boolean;
  26695. /**
  26696. * Creates a new MorphTargetManager
  26697. * @param scene defines the current scene
  26698. */
  26699. constructor(scene?: Nullable<Scene>);
  26700. /**
  26701. * Gets the unique ID of this manager
  26702. */
  26703. get uniqueId(): number;
  26704. /**
  26705. * Gets the number of vertices handled by this manager
  26706. */
  26707. get vertexCount(): number;
  26708. /**
  26709. * Gets a boolean indicating if this manager supports morphing of normals
  26710. */
  26711. get supportsNormals(): boolean;
  26712. /**
  26713. * Gets a boolean indicating if this manager supports morphing of tangents
  26714. */
  26715. get supportsTangents(): boolean;
  26716. /**
  26717. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26718. */
  26719. get supportsUVs(): boolean;
  26720. /**
  26721. * Gets the number of targets stored in this manager
  26722. */
  26723. get numTargets(): number;
  26724. /**
  26725. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26726. */
  26727. get numInfluencers(): number;
  26728. /**
  26729. * Gets the list of influences (one per target)
  26730. */
  26731. get influences(): Float32Array;
  26732. /**
  26733. * Gets the active target at specified index. An active target is a target with an influence > 0
  26734. * @param index defines the index to check
  26735. * @returns the requested target
  26736. */
  26737. getActiveTarget(index: number): MorphTarget;
  26738. /**
  26739. * Gets the target at specified index
  26740. * @param index defines the index to check
  26741. * @returns the requested target
  26742. */
  26743. getTarget(index: number): MorphTarget;
  26744. /**
  26745. * Add a new target to this manager
  26746. * @param target defines the target to add
  26747. */
  26748. addTarget(target: MorphTarget): void;
  26749. /**
  26750. * Removes a target from the manager
  26751. * @param target defines the target to remove
  26752. */
  26753. removeTarget(target: MorphTarget): void;
  26754. /**
  26755. * Clone the current manager
  26756. * @returns a new MorphTargetManager
  26757. */
  26758. clone(): MorphTargetManager;
  26759. /**
  26760. * Serializes the current manager into a Serialization object
  26761. * @returns the serialized object
  26762. */
  26763. serialize(): any;
  26764. private _syncActiveTargets;
  26765. /**
  26766. * Syncrhonize the targets with all the meshes using this morph target manager
  26767. */
  26768. synchronize(): void;
  26769. /**
  26770. * Creates a new MorphTargetManager from serialized data
  26771. * @param serializationObject defines the serialized data
  26772. * @param scene defines the hosting scene
  26773. * @returns the new MorphTargetManager
  26774. */
  26775. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26776. }
  26777. }
  26778. declare module BABYLON {
  26779. /**
  26780. * Class used to represent a specific level of detail of a mesh
  26781. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26782. */
  26783. export class MeshLODLevel {
  26784. /** Defines the distance where this level should start being displayed */
  26785. distance: number;
  26786. /** Defines the mesh to use to render this level */
  26787. mesh: Nullable<Mesh>;
  26788. /**
  26789. * Creates a new LOD level
  26790. * @param distance defines the distance where this level should star being displayed
  26791. * @param mesh defines the mesh to use to render this level
  26792. */
  26793. constructor(
  26794. /** Defines the distance where this level should start being displayed */
  26795. distance: number,
  26796. /** Defines the mesh to use to render this level */
  26797. mesh: Nullable<Mesh>);
  26798. }
  26799. }
  26800. declare module BABYLON {
  26801. /**
  26802. * Helper class used to generate a canvas to manipulate images
  26803. */
  26804. export class CanvasGenerator {
  26805. /**
  26806. * Create a new canvas (or offscreen canvas depending on the context)
  26807. * @param width defines the expected width
  26808. * @param height defines the expected height
  26809. * @return a new canvas or offscreen canvas
  26810. */
  26811. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26812. }
  26813. }
  26814. declare module BABYLON {
  26815. /**
  26816. * Mesh representing the gorund
  26817. */
  26818. export class GroundMesh extends Mesh {
  26819. /** If octree should be generated */
  26820. generateOctree: boolean;
  26821. private _heightQuads;
  26822. /** @hidden */
  26823. _subdivisionsX: number;
  26824. /** @hidden */
  26825. _subdivisionsY: number;
  26826. /** @hidden */
  26827. _width: number;
  26828. /** @hidden */
  26829. _height: number;
  26830. /** @hidden */
  26831. _minX: number;
  26832. /** @hidden */
  26833. _maxX: number;
  26834. /** @hidden */
  26835. _minZ: number;
  26836. /** @hidden */
  26837. _maxZ: number;
  26838. constructor(name: string, scene: Scene);
  26839. /**
  26840. * "GroundMesh"
  26841. * @returns "GroundMesh"
  26842. */
  26843. getClassName(): string;
  26844. /**
  26845. * The minimum of x and y subdivisions
  26846. */
  26847. get subdivisions(): number;
  26848. /**
  26849. * X subdivisions
  26850. */
  26851. get subdivisionsX(): number;
  26852. /**
  26853. * Y subdivisions
  26854. */
  26855. get subdivisionsY(): number;
  26856. /**
  26857. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26858. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26859. * @param chunksCount the number of subdivisions for x and y
  26860. * @param octreeBlocksSize (Default: 32)
  26861. */
  26862. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26863. /**
  26864. * Returns a height (y) value in the Worl system :
  26865. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26866. * @param x x coordinate
  26867. * @param z z coordinate
  26868. * @returns the ground y position if (x, z) are outside the ground surface.
  26869. */
  26870. getHeightAtCoordinates(x: number, z: number): number;
  26871. /**
  26872. * Returns a normalized vector (Vector3) orthogonal to the ground
  26873. * at the ground coordinates (x, z) expressed in the World system.
  26874. * @param x x coordinate
  26875. * @param z z coordinate
  26876. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26877. */
  26878. getNormalAtCoordinates(x: number, z: number): Vector3;
  26879. /**
  26880. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26881. * at the ground coordinates (x, z) expressed in the World system.
  26882. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26883. * @param x x coordinate
  26884. * @param z z coordinate
  26885. * @param ref vector to store the result
  26886. * @returns the GroundMesh.
  26887. */
  26888. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26889. /**
  26890. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26891. * if the ground has been updated.
  26892. * This can be used in the render loop.
  26893. * @returns the GroundMesh.
  26894. */
  26895. updateCoordinateHeights(): GroundMesh;
  26896. private _getFacetAt;
  26897. private _initHeightQuads;
  26898. private _computeHeightQuads;
  26899. /**
  26900. * Serializes this ground mesh
  26901. * @param serializationObject object to write serialization to
  26902. */
  26903. serialize(serializationObject: any): void;
  26904. /**
  26905. * Parses a serialized ground mesh
  26906. * @param parsedMesh the serialized mesh
  26907. * @param scene the scene to create the ground mesh in
  26908. * @returns the created ground mesh
  26909. */
  26910. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26911. }
  26912. }
  26913. declare module BABYLON {
  26914. /**
  26915. * Interface for Physics-Joint data
  26916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26917. */
  26918. export interface PhysicsJointData {
  26919. /**
  26920. * The main pivot of the joint
  26921. */
  26922. mainPivot?: Vector3;
  26923. /**
  26924. * The connected pivot of the joint
  26925. */
  26926. connectedPivot?: Vector3;
  26927. /**
  26928. * The main axis of the joint
  26929. */
  26930. mainAxis?: Vector3;
  26931. /**
  26932. * The connected axis of the joint
  26933. */
  26934. connectedAxis?: Vector3;
  26935. /**
  26936. * The collision of the joint
  26937. */
  26938. collision?: boolean;
  26939. /**
  26940. * Native Oimo/Cannon/Energy data
  26941. */
  26942. nativeParams?: any;
  26943. }
  26944. /**
  26945. * This is a holder class for the physics joint created by the physics plugin
  26946. * It holds a set of functions to control the underlying joint
  26947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26948. */
  26949. export class PhysicsJoint {
  26950. /**
  26951. * The type of the physics joint
  26952. */
  26953. type: number;
  26954. /**
  26955. * The data for the physics joint
  26956. */
  26957. jointData: PhysicsJointData;
  26958. private _physicsJoint;
  26959. protected _physicsPlugin: IPhysicsEnginePlugin;
  26960. /**
  26961. * Initializes the physics joint
  26962. * @param type The type of the physics joint
  26963. * @param jointData The data for the physics joint
  26964. */
  26965. constructor(
  26966. /**
  26967. * The type of the physics joint
  26968. */
  26969. type: number,
  26970. /**
  26971. * The data for the physics joint
  26972. */
  26973. jointData: PhysicsJointData);
  26974. /**
  26975. * Gets the physics joint
  26976. */
  26977. get physicsJoint(): any;
  26978. /**
  26979. * Sets the physics joint
  26980. */
  26981. set physicsJoint(newJoint: any);
  26982. /**
  26983. * Sets the physics plugin
  26984. */
  26985. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26986. /**
  26987. * Execute a function that is physics-plugin specific.
  26988. * @param {Function} func the function that will be executed.
  26989. * It accepts two parameters: the physics world and the physics joint
  26990. */
  26991. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26992. /**
  26993. * Distance-Joint type
  26994. */
  26995. static DistanceJoint: number;
  26996. /**
  26997. * Hinge-Joint type
  26998. */
  26999. static HingeJoint: number;
  27000. /**
  27001. * Ball-and-Socket joint type
  27002. */
  27003. static BallAndSocketJoint: number;
  27004. /**
  27005. * Wheel-Joint type
  27006. */
  27007. static WheelJoint: number;
  27008. /**
  27009. * Slider-Joint type
  27010. */
  27011. static SliderJoint: number;
  27012. /**
  27013. * Prismatic-Joint type
  27014. */
  27015. static PrismaticJoint: number;
  27016. /**
  27017. * Universal-Joint type
  27018. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27019. */
  27020. static UniversalJoint: number;
  27021. /**
  27022. * Hinge-Joint 2 type
  27023. */
  27024. static Hinge2Joint: number;
  27025. /**
  27026. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27027. */
  27028. static PointToPointJoint: number;
  27029. /**
  27030. * Spring-Joint type
  27031. */
  27032. static SpringJoint: number;
  27033. /**
  27034. * Lock-Joint type
  27035. */
  27036. static LockJoint: number;
  27037. }
  27038. /**
  27039. * A class representing a physics distance joint
  27040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27041. */
  27042. export class DistanceJoint extends PhysicsJoint {
  27043. /**
  27044. *
  27045. * @param jointData The data for the Distance-Joint
  27046. */
  27047. constructor(jointData: DistanceJointData);
  27048. /**
  27049. * Update the predefined distance.
  27050. * @param maxDistance The maximum preferred distance
  27051. * @param minDistance The minimum preferred distance
  27052. */
  27053. updateDistance(maxDistance: number, minDistance?: number): void;
  27054. }
  27055. /**
  27056. * Represents a Motor-Enabled Joint
  27057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27058. */
  27059. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27060. /**
  27061. * Initializes the Motor-Enabled Joint
  27062. * @param type The type of the joint
  27063. * @param jointData The physica joint data for the joint
  27064. */
  27065. constructor(type: number, jointData: PhysicsJointData);
  27066. /**
  27067. * Set the motor values.
  27068. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27069. * @param force the force to apply
  27070. * @param maxForce max force for this motor.
  27071. */
  27072. setMotor(force?: number, maxForce?: number): void;
  27073. /**
  27074. * Set the motor's limits.
  27075. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27076. * @param upperLimit The upper limit of the motor
  27077. * @param lowerLimit The lower limit of the motor
  27078. */
  27079. setLimit(upperLimit: number, lowerLimit?: number): void;
  27080. }
  27081. /**
  27082. * This class represents a single physics Hinge-Joint
  27083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27084. */
  27085. export class HingeJoint extends MotorEnabledJoint {
  27086. /**
  27087. * Initializes the Hinge-Joint
  27088. * @param jointData The joint data for the Hinge-Joint
  27089. */
  27090. constructor(jointData: PhysicsJointData);
  27091. /**
  27092. * Set the motor values.
  27093. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27094. * @param {number} force the force to apply
  27095. * @param {number} maxForce max force for this motor.
  27096. */
  27097. setMotor(force?: number, maxForce?: number): void;
  27098. /**
  27099. * Set the motor's limits.
  27100. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27101. * @param upperLimit The upper limit of the motor
  27102. * @param lowerLimit The lower limit of the motor
  27103. */
  27104. setLimit(upperLimit: number, lowerLimit?: number): void;
  27105. }
  27106. /**
  27107. * This class represents a dual hinge physics joint (same as wheel joint)
  27108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27109. */
  27110. export class Hinge2Joint extends MotorEnabledJoint {
  27111. /**
  27112. * Initializes the Hinge2-Joint
  27113. * @param jointData The joint data for the Hinge2-Joint
  27114. */
  27115. constructor(jointData: PhysicsJointData);
  27116. /**
  27117. * Set the motor values.
  27118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27119. * @param {number} targetSpeed the speed the motor is to reach
  27120. * @param {number} maxForce max force for this motor.
  27121. * @param {motorIndex} the motor's index, 0 or 1.
  27122. */
  27123. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27124. /**
  27125. * Set the motor limits.
  27126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27127. * @param {number} upperLimit the upper limit
  27128. * @param {number} lowerLimit lower limit
  27129. * @param {motorIndex} the motor's index, 0 or 1.
  27130. */
  27131. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27132. }
  27133. /**
  27134. * Interface for a motor enabled joint
  27135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27136. */
  27137. export interface IMotorEnabledJoint {
  27138. /**
  27139. * Physics joint
  27140. */
  27141. physicsJoint: any;
  27142. /**
  27143. * Sets the motor of the motor-enabled joint
  27144. * @param force The force of the motor
  27145. * @param maxForce The maximum force of the motor
  27146. * @param motorIndex The index of the motor
  27147. */
  27148. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27149. /**
  27150. * Sets the limit of the motor
  27151. * @param upperLimit The upper limit of the motor
  27152. * @param lowerLimit The lower limit of the motor
  27153. * @param motorIndex The index of the motor
  27154. */
  27155. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27156. }
  27157. /**
  27158. * Joint data for a Distance-Joint
  27159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27160. */
  27161. export interface DistanceJointData extends PhysicsJointData {
  27162. /**
  27163. * Max distance the 2 joint objects can be apart
  27164. */
  27165. maxDistance: number;
  27166. }
  27167. /**
  27168. * Joint data from a spring joint
  27169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27170. */
  27171. export interface SpringJointData extends PhysicsJointData {
  27172. /**
  27173. * Length of the spring
  27174. */
  27175. length: number;
  27176. /**
  27177. * Stiffness of the spring
  27178. */
  27179. stiffness: number;
  27180. /**
  27181. * Damping of the spring
  27182. */
  27183. damping: number;
  27184. /** this callback will be called when applying the force to the impostors. */
  27185. forceApplicationCallback: () => void;
  27186. }
  27187. }
  27188. declare module BABYLON {
  27189. /**
  27190. * Holds the data for the raycast result
  27191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27192. */
  27193. export class PhysicsRaycastResult {
  27194. private _hasHit;
  27195. private _hitDistance;
  27196. private _hitNormalWorld;
  27197. private _hitPointWorld;
  27198. private _rayFromWorld;
  27199. private _rayToWorld;
  27200. /**
  27201. * Gets if there was a hit
  27202. */
  27203. get hasHit(): boolean;
  27204. /**
  27205. * Gets the distance from the hit
  27206. */
  27207. get hitDistance(): number;
  27208. /**
  27209. * Gets the hit normal/direction in the world
  27210. */
  27211. get hitNormalWorld(): Vector3;
  27212. /**
  27213. * Gets the hit point in the world
  27214. */
  27215. get hitPointWorld(): Vector3;
  27216. /**
  27217. * Gets the ray "start point" of the ray in the world
  27218. */
  27219. get rayFromWorld(): Vector3;
  27220. /**
  27221. * Gets the ray "end point" of the ray in the world
  27222. */
  27223. get rayToWorld(): Vector3;
  27224. /**
  27225. * Sets the hit data (normal & point in world space)
  27226. * @param hitNormalWorld defines the normal in world space
  27227. * @param hitPointWorld defines the point in world space
  27228. */
  27229. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27230. /**
  27231. * Sets the distance from the start point to the hit point
  27232. * @param distance
  27233. */
  27234. setHitDistance(distance: number): void;
  27235. /**
  27236. * Calculates the distance manually
  27237. */
  27238. calculateHitDistance(): void;
  27239. /**
  27240. * Resets all the values to default
  27241. * @param from The from point on world space
  27242. * @param to The to point on world space
  27243. */
  27244. reset(from?: Vector3, to?: Vector3): void;
  27245. }
  27246. /**
  27247. * Interface for the size containing width and height
  27248. */
  27249. interface IXYZ {
  27250. /**
  27251. * X
  27252. */
  27253. x: number;
  27254. /**
  27255. * Y
  27256. */
  27257. y: number;
  27258. /**
  27259. * Z
  27260. */
  27261. z: number;
  27262. }
  27263. }
  27264. declare module BABYLON {
  27265. /**
  27266. * Interface used to describe a physics joint
  27267. */
  27268. export interface PhysicsImpostorJoint {
  27269. /** Defines the main impostor to which the joint is linked */
  27270. mainImpostor: PhysicsImpostor;
  27271. /** Defines the impostor that is connected to the main impostor using this joint */
  27272. connectedImpostor: PhysicsImpostor;
  27273. /** Defines the joint itself */
  27274. joint: PhysicsJoint;
  27275. }
  27276. /** @hidden */
  27277. export interface IPhysicsEnginePlugin {
  27278. world: any;
  27279. name: string;
  27280. setGravity(gravity: Vector3): void;
  27281. setTimeStep(timeStep: number): void;
  27282. getTimeStep(): number;
  27283. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27284. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27285. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27286. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27287. removePhysicsBody(impostor: PhysicsImpostor): void;
  27288. generateJoint(joint: PhysicsImpostorJoint): void;
  27289. removeJoint(joint: PhysicsImpostorJoint): void;
  27290. isSupported(): boolean;
  27291. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27292. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27293. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27294. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27295. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27296. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27297. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27298. getBodyMass(impostor: PhysicsImpostor): number;
  27299. getBodyFriction(impostor: PhysicsImpostor): number;
  27300. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27301. getBodyRestitution(impostor: PhysicsImpostor): number;
  27302. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27303. getBodyPressure?(impostor: PhysicsImpostor): number;
  27304. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27305. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27306. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27307. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27308. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27309. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27310. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27311. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27312. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27313. sleepBody(impostor: PhysicsImpostor): void;
  27314. wakeUpBody(impostor: PhysicsImpostor): void;
  27315. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27317. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27319. getRadius(impostor: PhysicsImpostor): number;
  27320. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27321. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27322. dispose(): void;
  27323. }
  27324. /**
  27325. * Interface used to define a physics engine
  27326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27327. */
  27328. export interface IPhysicsEngine {
  27329. /**
  27330. * Gets the gravity vector used by the simulation
  27331. */
  27332. gravity: Vector3;
  27333. /**
  27334. * Sets the gravity vector used by the simulation
  27335. * @param gravity defines the gravity vector to use
  27336. */
  27337. setGravity(gravity: Vector3): void;
  27338. /**
  27339. * Set the time step of the physics engine.
  27340. * Default is 1/60.
  27341. * To slow it down, enter 1/600 for example.
  27342. * To speed it up, 1/30
  27343. * @param newTimeStep the new timestep to apply to this world.
  27344. */
  27345. setTimeStep(newTimeStep: number): void;
  27346. /**
  27347. * Get the time step of the physics engine.
  27348. * @returns the current time step
  27349. */
  27350. getTimeStep(): number;
  27351. /**
  27352. * Set the sub time step of the physics engine.
  27353. * Default is 0 meaning there is no sub steps
  27354. * To increase physics resolution precision, set a small value (like 1 ms)
  27355. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27356. */
  27357. setSubTimeStep(subTimeStep: number): void;
  27358. /**
  27359. * Get the sub time step of the physics engine.
  27360. * @returns the current sub time step
  27361. */
  27362. getSubTimeStep(): number;
  27363. /**
  27364. * Release all resources
  27365. */
  27366. dispose(): void;
  27367. /**
  27368. * Gets the name of the current physics plugin
  27369. * @returns the name of the plugin
  27370. */
  27371. getPhysicsPluginName(): string;
  27372. /**
  27373. * Adding a new impostor for the impostor tracking.
  27374. * This will be done by the impostor itself.
  27375. * @param impostor the impostor to add
  27376. */
  27377. addImpostor(impostor: PhysicsImpostor): void;
  27378. /**
  27379. * Remove an impostor from the engine.
  27380. * This impostor and its mesh will not longer be updated by the physics engine.
  27381. * @param impostor the impostor to remove
  27382. */
  27383. removeImpostor(impostor: PhysicsImpostor): void;
  27384. /**
  27385. * Add a joint to the physics engine
  27386. * @param mainImpostor defines the main impostor to which the joint is added.
  27387. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27388. * @param joint defines the joint that will connect both impostors.
  27389. */
  27390. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27391. /**
  27392. * Removes a joint from the simulation
  27393. * @param mainImpostor defines the impostor used with the joint
  27394. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27395. * @param joint defines the joint to remove
  27396. */
  27397. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27398. /**
  27399. * Gets the current plugin used to run the simulation
  27400. * @returns current plugin
  27401. */
  27402. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27403. /**
  27404. * Gets the list of physic impostors
  27405. * @returns an array of PhysicsImpostor
  27406. */
  27407. getImpostors(): Array<PhysicsImpostor>;
  27408. /**
  27409. * Gets the impostor for a physics enabled object
  27410. * @param object defines the object impersonated by the impostor
  27411. * @returns the PhysicsImpostor or null if not found
  27412. */
  27413. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27414. /**
  27415. * Gets the impostor for a physics body object
  27416. * @param body defines physics body used by the impostor
  27417. * @returns the PhysicsImpostor or null if not found
  27418. */
  27419. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27420. /**
  27421. * Does a raycast in the physics world
  27422. * @param from when should the ray start?
  27423. * @param to when should the ray end?
  27424. * @returns PhysicsRaycastResult
  27425. */
  27426. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27427. /**
  27428. * Called by the scene. No need to call it.
  27429. * @param delta defines the timespam between frames
  27430. */
  27431. _step(delta: number): void;
  27432. }
  27433. }
  27434. declare module BABYLON {
  27435. /**
  27436. * The interface for the physics imposter parameters
  27437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27438. */
  27439. export interface PhysicsImpostorParameters {
  27440. /**
  27441. * The mass of the physics imposter
  27442. */
  27443. mass: number;
  27444. /**
  27445. * The friction of the physics imposter
  27446. */
  27447. friction?: number;
  27448. /**
  27449. * The coefficient of restitution of the physics imposter
  27450. */
  27451. restitution?: number;
  27452. /**
  27453. * The native options of the physics imposter
  27454. */
  27455. nativeOptions?: any;
  27456. /**
  27457. * Specifies if the parent should be ignored
  27458. */
  27459. ignoreParent?: boolean;
  27460. /**
  27461. * Specifies if bi-directional transformations should be disabled
  27462. */
  27463. disableBidirectionalTransformation?: boolean;
  27464. /**
  27465. * The pressure inside the physics imposter, soft object only
  27466. */
  27467. pressure?: number;
  27468. /**
  27469. * The stiffness the physics imposter, soft object only
  27470. */
  27471. stiffness?: number;
  27472. /**
  27473. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27474. */
  27475. velocityIterations?: number;
  27476. /**
  27477. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27478. */
  27479. positionIterations?: number;
  27480. /**
  27481. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27482. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27483. * Add to fix multiple points
  27484. */
  27485. fixedPoints?: number;
  27486. /**
  27487. * The collision margin around a soft object
  27488. */
  27489. margin?: number;
  27490. /**
  27491. * The collision margin around a soft object
  27492. */
  27493. damping?: number;
  27494. /**
  27495. * The path for a rope based on an extrusion
  27496. */
  27497. path?: any;
  27498. /**
  27499. * The shape of an extrusion used for a rope based on an extrusion
  27500. */
  27501. shape?: any;
  27502. }
  27503. /**
  27504. * Interface for a physics-enabled object
  27505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27506. */
  27507. export interface IPhysicsEnabledObject {
  27508. /**
  27509. * The position of the physics-enabled object
  27510. */
  27511. position: Vector3;
  27512. /**
  27513. * The rotation of the physics-enabled object
  27514. */
  27515. rotationQuaternion: Nullable<Quaternion>;
  27516. /**
  27517. * The scale of the physics-enabled object
  27518. */
  27519. scaling: Vector3;
  27520. /**
  27521. * The rotation of the physics-enabled object
  27522. */
  27523. rotation?: Vector3;
  27524. /**
  27525. * The parent of the physics-enabled object
  27526. */
  27527. parent?: any;
  27528. /**
  27529. * The bounding info of the physics-enabled object
  27530. * @returns The bounding info of the physics-enabled object
  27531. */
  27532. getBoundingInfo(): BoundingInfo;
  27533. /**
  27534. * Computes the world matrix
  27535. * @param force Specifies if the world matrix should be computed by force
  27536. * @returns A world matrix
  27537. */
  27538. computeWorldMatrix(force: boolean): Matrix;
  27539. /**
  27540. * Gets the world matrix
  27541. * @returns A world matrix
  27542. */
  27543. getWorldMatrix?(): Matrix;
  27544. /**
  27545. * Gets the child meshes
  27546. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27547. * @returns An array of abstract meshes
  27548. */
  27549. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27550. /**
  27551. * Gets the vertex data
  27552. * @param kind The type of vertex data
  27553. * @returns A nullable array of numbers, or a float32 array
  27554. */
  27555. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27556. /**
  27557. * Gets the indices from the mesh
  27558. * @returns A nullable array of index arrays
  27559. */
  27560. getIndices?(): Nullable<IndicesArray>;
  27561. /**
  27562. * Gets the scene from the mesh
  27563. * @returns the indices array or null
  27564. */
  27565. getScene?(): Scene;
  27566. /**
  27567. * Gets the absolute position from the mesh
  27568. * @returns the absolute position
  27569. */
  27570. getAbsolutePosition(): Vector3;
  27571. /**
  27572. * Gets the absolute pivot point from the mesh
  27573. * @returns the absolute pivot point
  27574. */
  27575. getAbsolutePivotPoint(): Vector3;
  27576. /**
  27577. * Rotates the mesh
  27578. * @param axis The axis of rotation
  27579. * @param amount The amount of rotation
  27580. * @param space The space of the rotation
  27581. * @returns The rotation transform node
  27582. */
  27583. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27584. /**
  27585. * Translates the mesh
  27586. * @param axis The axis of translation
  27587. * @param distance The distance of translation
  27588. * @param space The space of the translation
  27589. * @returns The transform node
  27590. */
  27591. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27592. /**
  27593. * Sets the absolute position of the mesh
  27594. * @param absolutePosition The absolute position of the mesh
  27595. * @returns The transform node
  27596. */
  27597. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27598. /**
  27599. * Gets the class name of the mesh
  27600. * @returns The class name
  27601. */
  27602. getClassName(): string;
  27603. }
  27604. /**
  27605. * Represents a physics imposter
  27606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27607. */
  27608. export class PhysicsImpostor {
  27609. /**
  27610. * The physics-enabled object used as the physics imposter
  27611. */
  27612. object: IPhysicsEnabledObject;
  27613. /**
  27614. * The type of the physics imposter
  27615. */
  27616. type: number;
  27617. private _options;
  27618. private _scene?;
  27619. /**
  27620. * The default object size of the imposter
  27621. */
  27622. static DEFAULT_OBJECT_SIZE: Vector3;
  27623. /**
  27624. * The identity quaternion of the imposter
  27625. */
  27626. static IDENTITY_QUATERNION: Quaternion;
  27627. /** @hidden */
  27628. _pluginData: any;
  27629. private _physicsEngine;
  27630. private _physicsBody;
  27631. private _bodyUpdateRequired;
  27632. private _onBeforePhysicsStepCallbacks;
  27633. private _onAfterPhysicsStepCallbacks;
  27634. /** @hidden */
  27635. _onPhysicsCollideCallbacks: Array<{
  27636. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27637. otherImpostors: Array<PhysicsImpostor>;
  27638. }>;
  27639. private _deltaPosition;
  27640. private _deltaRotation;
  27641. private _deltaRotationConjugated;
  27642. /** @hidden */
  27643. _isFromLine: boolean;
  27644. private _parent;
  27645. private _isDisposed;
  27646. private static _tmpVecs;
  27647. private static _tmpQuat;
  27648. /**
  27649. * Specifies if the physics imposter is disposed
  27650. */
  27651. get isDisposed(): boolean;
  27652. /**
  27653. * Gets the mass of the physics imposter
  27654. */
  27655. get mass(): number;
  27656. set mass(value: number);
  27657. /**
  27658. * Gets the coefficient of friction
  27659. */
  27660. get friction(): number;
  27661. /**
  27662. * Sets the coefficient of friction
  27663. */
  27664. set friction(value: number);
  27665. /**
  27666. * Gets the coefficient of restitution
  27667. */
  27668. get restitution(): number;
  27669. /**
  27670. * Sets the coefficient of restitution
  27671. */
  27672. set restitution(value: number);
  27673. /**
  27674. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27675. */
  27676. get pressure(): number;
  27677. /**
  27678. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27679. */
  27680. set pressure(value: number);
  27681. /**
  27682. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27683. */
  27684. get stiffness(): number;
  27685. /**
  27686. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27687. */
  27688. set stiffness(value: number);
  27689. /**
  27690. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27691. */
  27692. get velocityIterations(): number;
  27693. /**
  27694. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27695. */
  27696. set velocityIterations(value: number);
  27697. /**
  27698. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27699. */
  27700. get positionIterations(): number;
  27701. /**
  27702. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27703. */
  27704. set positionIterations(value: number);
  27705. /**
  27706. * The unique id of the physics imposter
  27707. * set by the physics engine when adding this impostor to the array
  27708. */
  27709. uniqueId: number;
  27710. /**
  27711. * @hidden
  27712. */
  27713. soft: boolean;
  27714. /**
  27715. * @hidden
  27716. */
  27717. segments: number;
  27718. private _joints;
  27719. /**
  27720. * Initializes the physics imposter
  27721. * @param object The physics-enabled object used as the physics imposter
  27722. * @param type The type of the physics imposter
  27723. * @param _options The options for the physics imposter
  27724. * @param _scene The Babylon scene
  27725. */
  27726. constructor(
  27727. /**
  27728. * The physics-enabled object used as the physics imposter
  27729. */
  27730. object: IPhysicsEnabledObject,
  27731. /**
  27732. * The type of the physics imposter
  27733. */
  27734. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27735. /**
  27736. * This function will completly initialize this impostor.
  27737. * It will create a new body - but only if this mesh has no parent.
  27738. * If it has, this impostor will not be used other than to define the impostor
  27739. * of the child mesh.
  27740. * @hidden
  27741. */
  27742. _init(): void;
  27743. private _getPhysicsParent;
  27744. /**
  27745. * Should a new body be generated.
  27746. * @returns boolean specifying if body initialization is required
  27747. */
  27748. isBodyInitRequired(): boolean;
  27749. /**
  27750. * Sets the updated scaling
  27751. * @param updated Specifies if the scaling is updated
  27752. */
  27753. setScalingUpdated(): void;
  27754. /**
  27755. * Force a regeneration of this or the parent's impostor's body.
  27756. * Use under cautious - This will remove all joints already implemented.
  27757. */
  27758. forceUpdate(): void;
  27759. /**
  27760. * Gets the body that holds this impostor. Either its own, or its parent.
  27761. */
  27762. get physicsBody(): any;
  27763. /**
  27764. * Get the parent of the physics imposter
  27765. * @returns Physics imposter or null
  27766. */
  27767. get parent(): Nullable<PhysicsImpostor>;
  27768. /**
  27769. * Sets the parent of the physics imposter
  27770. */
  27771. set parent(value: Nullable<PhysicsImpostor>);
  27772. /**
  27773. * Set the physics body. Used mainly by the physics engine/plugin
  27774. */
  27775. set physicsBody(physicsBody: any);
  27776. /**
  27777. * Resets the update flags
  27778. */
  27779. resetUpdateFlags(): void;
  27780. /**
  27781. * Gets the object extend size
  27782. * @returns the object extend size
  27783. */
  27784. getObjectExtendSize(): Vector3;
  27785. /**
  27786. * Gets the object center
  27787. * @returns The object center
  27788. */
  27789. getObjectCenter(): Vector3;
  27790. /**
  27791. * Get a specific parameter from the options parameters
  27792. * @param paramName The object parameter name
  27793. * @returns The object parameter
  27794. */
  27795. getParam(paramName: string): any;
  27796. /**
  27797. * Sets a specific parameter in the options given to the physics plugin
  27798. * @param paramName The parameter name
  27799. * @param value The value of the parameter
  27800. */
  27801. setParam(paramName: string, value: number): void;
  27802. /**
  27803. * Specifically change the body's mass option. Won't recreate the physics body object
  27804. * @param mass The mass of the physics imposter
  27805. */
  27806. setMass(mass: number): void;
  27807. /**
  27808. * Gets the linear velocity
  27809. * @returns linear velocity or null
  27810. */
  27811. getLinearVelocity(): Nullable<Vector3>;
  27812. /**
  27813. * Sets the linear velocity
  27814. * @param velocity linear velocity or null
  27815. */
  27816. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27817. /**
  27818. * Gets the angular velocity
  27819. * @returns angular velocity or null
  27820. */
  27821. getAngularVelocity(): Nullable<Vector3>;
  27822. /**
  27823. * Sets the angular velocity
  27824. * @param velocity The velocity or null
  27825. */
  27826. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27827. /**
  27828. * Execute a function with the physics plugin native code
  27829. * Provide a function the will have two variables - the world object and the physics body object
  27830. * @param func The function to execute with the physics plugin native code
  27831. */
  27832. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27833. /**
  27834. * Register a function that will be executed before the physics world is stepping forward
  27835. * @param func The function to execute before the physics world is stepped forward
  27836. */
  27837. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27838. /**
  27839. * Unregister a function that will be executed before the physics world is stepping forward
  27840. * @param func The function to execute before the physics world is stepped forward
  27841. */
  27842. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27843. /**
  27844. * Register a function that will be executed after the physics step
  27845. * @param func The function to execute after physics step
  27846. */
  27847. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27848. /**
  27849. * Unregisters a function that will be executed after the physics step
  27850. * @param func The function to execute after physics step
  27851. */
  27852. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27853. /**
  27854. * register a function that will be executed when this impostor collides against a different body
  27855. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27856. * @param func Callback that is executed on collision
  27857. */
  27858. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27859. /**
  27860. * Unregisters the physics imposter on contact
  27861. * @param collideAgainst The physics object to collide against
  27862. * @param func Callback to execute on collision
  27863. */
  27864. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27865. private _tmpQuat;
  27866. private _tmpQuat2;
  27867. /**
  27868. * Get the parent rotation
  27869. * @returns The parent rotation
  27870. */
  27871. getParentsRotation(): Quaternion;
  27872. /**
  27873. * this function is executed by the physics engine.
  27874. */
  27875. beforeStep: () => void;
  27876. /**
  27877. * this function is executed by the physics engine
  27878. */
  27879. afterStep: () => void;
  27880. /**
  27881. * Legacy collision detection event support
  27882. */
  27883. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27884. /**
  27885. * event and body object due to cannon's event-based architecture.
  27886. */
  27887. onCollide: (e: {
  27888. body: any;
  27889. }) => void;
  27890. /**
  27891. * Apply a force
  27892. * @param force The force to apply
  27893. * @param contactPoint The contact point for the force
  27894. * @returns The physics imposter
  27895. */
  27896. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27897. /**
  27898. * Apply an impulse
  27899. * @param force The impulse force
  27900. * @param contactPoint The contact point for the impulse force
  27901. * @returns The physics imposter
  27902. */
  27903. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27904. /**
  27905. * A help function to create a joint
  27906. * @param otherImpostor A physics imposter used to create a joint
  27907. * @param jointType The type of joint
  27908. * @param jointData The data for the joint
  27909. * @returns The physics imposter
  27910. */
  27911. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27912. /**
  27913. * Add a joint to this impostor with a different impostor
  27914. * @param otherImpostor A physics imposter used to add a joint
  27915. * @param joint The joint to add
  27916. * @returns The physics imposter
  27917. */
  27918. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27919. /**
  27920. * Add an anchor to a cloth impostor
  27921. * @param otherImpostor rigid impostor to anchor to
  27922. * @param width ratio across width from 0 to 1
  27923. * @param height ratio up height from 0 to 1
  27924. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27925. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27926. * @returns impostor the soft imposter
  27927. */
  27928. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27929. /**
  27930. * Add a hook to a rope impostor
  27931. * @param otherImpostor rigid impostor to anchor to
  27932. * @param length ratio across rope from 0 to 1
  27933. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27934. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27935. * @returns impostor the rope imposter
  27936. */
  27937. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27938. /**
  27939. * Will keep this body still, in a sleep mode.
  27940. * @returns the physics imposter
  27941. */
  27942. sleep(): PhysicsImpostor;
  27943. /**
  27944. * Wake the body up.
  27945. * @returns The physics imposter
  27946. */
  27947. wakeUp(): PhysicsImpostor;
  27948. /**
  27949. * Clones the physics imposter
  27950. * @param newObject The physics imposter clones to this physics-enabled object
  27951. * @returns A nullable physics imposter
  27952. */
  27953. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27954. /**
  27955. * Disposes the physics imposter
  27956. */
  27957. dispose(): void;
  27958. /**
  27959. * Sets the delta position
  27960. * @param position The delta position amount
  27961. */
  27962. setDeltaPosition(position: Vector3): void;
  27963. /**
  27964. * Sets the delta rotation
  27965. * @param rotation The delta rotation amount
  27966. */
  27967. setDeltaRotation(rotation: Quaternion): void;
  27968. /**
  27969. * Gets the box size of the physics imposter and stores the result in the input parameter
  27970. * @param result Stores the box size
  27971. * @returns The physics imposter
  27972. */
  27973. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27974. /**
  27975. * Gets the radius of the physics imposter
  27976. * @returns Radius of the physics imposter
  27977. */
  27978. getRadius(): number;
  27979. /**
  27980. * Sync a bone with this impostor
  27981. * @param bone The bone to sync to the impostor.
  27982. * @param boneMesh The mesh that the bone is influencing.
  27983. * @param jointPivot The pivot of the joint / bone in local space.
  27984. * @param distToJoint Optional distance from the impostor to the joint.
  27985. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27986. */
  27987. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27988. /**
  27989. * Sync impostor to a bone
  27990. * @param bone The bone that the impostor will be synced to.
  27991. * @param boneMesh The mesh that the bone is influencing.
  27992. * @param jointPivot The pivot of the joint / bone in local space.
  27993. * @param distToJoint Optional distance from the impostor to the joint.
  27994. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27995. * @param boneAxis Optional vector3 axis the bone is aligned with
  27996. */
  27997. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27998. /**
  27999. * No-Imposter type
  28000. */
  28001. static NoImpostor: number;
  28002. /**
  28003. * Sphere-Imposter type
  28004. */
  28005. static SphereImpostor: number;
  28006. /**
  28007. * Box-Imposter type
  28008. */
  28009. static BoxImpostor: number;
  28010. /**
  28011. * Plane-Imposter type
  28012. */
  28013. static PlaneImpostor: number;
  28014. /**
  28015. * Mesh-imposter type
  28016. */
  28017. static MeshImpostor: number;
  28018. /**
  28019. * Capsule-Impostor type (Ammo.js plugin only)
  28020. */
  28021. static CapsuleImpostor: number;
  28022. /**
  28023. * Cylinder-Imposter type
  28024. */
  28025. static CylinderImpostor: number;
  28026. /**
  28027. * Particle-Imposter type
  28028. */
  28029. static ParticleImpostor: number;
  28030. /**
  28031. * Heightmap-Imposter type
  28032. */
  28033. static HeightmapImpostor: number;
  28034. /**
  28035. * ConvexHull-Impostor type (Ammo.js plugin only)
  28036. */
  28037. static ConvexHullImpostor: number;
  28038. /**
  28039. * Custom-Imposter type (Ammo.js plugin only)
  28040. */
  28041. static CustomImpostor: number;
  28042. /**
  28043. * Rope-Imposter type
  28044. */
  28045. static RopeImpostor: number;
  28046. /**
  28047. * Cloth-Imposter type
  28048. */
  28049. static ClothImpostor: number;
  28050. /**
  28051. * Softbody-Imposter type
  28052. */
  28053. static SoftbodyImpostor: number;
  28054. }
  28055. }
  28056. declare module BABYLON {
  28057. /**
  28058. * @hidden
  28059. **/
  28060. export class _CreationDataStorage {
  28061. closePath?: boolean;
  28062. closeArray?: boolean;
  28063. idx: number[];
  28064. dashSize: number;
  28065. gapSize: number;
  28066. path3D: Path3D;
  28067. pathArray: Vector3[][];
  28068. arc: number;
  28069. radius: number;
  28070. cap: number;
  28071. tessellation: number;
  28072. }
  28073. /**
  28074. * @hidden
  28075. **/
  28076. class _InstanceDataStorage {
  28077. visibleInstances: any;
  28078. batchCache: _InstancesBatch;
  28079. instancesBufferSize: number;
  28080. instancesBuffer: Nullable<Buffer>;
  28081. instancesData: Float32Array;
  28082. overridenInstanceCount: number;
  28083. isFrozen: boolean;
  28084. previousBatch: Nullable<_InstancesBatch>;
  28085. hardwareInstancedRendering: boolean;
  28086. sideOrientation: number;
  28087. manualUpdate: boolean;
  28088. }
  28089. /**
  28090. * @hidden
  28091. **/
  28092. export class _InstancesBatch {
  28093. mustReturn: boolean;
  28094. visibleInstances: Nullable<InstancedMesh[]>[];
  28095. renderSelf: boolean[];
  28096. hardwareInstancedRendering: boolean[];
  28097. }
  28098. /**
  28099. * @hidden
  28100. **/
  28101. class _ThinInstanceDataStorage {
  28102. instancesCount: number;
  28103. matrixBuffer: Nullable<Buffer>;
  28104. matrixBufferSize: number;
  28105. matrixData: Nullable<Float32Array>;
  28106. boundingVectors: Array<Vector3>;
  28107. worldMatrices: Nullable<Matrix[]>;
  28108. }
  28109. /**
  28110. * Class used to represent renderable models
  28111. */
  28112. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28113. /**
  28114. * Mesh side orientation : usually the external or front surface
  28115. */
  28116. static readonly FRONTSIDE: number;
  28117. /**
  28118. * Mesh side orientation : usually the internal or back surface
  28119. */
  28120. static readonly BACKSIDE: number;
  28121. /**
  28122. * Mesh side orientation : both internal and external or front and back surfaces
  28123. */
  28124. static readonly DOUBLESIDE: number;
  28125. /**
  28126. * Mesh side orientation : by default, `FRONTSIDE`
  28127. */
  28128. static readonly DEFAULTSIDE: number;
  28129. /**
  28130. * Mesh cap setting : no cap
  28131. */
  28132. static readonly NO_CAP: number;
  28133. /**
  28134. * Mesh cap setting : one cap at the beginning of the mesh
  28135. */
  28136. static readonly CAP_START: number;
  28137. /**
  28138. * Mesh cap setting : one cap at the end of the mesh
  28139. */
  28140. static readonly CAP_END: number;
  28141. /**
  28142. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28143. */
  28144. static readonly CAP_ALL: number;
  28145. /**
  28146. * Mesh pattern setting : no flip or rotate
  28147. */
  28148. static readonly NO_FLIP: number;
  28149. /**
  28150. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28151. */
  28152. static readonly FLIP_TILE: number;
  28153. /**
  28154. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28155. */
  28156. static readonly ROTATE_TILE: number;
  28157. /**
  28158. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28159. */
  28160. static readonly FLIP_ROW: number;
  28161. /**
  28162. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28163. */
  28164. static readonly ROTATE_ROW: number;
  28165. /**
  28166. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28167. */
  28168. static readonly FLIP_N_ROTATE_TILE: number;
  28169. /**
  28170. * Mesh pattern setting : rotate pattern and rotate
  28171. */
  28172. static readonly FLIP_N_ROTATE_ROW: number;
  28173. /**
  28174. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28175. */
  28176. static readonly CENTER: number;
  28177. /**
  28178. * Mesh tile positioning : part tiles on left
  28179. */
  28180. static readonly LEFT: number;
  28181. /**
  28182. * Mesh tile positioning : part tiles on right
  28183. */
  28184. static readonly RIGHT: number;
  28185. /**
  28186. * Mesh tile positioning : part tiles on top
  28187. */
  28188. static readonly TOP: number;
  28189. /**
  28190. * Mesh tile positioning : part tiles on bottom
  28191. */
  28192. static readonly BOTTOM: number;
  28193. /**
  28194. * Gets the default side orientation.
  28195. * @param orientation the orientation to value to attempt to get
  28196. * @returns the default orientation
  28197. * @hidden
  28198. */
  28199. static _GetDefaultSideOrientation(orientation?: number): number;
  28200. private _internalMeshDataInfo;
  28201. get computeBonesUsingShaders(): boolean;
  28202. set computeBonesUsingShaders(value: boolean);
  28203. /**
  28204. * An event triggered before rendering the mesh
  28205. */
  28206. get onBeforeRenderObservable(): Observable<Mesh>;
  28207. /**
  28208. * An event triggered before binding the mesh
  28209. */
  28210. get onBeforeBindObservable(): Observable<Mesh>;
  28211. /**
  28212. * An event triggered after rendering the mesh
  28213. */
  28214. get onAfterRenderObservable(): Observable<Mesh>;
  28215. /**
  28216. * An event triggered before drawing the mesh
  28217. */
  28218. get onBeforeDrawObservable(): Observable<Mesh>;
  28219. private _onBeforeDrawObserver;
  28220. /**
  28221. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28222. */
  28223. set onBeforeDraw(callback: () => void);
  28224. get hasInstances(): boolean;
  28225. get hasThinInstances(): boolean;
  28226. /**
  28227. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28228. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28229. */
  28230. delayLoadState: number;
  28231. /**
  28232. * Gets the list of instances created from this mesh
  28233. * it is not supposed to be modified manually.
  28234. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28235. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28236. */
  28237. instances: InstancedMesh[];
  28238. /**
  28239. * Gets the file containing delay loading data for this mesh
  28240. */
  28241. delayLoadingFile: string;
  28242. /** @hidden */
  28243. _binaryInfo: any;
  28244. /**
  28245. * User defined function used to change how LOD level selection is done
  28246. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28247. */
  28248. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28249. /**
  28250. * Gets or sets the morph target manager
  28251. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28252. */
  28253. get morphTargetManager(): Nullable<MorphTargetManager>;
  28254. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28255. /** @hidden */
  28256. _creationDataStorage: Nullable<_CreationDataStorage>;
  28257. /** @hidden */
  28258. _geometry: Nullable<Geometry>;
  28259. /** @hidden */
  28260. _delayInfo: Array<string>;
  28261. /** @hidden */
  28262. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28263. /** @hidden */
  28264. _instanceDataStorage: _InstanceDataStorage;
  28265. /** @hidden */
  28266. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28267. private _effectiveMaterial;
  28268. /** @hidden */
  28269. _shouldGenerateFlatShading: boolean;
  28270. /** @hidden */
  28271. _originalBuilderSideOrientation: number;
  28272. /**
  28273. * Use this property to change the original side orientation defined at construction time
  28274. */
  28275. overrideMaterialSideOrientation: Nullable<number>;
  28276. /**
  28277. * Gets the source mesh (the one used to clone this one from)
  28278. */
  28279. get source(): Nullable<Mesh>;
  28280. /**
  28281. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28282. */
  28283. get isUnIndexed(): boolean;
  28284. set isUnIndexed(value: boolean);
  28285. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28286. get worldMatrixInstancedBuffer(): Float32Array;
  28287. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28288. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28289. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28290. /**
  28291. * @constructor
  28292. * @param name The value used by scene.getMeshByName() to do a lookup.
  28293. * @param scene The scene to add this mesh to.
  28294. * @param parent The parent of this mesh, if it has one
  28295. * @param source An optional Mesh from which geometry is shared, cloned.
  28296. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28297. * When false, achieved by calling a clone(), also passing False.
  28298. * This will make creation of children, recursive.
  28299. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28300. */
  28301. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28302. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28303. doNotInstantiate: boolean;
  28304. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28305. /**
  28306. * Gets the class name
  28307. * @returns the string "Mesh".
  28308. */
  28309. getClassName(): string;
  28310. /** @hidden */
  28311. get _isMesh(): boolean;
  28312. /**
  28313. * Returns a description of this mesh
  28314. * @param fullDetails define if full details about this mesh must be used
  28315. * @returns a descriptive string representing this mesh
  28316. */
  28317. toString(fullDetails?: boolean): string;
  28318. /** @hidden */
  28319. _unBindEffect(): void;
  28320. /**
  28321. * Gets a boolean indicating if this mesh has LOD
  28322. */
  28323. get hasLODLevels(): boolean;
  28324. /**
  28325. * Gets the list of MeshLODLevel associated with the current mesh
  28326. * @returns an array of MeshLODLevel
  28327. */
  28328. getLODLevels(): MeshLODLevel[];
  28329. private _sortLODLevels;
  28330. /**
  28331. * Add a mesh as LOD level triggered at the given distance.
  28332. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28333. * @param distance The distance from the center of the object to show this level
  28334. * @param mesh The mesh to be added as LOD level (can be null)
  28335. * @return This mesh (for chaining)
  28336. */
  28337. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28338. /**
  28339. * Returns the LOD level mesh at the passed distance or null if not found.
  28340. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28341. * @param distance The distance from the center of the object to show this level
  28342. * @returns a Mesh or `null`
  28343. */
  28344. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28345. /**
  28346. * Remove a mesh from the LOD array
  28347. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28348. * @param mesh defines the mesh to be removed
  28349. * @return This mesh (for chaining)
  28350. */
  28351. removeLODLevel(mesh: Mesh): Mesh;
  28352. /**
  28353. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28354. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28355. * @param camera defines the camera to use to compute distance
  28356. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28357. * @return This mesh (for chaining)
  28358. */
  28359. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28360. /**
  28361. * Gets the mesh internal Geometry object
  28362. */
  28363. get geometry(): Nullable<Geometry>;
  28364. /**
  28365. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28366. * @returns the total number of vertices
  28367. */
  28368. getTotalVertices(): number;
  28369. /**
  28370. * Returns the content of an associated vertex buffer
  28371. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28372. * - VertexBuffer.PositionKind
  28373. * - VertexBuffer.UVKind
  28374. * - VertexBuffer.UV2Kind
  28375. * - VertexBuffer.UV3Kind
  28376. * - VertexBuffer.UV4Kind
  28377. * - VertexBuffer.UV5Kind
  28378. * - VertexBuffer.UV6Kind
  28379. * - VertexBuffer.ColorKind
  28380. * - VertexBuffer.MatricesIndicesKind
  28381. * - VertexBuffer.MatricesIndicesExtraKind
  28382. * - VertexBuffer.MatricesWeightsKind
  28383. * - VertexBuffer.MatricesWeightsExtraKind
  28384. * @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
  28385. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28386. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28387. */
  28388. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28389. /**
  28390. * Returns the mesh VertexBuffer object from the requested `kind`
  28391. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28392. * - VertexBuffer.PositionKind
  28393. * - VertexBuffer.NormalKind
  28394. * - VertexBuffer.UVKind
  28395. * - VertexBuffer.UV2Kind
  28396. * - VertexBuffer.UV3Kind
  28397. * - VertexBuffer.UV4Kind
  28398. * - VertexBuffer.UV5Kind
  28399. * - VertexBuffer.UV6Kind
  28400. * - VertexBuffer.ColorKind
  28401. * - VertexBuffer.MatricesIndicesKind
  28402. * - VertexBuffer.MatricesIndicesExtraKind
  28403. * - VertexBuffer.MatricesWeightsKind
  28404. * - VertexBuffer.MatricesWeightsExtraKind
  28405. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28406. */
  28407. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28408. /**
  28409. * Tests if a specific vertex buffer is associated with this mesh
  28410. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28411. * - VertexBuffer.PositionKind
  28412. * - VertexBuffer.NormalKind
  28413. * - VertexBuffer.UVKind
  28414. * - VertexBuffer.UV2Kind
  28415. * - VertexBuffer.UV3Kind
  28416. * - VertexBuffer.UV4Kind
  28417. * - VertexBuffer.UV5Kind
  28418. * - VertexBuffer.UV6Kind
  28419. * - VertexBuffer.ColorKind
  28420. * - VertexBuffer.MatricesIndicesKind
  28421. * - VertexBuffer.MatricesIndicesExtraKind
  28422. * - VertexBuffer.MatricesWeightsKind
  28423. * - VertexBuffer.MatricesWeightsExtraKind
  28424. * @returns a boolean
  28425. */
  28426. isVerticesDataPresent(kind: string): boolean;
  28427. /**
  28428. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28429. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28430. * - VertexBuffer.PositionKind
  28431. * - VertexBuffer.UVKind
  28432. * - VertexBuffer.UV2Kind
  28433. * - VertexBuffer.UV3Kind
  28434. * - VertexBuffer.UV4Kind
  28435. * - VertexBuffer.UV5Kind
  28436. * - VertexBuffer.UV6Kind
  28437. * - VertexBuffer.ColorKind
  28438. * - VertexBuffer.MatricesIndicesKind
  28439. * - VertexBuffer.MatricesIndicesExtraKind
  28440. * - VertexBuffer.MatricesWeightsKind
  28441. * - VertexBuffer.MatricesWeightsExtraKind
  28442. * @returns a boolean
  28443. */
  28444. isVertexBufferUpdatable(kind: string): boolean;
  28445. /**
  28446. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28447. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28448. * - VertexBuffer.PositionKind
  28449. * - VertexBuffer.NormalKind
  28450. * - VertexBuffer.UVKind
  28451. * - VertexBuffer.UV2Kind
  28452. * - VertexBuffer.UV3Kind
  28453. * - VertexBuffer.UV4Kind
  28454. * - VertexBuffer.UV5Kind
  28455. * - VertexBuffer.UV6Kind
  28456. * - VertexBuffer.ColorKind
  28457. * - VertexBuffer.MatricesIndicesKind
  28458. * - VertexBuffer.MatricesIndicesExtraKind
  28459. * - VertexBuffer.MatricesWeightsKind
  28460. * - VertexBuffer.MatricesWeightsExtraKind
  28461. * @returns an array of strings
  28462. */
  28463. getVerticesDataKinds(): string[];
  28464. /**
  28465. * Returns a positive integer : the total number of indices in this mesh geometry.
  28466. * @returns the numner of indices or zero if the mesh has no geometry.
  28467. */
  28468. getTotalIndices(): number;
  28469. /**
  28470. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28471. * @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.
  28472. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28473. * @returns the indices array or an empty array if the mesh has no geometry
  28474. */
  28475. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28476. get isBlocked(): boolean;
  28477. /**
  28478. * Determine if the current mesh is ready to be rendered
  28479. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28480. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28481. * @returns true if all associated assets are ready (material, textures, shaders)
  28482. */
  28483. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28484. /**
  28485. * 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.
  28486. */
  28487. get areNormalsFrozen(): boolean;
  28488. /**
  28489. * 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.
  28490. * @returns the current mesh
  28491. */
  28492. freezeNormals(): Mesh;
  28493. /**
  28494. * 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
  28495. * @returns the current mesh
  28496. */
  28497. unfreezeNormals(): Mesh;
  28498. /**
  28499. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28500. */
  28501. set overridenInstanceCount(count: number);
  28502. /** @hidden */
  28503. _preActivate(): Mesh;
  28504. /** @hidden */
  28505. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28506. /** @hidden */
  28507. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28508. protected _afterComputeWorldMatrix(): void;
  28509. /** @hidden */
  28510. _postActivate(): void;
  28511. /**
  28512. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28513. * This means the mesh underlying bounding box and sphere are recomputed.
  28514. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28515. * @returns the current mesh
  28516. */
  28517. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28518. /** @hidden */
  28519. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28520. /**
  28521. * This function will subdivide the mesh into multiple submeshes
  28522. * @param count defines the expected number of submeshes
  28523. */
  28524. subdivide(count: number): void;
  28525. /**
  28526. * Copy a FloatArray into a specific associated vertex buffer
  28527. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28528. * - VertexBuffer.PositionKind
  28529. * - VertexBuffer.UVKind
  28530. * - VertexBuffer.UV2Kind
  28531. * - VertexBuffer.UV3Kind
  28532. * - VertexBuffer.UV4Kind
  28533. * - VertexBuffer.UV5Kind
  28534. * - VertexBuffer.UV6Kind
  28535. * - VertexBuffer.ColorKind
  28536. * - VertexBuffer.MatricesIndicesKind
  28537. * - VertexBuffer.MatricesIndicesExtraKind
  28538. * - VertexBuffer.MatricesWeightsKind
  28539. * - VertexBuffer.MatricesWeightsExtraKind
  28540. * @param data defines the data source
  28541. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28542. * @param stride defines the data stride size (can be null)
  28543. * @returns the current mesh
  28544. */
  28545. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28546. /**
  28547. * Delete a vertex buffer associated with this mesh
  28548. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28549. * - VertexBuffer.PositionKind
  28550. * - VertexBuffer.UVKind
  28551. * - VertexBuffer.UV2Kind
  28552. * - VertexBuffer.UV3Kind
  28553. * - VertexBuffer.UV4Kind
  28554. * - VertexBuffer.UV5Kind
  28555. * - VertexBuffer.UV6Kind
  28556. * - VertexBuffer.ColorKind
  28557. * - VertexBuffer.MatricesIndicesKind
  28558. * - VertexBuffer.MatricesIndicesExtraKind
  28559. * - VertexBuffer.MatricesWeightsKind
  28560. * - VertexBuffer.MatricesWeightsExtraKind
  28561. */
  28562. removeVerticesData(kind: string): void;
  28563. /**
  28564. * Flags an associated vertex buffer as updatable
  28565. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28566. * - VertexBuffer.PositionKind
  28567. * - VertexBuffer.UVKind
  28568. * - VertexBuffer.UV2Kind
  28569. * - VertexBuffer.UV3Kind
  28570. * - VertexBuffer.UV4Kind
  28571. * - VertexBuffer.UV5Kind
  28572. * - VertexBuffer.UV6Kind
  28573. * - VertexBuffer.ColorKind
  28574. * - VertexBuffer.MatricesIndicesKind
  28575. * - VertexBuffer.MatricesIndicesExtraKind
  28576. * - VertexBuffer.MatricesWeightsKind
  28577. * - VertexBuffer.MatricesWeightsExtraKind
  28578. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28579. */
  28580. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28581. /**
  28582. * Sets the mesh global Vertex Buffer
  28583. * @param buffer defines the buffer to use
  28584. * @returns the current mesh
  28585. */
  28586. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28587. /**
  28588. * Update a specific associated vertex buffer
  28589. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28590. * - VertexBuffer.PositionKind
  28591. * - VertexBuffer.UVKind
  28592. * - VertexBuffer.UV2Kind
  28593. * - VertexBuffer.UV3Kind
  28594. * - VertexBuffer.UV4Kind
  28595. * - VertexBuffer.UV5Kind
  28596. * - VertexBuffer.UV6Kind
  28597. * - VertexBuffer.ColorKind
  28598. * - VertexBuffer.MatricesIndicesKind
  28599. * - VertexBuffer.MatricesIndicesExtraKind
  28600. * - VertexBuffer.MatricesWeightsKind
  28601. * - VertexBuffer.MatricesWeightsExtraKind
  28602. * @param data defines the data source
  28603. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28604. * @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)
  28605. * @returns the current mesh
  28606. */
  28607. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28608. /**
  28609. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28610. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28611. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28612. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28613. * @returns the current mesh
  28614. */
  28615. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28616. /**
  28617. * Creates a un-shared specific occurence of the geometry for the mesh.
  28618. * @returns the current mesh
  28619. */
  28620. makeGeometryUnique(): Mesh;
  28621. /**
  28622. * Set the index buffer of this mesh
  28623. * @param indices defines the source data
  28624. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28625. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28626. * @returns the current mesh
  28627. */
  28628. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28629. /**
  28630. * Update the current index buffer
  28631. * @param indices defines the source data
  28632. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28633. * @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)
  28634. * @returns the current mesh
  28635. */
  28636. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28637. /**
  28638. * Invert the geometry to move from a right handed system to a left handed one.
  28639. * @returns the current mesh
  28640. */
  28641. toLeftHanded(): Mesh;
  28642. /** @hidden */
  28643. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28644. /** @hidden */
  28645. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28646. /**
  28647. * Registers for this mesh a javascript function called just before the rendering process
  28648. * @param func defines the function to call before rendering this mesh
  28649. * @returns the current mesh
  28650. */
  28651. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28652. /**
  28653. * Disposes a previously registered javascript function called before the rendering
  28654. * @param func defines the function to remove
  28655. * @returns the current mesh
  28656. */
  28657. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28658. /**
  28659. * Registers for this mesh a javascript function called just after the rendering is complete
  28660. * @param func defines the function to call after rendering this mesh
  28661. * @returns the current mesh
  28662. */
  28663. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28664. /**
  28665. * Disposes a previously registered javascript function called after the rendering.
  28666. * @param func defines the function to remove
  28667. * @returns the current mesh
  28668. */
  28669. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28670. /** @hidden */
  28671. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28672. /** @hidden */
  28673. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28674. /** @hidden */
  28675. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28676. /** @hidden */
  28677. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28678. /** @hidden */
  28679. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28680. /** @hidden */
  28681. _rebuild(): void;
  28682. /** @hidden */
  28683. _freeze(): void;
  28684. /** @hidden */
  28685. _unFreeze(): void;
  28686. /**
  28687. * 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
  28688. * @param subMesh defines the subMesh to render
  28689. * @param enableAlphaMode defines if alpha mode can be changed
  28690. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28691. * @returns the current mesh
  28692. */
  28693. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28694. private _onBeforeDraw;
  28695. /**
  28696. * Renormalize the mesh and patch it up if there are no weights
  28697. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28698. * However in the case of zero weights then we set just a single influence to 1.
  28699. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28700. */
  28701. cleanMatrixWeights(): void;
  28702. private normalizeSkinFourWeights;
  28703. private normalizeSkinWeightsAndExtra;
  28704. /**
  28705. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28706. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28707. * the user know there was an issue with importing the mesh
  28708. * @returns a validation object with skinned, valid and report string
  28709. */
  28710. validateSkinning(): {
  28711. skinned: boolean;
  28712. valid: boolean;
  28713. report: string;
  28714. };
  28715. /** @hidden */
  28716. _checkDelayState(): Mesh;
  28717. private _queueLoad;
  28718. /**
  28719. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28720. * A mesh is in the frustum if its bounding box intersects the frustum
  28721. * @param frustumPlanes defines the frustum to test
  28722. * @returns true if the mesh is in the frustum planes
  28723. */
  28724. isInFrustum(frustumPlanes: Plane[]): boolean;
  28725. /**
  28726. * Sets the mesh material by the material or multiMaterial `id` property
  28727. * @param id is a string identifying the material or the multiMaterial
  28728. * @returns the current mesh
  28729. */
  28730. setMaterialByID(id: string): Mesh;
  28731. /**
  28732. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28733. * @returns an array of IAnimatable
  28734. */
  28735. getAnimatables(): IAnimatable[];
  28736. /**
  28737. * Modifies the mesh geometry according to the passed transformation matrix.
  28738. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28739. * The mesh normals are modified using the same transformation.
  28740. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28741. * @param transform defines the transform matrix to use
  28742. * @see https://doc.babylonjs.com/resources/baking_transformations
  28743. * @returns the current mesh
  28744. */
  28745. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28746. /**
  28747. * Modifies the mesh geometry according to its own current World Matrix.
  28748. * The mesh World Matrix is then reset.
  28749. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28750. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28751. * @see https://doc.babylonjs.com/resources/baking_transformations
  28752. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28753. * @returns the current mesh
  28754. */
  28755. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28756. /** @hidden */
  28757. get _positions(): Nullable<Vector3[]>;
  28758. /** @hidden */
  28759. _resetPointsArrayCache(): Mesh;
  28760. /** @hidden */
  28761. _generatePointsArray(): boolean;
  28762. /**
  28763. * Returns a new Mesh object generated from the current mesh properties.
  28764. * This method must not get confused with createInstance()
  28765. * @param name is a string, the name given to the new mesh
  28766. * @param newParent can be any Node object (default `null`)
  28767. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28768. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28769. * @returns a new mesh
  28770. */
  28771. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28772. /**
  28773. * Releases resources associated with this mesh.
  28774. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28775. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28776. */
  28777. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28778. /** @hidden */
  28779. _disposeInstanceSpecificData(): void;
  28780. /** @hidden */
  28781. _disposeThinInstanceSpecificData(): void;
  28782. /**
  28783. * Modifies the mesh geometry according to a displacement map.
  28784. * 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.
  28785. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28786. * @param url is a string, the URL from the image file is to be downloaded.
  28787. * @param minHeight is the lower limit of the displacement.
  28788. * @param maxHeight is the upper limit of the displacement.
  28789. * @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.
  28790. * @param uvOffset is an optional vector2 used to offset UV.
  28791. * @param uvScale is an optional vector2 used to scale UV.
  28792. * @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.
  28793. * @returns the Mesh.
  28794. */
  28795. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28796. /**
  28797. * Modifies the mesh geometry according to a displacementMap buffer.
  28798. * 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.
  28799. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28800. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28801. * @param heightMapWidth is the width of the buffer image.
  28802. * @param heightMapHeight is the height of the buffer image.
  28803. * @param minHeight is the lower limit of the displacement.
  28804. * @param maxHeight is the upper limit of the displacement.
  28805. * @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.
  28806. * @param uvOffset is an optional vector2 used to offset UV.
  28807. * @param uvScale is an optional vector2 used to scale UV.
  28808. * @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.
  28809. * @returns the Mesh.
  28810. */
  28811. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28812. /**
  28813. * Modify the mesh to get a flat shading rendering.
  28814. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28815. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28816. * @returns current mesh
  28817. */
  28818. convertToFlatShadedMesh(): Mesh;
  28819. /**
  28820. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28821. * In other words, more vertices, no more indices and a single bigger VBO.
  28822. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28823. * @returns current mesh
  28824. */
  28825. convertToUnIndexedMesh(): Mesh;
  28826. /**
  28827. * Inverses facet orientations.
  28828. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28829. * @param flipNormals will also inverts the normals
  28830. * @returns current mesh
  28831. */
  28832. flipFaces(flipNormals?: boolean): Mesh;
  28833. /**
  28834. * Increase the number of facets and hence vertices in a mesh
  28835. * Vertex normals are interpolated from existing vertex normals
  28836. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28837. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28838. */
  28839. increaseVertices(numberPerEdge: number): void;
  28840. /**
  28841. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28842. * This will undo any application of covertToFlatShadedMesh
  28843. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28844. */
  28845. forceSharedVertices(): void;
  28846. /** @hidden */
  28847. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28848. /** @hidden */
  28849. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28850. /**
  28851. * Creates a new InstancedMesh object from the mesh model.
  28852. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28853. * @param name defines the name of the new instance
  28854. * @returns a new InstancedMesh
  28855. */
  28856. createInstance(name: string): InstancedMesh;
  28857. /**
  28858. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28859. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28860. * @returns the current mesh
  28861. */
  28862. synchronizeInstances(): Mesh;
  28863. /**
  28864. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28865. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28866. * This should be used together with the simplification to avoid disappearing triangles.
  28867. * @param successCallback an optional success callback to be called after the optimization finished.
  28868. * @returns the current mesh
  28869. */
  28870. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28871. /**
  28872. * Serialize current mesh
  28873. * @param serializationObject defines the object which will receive the serialization data
  28874. */
  28875. serialize(serializationObject: any): void;
  28876. /** @hidden */
  28877. _syncGeometryWithMorphTargetManager(): void;
  28878. /** @hidden */
  28879. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28880. /**
  28881. * Returns a new Mesh object parsed from the source provided.
  28882. * @param parsedMesh is the source
  28883. * @param scene defines the hosting scene
  28884. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28885. * @returns a new Mesh
  28886. */
  28887. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28888. /**
  28889. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28891. * @param name defines the name of the mesh to create
  28892. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28893. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28894. * @param closePath creates a seam between the first and the last points of each path of the path array
  28895. * @param offset is taken in account only if the `pathArray` is containing a single path
  28896. * @param scene defines the hosting scene
  28897. * @param updatable defines if the mesh must be flagged as updatable
  28898. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28899. * @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)
  28900. * @returns a new Mesh
  28901. */
  28902. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28903. /**
  28904. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28905. * @param name defines the name of the mesh to create
  28906. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28907. * @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
  28908. * @param scene defines the hosting scene
  28909. * @param updatable defines if the mesh must be flagged as updatable
  28910. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28911. * @returns a new Mesh
  28912. */
  28913. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28914. /**
  28915. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28916. * @param name defines the name of the mesh to create
  28917. * @param size sets the size (float) of each box side (default 1)
  28918. * @param scene defines the hosting scene
  28919. * @param updatable defines if the mesh must be flagged as updatable
  28920. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28921. * @returns a new Mesh
  28922. */
  28923. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28924. /**
  28925. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28926. * @param name defines the name of the mesh to create
  28927. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28928. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28929. * @param scene defines the hosting scene
  28930. * @param updatable defines if the mesh must be flagged as updatable
  28931. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28932. * @returns a new Mesh
  28933. */
  28934. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28935. /**
  28936. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28937. * @param name defines the name of the mesh to create
  28938. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28939. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28940. * @param scene defines the hosting scene
  28941. * @returns a new Mesh
  28942. */
  28943. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28944. /**
  28945. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28946. * @param name defines the name of the mesh to create
  28947. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28948. * @param diameterTop set the top cap diameter (floats, default 1)
  28949. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28950. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28951. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28952. * @param scene defines the hosting scene
  28953. * @param updatable defines if the mesh must be flagged as updatable
  28954. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28955. * @returns a new Mesh
  28956. */
  28957. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28958. /**
  28959. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28960. * @param name defines the name of the mesh to create
  28961. * @param diameter sets the diameter size (float) of the torus (default 1)
  28962. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28963. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28964. * @param scene defines the hosting scene
  28965. * @param updatable defines if the mesh must be flagged as updatable
  28966. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28967. * @returns a new Mesh
  28968. */
  28969. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28970. /**
  28971. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28972. * @param name defines the name of the mesh to create
  28973. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28974. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28975. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28976. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28977. * @param p the number of windings on X axis (positive integers, default 2)
  28978. * @param q the number of windings on Y axis (positive integers, default 3)
  28979. * @param scene defines the hosting scene
  28980. * @param updatable defines if the mesh must be flagged as updatable
  28981. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28982. * @returns a new Mesh
  28983. */
  28984. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28985. /**
  28986. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28987. * @param name defines the name of the mesh to create
  28988. * @param points is an array successive Vector3
  28989. * @param scene defines the hosting scene
  28990. * @param updatable defines if the mesh must be flagged as updatable
  28991. * @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).
  28992. * @returns a new Mesh
  28993. */
  28994. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28995. /**
  28996. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28997. * @param name defines the name of the mesh to create
  28998. * @param points is an array successive Vector3
  28999. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29000. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29001. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29002. * @param scene defines the hosting scene
  29003. * @param updatable defines if the mesh must be flagged as updatable
  29004. * @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)
  29005. * @returns a new Mesh
  29006. */
  29007. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29008. /**
  29009. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29010. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29011. * 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.
  29012. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29013. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29014. * Remember you can only change the shape positions, not their number when updating a polygon.
  29015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29016. * @param name defines the name of the mesh to create
  29017. * @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
  29018. * @param scene defines the hosting scene
  29019. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29020. * @param updatable defines if the mesh must be flagged as updatable
  29021. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29022. * @param earcutInjection can be used to inject your own earcut reference
  29023. * @returns a new Mesh
  29024. */
  29025. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29026. /**
  29027. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29029. * @param name defines the name of the mesh to create
  29030. * @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
  29031. * @param depth defines the height of extrusion
  29032. * @param scene defines the hosting scene
  29033. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29034. * @param updatable defines if the mesh must be flagged as updatable
  29035. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29036. * @param earcutInjection can be used to inject your own earcut reference
  29037. * @returns a new Mesh
  29038. */
  29039. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29040. /**
  29041. * Creates an extruded shape mesh.
  29042. * 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
  29043. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29045. * @param name defines the name of the mesh to create
  29046. * @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
  29047. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29048. * @param scale is the value to scale the shape
  29049. * @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
  29050. * @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
  29051. * @param scene defines the hosting scene
  29052. * @param updatable defines if the mesh must be flagged as updatable
  29053. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29054. * @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)
  29055. * @returns a new Mesh
  29056. */
  29057. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29058. /**
  29059. * Creates an custom extruded shape mesh.
  29060. * The custom extrusion is a parametric shape.
  29061. * It has no predefined shape. Its final shape will depend on the input parameters.
  29062. * Please consider using the same method from the MeshBuilder class instead
  29063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29064. * @param name defines the name of the mesh to create
  29065. * @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
  29066. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29067. * @param scaleFunction is a custom Javascript function called on each path point
  29068. * @param rotationFunction is a custom Javascript function called on each path point
  29069. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29070. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29071. * @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
  29072. * @param scene defines the hosting scene
  29073. * @param updatable defines if the mesh must be flagged as updatable
  29074. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29075. * @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)
  29076. * @returns a new Mesh
  29077. */
  29078. 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;
  29079. /**
  29080. * Creates lathe mesh.
  29081. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29082. * Please consider using the same method from the MeshBuilder class instead
  29083. * @param name defines the name of the mesh to create
  29084. * @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
  29085. * @param radius is the radius value of the lathe
  29086. * @param tessellation is the side number of the lathe.
  29087. * @param scene defines the hosting scene
  29088. * @param updatable defines if the mesh must be flagged as updatable
  29089. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29090. * @returns a new Mesh
  29091. */
  29092. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29093. /**
  29094. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29095. * @param name defines the name of the mesh to create
  29096. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29097. * @param scene defines the hosting scene
  29098. * @param updatable defines if the mesh must be flagged as updatable
  29099. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29100. * @returns a new Mesh
  29101. */
  29102. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29103. /**
  29104. * Creates a ground mesh.
  29105. * Please consider using the same method from the MeshBuilder class instead
  29106. * @param name defines the name of the mesh to create
  29107. * @param width set the width of the ground
  29108. * @param height set the height of the ground
  29109. * @param subdivisions sets the number of subdivisions per side
  29110. * @param scene defines the hosting scene
  29111. * @param updatable defines if the mesh must be flagged as updatable
  29112. * @returns a new Mesh
  29113. */
  29114. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29115. /**
  29116. * Creates a tiled ground mesh.
  29117. * Please consider using the same method from the MeshBuilder class instead
  29118. * @param name defines the name of the mesh to create
  29119. * @param xmin set the ground minimum X coordinate
  29120. * @param zmin set the ground minimum Y coordinate
  29121. * @param xmax set the ground maximum X coordinate
  29122. * @param zmax set the ground maximum Z coordinate
  29123. * @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
  29124. * @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
  29125. * @param scene defines the hosting scene
  29126. * @param updatable defines if the mesh must be flagged as updatable
  29127. * @returns a new Mesh
  29128. */
  29129. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29130. w: number;
  29131. h: number;
  29132. }, precision: {
  29133. w: number;
  29134. h: number;
  29135. }, scene: Scene, updatable?: boolean): Mesh;
  29136. /**
  29137. * Creates a ground mesh from a height map.
  29138. * Please consider using the same method from the MeshBuilder class instead
  29139. * @see https://doc.babylonjs.com/babylon101/height_map
  29140. * @param name defines the name of the mesh to create
  29141. * @param url sets the URL of the height map image resource
  29142. * @param width set the ground width size
  29143. * @param height set the ground height size
  29144. * @param subdivisions sets the number of subdivision per side
  29145. * @param minHeight is the minimum altitude on the ground
  29146. * @param maxHeight is the maximum altitude on the ground
  29147. * @param scene defines the hosting scene
  29148. * @param updatable defines if the mesh must be flagged as updatable
  29149. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29150. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29151. * @returns a new Mesh
  29152. */
  29153. 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;
  29154. /**
  29155. * Creates a tube mesh.
  29156. * The tube is a parametric shape.
  29157. * It has no predefined shape. Its final shape will depend on the input parameters.
  29158. * Please consider using the same method from the MeshBuilder class instead
  29159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29160. * @param name defines the name of the mesh to create
  29161. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29162. * @param radius sets the tube radius size
  29163. * @param tessellation is the number of sides on the tubular surface
  29164. * @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
  29165. * @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
  29166. * @param scene defines the hosting scene
  29167. * @param updatable defines if the mesh must be flagged as updatable
  29168. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29169. * @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)
  29170. * @returns a new Mesh
  29171. */
  29172. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29173. (i: number, distance: number): number;
  29174. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29175. /**
  29176. * Creates a polyhedron mesh.
  29177. * Please consider using the same method from the MeshBuilder class instead.
  29178. * * 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
  29179. * * The parameter `size` (positive float, default 1) sets the polygon size
  29180. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29181. * * 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`
  29182. * * 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
  29183. * * 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)`)
  29184. * * 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
  29185. * * 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
  29186. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29187. * * 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
  29188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29189. * @param name defines the name of the mesh to create
  29190. * @param options defines the options used to create the mesh
  29191. * @param scene defines the hosting scene
  29192. * @returns a new Mesh
  29193. */
  29194. static CreatePolyhedron(name: string, options: {
  29195. type?: number;
  29196. size?: number;
  29197. sizeX?: number;
  29198. sizeY?: number;
  29199. sizeZ?: number;
  29200. custom?: any;
  29201. faceUV?: Vector4[];
  29202. faceColors?: Color4[];
  29203. updatable?: boolean;
  29204. sideOrientation?: number;
  29205. }, scene: Scene): Mesh;
  29206. /**
  29207. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29208. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29209. * * 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`)
  29210. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29211. * * 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
  29212. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29213. * * 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
  29214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29215. * @param name defines the name of the mesh
  29216. * @param options defines the options used to create the mesh
  29217. * @param scene defines the hosting scene
  29218. * @returns a new Mesh
  29219. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29220. */
  29221. static CreateIcoSphere(name: string, options: {
  29222. radius?: number;
  29223. flat?: boolean;
  29224. subdivisions?: number;
  29225. sideOrientation?: number;
  29226. updatable?: boolean;
  29227. }, scene: Scene): Mesh;
  29228. /**
  29229. * Creates a decal mesh.
  29230. * Please consider using the same method from the MeshBuilder class instead.
  29231. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29232. * @param name defines the name of the mesh
  29233. * @param sourceMesh defines the mesh receiving the decal
  29234. * @param position sets the position of the decal in world coordinates
  29235. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29236. * @param size sets the decal scaling
  29237. * @param angle sets the angle to rotate the decal
  29238. * @returns a new Mesh
  29239. */
  29240. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29241. /**
  29242. * Prepare internal position array for software CPU skinning
  29243. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29244. */
  29245. setPositionsForCPUSkinning(): Float32Array;
  29246. /**
  29247. * Prepare internal normal array for software CPU skinning
  29248. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29249. */
  29250. setNormalsForCPUSkinning(): Float32Array;
  29251. /**
  29252. * Updates the vertex buffer by applying transformation from the bones
  29253. * @param skeleton defines the skeleton to apply to current mesh
  29254. * @returns the current mesh
  29255. */
  29256. applySkeleton(skeleton: Skeleton): Mesh;
  29257. /**
  29258. * 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
  29259. * @param meshes defines the list of meshes to scan
  29260. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29261. */
  29262. static MinMax(meshes: AbstractMesh[]): {
  29263. min: Vector3;
  29264. max: Vector3;
  29265. };
  29266. /**
  29267. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29268. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29269. * @returns a vector3
  29270. */
  29271. static Center(meshesOrMinMaxVector: {
  29272. min: Vector3;
  29273. max: Vector3;
  29274. } | AbstractMesh[]): Vector3;
  29275. /**
  29276. * Merge the array of meshes into a single mesh for performance reasons.
  29277. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29278. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29279. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29280. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29281. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29282. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29283. * @returns a new mesh
  29284. */
  29285. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29286. /** @hidden */
  29287. addInstance(instance: InstancedMesh): void;
  29288. /** @hidden */
  29289. removeInstance(instance: InstancedMesh): void;
  29290. }
  29291. }
  29292. declare module BABYLON {
  29293. /**
  29294. * This is the base class of all the camera used in the application.
  29295. * @see https://doc.babylonjs.com/features/cameras
  29296. */
  29297. export class Camera extends Node {
  29298. /** @hidden */
  29299. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29300. /**
  29301. * This is the default projection mode used by the cameras.
  29302. * It helps recreating a feeling of perspective and better appreciate depth.
  29303. * This is the best way to simulate real life cameras.
  29304. */
  29305. static readonly PERSPECTIVE_CAMERA: number;
  29306. /**
  29307. * This helps creating camera with an orthographic mode.
  29308. * 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.
  29309. */
  29310. static readonly ORTHOGRAPHIC_CAMERA: number;
  29311. /**
  29312. * This is the default FOV mode for perspective cameras.
  29313. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29314. */
  29315. static readonly FOVMODE_VERTICAL_FIXED: number;
  29316. /**
  29317. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29318. */
  29319. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29320. /**
  29321. * This specifies ther is no need for a camera rig.
  29322. * Basically only one eye is rendered corresponding to the camera.
  29323. */
  29324. static readonly RIG_MODE_NONE: number;
  29325. /**
  29326. * Simulates a camera Rig with one blue eye and one red eye.
  29327. * This can be use with 3d blue and red glasses.
  29328. */
  29329. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29330. /**
  29331. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29332. */
  29333. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29334. /**
  29335. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29336. */
  29337. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29338. /**
  29339. * Defines that both eyes of the camera will be rendered over under each other.
  29340. */
  29341. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29342. /**
  29343. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29344. */
  29345. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29346. /**
  29347. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29348. */
  29349. static readonly RIG_MODE_VR: number;
  29350. /**
  29351. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29352. */
  29353. static readonly RIG_MODE_WEBVR: number;
  29354. /**
  29355. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29356. */
  29357. static readonly RIG_MODE_CUSTOM: number;
  29358. /**
  29359. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29360. */
  29361. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29362. /**
  29363. * Define the input manager associated with the camera.
  29364. */
  29365. inputs: CameraInputsManager<Camera>;
  29366. /** @hidden */
  29367. _position: Vector3;
  29368. /**
  29369. * Define the current local position of the camera in the scene
  29370. */
  29371. get position(): Vector3;
  29372. set position(newPosition: Vector3);
  29373. protected _upVector: Vector3;
  29374. /**
  29375. * The vector the camera should consider as up.
  29376. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29377. */
  29378. set upVector(vec: Vector3);
  29379. get upVector(): Vector3;
  29380. /**
  29381. * Define the current limit on the left side for an orthographic camera
  29382. * In scene unit
  29383. */
  29384. orthoLeft: Nullable<number>;
  29385. /**
  29386. * Define the current limit on the right side for an orthographic camera
  29387. * In scene unit
  29388. */
  29389. orthoRight: Nullable<number>;
  29390. /**
  29391. * Define the current limit on the bottom side for an orthographic camera
  29392. * In scene unit
  29393. */
  29394. orthoBottom: Nullable<number>;
  29395. /**
  29396. * Define the current limit on the top side for an orthographic camera
  29397. * In scene unit
  29398. */
  29399. orthoTop: Nullable<number>;
  29400. /**
  29401. * Field Of View is set in Radians. (default is 0.8)
  29402. */
  29403. fov: number;
  29404. /**
  29405. * Define the minimum distance the camera can see from.
  29406. * This is important to note that the depth buffer are not infinite and the closer it starts
  29407. * the more your scene might encounter depth fighting issue.
  29408. */
  29409. minZ: number;
  29410. /**
  29411. * Define the maximum distance the camera can see to.
  29412. * This is important to note that the depth buffer are not infinite and the further it end
  29413. * the more your scene might encounter depth fighting issue.
  29414. */
  29415. maxZ: number;
  29416. /**
  29417. * Define the default inertia of the camera.
  29418. * This helps giving a smooth feeling to the camera movement.
  29419. */
  29420. inertia: number;
  29421. /**
  29422. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29423. */
  29424. mode: number;
  29425. /**
  29426. * Define whether the camera is intermediate.
  29427. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29428. */
  29429. isIntermediate: boolean;
  29430. /**
  29431. * Define the viewport of the camera.
  29432. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29433. */
  29434. viewport: Viewport;
  29435. /**
  29436. * Restricts the camera to viewing objects with the same layerMask.
  29437. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29438. */
  29439. layerMask: number;
  29440. /**
  29441. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29442. */
  29443. fovMode: number;
  29444. /**
  29445. * Rig mode of the camera.
  29446. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29447. * This is normally controlled byt the camera themselves as internal use.
  29448. */
  29449. cameraRigMode: number;
  29450. /**
  29451. * Defines the distance between both "eyes" in case of a RIG
  29452. */
  29453. interaxialDistance: number;
  29454. /**
  29455. * Defines if stereoscopic rendering is done side by side or over under.
  29456. */
  29457. isStereoscopicSideBySide: boolean;
  29458. /**
  29459. * 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
  29460. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29461. * else in the scene. (Eg. security camera)
  29462. *
  29463. * 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)
  29464. */
  29465. customRenderTargets: RenderTargetTexture[];
  29466. /**
  29467. * When set, the camera will render to this render target instead of the default canvas
  29468. *
  29469. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29470. */
  29471. outputRenderTarget: Nullable<RenderTargetTexture>;
  29472. /**
  29473. * Observable triggered when the camera view matrix has changed.
  29474. */
  29475. onViewMatrixChangedObservable: Observable<Camera>;
  29476. /**
  29477. * Observable triggered when the camera Projection matrix has changed.
  29478. */
  29479. onProjectionMatrixChangedObservable: Observable<Camera>;
  29480. /**
  29481. * Observable triggered when the inputs have been processed.
  29482. */
  29483. onAfterCheckInputsObservable: Observable<Camera>;
  29484. /**
  29485. * Observable triggered when reset has been called and applied to the camera.
  29486. */
  29487. onRestoreStateObservable: Observable<Camera>;
  29488. /**
  29489. * Is this camera a part of a rig system?
  29490. */
  29491. isRigCamera: boolean;
  29492. /**
  29493. * If isRigCamera set to true this will be set with the parent camera.
  29494. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29495. */
  29496. rigParent?: Camera;
  29497. /** @hidden */
  29498. _cameraRigParams: any;
  29499. /** @hidden */
  29500. _rigCameras: Camera[];
  29501. /** @hidden */
  29502. _rigPostProcess: Nullable<PostProcess>;
  29503. protected _webvrViewMatrix: Matrix;
  29504. /** @hidden */
  29505. _skipRendering: boolean;
  29506. /** @hidden */
  29507. _projectionMatrix: Matrix;
  29508. /** @hidden */
  29509. _postProcesses: Nullable<PostProcess>[];
  29510. /** @hidden */
  29511. _activeMeshes: SmartArray<AbstractMesh>;
  29512. protected _globalPosition: Vector3;
  29513. /** @hidden */
  29514. _computedViewMatrix: Matrix;
  29515. private _doNotComputeProjectionMatrix;
  29516. private _transformMatrix;
  29517. private _frustumPlanes;
  29518. private _refreshFrustumPlanes;
  29519. private _storedFov;
  29520. private _stateStored;
  29521. /**
  29522. * Instantiates a new camera object.
  29523. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29524. * @see https://doc.babylonjs.com/features/cameras
  29525. * @param name Defines the name of the camera in the scene
  29526. * @param position Defines the position of the camera
  29527. * @param scene Defines the scene the camera belongs too
  29528. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29529. */
  29530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29531. /**
  29532. * Store current camera state (fov, position, etc..)
  29533. * @returns the camera
  29534. */
  29535. storeState(): Camera;
  29536. /**
  29537. * Restores the camera state values if it has been stored. You must call storeState() first
  29538. */
  29539. protected _restoreStateValues(): boolean;
  29540. /**
  29541. * Restored camera state. You must call storeState() first.
  29542. * @returns true if restored and false otherwise
  29543. */
  29544. restoreState(): boolean;
  29545. /**
  29546. * Gets the class name of the camera.
  29547. * @returns the class name
  29548. */
  29549. getClassName(): string;
  29550. /** @hidden */
  29551. readonly _isCamera: boolean;
  29552. /**
  29553. * Gets a string representation of the camera useful for debug purpose.
  29554. * @param fullDetails Defines that a more verboe level of logging is required
  29555. * @returns the string representation
  29556. */
  29557. toString(fullDetails?: boolean): string;
  29558. /**
  29559. * Gets the current world space position of the camera.
  29560. */
  29561. get globalPosition(): Vector3;
  29562. /**
  29563. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29564. * @returns the active meshe list
  29565. */
  29566. getActiveMeshes(): SmartArray<AbstractMesh>;
  29567. /**
  29568. * Check whether a mesh is part of the current active mesh list of the camera
  29569. * @param mesh Defines the mesh to check
  29570. * @returns true if active, false otherwise
  29571. */
  29572. isActiveMesh(mesh: Mesh): boolean;
  29573. /**
  29574. * Is this camera ready to be used/rendered
  29575. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29576. * @return true if the camera is ready
  29577. */
  29578. isReady(completeCheck?: boolean): boolean;
  29579. /** @hidden */
  29580. _initCache(): void;
  29581. /** @hidden */
  29582. _updateCache(ignoreParentClass?: boolean): void;
  29583. /** @hidden */
  29584. _isSynchronized(): boolean;
  29585. /** @hidden */
  29586. _isSynchronizedViewMatrix(): boolean;
  29587. /** @hidden */
  29588. _isSynchronizedProjectionMatrix(): boolean;
  29589. /**
  29590. * Attach the input controls to a specific dom element to get the input from.
  29591. * @param element Defines the element the controls should be listened from
  29592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29593. */
  29594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29595. /**
  29596. * Detach the current controls from the specified dom element.
  29597. * @param element Defines the element to stop listening the inputs from
  29598. */
  29599. detachControl(element: HTMLElement): void;
  29600. /**
  29601. * Update the camera state according to the different inputs gathered during the frame.
  29602. */
  29603. update(): void;
  29604. /** @hidden */
  29605. _checkInputs(): void;
  29606. /** @hidden */
  29607. get rigCameras(): Camera[];
  29608. /**
  29609. * Gets the post process used by the rig cameras
  29610. */
  29611. get rigPostProcess(): Nullable<PostProcess>;
  29612. /**
  29613. * Internal, gets the first post proces.
  29614. * @returns the first post process to be run on this camera.
  29615. */
  29616. _getFirstPostProcess(): Nullable<PostProcess>;
  29617. private _cascadePostProcessesToRigCams;
  29618. /**
  29619. * Attach a post process to the camera.
  29620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29621. * @param postProcess The post process to attach to the camera
  29622. * @param insertAt The position of the post process in case several of them are in use in the scene
  29623. * @returns the position the post process has been inserted at
  29624. */
  29625. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29626. /**
  29627. * Detach a post process to the camera.
  29628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29629. * @param postProcess The post process to detach from the camera
  29630. */
  29631. detachPostProcess(postProcess: PostProcess): void;
  29632. /**
  29633. * Gets the current world matrix of the camera
  29634. */
  29635. getWorldMatrix(): Matrix;
  29636. /** @hidden */
  29637. _getViewMatrix(): Matrix;
  29638. /**
  29639. * Gets the current view matrix of the camera.
  29640. * @param force forces the camera to recompute the matrix without looking at the cached state
  29641. * @returns the view matrix
  29642. */
  29643. getViewMatrix(force?: boolean): Matrix;
  29644. /**
  29645. * Freeze the projection matrix.
  29646. * It will prevent the cache check of the camera projection compute and can speed up perf
  29647. * if no parameter of the camera are meant to change
  29648. * @param projection Defines manually a projection if necessary
  29649. */
  29650. freezeProjectionMatrix(projection?: Matrix): void;
  29651. /**
  29652. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29653. */
  29654. unfreezeProjectionMatrix(): void;
  29655. /**
  29656. * Gets the current projection matrix of the camera.
  29657. * @param force forces the camera to recompute the matrix without looking at the cached state
  29658. * @returns the projection matrix
  29659. */
  29660. getProjectionMatrix(force?: boolean): Matrix;
  29661. /**
  29662. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29663. * @returns a Matrix
  29664. */
  29665. getTransformationMatrix(): Matrix;
  29666. private _updateFrustumPlanes;
  29667. /**
  29668. * Checks if a cullable object (mesh...) is in the camera frustum
  29669. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29670. * @param target The object to check
  29671. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29672. * @returns true if the object is in frustum otherwise false
  29673. */
  29674. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29675. /**
  29676. * Checks if a cullable object (mesh...) is in the camera frustum
  29677. * Unlike isInFrustum this cheks the full bounding box
  29678. * @param target The object to check
  29679. * @returns true if the object is in frustum otherwise false
  29680. */
  29681. isCompletelyInFrustum(target: ICullable): boolean;
  29682. /**
  29683. * Gets a ray in the forward direction from the camera.
  29684. * @param length Defines the length of the ray to create
  29685. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29686. * @param origin Defines the start point of the ray which defaults to the camera position
  29687. * @returns the forward ray
  29688. */
  29689. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29690. /**
  29691. * Gets a ray in the forward direction from the camera.
  29692. * @param refRay the ray to (re)use when setting the values
  29693. * @param length Defines the length of the ray to create
  29694. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29695. * @param origin Defines the start point of the ray which defaults to the camera position
  29696. * @returns the forward ray
  29697. */
  29698. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29699. /**
  29700. * Releases resources associated with this node.
  29701. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29702. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29703. */
  29704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29705. /** @hidden */
  29706. _isLeftCamera: boolean;
  29707. /**
  29708. * Gets the left camera of a rig setup in case of Rigged Camera
  29709. */
  29710. get isLeftCamera(): boolean;
  29711. /** @hidden */
  29712. _isRightCamera: boolean;
  29713. /**
  29714. * Gets the right camera of a rig setup in case of Rigged Camera
  29715. */
  29716. get isRightCamera(): boolean;
  29717. /**
  29718. * Gets the left camera of a rig setup in case of Rigged Camera
  29719. */
  29720. get leftCamera(): Nullable<FreeCamera>;
  29721. /**
  29722. * Gets the right camera of a rig setup in case of Rigged Camera
  29723. */
  29724. get rightCamera(): Nullable<FreeCamera>;
  29725. /**
  29726. * Gets the left camera target of a rig setup in case of Rigged Camera
  29727. * @returns the target position
  29728. */
  29729. getLeftTarget(): Nullable<Vector3>;
  29730. /**
  29731. * Gets the right camera target of a rig setup in case of Rigged Camera
  29732. * @returns the target position
  29733. */
  29734. getRightTarget(): Nullable<Vector3>;
  29735. /**
  29736. * @hidden
  29737. */
  29738. setCameraRigMode(mode: number, rigParams: any): void;
  29739. /** @hidden */
  29740. static _setStereoscopicRigMode(camera: Camera): void;
  29741. /** @hidden */
  29742. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29743. /** @hidden */
  29744. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29745. /** @hidden */
  29746. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29747. /** @hidden */
  29748. _getVRProjectionMatrix(): Matrix;
  29749. protected _updateCameraRotationMatrix(): void;
  29750. protected _updateWebVRCameraRotationMatrix(): void;
  29751. /**
  29752. * This function MUST be overwritten by the different WebVR cameras available.
  29753. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29754. * @hidden
  29755. */
  29756. _getWebVRProjectionMatrix(): Matrix;
  29757. /**
  29758. * This function MUST be overwritten by the different WebVR cameras available.
  29759. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29760. * @hidden
  29761. */
  29762. _getWebVRViewMatrix(): Matrix;
  29763. /** @hidden */
  29764. setCameraRigParameter(name: string, value: any): void;
  29765. /**
  29766. * needs to be overridden by children so sub has required properties to be copied
  29767. * @hidden
  29768. */
  29769. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29770. /**
  29771. * May need to be overridden by children
  29772. * @hidden
  29773. */
  29774. _updateRigCameras(): void;
  29775. /** @hidden */
  29776. _setupInputs(): void;
  29777. /**
  29778. * Serialiaze the camera setup to a json represention
  29779. * @returns the JSON representation
  29780. */
  29781. serialize(): any;
  29782. /**
  29783. * Clones the current camera.
  29784. * @param name The cloned camera name
  29785. * @returns the cloned camera
  29786. */
  29787. clone(name: string): Camera;
  29788. /**
  29789. * Gets the direction of the camera relative to a given local axis.
  29790. * @param localAxis Defines the reference axis to provide a relative direction.
  29791. * @return the direction
  29792. */
  29793. getDirection(localAxis: Vector3): Vector3;
  29794. /**
  29795. * Returns the current camera absolute rotation
  29796. */
  29797. get absoluteRotation(): Quaternion;
  29798. /**
  29799. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29800. * @param localAxis Defines the reference axis to provide a relative direction.
  29801. * @param result Defines the vector to store the result in
  29802. */
  29803. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29804. /**
  29805. * Gets a camera constructor for a given camera type
  29806. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29807. * @param name The name of the camera the result will be able to instantiate
  29808. * @param scene The scene the result will construct the camera in
  29809. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29810. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29811. * @returns a factory method to construc the camera
  29812. */
  29813. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29814. /**
  29815. * Compute the world matrix of the camera.
  29816. * @returns the camera world matrix
  29817. */
  29818. computeWorldMatrix(): Matrix;
  29819. /**
  29820. * Parse a JSON and creates the camera from the parsed information
  29821. * @param parsedCamera The JSON to parse
  29822. * @param scene The scene to instantiate the camera in
  29823. * @returns the newly constructed camera
  29824. */
  29825. static Parse(parsedCamera: any, scene: Scene): Camera;
  29826. }
  29827. }
  29828. declare module BABYLON {
  29829. /**
  29830. * Class containing static functions to help procedurally build meshes
  29831. */
  29832. export class DiscBuilder {
  29833. /**
  29834. * Creates a plane polygonal mesh. By default, this is a disc
  29835. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29836. * * 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
  29837. * * 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
  29838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29839. * * 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
  29840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29841. * @param name defines the name of the mesh
  29842. * @param options defines the options used to create the mesh
  29843. * @param scene defines the hosting scene
  29844. * @returns the plane polygonal mesh
  29845. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29846. */
  29847. static CreateDisc(name: string, options: {
  29848. radius?: number;
  29849. tessellation?: number;
  29850. arc?: number;
  29851. updatable?: boolean;
  29852. sideOrientation?: number;
  29853. frontUVs?: Vector4;
  29854. backUVs?: Vector4;
  29855. }, scene?: Nullable<Scene>): Mesh;
  29856. }
  29857. }
  29858. declare module BABYLON {
  29859. /**
  29860. * Options to be used when creating a FresnelParameters.
  29861. */
  29862. export type IFresnelParametersCreationOptions = {
  29863. /**
  29864. * Define the color used on edges (grazing angle)
  29865. */
  29866. leftColor?: Color3;
  29867. /**
  29868. * Define the color used on center
  29869. */
  29870. rightColor?: Color3;
  29871. /**
  29872. * Define bias applied to computed fresnel term
  29873. */
  29874. bias?: number;
  29875. /**
  29876. * Defined the power exponent applied to fresnel term
  29877. */
  29878. power?: number;
  29879. /**
  29880. * Define if the fresnel effect is enable or not.
  29881. */
  29882. isEnabled?: boolean;
  29883. };
  29884. /**
  29885. * Serialized format for FresnelParameters.
  29886. */
  29887. export type IFresnelParametersSerialized = {
  29888. /**
  29889. * Define the color used on edges (grazing angle) [as an array]
  29890. */
  29891. leftColor: number[];
  29892. /**
  29893. * Define the color used on center [as an array]
  29894. */
  29895. rightColor: number[];
  29896. /**
  29897. * Define bias applied to computed fresnel term
  29898. */
  29899. bias: number;
  29900. /**
  29901. * Defined the power exponent applied to fresnel term
  29902. */
  29903. power?: number;
  29904. /**
  29905. * Define if the fresnel effect is enable or not.
  29906. */
  29907. isEnabled: boolean;
  29908. };
  29909. /**
  29910. * This represents all the required information to add a fresnel effect on a material:
  29911. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29912. */
  29913. export class FresnelParameters {
  29914. private _isEnabled;
  29915. /**
  29916. * Define if the fresnel effect is enable or not.
  29917. */
  29918. get isEnabled(): boolean;
  29919. set isEnabled(value: boolean);
  29920. /**
  29921. * Define the color used on edges (grazing angle)
  29922. */
  29923. leftColor: Color3;
  29924. /**
  29925. * Define the color used on center
  29926. */
  29927. rightColor: Color3;
  29928. /**
  29929. * Define bias applied to computed fresnel term
  29930. */
  29931. bias: number;
  29932. /**
  29933. * Defined the power exponent applied to fresnel term
  29934. */
  29935. power: number;
  29936. /**
  29937. * Creates a new FresnelParameters object.
  29938. *
  29939. * @param options provide your own settings to optionally to override defaults
  29940. */
  29941. constructor(options?: IFresnelParametersCreationOptions);
  29942. /**
  29943. * Clones the current fresnel and its valuues
  29944. * @returns a clone fresnel configuration
  29945. */
  29946. clone(): FresnelParameters;
  29947. /**
  29948. * Determines equality between FresnelParameters objects
  29949. * @param otherFresnelParameters defines the second operand
  29950. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29951. */
  29952. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29953. /**
  29954. * Serializes the current fresnel parameters to a JSON representation.
  29955. * @return the JSON serialization
  29956. */
  29957. serialize(): IFresnelParametersSerialized;
  29958. /**
  29959. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29960. * @param parsedFresnelParameters Define the JSON representation
  29961. * @returns the parsed parameters
  29962. */
  29963. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29964. }
  29965. }
  29966. declare module BABYLON {
  29967. /**
  29968. * This groups all the flags used to control the materials channel.
  29969. */
  29970. export class MaterialFlags {
  29971. private static _DiffuseTextureEnabled;
  29972. /**
  29973. * Are diffuse textures enabled in the application.
  29974. */
  29975. static get DiffuseTextureEnabled(): boolean;
  29976. static set DiffuseTextureEnabled(value: boolean);
  29977. private static _DetailTextureEnabled;
  29978. /**
  29979. * Are detail textures enabled in the application.
  29980. */
  29981. static get DetailTextureEnabled(): boolean;
  29982. static set DetailTextureEnabled(value: boolean);
  29983. private static _AmbientTextureEnabled;
  29984. /**
  29985. * Are ambient textures enabled in the application.
  29986. */
  29987. static get AmbientTextureEnabled(): boolean;
  29988. static set AmbientTextureEnabled(value: boolean);
  29989. private static _OpacityTextureEnabled;
  29990. /**
  29991. * Are opacity textures enabled in the application.
  29992. */
  29993. static get OpacityTextureEnabled(): boolean;
  29994. static set OpacityTextureEnabled(value: boolean);
  29995. private static _ReflectionTextureEnabled;
  29996. /**
  29997. * Are reflection textures enabled in the application.
  29998. */
  29999. static get ReflectionTextureEnabled(): boolean;
  30000. static set ReflectionTextureEnabled(value: boolean);
  30001. private static _EmissiveTextureEnabled;
  30002. /**
  30003. * Are emissive textures enabled in the application.
  30004. */
  30005. static get EmissiveTextureEnabled(): boolean;
  30006. static set EmissiveTextureEnabled(value: boolean);
  30007. private static _SpecularTextureEnabled;
  30008. /**
  30009. * Are specular textures enabled in the application.
  30010. */
  30011. static get SpecularTextureEnabled(): boolean;
  30012. static set SpecularTextureEnabled(value: boolean);
  30013. private static _BumpTextureEnabled;
  30014. /**
  30015. * Are bump textures enabled in the application.
  30016. */
  30017. static get BumpTextureEnabled(): boolean;
  30018. static set BumpTextureEnabled(value: boolean);
  30019. private static _LightmapTextureEnabled;
  30020. /**
  30021. * Are lightmap textures enabled in the application.
  30022. */
  30023. static get LightmapTextureEnabled(): boolean;
  30024. static set LightmapTextureEnabled(value: boolean);
  30025. private static _RefractionTextureEnabled;
  30026. /**
  30027. * Are refraction textures enabled in the application.
  30028. */
  30029. static get RefractionTextureEnabled(): boolean;
  30030. static set RefractionTextureEnabled(value: boolean);
  30031. private static _ColorGradingTextureEnabled;
  30032. /**
  30033. * Are color grading textures enabled in the application.
  30034. */
  30035. static get ColorGradingTextureEnabled(): boolean;
  30036. static set ColorGradingTextureEnabled(value: boolean);
  30037. private static _FresnelEnabled;
  30038. /**
  30039. * Are fresnels enabled in the application.
  30040. */
  30041. static get FresnelEnabled(): boolean;
  30042. static set FresnelEnabled(value: boolean);
  30043. private static _ClearCoatTextureEnabled;
  30044. /**
  30045. * Are clear coat textures enabled in the application.
  30046. */
  30047. static get ClearCoatTextureEnabled(): boolean;
  30048. static set ClearCoatTextureEnabled(value: boolean);
  30049. private static _ClearCoatBumpTextureEnabled;
  30050. /**
  30051. * Are clear coat bump textures enabled in the application.
  30052. */
  30053. static get ClearCoatBumpTextureEnabled(): boolean;
  30054. static set ClearCoatBumpTextureEnabled(value: boolean);
  30055. private static _ClearCoatTintTextureEnabled;
  30056. /**
  30057. * Are clear coat tint textures enabled in the application.
  30058. */
  30059. static get ClearCoatTintTextureEnabled(): boolean;
  30060. static set ClearCoatTintTextureEnabled(value: boolean);
  30061. private static _SheenTextureEnabled;
  30062. /**
  30063. * Are sheen textures enabled in the application.
  30064. */
  30065. static get SheenTextureEnabled(): boolean;
  30066. static set SheenTextureEnabled(value: boolean);
  30067. private static _AnisotropicTextureEnabled;
  30068. /**
  30069. * Are anisotropic textures enabled in the application.
  30070. */
  30071. static get AnisotropicTextureEnabled(): boolean;
  30072. static set AnisotropicTextureEnabled(value: boolean);
  30073. private static _ThicknessTextureEnabled;
  30074. /**
  30075. * Are thickness textures enabled in the application.
  30076. */
  30077. static get ThicknessTextureEnabled(): boolean;
  30078. static set ThicknessTextureEnabled(value: boolean);
  30079. }
  30080. }
  30081. declare module BABYLON {
  30082. /** @hidden */
  30083. export var defaultFragmentDeclaration: {
  30084. name: string;
  30085. shader: string;
  30086. };
  30087. }
  30088. declare module BABYLON {
  30089. /** @hidden */
  30090. export var defaultUboDeclaration: {
  30091. name: string;
  30092. shader: string;
  30093. };
  30094. }
  30095. declare module BABYLON {
  30096. /** @hidden */
  30097. export var prePassDeclaration: {
  30098. name: string;
  30099. shader: string;
  30100. };
  30101. }
  30102. declare module BABYLON {
  30103. /** @hidden */
  30104. export var lightFragmentDeclaration: {
  30105. name: string;
  30106. shader: string;
  30107. };
  30108. }
  30109. declare module BABYLON {
  30110. /** @hidden */
  30111. export var lightUboDeclaration: {
  30112. name: string;
  30113. shader: string;
  30114. };
  30115. }
  30116. declare module BABYLON {
  30117. /** @hidden */
  30118. export var lightsFragmentFunctions: {
  30119. name: string;
  30120. shader: string;
  30121. };
  30122. }
  30123. declare module BABYLON {
  30124. /** @hidden */
  30125. export var shadowsFragmentFunctions: {
  30126. name: string;
  30127. shader: string;
  30128. };
  30129. }
  30130. declare module BABYLON {
  30131. /** @hidden */
  30132. export var fresnelFunction: {
  30133. name: string;
  30134. shader: string;
  30135. };
  30136. }
  30137. declare module BABYLON {
  30138. /** @hidden */
  30139. export var bumpFragmentMainFunctions: {
  30140. name: string;
  30141. shader: string;
  30142. };
  30143. }
  30144. declare module BABYLON {
  30145. /** @hidden */
  30146. export var bumpFragmentFunctions: {
  30147. name: string;
  30148. shader: string;
  30149. };
  30150. }
  30151. declare module BABYLON {
  30152. /** @hidden */
  30153. export var logDepthDeclaration: {
  30154. name: string;
  30155. shader: string;
  30156. };
  30157. }
  30158. declare module BABYLON {
  30159. /** @hidden */
  30160. export var bumpFragment: {
  30161. name: string;
  30162. shader: string;
  30163. };
  30164. }
  30165. declare module BABYLON {
  30166. /** @hidden */
  30167. export var depthPrePass: {
  30168. name: string;
  30169. shader: string;
  30170. };
  30171. }
  30172. declare module BABYLON {
  30173. /** @hidden */
  30174. export var lightFragment: {
  30175. name: string;
  30176. shader: string;
  30177. };
  30178. }
  30179. declare module BABYLON {
  30180. /** @hidden */
  30181. export var logDepthFragment: {
  30182. name: string;
  30183. shader: string;
  30184. };
  30185. }
  30186. declare module BABYLON {
  30187. /** @hidden */
  30188. export var defaultPixelShader: {
  30189. name: string;
  30190. shader: string;
  30191. };
  30192. }
  30193. declare module BABYLON {
  30194. /** @hidden */
  30195. export var defaultVertexDeclaration: {
  30196. name: string;
  30197. shader: string;
  30198. };
  30199. }
  30200. declare module BABYLON {
  30201. /** @hidden */
  30202. export var bumpVertexDeclaration: {
  30203. name: string;
  30204. shader: string;
  30205. };
  30206. }
  30207. declare module BABYLON {
  30208. /** @hidden */
  30209. export var bumpVertex: {
  30210. name: string;
  30211. shader: string;
  30212. };
  30213. }
  30214. declare module BABYLON {
  30215. /** @hidden */
  30216. export var fogVertex: {
  30217. name: string;
  30218. shader: string;
  30219. };
  30220. }
  30221. declare module BABYLON {
  30222. /** @hidden */
  30223. export var shadowsVertex: {
  30224. name: string;
  30225. shader: string;
  30226. };
  30227. }
  30228. declare module BABYLON {
  30229. /** @hidden */
  30230. export var pointCloudVertex: {
  30231. name: string;
  30232. shader: string;
  30233. };
  30234. }
  30235. declare module BABYLON {
  30236. /** @hidden */
  30237. export var logDepthVertex: {
  30238. name: string;
  30239. shader: string;
  30240. };
  30241. }
  30242. declare module BABYLON {
  30243. /** @hidden */
  30244. export var defaultVertexShader: {
  30245. name: string;
  30246. shader: string;
  30247. };
  30248. }
  30249. declare module BABYLON {
  30250. /**
  30251. * @hidden
  30252. */
  30253. export interface IMaterialDetailMapDefines {
  30254. DETAIL: boolean;
  30255. DETAILDIRECTUV: number;
  30256. DETAIL_NORMALBLENDMETHOD: number;
  30257. /** @hidden */
  30258. _areTexturesDirty: boolean;
  30259. }
  30260. /**
  30261. * Define the code related to the detail map parameters of a material
  30262. *
  30263. * Inspired from:
  30264. * 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
  30265. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30266. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30267. */
  30268. export class DetailMapConfiguration {
  30269. private _texture;
  30270. /**
  30271. * The detail texture of the material.
  30272. */
  30273. texture: Nullable<BaseTexture>;
  30274. /**
  30275. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30276. * Bigger values mean stronger blending
  30277. */
  30278. diffuseBlendLevel: number;
  30279. /**
  30280. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30281. * Bigger values mean stronger blending. Only used with PBR materials
  30282. */
  30283. roughnessBlendLevel: number;
  30284. /**
  30285. * Defines how strong the bump effect from the detail map is
  30286. * Bigger values mean stronger effect
  30287. */
  30288. bumpLevel: number;
  30289. private _normalBlendMethod;
  30290. /**
  30291. * The method used to blend the bump and detail normals together
  30292. */
  30293. normalBlendMethod: number;
  30294. private _isEnabled;
  30295. /**
  30296. * Enable or disable the detail map on this material
  30297. */
  30298. isEnabled: boolean;
  30299. /** @hidden */
  30300. private _internalMarkAllSubMeshesAsTexturesDirty;
  30301. /** @hidden */
  30302. _markAllSubMeshesAsTexturesDirty(): void;
  30303. /**
  30304. * Instantiate a new detail map
  30305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30306. */
  30307. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30308. /**
  30309. * Gets whether the submesh is ready to be used or not.
  30310. * @param defines the list of "defines" to update.
  30311. * @param scene defines the scene the material belongs to.
  30312. * @returns - boolean indicating that the submesh is ready or not.
  30313. */
  30314. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30315. /**
  30316. * Update the defines for detail map usage
  30317. * @param defines the list of "defines" to update.
  30318. * @param scene defines the scene the material belongs to.
  30319. */
  30320. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30321. /**
  30322. * Binds the material data.
  30323. * @param uniformBuffer defines the Uniform buffer to fill in.
  30324. * @param scene defines the scene the material belongs to.
  30325. * @param isFrozen defines whether the material is frozen or not.
  30326. */
  30327. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30328. /**
  30329. * Checks to see if a texture is used in the material.
  30330. * @param texture - Base texture to use.
  30331. * @returns - Boolean specifying if a texture is used in the material.
  30332. */
  30333. hasTexture(texture: BaseTexture): boolean;
  30334. /**
  30335. * Returns an array of the actively used textures.
  30336. * @param activeTextures Array of BaseTextures
  30337. */
  30338. getActiveTextures(activeTextures: BaseTexture[]): void;
  30339. /**
  30340. * Returns the animatable textures.
  30341. * @param animatables Array of animatable textures.
  30342. */
  30343. getAnimatables(animatables: IAnimatable[]): void;
  30344. /**
  30345. * Disposes the resources of the material.
  30346. * @param forceDisposeTextures - Forces the disposal of all textures.
  30347. */
  30348. dispose(forceDisposeTextures?: boolean): void;
  30349. /**
  30350. * Get the current class name useful for serialization or dynamic coding.
  30351. * @returns "DetailMap"
  30352. */
  30353. getClassName(): string;
  30354. /**
  30355. * Add the required uniforms to the current list.
  30356. * @param uniforms defines the current uniform list.
  30357. */
  30358. static AddUniforms(uniforms: string[]): void;
  30359. /**
  30360. * Add the required samplers to the current list.
  30361. * @param samplers defines the current sampler list.
  30362. */
  30363. static AddSamplers(samplers: string[]): void;
  30364. /**
  30365. * Add the required uniforms to the current buffer.
  30366. * @param uniformBuffer defines the current uniform buffer.
  30367. */
  30368. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30369. /**
  30370. * Makes a duplicate of the current instance into another one.
  30371. * @param detailMap define the instance where to copy the info
  30372. */
  30373. copyTo(detailMap: DetailMapConfiguration): void;
  30374. /**
  30375. * Serializes this detail map instance
  30376. * @returns - An object with the serialized instance.
  30377. */
  30378. serialize(): any;
  30379. /**
  30380. * Parses a detail map setting from a serialized object.
  30381. * @param source - Serialized object.
  30382. * @param scene Defines the scene we are parsing for
  30383. * @param rootUrl Defines the rootUrl to load from
  30384. */
  30385. parse(source: any, scene: Scene, rootUrl: string): void;
  30386. }
  30387. }
  30388. declare module BABYLON {
  30389. /** @hidden */
  30390. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30391. MAINUV1: boolean;
  30392. MAINUV2: boolean;
  30393. DIFFUSE: boolean;
  30394. DIFFUSEDIRECTUV: number;
  30395. DETAIL: boolean;
  30396. DETAILDIRECTUV: number;
  30397. DETAIL_NORMALBLENDMETHOD: number;
  30398. AMBIENT: boolean;
  30399. AMBIENTDIRECTUV: number;
  30400. OPACITY: boolean;
  30401. OPACITYDIRECTUV: number;
  30402. OPACITYRGB: boolean;
  30403. REFLECTION: boolean;
  30404. EMISSIVE: boolean;
  30405. EMISSIVEDIRECTUV: number;
  30406. SPECULAR: boolean;
  30407. SPECULARDIRECTUV: number;
  30408. BUMP: boolean;
  30409. BUMPDIRECTUV: number;
  30410. PARALLAX: boolean;
  30411. PARALLAXOCCLUSION: boolean;
  30412. SPECULAROVERALPHA: boolean;
  30413. CLIPPLANE: boolean;
  30414. CLIPPLANE2: boolean;
  30415. CLIPPLANE3: boolean;
  30416. CLIPPLANE4: boolean;
  30417. CLIPPLANE5: boolean;
  30418. CLIPPLANE6: boolean;
  30419. ALPHATEST: boolean;
  30420. DEPTHPREPASS: boolean;
  30421. ALPHAFROMDIFFUSE: boolean;
  30422. POINTSIZE: boolean;
  30423. FOG: boolean;
  30424. SPECULARTERM: boolean;
  30425. DIFFUSEFRESNEL: boolean;
  30426. OPACITYFRESNEL: boolean;
  30427. REFLECTIONFRESNEL: boolean;
  30428. REFRACTIONFRESNEL: boolean;
  30429. EMISSIVEFRESNEL: boolean;
  30430. FRESNEL: boolean;
  30431. NORMAL: boolean;
  30432. UV1: boolean;
  30433. UV2: boolean;
  30434. VERTEXCOLOR: boolean;
  30435. VERTEXALPHA: boolean;
  30436. NUM_BONE_INFLUENCERS: number;
  30437. BonesPerMesh: number;
  30438. BONETEXTURE: boolean;
  30439. INSTANCES: boolean;
  30440. THIN_INSTANCES: boolean;
  30441. GLOSSINESS: boolean;
  30442. ROUGHNESS: boolean;
  30443. EMISSIVEASILLUMINATION: boolean;
  30444. LINKEMISSIVEWITHDIFFUSE: boolean;
  30445. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30446. LIGHTMAP: boolean;
  30447. LIGHTMAPDIRECTUV: number;
  30448. OBJECTSPACE_NORMALMAP: boolean;
  30449. USELIGHTMAPASSHADOWMAP: boolean;
  30450. REFLECTIONMAP_3D: boolean;
  30451. REFLECTIONMAP_SPHERICAL: boolean;
  30452. REFLECTIONMAP_PLANAR: boolean;
  30453. REFLECTIONMAP_CUBIC: boolean;
  30454. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30455. REFLECTIONMAP_PROJECTION: boolean;
  30456. REFLECTIONMAP_SKYBOX: boolean;
  30457. REFLECTIONMAP_EXPLICIT: boolean;
  30458. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30459. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30460. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30461. INVERTCUBICMAP: boolean;
  30462. LOGARITHMICDEPTH: boolean;
  30463. REFRACTION: boolean;
  30464. REFRACTIONMAP_3D: boolean;
  30465. REFLECTIONOVERALPHA: boolean;
  30466. TWOSIDEDLIGHTING: boolean;
  30467. SHADOWFLOAT: boolean;
  30468. MORPHTARGETS: boolean;
  30469. MORPHTARGETS_NORMAL: boolean;
  30470. MORPHTARGETS_TANGENT: boolean;
  30471. MORPHTARGETS_UV: boolean;
  30472. NUM_MORPH_INFLUENCERS: number;
  30473. NONUNIFORMSCALING: boolean;
  30474. PREMULTIPLYALPHA: boolean;
  30475. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30476. ALPHABLEND: boolean;
  30477. PREPASS: boolean;
  30478. SCENE_MRT_COUNT: number;
  30479. RGBDLIGHTMAP: boolean;
  30480. RGBDREFLECTION: boolean;
  30481. RGBDREFRACTION: boolean;
  30482. IMAGEPROCESSING: boolean;
  30483. VIGNETTE: boolean;
  30484. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30485. VIGNETTEBLENDMODEOPAQUE: boolean;
  30486. TONEMAPPING: boolean;
  30487. TONEMAPPING_ACES: boolean;
  30488. CONTRAST: boolean;
  30489. COLORCURVES: boolean;
  30490. COLORGRADING: boolean;
  30491. COLORGRADING3D: boolean;
  30492. SAMPLER3DGREENDEPTH: boolean;
  30493. SAMPLER3DBGRMAP: boolean;
  30494. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30495. MULTIVIEW: boolean;
  30496. /**
  30497. * If the reflection texture on this material is in linear color space
  30498. * @hidden
  30499. */
  30500. IS_REFLECTION_LINEAR: boolean;
  30501. /**
  30502. * If the refraction texture on this material is in linear color space
  30503. * @hidden
  30504. */
  30505. IS_REFRACTION_LINEAR: boolean;
  30506. EXPOSURE: boolean;
  30507. constructor();
  30508. setReflectionMode(modeToEnable: string): void;
  30509. }
  30510. /**
  30511. * This is the default material used in Babylon. It is the best trade off between quality
  30512. * and performances.
  30513. * @see https://doc.babylonjs.com/babylon101/materials
  30514. */
  30515. export class StandardMaterial extends PushMaterial {
  30516. private _diffuseTexture;
  30517. /**
  30518. * The basic texture of the material as viewed under a light.
  30519. */
  30520. diffuseTexture: Nullable<BaseTexture>;
  30521. private _ambientTexture;
  30522. /**
  30523. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30524. */
  30525. ambientTexture: Nullable<BaseTexture>;
  30526. private _opacityTexture;
  30527. /**
  30528. * Define the transparency of the material from a texture.
  30529. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30530. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30531. */
  30532. opacityTexture: Nullable<BaseTexture>;
  30533. private _reflectionTexture;
  30534. /**
  30535. * Define the texture used to display the reflection.
  30536. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30537. */
  30538. reflectionTexture: Nullable<BaseTexture>;
  30539. private _emissiveTexture;
  30540. /**
  30541. * Define texture of the material as if self lit.
  30542. * This will be mixed in the final result even in the absence of light.
  30543. */
  30544. emissiveTexture: Nullable<BaseTexture>;
  30545. private _specularTexture;
  30546. /**
  30547. * Define how the color and intensity of the highlight given by the light in the material.
  30548. */
  30549. specularTexture: Nullable<BaseTexture>;
  30550. private _bumpTexture;
  30551. /**
  30552. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30553. * 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.
  30554. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30555. */
  30556. bumpTexture: Nullable<BaseTexture>;
  30557. private _lightmapTexture;
  30558. /**
  30559. * Complex lighting can be computationally expensive to compute at runtime.
  30560. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30561. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30562. */
  30563. lightmapTexture: Nullable<BaseTexture>;
  30564. private _refractionTexture;
  30565. /**
  30566. * Define the texture used to display the refraction.
  30567. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30568. */
  30569. refractionTexture: Nullable<BaseTexture>;
  30570. /**
  30571. * The color of the material lit by the environmental background lighting.
  30572. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30573. */
  30574. ambientColor: Color3;
  30575. /**
  30576. * The basic color of the material as viewed under a light.
  30577. */
  30578. diffuseColor: Color3;
  30579. /**
  30580. * Define how the color and intensity of the highlight given by the light in the material.
  30581. */
  30582. specularColor: Color3;
  30583. /**
  30584. * Define the color of the material as if self lit.
  30585. * This will be mixed in the final result even in the absence of light.
  30586. */
  30587. emissiveColor: Color3;
  30588. /**
  30589. * Defines how sharp are the highlights in the material.
  30590. * The bigger the value the sharper giving a more glossy feeling to the result.
  30591. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30592. */
  30593. specularPower: number;
  30594. private _useAlphaFromDiffuseTexture;
  30595. /**
  30596. * Does the transparency come from the diffuse texture alpha channel.
  30597. */
  30598. useAlphaFromDiffuseTexture: boolean;
  30599. private _useEmissiveAsIllumination;
  30600. /**
  30601. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30602. */
  30603. useEmissiveAsIllumination: boolean;
  30604. private _linkEmissiveWithDiffuse;
  30605. /**
  30606. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30607. * the emissive level when the final color is close to one.
  30608. */
  30609. linkEmissiveWithDiffuse: boolean;
  30610. private _useSpecularOverAlpha;
  30611. /**
  30612. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30613. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30614. */
  30615. useSpecularOverAlpha: boolean;
  30616. private _useReflectionOverAlpha;
  30617. /**
  30618. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30619. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30620. */
  30621. useReflectionOverAlpha: boolean;
  30622. private _disableLighting;
  30623. /**
  30624. * Does lights from the scene impacts this material.
  30625. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30626. */
  30627. disableLighting: boolean;
  30628. private _useObjectSpaceNormalMap;
  30629. /**
  30630. * Allows using an object space normal map (instead of tangent space).
  30631. */
  30632. useObjectSpaceNormalMap: boolean;
  30633. private _useParallax;
  30634. /**
  30635. * Is parallax enabled or not.
  30636. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30637. */
  30638. useParallax: boolean;
  30639. private _useParallaxOcclusion;
  30640. /**
  30641. * Is parallax occlusion enabled or not.
  30642. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30643. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30644. */
  30645. useParallaxOcclusion: boolean;
  30646. /**
  30647. * 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.
  30648. */
  30649. parallaxScaleBias: number;
  30650. private _roughness;
  30651. /**
  30652. * Helps to define how blurry the reflections should appears in the material.
  30653. */
  30654. roughness: number;
  30655. /**
  30656. * In case of refraction, define the value of the index of refraction.
  30657. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30658. */
  30659. indexOfRefraction: number;
  30660. /**
  30661. * Invert the refraction texture alongside the y axis.
  30662. * It can be useful with procedural textures or probe for instance.
  30663. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30664. */
  30665. invertRefractionY: boolean;
  30666. /**
  30667. * Defines the alpha limits in alpha test mode.
  30668. */
  30669. alphaCutOff: number;
  30670. private _useLightmapAsShadowmap;
  30671. /**
  30672. * In case of light mapping, define whether the map contains light or shadow informations.
  30673. */
  30674. useLightmapAsShadowmap: boolean;
  30675. private _diffuseFresnelParameters;
  30676. /**
  30677. * Define the diffuse fresnel parameters of the material.
  30678. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30679. */
  30680. diffuseFresnelParameters: FresnelParameters;
  30681. private _opacityFresnelParameters;
  30682. /**
  30683. * Define the opacity fresnel parameters of the material.
  30684. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30685. */
  30686. opacityFresnelParameters: FresnelParameters;
  30687. private _reflectionFresnelParameters;
  30688. /**
  30689. * Define the reflection fresnel parameters of the material.
  30690. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30691. */
  30692. reflectionFresnelParameters: FresnelParameters;
  30693. private _refractionFresnelParameters;
  30694. /**
  30695. * Define the refraction fresnel parameters of the material.
  30696. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30697. */
  30698. refractionFresnelParameters: FresnelParameters;
  30699. private _emissiveFresnelParameters;
  30700. /**
  30701. * Define the emissive fresnel parameters of the material.
  30702. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30703. */
  30704. emissiveFresnelParameters: FresnelParameters;
  30705. private _useReflectionFresnelFromSpecular;
  30706. /**
  30707. * If true automatically deducts the fresnels values from the material specularity.
  30708. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30709. */
  30710. useReflectionFresnelFromSpecular: boolean;
  30711. private _useGlossinessFromSpecularMapAlpha;
  30712. /**
  30713. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30714. */
  30715. useGlossinessFromSpecularMapAlpha: boolean;
  30716. private _maxSimultaneousLights;
  30717. /**
  30718. * Defines the maximum number of lights that can be used in the material
  30719. */
  30720. maxSimultaneousLights: number;
  30721. private _invertNormalMapX;
  30722. /**
  30723. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30724. */
  30725. invertNormalMapX: boolean;
  30726. private _invertNormalMapY;
  30727. /**
  30728. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30729. */
  30730. invertNormalMapY: boolean;
  30731. private _twoSidedLighting;
  30732. /**
  30733. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30734. */
  30735. twoSidedLighting: boolean;
  30736. /**
  30737. * Default configuration related to image processing available in the standard Material.
  30738. */
  30739. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30740. /**
  30741. * Gets the image processing configuration used either in this material.
  30742. */
  30743. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30744. /**
  30745. * Sets the Default image processing configuration used either in the this material.
  30746. *
  30747. * If sets to null, the scene one is in use.
  30748. */
  30749. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30750. /**
  30751. * Keep track of the image processing observer to allow dispose and replace.
  30752. */
  30753. private _imageProcessingObserver;
  30754. /**
  30755. * Attaches a new image processing configuration to the Standard Material.
  30756. * @param configuration
  30757. */
  30758. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30759. /**
  30760. * Gets wether the color curves effect is enabled.
  30761. */
  30762. get cameraColorCurvesEnabled(): boolean;
  30763. /**
  30764. * Sets wether the color curves effect is enabled.
  30765. */
  30766. set cameraColorCurvesEnabled(value: boolean);
  30767. /**
  30768. * Gets wether the color grading effect is enabled.
  30769. */
  30770. get cameraColorGradingEnabled(): boolean;
  30771. /**
  30772. * Gets wether the color grading effect is enabled.
  30773. */
  30774. set cameraColorGradingEnabled(value: boolean);
  30775. /**
  30776. * Gets wether tonemapping is enabled or not.
  30777. */
  30778. get cameraToneMappingEnabled(): boolean;
  30779. /**
  30780. * Sets wether tonemapping is enabled or not
  30781. */
  30782. set cameraToneMappingEnabled(value: boolean);
  30783. /**
  30784. * The camera exposure used on this material.
  30785. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30786. * This corresponds to a photographic exposure.
  30787. */
  30788. get cameraExposure(): number;
  30789. /**
  30790. * The camera exposure used on this material.
  30791. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30792. * This corresponds to a photographic exposure.
  30793. */
  30794. set cameraExposure(value: number);
  30795. /**
  30796. * Gets The camera contrast used on this material.
  30797. */
  30798. get cameraContrast(): number;
  30799. /**
  30800. * Sets The camera contrast used on this material.
  30801. */
  30802. set cameraContrast(value: number);
  30803. /**
  30804. * Gets the Color Grading 2D Lookup Texture.
  30805. */
  30806. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30807. /**
  30808. * Sets the Color Grading 2D Lookup Texture.
  30809. */
  30810. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30811. /**
  30812. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30813. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30814. * 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;
  30815. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30816. */
  30817. get cameraColorCurves(): Nullable<ColorCurves>;
  30818. /**
  30819. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30820. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30821. * 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;
  30822. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30823. */
  30824. set cameraColorCurves(value: Nullable<ColorCurves>);
  30825. /**
  30826. * Can this material render to several textures at once
  30827. */
  30828. get canRenderToMRT(): boolean;
  30829. /**
  30830. * Defines the detail map parameters for the material.
  30831. */
  30832. readonly detailMap: DetailMapConfiguration;
  30833. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30834. protected _worldViewProjectionMatrix: Matrix;
  30835. protected _globalAmbientColor: Color3;
  30836. protected _useLogarithmicDepth: boolean;
  30837. protected _rebuildInParallel: boolean;
  30838. /**
  30839. * Instantiates a new standard material.
  30840. * This is the default material used in Babylon. It is the best trade off between quality
  30841. * and performances.
  30842. * @see https://doc.babylonjs.com/babylon101/materials
  30843. * @param name Define the name of the material in the scene
  30844. * @param scene Define the scene the material belong to
  30845. */
  30846. constructor(name: string, scene: Scene);
  30847. /**
  30848. * Gets a boolean indicating that current material needs to register RTT
  30849. */
  30850. get hasRenderTargetTextures(): boolean;
  30851. /**
  30852. * Gets the current class name of the material e.g. "StandardMaterial"
  30853. * Mainly use in serialization.
  30854. * @returns the class name
  30855. */
  30856. getClassName(): string;
  30857. /**
  30858. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30859. * You can try switching to logarithmic depth.
  30860. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30861. */
  30862. get useLogarithmicDepth(): boolean;
  30863. set useLogarithmicDepth(value: boolean);
  30864. /**
  30865. * Specifies if the material will require alpha blending
  30866. * @returns a boolean specifying if alpha blending is needed
  30867. */
  30868. needAlphaBlending(): boolean;
  30869. /**
  30870. * Specifies if this material should be rendered in alpha test mode
  30871. * @returns a boolean specifying if an alpha test is needed.
  30872. */
  30873. needAlphaTesting(): boolean;
  30874. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30875. /**
  30876. * Get the texture used for alpha test purpose.
  30877. * @returns the diffuse texture in case of the standard material.
  30878. */
  30879. getAlphaTestTexture(): Nullable<BaseTexture>;
  30880. /**
  30881. * Get if the submesh is ready to be used and all its information available.
  30882. * Child classes can use it to update shaders
  30883. * @param mesh defines the mesh to check
  30884. * @param subMesh defines which submesh to check
  30885. * @param useInstances specifies that instances should be used
  30886. * @returns a boolean indicating that the submesh is ready or not
  30887. */
  30888. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30889. /**
  30890. * Builds the material UBO layouts.
  30891. * Used internally during the effect preparation.
  30892. */
  30893. buildUniformLayout(): void;
  30894. /**
  30895. * Unbinds the material from the mesh
  30896. */
  30897. unbind(): void;
  30898. /**
  30899. * Binds the submesh to this material by preparing the effect and shader to draw
  30900. * @param world defines the world transformation matrix
  30901. * @param mesh defines the mesh containing the submesh
  30902. * @param subMesh defines the submesh to bind the material to
  30903. */
  30904. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30905. /**
  30906. * Get the list of animatables in the material.
  30907. * @returns the list of animatables object used in the material
  30908. */
  30909. getAnimatables(): IAnimatable[];
  30910. /**
  30911. * Gets the active textures from the material
  30912. * @returns an array of textures
  30913. */
  30914. getActiveTextures(): BaseTexture[];
  30915. /**
  30916. * Specifies if the material uses a texture
  30917. * @param texture defines the texture to check against the material
  30918. * @returns a boolean specifying if the material uses the texture
  30919. */
  30920. hasTexture(texture: BaseTexture): boolean;
  30921. /**
  30922. * Disposes the material
  30923. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30924. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30925. */
  30926. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30927. /**
  30928. * Makes a duplicate of the material, and gives it a new name
  30929. * @param name defines the new name for the duplicated material
  30930. * @returns the cloned material
  30931. */
  30932. clone(name: string): StandardMaterial;
  30933. /**
  30934. * Serializes this material in a JSON representation
  30935. * @returns the serialized material object
  30936. */
  30937. serialize(): any;
  30938. /**
  30939. * Creates a standard material from parsed material data
  30940. * @param source defines the JSON representation of the material
  30941. * @param scene defines the hosting scene
  30942. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30943. * @returns a new standard material
  30944. */
  30945. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30946. /**
  30947. * Are diffuse textures enabled in the application.
  30948. */
  30949. static get DiffuseTextureEnabled(): boolean;
  30950. static set DiffuseTextureEnabled(value: boolean);
  30951. /**
  30952. * Are detail textures enabled in the application.
  30953. */
  30954. static get DetailTextureEnabled(): boolean;
  30955. static set DetailTextureEnabled(value: boolean);
  30956. /**
  30957. * Are ambient textures enabled in the application.
  30958. */
  30959. static get AmbientTextureEnabled(): boolean;
  30960. static set AmbientTextureEnabled(value: boolean);
  30961. /**
  30962. * Are opacity textures enabled in the application.
  30963. */
  30964. static get OpacityTextureEnabled(): boolean;
  30965. static set OpacityTextureEnabled(value: boolean);
  30966. /**
  30967. * Are reflection textures enabled in the application.
  30968. */
  30969. static get ReflectionTextureEnabled(): boolean;
  30970. static set ReflectionTextureEnabled(value: boolean);
  30971. /**
  30972. * Are emissive textures enabled in the application.
  30973. */
  30974. static get EmissiveTextureEnabled(): boolean;
  30975. static set EmissiveTextureEnabled(value: boolean);
  30976. /**
  30977. * Are specular textures enabled in the application.
  30978. */
  30979. static get SpecularTextureEnabled(): boolean;
  30980. static set SpecularTextureEnabled(value: boolean);
  30981. /**
  30982. * Are bump textures enabled in the application.
  30983. */
  30984. static get BumpTextureEnabled(): boolean;
  30985. static set BumpTextureEnabled(value: boolean);
  30986. /**
  30987. * Are lightmap textures enabled in the application.
  30988. */
  30989. static get LightmapTextureEnabled(): boolean;
  30990. static set LightmapTextureEnabled(value: boolean);
  30991. /**
  30992. * Are refraction textures enabled in the application.
  30993. */
  30994. static get RefractionTextureEnabled(): boolean;
  30995. static set RefractionTextureEnabled(value: boolean);
  30996. /**
  30997. * Are color grading textures enabled in the application.
  30998. */
  30999. static get ColorGradingTextureEnabled(): boolean;
  31000. static set ColorGradingTextureEnabled(value: boolean);
  31001. /**
  31002. * Are fresnels enabled in the application.
  31003. */
  31004. static get FresnelEnabled(): boolean;
  31005. static set FresnelEnabled(value: boolean);
  31006. }
  31007. }
  31008. declare module BABYLON {
  31009. /**
  31010. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31011. *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.
  31012. * The SPS is also a particle system. It provides some methods to manage the particles.
  31013. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31014. *
  31015. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31016. */
  31017. export class SolidParticleSystem implements IDisposable {
  31018. /**
  31019. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31020. * Example : var p = SPS.particles[i];
  31021. */
  31022. particles: SolidParticle[];
  31023. /**
  31024. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31025. */
  31026. nbParticles: number;
  31027. /**
  31028. * If the particles must ever face the camera (default false). Useful for planar particles.
  31029. */
  31030. billboard: boolean;
  31031. /**
  31032. * Recompute normals when adding a shape
  31033. */
  31034. recomputeNormals: boolean;
  31035. /**
  31036. * This a counter ofr your own usage. It's not set by any SPS functions.
  31037. */
  31038. counter: number;
  31039. /**
  31040. * The SPS name. This name is also given to the underlying mesh.
  31041. */
  31042. name: string;
  31043. /**
  31044. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31045. */
  31046. mesh: Mesh;
  31047. /**
  31048. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31049. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31050. */
  31051. vars: any;
  31052. /**
  31053. * This array is populated when the SPS is set as 'pickable'.
  31054. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31055. * Each element of this array is an object `{idx: int, faceId: int}`.
  31056. * `idx` is the picked particle index in the `SPS.particles` array
  31057. * `faceId` is the picked face index counted within this particle.
  31058. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31059. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31060. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31061. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31062. */
  31063. pickedParticles: {
  31064. idx: number;
  31065. faceId: number;
  31066. }[];
  31067. /**
  31068. * This array is populated when the SPS is set as 'pickable'
  31069. * Each key of this array is a submesh index.
  31070. * Each element of this array is a second array defined like this :
  31071. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31072. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31073. * `idx` is the picked particle index in the `SPS.particles` array
  31074. * `faceId` is the picked face index counted within this particle.
  31075. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31076. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31077. */
  31078. pickedBySubMesh: {
  31079. idx: number;
  31080. faceId: number;
  31081. }[][];
  31082. /**
  31083. * This array is populated when `enableDepthSort` is set to true.
  31084. * Each element of this array is an instance of the class DepthSortedParticle.
  31085. */
  31086. depthSortedParticles: DepthSortedParticle[];
  31087. /**
  31088. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31089. * @hidden
  31090. */
  31091. _bSphereOnly: boolean;
  31092. /**
  31093. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31094. * @hidden
  31095. */
  31096. _bSphereRadiusFactor: number;
  31097. private _scene;
  31098. private _positions;
  31099. private _indices;
  31100. private _normals;
  31101. private _colors;
  31102. private _uvs;
  31103. private _indices32;
  31104. private _positions32;
  31105. private _normals32;
  31106. private _fixedNormal32;
  31107. private _colors32;
  31108. private _uvs32;
  31109. private _index;
  31110. private _updatable;
  31111. private _pickable;
  31112. private _isVisibilityBoxLocked;
  31113. private _alwaysVisible;
  31114. private _depthSort;
  31115. private _expandable;
  31116. private _shapeCounter;
  31117. private _copy;
  31118. private _color;
  31119. private _computeParticleColor;
  31120. private _computeParticleTexture;
  31121. private _computeParticleRotation;
  31122. private _computeParticleVertex;
  31123. private _computeBoundingBox;
  31124. private _depthSortParticles;
  31125. private _camera;
  31126. private _mustUnrotateFixedNormals;
  31127. private _particlesIntersect;
  31128. private _needs32Bits;
  31129. private _isNotBuilt;
  31130. private _lastParticleId;
  31131. private _idxOfId;
  31132. private _multimaterialEnabled;
  31133. private _useModelMaterial;
  31134. private _indicesByMaterial;
  31135. private _materialIndexes;
  31136. private _depthSortFunction;
  31137. private _materialSortFunction;
  31138. private _materials;
  31139. private _multimaterial;
  31140. private _materialIndexesById;
  31141. private _defaultMaterial;
  31142. private _autoUpdateSubMeshes;
  31143. private _tmpVertex;
  31144. /**
  31145. * Creates a SPS (Solid Particle System) object.
  31146. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31147. * @param scene (Scene) is the scene in which the SPS is added.
  31148. * @param options defines the options of the sps e.g.
  31149. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31150. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31151. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31152. * * 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.
  31153. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31154. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31155. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31156. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31157. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31158. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31159. */
  31160. constructor(name: string, scene: Scene, options?: {
  31161. updatable?: boolean;
  31162. isPickable?: boolean;
  31163. enableDepthSort?: boolean;
  31164. particleIntersection?: boolean;
  31165. boundingSphereOnly?: boolean;
  31166. bSphereRadiusFactor?: number;
  31167. expandable?: boolean;
  31168. useModelMaterial?: boolean;
  31169. enableMultiMaterial?: boolean;
  31170. });
  31171. /**
  31172. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31173. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31174. * @returns the created mesh
  31175. */
  31176. buildMesh(): Mesh;
  31177. /**
  31178. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31179. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31180. * Thus the particles generated from `digest()` have their property `position` set yet.
  31181. * @param mesh ( Mesh ) is the mesh to be digested
  31182. * @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
  31183. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31184. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31185. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31186. * @returns the current SPS
  31187. */
  31188. digest(mesh: Mesh, options?: {
  31189. facetNb?: number;
  31190. number?: number;
  31191. delta?: number;
  31192. storage?: [];
  31193. }): SolidParticleSystem;
  31194. /**
  31195. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31196. * @hidden
  31197. */
  31198. private _unrotateFixedNormals;
  31199. /**
  31200. * Resets the temporary working copy particle
  31201. * @hidden
  31202. */
  31203. private _resetCopy;
  31204. /**
  31205. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31206. * @param p the current index in the positions array to be updated
  31207. * @param ind the current index in the indices array
  31208. * @param shape a Vector3 array, the shape geometry
  31209. * @param positions the positions array to be updated
  31210. * @param meshInd the shape indices array
  31211. * @param indices the indices array to be updated
  31212. * @param meshUV the shape uv array
  31213. * @param uvs the uv array to be updated
  31214. * @param meshCol the shape color array
  31215. * @param colors the color array to be updated
  31216. * @param meshNor the shape normals array
  31217. * @param normals the normals array to be updated
  31218. * @param idx the particle index
  31219. * @param idxInShape the particle index in its shape
  31220. * @param options the addShape() method passed options
  31221. * @model the particle model
  31222. * @hidden
  31223. */
  31224. private _meshBuilder;
  31225. /**
  31226. * Returns a shape Vector3 array from positions float array
  31227. * @param positions float array
  31228. * @returns a vector3 array
  31229. * @hidden
  31230. */
  31231. private _posToShape;
  31232. /**
  31233. * Returns a shapeUV array from a float uvs (array deep copy)
  31234. * @param uvs as a float array
  31235. * @returns a shapeUV array
  31236. * @hidden
  31237. */
  31238. private _uvsToShapeUV;
  31239. /**
  31240. * Adds a new particle object in the particles array
  31241. * @param idx particle index in particles array
  31242. * @param id particle id
  31243. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31244. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31245. * @param model particle ModelShape object
  31246. * @param shapeId model shape identifier
  31247. * @param idxInShape index of the particle in the current model
  31248. * @param bInfo model bounding info object
  31249. * @param storage target storage array, if any
  31250. * @hidden
  31251. */
  31252. private _addParticle;
  31253. /**
  31254. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31255. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31256. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31257. * @param nb (positive integer) the number of particles to be created from this model
  31258. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31259. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31260. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31261. * @returns the number of shapes in the system
  31262. */
  31263. addShape(mesh: Mesh, nb: number, options?: {
  31264. positionFunction?: any;
  31265. vertexFunction?: any;
  31266. storage?: [];
  31267. }): number;
  31268. /**
  31269. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31270. * @hidden
  31271. */
  31272. private _rebuildParticle;
  31273. /**
  31274. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31275. * @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.
  31276. * @returns the SPS.
  31277. */
  31278. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31279. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31280. * Returns an array with the removed particles.
  31281. * 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.
  31282. * The SPS can't be empty so at least one particle needs to remain in place.
  31283. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31284. * @param start index of the first particle to remove
  31285. * @param end index of the last particle to remove (included)
  31286. * @returns an array populated with the removed particles
  31287. */
  31288. removeParticles(start: number, end: number): SolidParticle[];
  31289. /**
  31290. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31291. * @param solidParticleArray an array populated with Solid Particles objects
  31292. * @returns the SPS
  31293. */
  31294. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31295. /**
  31296. * Creates a new particle and modifies the SPS mesh geometry :
  31297. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31298. * - calls _addParticle() to populate the particle array
  31299. * factorized code from addShape() and insertParticlesFromArray()
  31300. * @param idx particle index in the particles array
  31301. * @param i particle index in its shape
  31302. * @param modelShape particle ModelShape object
  31303. * @param shape shape vertex array
  31304. * @param meshInd shape indices array
  31305. * @param meshUV shape uv array
  31306. * @param meshCol shape color array
  31307. * @param meshNor shape normals array
  31308. * @param bbInfo shape bounding info
  31309. * @param storage target particle storage
  31310. * @options addShape() passed options
  31311. * @hidden
  31312. */
  31313. private _insertNewParticle;
  31314. /**
  31315. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31316. * This method calls `updateParticle()` for each particle of the SPS.
  31317. * For an animated SPS, it is usually called within the render loop.
  31318. * 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.
  31319. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31320. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31321. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31322. * @returns the SPS.
  31323. */
  31324. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31325. /**
  31326. * Disposes the SPS.
  31327. */
  31328. dispose(): void;
  31329. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31330. * idx is the particle index in the SPS
  31331. * faceId is the picked face index counted within this particle.
  31332. * Returns null if the pickInfo can't identify a picked particle.
  31333. * @param pickingInfo (PickingInfo object)
  31334. * @returns {idx: number, faceId: number} or null
  31335. */
  31336. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31337. idx: number;
  31338. faceId: number;
  31339. }>;
  31340. /**
  31341. * Returns a SolidParticle object from its identifier : particle.id
  31342. * @param id (integer) the particle Id
  31343. * @returns the searched particle or null if not found in the SPS.
  31344. */
  31345. getParticleById(id: number): Nullable<SolidParticle>;
  31346. /**
  31347. * Returns a new array populated with the particles having the passed shapeId.
  31348. * @param shapeId (integer) the shape identifier
  31349. * @returns a new solid particle array
  31350. */
  31351. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31352. /**
  31353. * Populates the passed array "ref" with the particles having the passed shapeId.
  31354. * @param shapeId the shape identifier
  31355. * @returns the SPS
  31356. * @param ref
  31357. */
  31358. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31359. /**
  31360. * Computes the required SubMeshes according the materials assigned to the particles.
  31361. * @returns the solid particle system.
  31362. * Does nothing if called before the SPS mesh is built.
  31363. */
  31364. computeSubMeshes(): SolidParticleSystem;
  31365. /**
  31366. * Sorts the solid particles by material when MultiMaterial is enabled.
  31367. * Updates the indices32 array.
  31368. * Updates the indicesByMaterial array.
  31369. * Updates the mesh indices array.
  31370. * @returns the SPS
  31371. * @hidden
  31372. */
  31373. private _sortParticlesByMaterial;
  31374. /**
  31375. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31376. * @hidden
  31377. */
  31378. private _setMaterialIndexesById;
  31379. /**
  31380. * Returns an array with unique values of Materials from the passed array
  31381. * @param array the material array to be checked and filtered
  31382. * @hidden
  31383. */
  31384. private _filterUniqueMaterialId;
  31385. /**
  31386. * Sets a new Standard Material as _defaultMaterial if not already set.
  31387. * @hidden
  31388. */
  31389. private _setDefaultMaterial;
  31390. /**
  31391. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31392. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31393. * @returns the SPS.
  31394. */
  31395. refreshVisibleSize(): SolidParticleSystem;
  31396. /**
  31397. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31398. * @param size the size (float) of the visibility box
  31399. * note : this doesn't lock the SPS mesh bounding box.
  31400. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31401. */
  31402. setVisibilityBox(size: number): void;
  31403. /**
  31404. * Gets whether the SPS as always visible or not
  31405. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31406. */
  31407. get isAlwaysVisible(): boolean;
  31408. /**
  31409. * Sets the SPS as always visible or not
  31410. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31411. */
  31412. set isAlwaysVisible(val: boolean);
  31413. /**
  31414. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31415. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31416. */
  31417. set isVisibilityBoxLocked(val: boolean);
  31418. /**
  31419. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31420. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31421. */
  31422. get isVisibilityBoxLocked(): boolean;
  31423. /**
  31424. * Tells to `setParticles()` to compute the particle rotations or not.
  31425. * Default value : true. The SPS is faster when it's set to false.
  31426. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31427. */
  31428. set computeParticleRotation(val: boolean);
  31429. /**
  31430. * Tells to `setParticles()` to compute the particle colors or not.
  31431. * Default value : true. The SPS is faster when it's set to false.
  31432. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31433. */
  31434. set computeParticleColor(val: boolean);
  31435. set computeParticleTexture(val: boolean);
  31436. /**
  31437. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31438. * Default value : false. The SPS is faster when it's set to false.
  31439. * Note : the particle custom vertex positions aren't stored values.
  31440. */
  31441. set computeParticleVertex(val: boolean);
  31442. /**
  31443. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31444. */
  31445. set computeBoundingBox(val: boolean);
  31446. /**
  31447. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31448. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31449. * Default : `true`
  31450. */
  31451. set depthSortParticles(val: boolean);
  31452. /**
  31453. * Gets if `setParticles()` computes the particle rotations or not.
  31454. * Default value : true. The SPS is faster when it's set to false.
  31455. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31456. */
  31457. get computeParticleRotation(): boolean;
  31458. /**
  31459. * Gets if `setParticles()` computes the particle colors or not.
  31460. * Default value : true. The SPS is faster when it's set to false.
  31461. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31462. */
  31463. get computeParticleColor(): boolean;
  31464. /**
  31465. * Gets if `setParticles()` computes the particle textures or not.
  31466. * Default value : true. The SPS is faster when it's set to false.
  31467. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31468. */
  31469. get computeParticleTexture(): boolean;
  31470. /**
  31471. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31472. * Default value : false. The SPS is faster when it's set to false.
  31473. * Note : the particle custom vertex positions aren't stored values.
  31474. */
  31475. get computeParticleVertex(): boolean;
  31476. /**
  31477. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31478. */
  31479. get computeBoundingBox(): boolean;
  31480. /**
  31481. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31482. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31483. * Default : `true`
  31484. */
  31485. get depthSortParticles(): boolean;
  31486. /**
  31487. * Gets if the SPS is created as expandable at construction time.
  31488. * Default : `false`
  31489. */
  31490. get expandable(): boolean;
  31491. /**
  31492. * Gets if the SPS supports the Multi Materials
  31493. */
  31494. get multimaterialEnabled(): boolean;
  31495. /**
  31496. * Gets if the SPS uses the model materials for its own multimaterial.
  31497. */
  31498. get useModelMaterial(): boolean;
  31499. /**
  31500. * The SPS used material array.
  31501. */
  31502. get materials(): Material[];
  31503. /**
  31504. * Sets the SPS MultiMaterial from the passed materials.
  31505. * Note : the passed array is internally copied and not used then by reference.
  31506. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31507. */
  31508. setMultiMaterial(materials: Material[]): void;
  31509. /**
  31510. * The SPS computed multimaterial object
  31511. */
  31512. get multimaterial(): MultiMaterial;
  31513. set multimaterial(mm: MultiMaterial);
  31514. /**
  31515. * If the subMeshes must be updated on the next call to setParticles()
  31516. */
  31517. get autoUpdateSubMeshes(): boolean;
  31518. set autoUpdateSubMeshes(val: boolean);
  31519. /**
  31520. * This function does nothing. It may be overwritten to set all the particle first values.
  31521. * The SPS doesn't call this function, you may have to call it by your own.
  31522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31523. */
  31524. initParticles(): void;
  31525. /**
  31526. * This function does nothing. It may be overwritten to recycle a particle.
  31527. * The SPS doesn't call this function, you may have to call it by your own.
  31528. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31529. * @param particle The particle to recycle
  31530. * @returns the recycled particle
  31531. */
  31532. recycleParticle(particle: SolidParticle): SolidParticle;
  31533. /**
  31534. * Updates a particle : this function should be overwritten by the user.
  31535. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31536. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31537. * @example : just set a particle position or velocity and recycle conditions
  31538. * @param particle The particle to update
  31539. * @returns the updated particle
  31540. */
  31541. updateParticle(particle: SolidParticle): SolidParticle;
  31542. /**
  31543. * Updates a vertex of a particle : it can be overwritten by the user.
  31544. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31545. * @param particle the current particle
  31546. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31547. * @param pt the index of the current vertex in the particle shape
  31548. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31549. * @example : just set a vertex particle position or color
  31550. * @returns the sps
  31551. */
  31552. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31553. /**
  31554. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31555. * This does nothing and may be overwritten by the user.
  31556. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31557. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31558. * @param update the boolean update value actually passed to setParticles()
  31559. */
  31560. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31561. /**
  31562. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31563. * This will be passed three parameters.
  31564. * This does nothing and may be overwritten by the user.
  31565. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31566. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31567. * @param update the boolean update value actually passed to setParticles()
  31568. */
  31569. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31570. }
  31571. }
  31572. declare module BABYLON {
  31573. /**
  31574. * Represents one particle of a solid particle system.
  31575. */
  31576. export class SolidParticle {
  31577. /**
  31578. * particle global index
  31579. */
  31580. idx: number;
  31581. /**
  31582. * particle identifier
  31583. */
  31584. id: number;
  31585. /**
  31586. * The color of the particle
  31587. */
  31588. color: Nullable<Color4>;
  31589. /**
  31590. * The world space position of the particle.
  31591. */
  31592. position: Vector3;
  31593. /**
  31594. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31595. */
  31596. rotation: Vector3;
  31597. /**
  31598. * The world space rotation quaternion of the particle.
  31599. */
  31600. rotationQuaternion: Nullable<Quaternion>;
  31601. /**
  31602. * The scaling of the particle.
  31603. */
  31604. scaling: Vector3;
  31605. /**
  31606. * The uvs of the particle.
  31607. */
  31608. uvs: Vector4;
  31609. /**
  31610. * The current speed of the particle.
  31611. */
  31612. velocity: Vector3;
  31613. /**
  31614. * The pivot point in the particle local space.
  31615. */
  31616. pivot: Vector3;
  31617. /**
  31618. * Must the particle be translated from its pivot point in its local space ?
  31619. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31620. * Default : false
  31621. */
  31622. translateFromPivot: boolean;
  31623. /**
  31624. * Is the particle active or not ?
  31625. */
  31626. alive: boolean;
  31627. /**
  31628. * Is the particle visible or not ?
  31629. */
  31630. isVisible: boolean;
  31631. /**
  31632. * Index of this particle in the global "positions" array (Internal use)
  31633. * @hidden
  31634. */
  31635. _pos: number;
  31636. /**
  31637. * @hidden Index of this particle in the global "indices" array (Internal use)
  31638. */
  31639. _ind: number;
  31640. /**
  31641. * @hidden ModelShape of this particle (Internal use)
  31642. */
  31643. _model: ModelShape;
  31644. /**
  31645. * ModelShape id of this particle
  31646. */
  31647. shapeId: number;
  31648. /**
  31649. * Index of the particle in its shape id
  31650. */
  31651. idxInShape: number;
  31652. /**
  31653. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31654. */
  31655. _modelBoundingInfo: BoundingInfo;
  31656. /**
  31657. * @hidden Particle BoundingInfo object (Internal use)
  31658. */
  31659. _boundingInfo: BoundingInfo;
  31660. /**
  31661. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31662. */
  31663. _sps: SolidParticleSystem;
  31664. /**
  31665. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31666. */
  31667. _stillInvisible: boolean;
  31668. /**
  31669. * @hidden Last computed particle rotation matrix
  31670. */
  31671. _rotationMatrix: number[];
  31672. /**
  31673. * Parent particle Id, if any.
  31674. * Default null.
  31675. */
  31676. parentId: Nullable<number>;
  31677. /**
  31678. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31679. */
  31680. materialIndex: Nullable<number>;
  31681. /**
  31682. * Custom object or properties.
  31683. */
  31684. props: Nullable<any>;
  31685. /**
  31686. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31687. * The possible values are :
  31688. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31689. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31690. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31691. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31692. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31693. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31694. * */
  31695. cullingStrategy: number;
  31696. /**
  31697. * @hidden Internal global position in the SPS.
  31698. */
  31699. _globalPosition: Vector3;
  31700. /**
  31701. * Creates a Solid Particle object.
  31702. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31703. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31704. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31705. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31706. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31707. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31708. * @param shapeId (integer) is the model shape identifier in the SPS.
  31709. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31710. * @param sps defines the sps it is associated to
  31711. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31712. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31713. */
  31714. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31715. /**
  31716. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31717. * @param target the particle target
  31718. * @returns the current particle
  31719. */
  31720. copyToRef(target: SolidParticle): SolidParticle;
  31721. /**
  31722. * Legacy support, changed scale to scaling
  31723. */
  31724. get scale(): Vector3;
  31725. /**
  31726. * Legacy support, changed scale to scaling
  31727. */
  31728. set scale(scale: Vector3);
  31729. /**
  31730. * Legacy support, changed quaternion to rotationQuaternion
  31731. */
  31732. get quaternion(): Nullable<Quaternion>;
  31733. /**
  31734. * Legacy support, changed quaternion to rotationQuaternion
  31735. */
  31736. set quaternion(q: Nullable<Quaternion>);
  31737. /**
  31738. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31739. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31740. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31741. * @returns true if it intersects
  31742. */
  31743. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31744. /**
  31745. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31746. * A particle is in the frustum if its bounding box intersects the frustum
  31747. * @param frustumPlanes defines the frustum to test
  31748. * @returns true if the particle is in the frustum planes
  31749. */
  31750. isInFrustum(frustumPlanes: Plane[]): boolean;
  31751. /**
  31752. * get the rotation matrix of the particle
  31753. * @hidden
  31754. */
  31755. getRotationMatrix(m: Matrix): void;
  31756. }
  31757. /**
  31758. * Represents the shape of the model used by one particle of a solid particle system.
  31759. * SPS internal tool, don't use it manually.
  31760. */
  31761. export class ModelShape {
  31762. /**
  31763. * The shape id
  31764. * @hidden
  31765. */
  31766. shapeID: number;
  31767. /**
  31768. * flat array of model positions (internal use)
  31769. * @hidden
  31770. */
  31771. _shape: Vector3[];
  31772. /**
  31773. * flat array of model UVs (internal use)
  31774. * @hidden
  31775. */
  31776. _shapeUV: number[];
  31777. /**
  31778. * color array of the model
  31779. * @hidden
  31780. */
  31781. _shapeColors: number[];
  31782. /**
  31783. * indices array of the model
  31784. * @hidden
  31785. */
  31786. _indices: number[];
  31787. /**
  31788. * normals array of the model
  31789. * @hidden
  31790. */
  31791. _normals: number[];
  31792. /**
  31793. * length of the shape in the model indices array (internal use)
  31794. * @hidden
  31795. */
  31796. _indicesLength: number;
  31797. /**
  31798. * Custom position function (internal use)
  31799. * @hidden
  31800. */
  31801. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31802. /**
  31803. * Custom vertex function (internal use)
  31804. * @hidden
  31805. */
  31806. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31807. /**
  31808. * Model material (internal use)
  31809. * @hidden
  31810. */
  31811. _material: Nullable<Material>;
  31812. /**
  31813. * 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.
  31814. * SPS internal tool, don't use it manually.
  31815. * @hidden
  31816. */
  31817. 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>);
  31818. }
  31819. /**
  31820. * Represents a Depth Sorted Particle in the solid particle system.
  31821. * @hidden
  31822. */
  31823. export class DepthSortedParticle {
  31824. /**
  31825. * Particle index
  31826. */
  31827. idx: number;
  31828. /**
  31829. * Index of the particle in the "indices" array
  31830. */
  31831. ind: number;
  31832. /**
  31833. * Length of the particle shape in the "indices" array
  31834. */
  31835. indicesLength: number;
  31836. /**
  31837. * Squared distance from the particle to the camera
  31838. */
  31839. sqDistance: number;
  31840. /**
  31841. * Material index when used with MultiMaterials
  31842. */
  31843. materialIndex: number;
  31844. /**
  31845. * Creates a new sorted particle
  31846. * @param materialIndex
  31847. */
  31848. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31849. }
  31850. /**
  31851. * Represents a solid particle vertex
  31852. */
  31853. export class SolidParticleVertex {
  31854. /**
  31855. * Vertex position
  31856. */
  31857. position: Vector3;
  31858. /**
  31859. * Vertex color
  31860. */
  31861. color: Color4;
  31862. /**
  31863. * Vertex UV
  31864. */
  31865. uv: Vector2;
  31866. /**
  31867. * Creates a new solid particle vertex
  31868. */
  31869. constructor();
  31870. /** Vertex x coordinate */
  31871. get x(): number;
  31872. set x(val: number);
  31873. /** Vertex y coordinate */
  31874. get y(): number;
  31875. set y(val: number);
  31876. /** Vertex z coordinate */
  31877. get z(): number;
  31878. set z(val: number);
  31879. }
  31880. }
  31881. declare module BABYLON {
  31882. /**
  31883. * @hidden
  31884. */
  31885. export class _MeshCollisionData {
  31886. _checkCollisions: boolean;
  31887. _collisionMask: number;
  31888. _collisionGroup: number;
  31889. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31890. _collider: Nullable<Collider>;
  31891. _oldPositionForCollisions: Vector3;
  31892. _diffPositionForCollisions: Vector3;
  31893. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31894. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31895. }
  31896. }
  31897. declare module BABYLON {
  31898. /** @hidden */
  31899. class _FacetDataStorage {
  31900. facetPositions: Vector3[];
  31901. facetNormals: Vector3[];
  31902. facetPartitioning: number[][];
  31903. facetNb: number;
  31904. partitioningSubdivisions: number;
  31905. partitioningBBoxRatio: number;
  31906. facetDataEnabled: boolean;
  31907. facetParameters: any;
  31908. bbSize: Vector3;
  31909. subDiv: {
  31910. max: number;
  31911. X: number;
  31912. Y: number;
  31913. Z: number;
  31914. };
  31915. facetDepthSort: boolean;
  31916. facetDepthSortEnabled: boolean;
  31917. depthSortedIndices: IndicesArray;
  31918. depthSortedFacets: {
  31919. ind: number;
  31920. sqDistance: number;
  31921. }[];
  31922. facetDepthSortFunction: (f1: {
  31923. ind: number;
  31924. sqDistance: number;
  31925. }, f2: {
  31926. ind: number;
  31927. sqDistance: number;
  31928. }) => number;
  31929. facetDepthSortFrom: Vector3;
  31930. facetDepthSortOrigin: Vector3;
  31931. invertedMatrix: Matrix;
  31932. }
  31933. /**
  31934. * @hidden
  31935. **/
  31936. class _InternalAbstractMeshDataInfo {
  31937. _hasVertexAlpha: boolean;
  31938. _useVertexColors: boolean;
  31939. _numBoneInfluencers: number;
  31940. _applyFog: boolean;
  31941. _receiveShadows: boolean;
  31942. _facetData: _FacetDataStorage;
  31943. _visibility: number;
  31944. _skeleton: Nullable<Skeleton>;
  31945. _layerMask: number;
  31946. _computeBonesUsingShaders: boolean;
  31947. _isActive: boolean;
  31948. _onlyForInstances: boolean;
  31949. _isActiveIntermediate: boolean;
  31950. _onlyForInstancesIntermediate: boolean;
  31951. _actAsRegularMesh: boolean;
  31952. }
  31953. /**
  31954. * Class used to store all common mesh properties
  31955. */
  31956. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31957. /** No occlusion */
  31958. static OCCLUSION_TYPE_NONE: number;
  31959. /** Occlusion set to optimisitic */
  31960. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31961. /** Occlusion set to strict */
  31962. static OCCLUSION_TYPE_STRICT: number;
  31963. /** Use an accurante occlusion algorithm */
  31964. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31965. /** Use a conservative occlusion algorithm */
  31966. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31967. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31968. * Test order :
  31969. * Is the bounding sphere outside the frustum ?
  31970. * If not, are the bounding box vertices outside the frustum ?
  31971. * It not, then the cullable object is in the frustum.
  31972. */
  31973. static readonly CULLINGSTRATEGY_STANDARD: number;
  31974. /** Culling strategy : Bounding Sphere Only.
  31975. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31976. * It's also less accurate than the standard because some not visible objects can still be selected.
  31977. * Test : is the bounding sphere outside the frustum ?
  31978. * If not, then the cullable object is in the frustum.
  31979. */
  31980. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31981. /** Culling strategy : Optimistic Inclusion.
  31982. * This in an inclusion test first, then the standard exclusion test.
  31983. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31984. * 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.
  31985. * Anyway, it's as accurate as the standard strategy.
  31986. * Test :
  31987. * Is the cullable object bounding sphere center in the frustum ?
  31988. * If not, apply the default culling strategy.
  31989. */
  31990. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31991. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31992. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31993. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31994. * 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.
  31995. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31996. * Test :
  31997. * Is the cullable object bounding sphere center in the frustum ?
  31998. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31999. */
  32000. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32001. /**
  32002. * No billboard
  32003. */
  32004. static get BILLBOARDMODE_NONE(): number;
  32005. /** Billboard on X axis */
  32006. static get BILLBOARDMODE_X(): number;
  32007. /** Billboard on Y axis */
  32008. static get BILLBOARDMODE_Y(): number;
  32009. /** Billboard on Z axis */
  32010. static get BILLBOARDMODE_Z(): number;
  32011. /** Billboard on all axes */
  32012. static get BILLBOARDMODE_ALL(): number;
  32013. /** Billboard on using position instead of orientation */
  32014. static get BILLBOARDMODE_USE_POSITION(): number;
  32015. /** @hidden */
  32016. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32017. /**
  32018. * The culling strategy to use to check whether the mesh must be rendered or not.
  32019. * This value can be changed at any time and will be used on the next render mesh selection.
  32020. * The possible values are :
  32021. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32022. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32023. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32024. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32025. * Please read each static variable documentation to get details about the culling process.
  32026. * */
  32027. cullingStrategy: number;
  32028. /**
  32029. * Gets the number of facets in the mesh
  32030. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32031. */
  32032. get facetNb(): number;
  32033. /**
  32034. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32035. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32036. */
  32037. get partitioningSubdivisions(): number;
  32038. set partitioningSubdivisions(nb: number);
  32039. /**
  32040. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32041. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32042. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32043. */
  32044. get partitioningBBoxRatio(): number;
  32045. set partitioningBBoxRatio(ratio: number);
  32046. /**
  32047. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32048. * Works only for updatable meshes.
  32049. * Doesn't work with multi-materials
  32050. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32051. */
  32052. get mustDepthSortFacets(): boolean;
  32053. set mustDepthSortFacets(sort: boolean);
  32054. /**
  32055. * The location (Vector3) where the facet depth sort must be computed from.
  32056. * By default, the active camera position.
  32057. * Used only when facet depth sort is enabled
  32058. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32059. */
  32060. get facetDepthSortFrom(): Vector3;
  32061. set facetDepthSortFrom(location: Vector3);
  32062. /**
  32063. * gets a boolean indicating if facetData is enabled
  32064. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32065. */
  32066. get isFacetDataEnabled(): boolean;
  32067. /** @hidden */
  32068. _updateNonUniformScalingState(value: boolean): boolean;
  32069. /**
  32070. * An event triggered when this mesh collides with another one
  32071. */
  32072. onCollideObservable: Observable<AbstractMesh>;
  32073. /** Set a function to call when this mesh collides with another one */
  32074. set onCollide(callback: () => void);
  32075. /**
  32076. * An event triggered when the collision's position changes
  32077. */
  32078. onCollisionPositionChangeObservable: Observable<Vector3>;
  32079. /** Set a function to call when the collision's position changes */
  32080. set onCollisionPositionChange(callback: () => void);
  32081. /**
  32082. * An event triggered when material is changed
  32083. */
  32084. onMaterialChangedObservable: Observable<AbstractMesh>;
  32085. /**
  32086. * Gets or sets the orientation for POV movement & rotation
  32087. */
  32088. definedFacingForward: boolean;
  32089. /** @hidden */
  32090. _occlusionQuery: Nullable<WebGLQuery>;
  32091. /** @hidden */
  32092. _renderingGroup: Nullable<RenderingGroup>;
  32093. /**
  32094. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32095. */
  32096. get visibility(): number;
  32097. /**
  32098. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32099. */
  32100. set visibility(value: number);
  32101. /** Gets or sets the alpha index used to sort transparent meshes
  32102. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32103. */
  32104. alphaIndex: number;
  32105. /**
  32106. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32107. */
  32108. isVisible: boolean;
  32109. /**
  32110. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32111. */
  32112. isPickable: boolean;
  32113. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32114. showSubMeshesBoundingBox: boolean;
  32115. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32116. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32117. */
  32118. isBlocker: boolean;
  32119. /**
  32120. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32121. */
  32122. enablePointerMoveEvents: boolean;
  32123. private _renderingGroupId;
  32124. /**
  32125. * Specifies the rendering group id for this mesh (0 by default)
  32126. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32127. */
  32128. get renderingGroupId(): number;
  32129. set renderingGroupId(value: number);
  32130. private _material;
  32131. /** Gets or sets current material */
  32132. get material(): Nullable<Material>;
  32133. set material(value: Nullable<Material>);
  32134. /**
  32135. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32136. * @see https://doc.babylonjs.com/babylon101/shadows
  32137. */
  32138. get receiveShadows(): boolean;
  32139. set receiveShadows(value: boolean);
  32140. /** Defines color to use when rendering outline */
  32141. outlineColor: Color3;
  32142. /** Define width to use when rendering outline */
  32143. outlineWidth: number;
  32144. /** Defines color to use when rendering overlay */
  32145. overlayColor: Color3;
  32146. /** Defines alpha to use when rendering overlay */
  32147. overlayAlpha: number;
  32148. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32149. get hasVertexAlpha(): boolean;
  32150. set hasVertexAlpha(value: boolean);
  32151. /** 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) */
  32152. get useVertexColors(): boolean;
  32153. set useVertexColors(value: boolean);
  32154. /**
  32155. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32156. */
  32157. get computeBonesUsingShaders(): boolean;
  32158. set computeBonesUsingShaders(value: boolean);
  32159. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32160. get numBoneInfluencers(): number;
  32161. set numBoneInfluencers(value: number);
  32162. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32163. get applyFog(): boolean;
  32164. set applyFog(value: boolean);
  32165. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32166. useOctreeForRenderingSelection: boolean;
  32167. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32168. useOctreeForPicking: boolean;
  32169. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32170. useOctreeForCollisions: boolean;
  32171. /**
  32172. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32173. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32174. */
  32175. get layerMask(): number;
  32176. set layerMask(value: number);
  32177. /**
  32178. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32179. */
  32180. alwaysSelectAsActiveMesh: boolean;
  32181. /**
  32182. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32183. */
  32184. doNotSyncBoundingInfo: boolean;
  32185. /**
  32186. * Gets or sets the current action manager
  32187. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32188. */
  32189. actionManager: Nullable<AbstractActionManager>;
  32190. private _meshCollisionData;
  32191. /**
  32192. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32193. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32194. */
  32195. ellipsoid: Vector3;
  32196. /**
  32197. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32198. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32199. */
  32200. ellipsoidOffset: Vector3;
  32201. /**
  32202. * Gets or sets a collision mask used to mask collisions (default is -1).
  32203. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32204. */
  32205. get collisionMask(): number;
  32206. set collisionMask(mask: number);
  32207. /**
  32208. * Gets or sets the current collision group mask (-1 by default).
  32209. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32210. */
  32211. get collisionGroup(): number;
  32212. set collisionGroup(mask: number);
  32213. /**
  32214. * Gets or sets current surrounding meshes (null by default).
  32215. *
  32216. * By default collision detection is tested against every mesh in the scene.
  32217. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32218. * meshes will be tested for the collision.
  32219. *
  32220. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32221. */
  32222. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32223. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32224. /**
  32225. * Defines edge width used when edgesRenderer is enabled
  32226. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32227. */
  32228. edgesWidth: number;
  32229. /**
  32230. * Defines edge color used when edgesRenderer is enabled
  32231. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32232. */
  32233. edgesColor: Color4;
  32234. /** @hidden */
  32235. _edgesRenderer: Nullable<IEdgesRenderer>;
  32236. /** @hidden */
  32237. _masterMesh: Nullable<AbstractMesh>;
  32238. /** @hidden */
  32239. _boundingInfo: Nullable<BoundingInfo>;
  32240. /** @hidden */
  32241. _renderId: number;
  32242. /**
  32243. * Gets or sets the list of subMeshes
  32244. * @see https://doc.babylonjs.com/how_to/multi_materials
  32245. */
  32246. subMeshes: SubMesh[];
  32247. /** @hidden */
  32248. _intersectionsInProgress: AbstractMesh[];
  32249. /** @hidden */
  32250. _unIndexed: boolean;
  32251. /** @hidden */
  32252. _lightSources: Light[];
  32253. /** Gets the list of lights affecting that mesh */
  32254. get lightSources(): Light[];
  32255. /** @hidden */
  32256. get _positions(): Nullable<Vector3[]>;
  32257. /** @hidden */
  32258. _waitingData: {
  32259. lods: Nullable<any>;
  32260. actions: Nullable<any>;
  32261. freezeWorldMatrix: Nullable<boolean>;
  32262. };
  32263. /** @hidden */
  32264. _bonesTransformMatrices: Nullable<Float32Array>;
  32265. /** @hidden */
  32266. _transformMatrixTexture: Nullable<RawTexture>;
  32267. /**
  32268. * Gets or sets a skeleton to apply skining transformations
  32269. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32270. */
  32271. set skeleton(value: Nullable<Skeleton>);
  32272. get skeleton(): Nullable<Skeleton>;
  32273. /**
  32274. * An event triggered when the mesh is rebuilt.
  32275. */
  32276. onRebuildObservable: Observable<AbstractMesh>;
  32277. /**
  32278. * Creates a new AbstractMesh
  32279. * @param name defines the name of the mesh
  32280. * @param scene defines the hosting scene
  32281. */
  32282. constructor(name: string, scene?: Nullable<Scene>);
  32283. /**
  32284. * Returns the string "AbstractMesh"
  32285. * @returns "AbstractMesh"
  32286. */
  32287. getClassName(): string;
  32288. /**
  32289. * Gets a string representation of the current mesh
  32290. * @param fullDetails defines a boolean indicating if full details must be included
  32291. * @returns a string representation of the current mesh
  32292. */
  32293. toString(fullDetails?: boolean): string;
  32294. /**
  32295. * @hidden
  32296. */
  32297. protected _getEffectiveParent(): Nullable<Node>;
  32298. /** @hidden */
  32299. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32300. /** @hidden */
  32301. _rebuild(): void;
  32302. /** @hidden */
  32303. _resyncLightSources(): void;
  32304. /** @hidden */
  32305. _resyncLightSource(light: Light): void;
  32306. /** @hidden */
  32307. _unBindEffect(): void;
  32308. /** @hidden */
  32309. _removeLightSource(light: Light, dispose: boolean): void;
  32310. private _markSubMeshesAsDirty;
  32311. /** @hidden */
  32312. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32313. /** @hidden */
  32314. _markSubMeshesAsAttributesDirty(): void;
  32315. /** @hidden */
  32316. _markSubMeshesAsMiscDirty(): void;
  32317. /**
  32318. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32319. */
  32320. get scaling(): Vector3;
  32321. set scaling(newScaling: Vector3);
  32322. /**
  32323. * Returns true if the mesh is blocked. Implemented by child classes
  32324. */
  32325. get isBlocked(): boolean;
  32326. /**
  32327. * Returns the mesh itself by default. Implemented by child classes
  32328. * @param camera defines the camera to use to pick the right LOD level
  32329. * @returns the currentAbstractMesh
  32330. */
  32331. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32332. /**
  32333. * Returns 0 by default. Implemented by child classes
  32334. * @returns an integer
  32335. */
  32336. getTotalVertices(): number;
  32337. /**
  32338. * Returns a positive integer : the total number of indices in this mesh geometry.
  32339. * @returns the numner of indices or zero if the mesh has no geometry.
  32340. */
  32341. getTotalIndices(): number;
  32342. /**
  32343. * Returns null by default. Implemented by child classes
  32344. * @returns null
  32345. */
  32346. getIndices(): Nullable<IndicesArray>;
  32347. /**
  32348. * Returns the array of the requested vertex data kind. Implemented by child classes
  32349. * @param kind defines the vertex data kind to use
  32350. * @returns null
  32351. */
  32352. getVerticesData(kind: string): Nullable<FloatArray>;
  32353. /**
  32354. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32355. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32356. * Note that a new underlying VertexBuffer object is created each call.
  32357. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32358. * @param kind defines vertex data kind:
  32359. * * VertexBuffer.PositionKind
  32360. * * VertexBuffer.UVKind
  32361. * * VertexBuffer.UV2Kind
  32362. * * VertexBuffer.UV3Kind
  32363. * * VertexBuffer.UV4Kind
  32364. * * VertexBuffer.UV5Kind
  32365. * * VertexBuffer.UV6Kind
  32366. * * VertexBuffer.ColorKind
  32367. * * VertexBuffer.MatricesIndicesKind
  32368. * * VertexBuffer.MatricesIndicesExtraKind
  32369. * * VertexBuffer.MatricesWeightsKind
  32370. * * VertexBuffer.MatricesWeightsExtraKind
  32371. * @param data defines the data source
  32372. * @param updatable defines if the data must be flagged as updatable (or static)
  32373. * @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
  32374. * @returns the current mesh
  32375. */
  32376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32377. /**
  32378. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32379. * If the mesh has no geometry, it is simply returned as it is.
  32380. * @param kind defines vertex data kind:
  32381. * * VertexBuffer.PositionKind
  32382. * * VertexBuffer.UVKind
  32383. * * VertexBuffer.UV2Kind
  32384. * * VertexBuffer.UV3Kind
  32385. * * VertexBuffer.UV4Kind
  32386. * * VertexBuffer.UV5Kind
  32387. * * VertexBuffer.UV6Kind
  32388. * * VertexBuffer.ColorKind
  32389. * * VertexBuffer.MatricesIndicesKind
  32390. * * VertexBuffer.MatricesIndicesExtraKind
  32391. * * VertexBuffer.MatricesWeightsKind
  32392. * * VertexBuffer.MatricesWeightsExtraKind
  32393. * @param data defines the data source
  32394. * @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
  32395. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32396. * @returns the current mesh
  32397. */
  32398. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32399. /**
  32400. * Sets the mesh indices,
  32401. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32402. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32403. * @param totalVertices Defines the total number of vertices
  32404. * @returns the current mesh
  32405. */
  32406. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32407. /**
  32408. * Gets a boolean indicating if specific vertex data is present
  32409. * @param kind defines the vertex data kind to use
  32410. * @returns true is data kind is present
  32411. */
  32412. isVerticesDataPresent(kind: string): boolean;
  32413. /**
  32414. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32415. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32416. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32417. * @returns a BoundingInfo
  32418. */
  32419. getBoundingInfo(): BoundingInfo;
  32420. /**
  32421. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32422. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32423. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32424. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32425. * @returns the current mesh
  32426. */
  32427. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32428. /**
  32429. * Overwrite the current bounding info
  32430. * @param boundingInfo defines the new bounding info
  32431. * @returns the current mesh
  32432. */
  32433. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32434. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32435. get useBones(): boolean;
  32436. /** @hidden */
  32437. _preActivate(): void;
  32438. /** @hidden */
  32439. _preActivateForIntermediateRendering(renderId: number): void;
  32440. /** @hidden */
  32441. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32442. /** @hidden */
  32443. _postActivate(): void;
  32444. /** @hidden */
  32445. _freeze(): void;
  32446. /** @hidden */
  32447. _unFreeze(): void;
  32448. /**
  32449. * Gets the current world matrix
  32450. * @returns a Matrix
  32451. */
  32452. getWorldMatrix(): Matrix;
  32453. /** @hidden */
  32454. _getWorldMatrixDeterminant(): number;
  32455. /**
  32456. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32457. */
  32458. get isAnInstance(): boolean;
  32459. /**
  32460. * Gets a boolean indicating if this mesh has instances
  32461. */
  32462. get hasInstances(): boolean;
  32463. /**
  32464. * Gets a boolean indicating if this mesh has thin instances
  32465. */
  32466. get hasThinInstances(): boolean;
  32467. /**
  32468. * Perform relative position change from the point of view of behind the front of the mesh.
  32469. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32470. * Supports definition of mesh facing forward or backward
  32471. * @param amountRight defines the distance on the right axis
  32472. * @param amountUp defines the distance on the up axis
  32473. * @param amountForward defines the distance on the forward axis
  32474. * @returns the current mesh
  32475. */
  32476. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32477. /**
  32478. * Calculate relative position change from the point of view of behind the front of the mesh.
  32479. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32480. * Supports definition of mesh facing forward or backward
  32481. * @param amountRight defines the distance on the right axis
  32482. * @param amountUp defines the distance on the up axis
  32483. * @param amountForward defines the distance on the forward axis
  32484. * @returns the new displacement vector
  32485. */
  32486. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32487. /**
  32488. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32489. * Supports definition of mesh facing forward or backward
  32490. * @param flipBack defines the flip
  32491. * @param twirlClockwise defines the twirl
  32492. * @param tiltRight defines the tilt
  32493. * @returns the current mesh
  32494. */
  32495. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32496. /**
  32497. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32498. * Supports definition of mesh facing forward or backward.
  32499. * @param flipBack defines the flip
  32500. * @param twirlClockwise defines the twirl
  32501. * @param tiltRight defines the tilt
  32502. * @returns the new rotation vector
  32503. */
  32504. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32505. /**
  32506. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32507. * This means the mesh underlying bounding box and sphere are recomputed.
  32508. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32509. * @returns the current mesh
  32510. */
  32511. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32512. /** @hidden */
  32513. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32514. /** @hidden */
  32515. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32516. /** @hidden */
  32517. _updateBoundingInfo(): AbstractMesh;
  32518. /** @hidden */
  32519. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32520. /** @hidden */
  32521. protected _afterComputeWorldMatrix(): void;
  32522. /** @hidden */
  32523. get _effectiveMesh(): AbstractMesh;
  32524. /**
  32525. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32526. * A mesh is in the frustum if its bounding box intersects the frustum
  32527. * @param frustumPlanes defines the frustum to test
  32528. * @returns true if the mesh is in the frustum planes
  32529. */
  32530. isInFrustum(frustumPlanes: Plane[]): boolean;
  32531. /**
  32532. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32533. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32534. * @param frustumPlanes defines the frustum to test
  32535. * @returns true if the mesh is completely in the frustum planes
  32536. */
  32537. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32538. /**
  32539. * True if the mesh intersects another mesh or a SolidParticle object
  32540. * @param mesh defines a target mesh or SolidParticle to test
  32541. * @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)
  32542. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32543. * @returns true if there is an intersection
  32544. */
  32545. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32546. /**
  32547. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32548. * @param point defines the point to test
  32549. * @returns true if there is an intersection
  32550. */
  32551. intersectsPoint(point: Vector3): boolean;
  32552. /**
  32553. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32554. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32555. */
  32556. get checkCollisions(): boolean;
  32557. set checkCollisions(collisionEnabled: boolean);
  32558. /**
  32559. * Gets Collider object used to compute collisions (not physics)
  32560. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32561. */
  32562. get collider(): Nullable<Collider>;
  32563. /**
  32564. * Move the mesh using collision engine
  32565. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32566. * @param displacement defines the requested displacement vector
  32567. * @returns the current mesh
  32568. */
  32569. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32570. private _onCollisionPositionChange;
  32571. /** @hidden */
  32572. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32573. /** @hidden */
  32574. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32575. /** @hidden */
  32576. _checkCollision(collider: Collider): AbstractMesh;
  32577. /** @hidden */
  32578. _generatePointsArray(): boolean;
  32579. /**
  32580. * Checks if the passed Ray intersects with the mesh
  32581. * @param ray defines the ray to use
  32582. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32583. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32584. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32585. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32586. * @returns the picking info
  32587. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32588. */
  32589. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32590. /**
  32591. * Clones the current mesh
  32592. * @param name defines the mesh name
  32593. * @param newParent defines the new mesh parent
  32594. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32595. * @returns the new mesh
  32596. */
  32597. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32598. /**
  32599. * Disposes all the submeshes of the current meshnp
  32600. * @returns the current mesh
  32601. */
  32602. releaseSubMeshes(): AbstractMesh;
  32603. /**
  32604. * Releases resources associated with this abstract mesh.
  32605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32607. */
  32608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32609. /**
  32610. * Adds the passed mesh as a child to the current mesh
  32611. * @param mesh defines the child mesh
  32612. * @returns the current mesh
  32613. */
  32614. addChild(mesh: AbstractMesh): AbstractMesh;
  32615. /**
  32616. * Removes the passed mesh from the current mesh children list
  32617. * @param mesh defines the child mesh
  32618. * @returns the current mesh
  32619. */
  32620. removeChild(mesh: AbstractMesh): AbstractMesh;
  32621. /** @hidden */
  32622. private _initFacetData;
  32623. /**
  32624. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32625. * This method can be called within the render loop.
  32626. * 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
  32627. * @returns the current mesh
  32628. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32629. */
  32630. updateFacetData(): AbstractMesh;
  32631. /**
  32632. * Returns the facetLocalNormals array.
  32633. * The normals are expressed in the mesh local spac
  32634. * @returns an array of Vector3
  32635. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32636. */
  32637. getFacetLocalNormals(): Vector3[];
  32638. /**
  32639. * Returns the facetLocalPositions array.
  32640. * The facet positions are expressed in the mesh local space
  32641. * @returns an array of Vector3
  32642. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32643. */
  32644. getFacetLocalPositions(): Vector3[];
  32645. /**
  32646. * Returns the facetLocalPartioning array
  32647. * @returns an array of array of numbers
  32648. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32649. */
  32650. getFacetLocalPartitioning(): number[][];
  32651. /**
  32652. * Returns the i-th facet position in the world system.
  32653. * This method allocates a new Vector3 per call
  32654. * @param i defines the facet index
  32655. * @returns a new Vector3
  32656. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32657. */
  32658. getFacetPosition(i: number): Vector3;
  32659. /**
  32660. * Sets the reference Vector3 with the i-th facet position in the world system
  32661. * @param i defines the facet index
  32662. * @param ref defines the target vector
  32663. * @returns the current mesh
  32664. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32665. */
  32666. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32667. /**
  32668. * Returns the i-th facet normal in the world system.
  32669. * This method allocates a new Vector3 per call
  32670. * @param i defines the facet index
  32671. * @returns a new Vector3
  32672. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32673. */
  32674. getFacetNormal(i: number): Vector3;
  32675. /**
  32676. * Sets the reference Vector3 with the i-th facet normal in the world system
  32677. * @param i defines the facet index
  32678. * @param ref defines the target vector
  32679. * @returns the current mesh
  32680. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32681. */
  32682. getFacetNormalToRef(i: number, ref: Vector3): this;
  32683. /**
  32684. * 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)
  32685. * @param x defines x coordinate
  32686. * @param y defines y coordinate
  32687. * @param z defines z coordinate
  32688. * @returns the array of facet indexes
  32689. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32690. */
  32691. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32692. /**
  32693. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32694. * @param projected sets as the (x,y,z) world projection on the facet
  32695. * @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
  32696. * @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
  32697. * @param x defines x coordinate
  32698. * @param y defines y coordinate
  32699. * @param z defines z coordinate
  32700. * @returns the face index if found (or null instead)
  32701. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32702. */
  32703. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32704. /**
  32705. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32706. * @param projected sets as the (x,y,z) local projection on the facet
  32707. * @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
  32708. * @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
  32709. * @param x defines x coordinate
  32710. * @param y defines y coordinate
  32711. * @param z defines z coordinate
  32712. * @returns the face index if found (or null instead)
  32713. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32714. */
  32715. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32716. /**
  32717. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32718. * @returns the parameters
  32719. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32720. */
  32721. getFacetDataParameters(): any;
  32722. /**
  32723. * Disables the feature FacetData and frees the related memory
  32724. * @returns the current mesh
  32725. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32726. */
  32727. disableFacetData(): AbstractMesh;
  32728. /**
  32729. * Updates the AbstractMesh indices array
  32730. * @param indices defines the data source
  32731. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32732. * @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)
  32733. * @returns the current mesh
  32734. */
  32735. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32736. /**
  32737. * Creates new normals data for the mesh
  32738. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32739. * @returns the current mesh
  32740. */
  32741. createNormals(updatable: boolean): AbstractMesh;
  32742. /**
  32743. * Align the mesh with a normal
  32744. * @param normal defines the normal to use
  32745. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32746. * @returns the current mesh
  32747. */
  32748. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32749. /** @hidden */
  32750. _checkOcclusionQuery(): boolean;
  32751. /**
  32752. * Disables the mesh edge rendering mode
  32753. * @returns the currentAbstractMesh
  32754. */
  32755. disableEdgesRendering(): AbstractMesh;
  32756. /**
  32757. * Enables the edge rendering mode on the mesh.
  32758. * This mode makes the mesh edges visible
  32759. * @param epsilon defines the maximal distance between two angles to detect a face
  32760. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32761. * @returns the currentAbstractMesh
  32762. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32763. */
  32764. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32765. /**
  32766. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32767. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32768. */
  32769. getConnectedParticleSystems(): IParticleSystem[];
  32770. }
  32771. }
  32772. declare module BABYLON {
  32773. /**
  32774. * Interface used to define ActionEvent
  32775. */
  32776. export interface IActionEvent {
  32777. /** The mesh or sprite that triggered the action */
  32778. source: any;
  32779. /** The X mouse cursor position at the time of the event */
  32780. pointerX: number;
  32781. /** The Y mouse cursor position at the time of the event */
  32782. pointerY: number;
  32783. /** The mesh that is currently pointed at (can be null) */
  32784. meshUnderPointer: Nullable<AbstractMesh>;
  32785. /** the original (browser) event that triggered the ActionEvent */
  32786. sourceEvent?: any;
  32787. /** additional data for the event */
  32788. additionalData?: any;
  32789. }
  32790. /**
  32791. * ActionEvent is the event being sent when an action is triggered.
  32792. */
  32793. export class ActionEvent implements IActionEvent {
  32794. /** The mesh or sprite that triggered the action */
  32795. source: any;
  32796. /** The X mouse cursor position at the time of the event */
  32797. pointerX: number;
  32798. /** The Y mouse cursor position at the time of the event */
  32799. pointerY: number;
  32800. /** The mesh that is currently pointed at (can be null) */
  32801. meshUnderPointer: Nullable<AbstractMesh>;
  32802. /** the original (browser) event that triggered the ActionEvent */
  32803. sourceEvent?: any;
  32804. /** additional data for the event */
  32805. additionalData?: any;
  32806. /**
  32807. * Creates a new ActionEvent
  32808. * @param source The mesh or sprite that triggered the action
  32809. * @param pointerX The X mouse cursor position at the time of the event
  32810. * @param pointerY The Y mouse cursor position at the time of the event
  32811. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32812. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32813. * @param additionalData additional data for the event
  32814. */
  32815. constructor(
  32816. /** The mesh or sprite that triggered the action */
  32817. source: any,
  32818. /** The X mouse cursor position at the time of the event */
  32819. pointerX: number,
  32820. /** The Y mouse cursor position at the time of the event */
  32821. pointerY: number,
  32822. /** The mesh that is currently pointed at (can be null) */
  32823. meshUnderPointer: Nullable<AbstractMesh>,
  32824. /** the original (browser) event that triggered the ActionEvent */
  32825. sourceEvent?: any,
  32826. /** additional data for the event */
  32827. additionalData?: any);
  32828. /**
  32829. * Helper function to auto-create an ActionEvent from a source mesh.
  32830. * @param source The source mesh that triggered the event
  32831. * @param evt The original (browser) event
  32832. * @param additionalData additional data for the event
  32833. * @returns the new ActionEvent
  32834. */
  32835. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32836. /**
  32837. * Helper function to auto-create an ActionEvent from a source sprite
  32838. * @param source The source sprite that triggered the event
  32839. * @param scene Scene associated with the sprite
  32840. * @param evt The original (browser) event
  32841. * @param additionalData additional data for the event
  32842. * @returns the new ActionEvent
  32843. */
  32844. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32845. /**
  32846. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32847. * @param scene the scene where the event occurred
  32848. * @param evt The original (browser) event
  32849. * @returns the new ActionEvent
  32850. */
  32851. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32852. /**
  32853. * Helper function to auto-create an ActionEvent from a primitive
  32854. * @param prim defines the target primitive
  32855. * @param pointerPos defines the pointer position
  32856. * @param evt The original (browser) event
  32857. * @param additionalData additional data for the event
  32858. * @returns the new ActionEvent
  32859. */
  32860. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32861. }
  32862. }
  32863. declare module BABYLON {
  32864. /**
  32865. * Abstract class used to decouple action Manager from scene and meshes.
  32866. * Do not instantiate.
  32867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32868. */
  32869. export abstract class AbstractActionManager implements IDisposable {
  32870. /** Gets the list of active triggers */
  32871. static Triggers: {
  32872. [key: string]: number;
  32873. };
  32874. /** Gets the cursor to use when hovering items */
  32875. hoverCursor: string;
  32876. /** Gets the list of actions */
  32877. actions: IAction[];
  32878. /**
  32879. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32880. */
  32881. isRecursive: boolean;
  32882. /**
  32883. * Releases all associated resources
  32884. */
  32885. abstract dispose(): void;
  32886. /**
  32887. * Does this action manager has pointer triggers
  32888. */
  32889. abstract get hasPointerTriggers(): boolean;
  32890. /**
  32891. * Does this action manager has pick triggers
  32892. */
  32893. abstract get hasPickTriggers(): boolean;
  32894. /**
  32895. * Process a specific trigger
  32896. * @param trigger defines the trigger to process
  32897. * @param evt defines the event details to be processed
  32898. */
  32899. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32900. /**
  32901. * Does this action manager handles actions of any of the given triggers
  32902. * @param triggers defines the triggers to be tested
  32903. * @return a boolean indicating whether one (or more) of the triggers is handled
  32904. */
  32905. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32906. /**
  32907. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32908. * speed.
  32909. * @param triggerA defines the trigger to be tested
  32910. * @param triggerB defines the trigger to be tested
  32911. * @return a boolean indicating whether one (or more) of the triggers is handled
  32912. */
  32913. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32914. /**
  32915. * Does this action manager handles actions of a given trigger
  32916. * @param trigger defines the trigger to be tested
  32917. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32918. * @return whether the trigger is handled
  32919. */
  32920. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32921. /**
  32922. * Serialize this manager to a JSON object
  32923. * @param name defines the property name to store this manager
  32924. * @returns a JSON representation of this manager
  32925. */
  32926. abstract serialize(name: string): any;
  32927. /**
  32928. * Registers an action to this action manager
  32929. * @param action defines the action to be registered
  32930. * @return the action amended (prepared) after registration
  32931. */
  32932. abstract registerAction(action: IAction): Nullable<IAction>;
  32933. /**
  32934. * Unregisters an action to this action manager
  32935. * @param action defines the action to be unregistered
  32936. * @return a boolean indicating whether the action has been unregistered
  32937. */
  32938. abstract unregisterAction(action: IAction): Boolean;
  32939. /**
  32940. * Does exist one action manager with at least one trigger
  32941. **/
  32942. static get HasTriggers(): boolean;
  32943. /**
  32944. * Does exist one action manager with at least one pick trigger
  32945. **/
  32946. static get HasPickTriggers(): boolean;
  32947. /**
  32948. * Does exist one action manager that handles actions of a given trigger
  32949. * @param trigger defines the trigger to be tested
  32950. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32951. **/
  32952. static HasSpecificTrigger(trigger: number): boolean;
  32953. }
  32954. }
  32955. declare module BABYLON {
  32956. /**
  32957. * Defines how a node can be built from a string name.
  32958. */
  32959. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32960. /**
  32961. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32962. */
  32963. export class Node implements IBehaviorAware<Node> {
  32964. /** @hidden */
  32965. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32966. private static _NodeConstructors;
  32967. /**
  32968. * Add a new node constructor
  32969. * @param type defines the type name of the node to construct
  32970. * @param constructorFunc defines the constructor function
  32971. */
  32972. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32973. /**
  32974. * Returns a node constructor based on type name
  32975. * @param type defines the type name
  32976. * @param name defines the new node name
  32977. * @param scene defines the hosting scene
  32978. * @param options defines optional options to transmit to constructors
  32979. * @returns the new constructor or null
  32980. */
  32981. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32982. /**
  32983. * Gets or sets the name of the node
  32984. */
  32985. name: string;
  32986. /**
  32987. * Gets or sets the id of the node
  32988. */
  32989. id: string;
  32990. /**
  32991. * Gets or sets the unique id of the node
  32992. */
  32993. uniqueId: number;
  32994. /**
  32995. * Gets or sets a string used to store user defined state for the node
  32996. */
  32997. state: string;
  32998. /**
  32999. * Gets or sets an object used to store user defined information for the node
  33000. */
  33001. metadata: any;
  33002. /**
  33003. * For internal use only. Please do not use.
  33004. */
  33005. reservedDataStore: any;
  33006. /**
  33007. * List of inspectable custom properties (used by the Inspector)
  33008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33009. */
  33010. inspectableCustomProperties: IInspectable[];
  33011. private _doNotSerialize;
  33012. /**
  33013. * Gets or sets a boolean used to define if the node must be serialized
  33014. */
  33015. get doNotSerialize(): boolean;
  33016. set doNotSerialize(value: boolean);
  33017. /** @hidden */
  33018. _isDisposed: boolean;
  33019. /**
  33020. * Gets a list of Animations associated with the node
  33021. */
  33022. animations: Animation[];
  33023. protected _ranges: {
  33024. [name: string]: Nullable<AnimationRange>;
  33025. };
  33026. /**
  33027. * Callback raised when the node is ready to be used
  33028. */
  33029. onReady: Nullable<(node: Node) => void>;
  33030. private _isEnabled;
  33031. private _isParentEnabled;
  33032. private _isReady;
  33033. /** @hidden */
  33034. _currentRenderId: number;
  33035. private _parentUpdateId;
  33036. /** @hidden */
  33037. _childUpdateId: number;
  33038. /** @hidden */
  33039. _waitingParentId: Nullable<string>;
  33040. /** @hidden */
  33041. _scene: Scene;
  33042. /** @hidden */
  33043. _cache: any;
  33044. private _parentNode;
  33045. private _children;
  33046. /** @hidden */
  33047. _worldMatrix: Matrix;
  33048. /** @hidden */
  33049. _worldMatrixDeterminant: number;
  33050. /** @hidden */
  33051. _worldMatrixDeterminantIsDirty: boolean;
  33052. /** @hidden */
  33053. private _sceneRootNodesIndex;
  33054. /**
  33055. * Gets a boolean indicating if the node has been disposed
  33056. * @returns true if the node was disposed
  33057. */
  33058. isDisposed(): boolean;
  33059. /**
  33060. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33061. * @see https://doc.babylonjs.com/how_to/parenting
  33062. */
  33063. set parent(parent: Nullable<Node>);
  33064. get parent(): Nullable<Node>;
  33065. /** @hidden */
  33066. _addToSceneRootNodes(): void;
  33067. /** @hidden */
  33068. _removeFromSceneRootNodes(): void;
  33069. private _animationPropertiesOverride;
  33070. /**
  33071. * Gets or sets the animation properties override
  33072. */
  33073. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33074. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33075. /**
  33076. * Gets a string identifying the name of the class
  33077. * @returns "Node" string
  33078. */
  33079. getClassName(): string;
  33080. /** @hidden */
  33081. readonly _isNode: boolean;
  33082. /**
  33083. * An event triggered when the mesh is disposed
  33084. */
  33085. onDisposeObservable: Observable<Node>;
  33086. private _onDisposeObserver;
  33087. /**
  33088. * Sets a callback that will be raised when the node will be disposed
  33089. */
  33090. set onDispose(callback: () => void);
  33091. /**
  33092. * Creates a new Node
  33093. * @param name the name and id to be given to this node
  33094. * @param scene the scene this node will be added to
  33095. */
  33096. constructor(name: string, scene?: Nullable<Scene>);
  33097. /**
  33098. * Gets the scene of the node
  33099. * @returns a scene
  33100. */
  33101. getScene(): Scene;
  33102. /**
  33103. * Gets the engine of the node
  33104. * @returns a Engine
  33105. */
  33106. getEngine(): Engine;
  33107. private _behaviors;
  33108. /**
  33109. * Attach a behavior to the node
  33110. * @see https://doc.babylonjs.com/features/behaviour
  33111. * @param behavior defines the behavior to attach
  33112. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33113. * @returns the current Node
  33114. */
  33115. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33116. /**
  33117. * Remove an attached behavior
  33118. * @see https://doc.babylonjs.com/features/behaviour
  33119. * @param behavior defines the behavior to attach
  33120. * @returns the current Node
  33121. */
  33122. removeBehavior(behavior: Behavior<Node>): Node;
  33123. /**
  33124. * Gets the list of attached behaviors
  33125. * @see https://doc.babylonjs.com/features/behaviour
  33126. */
  33127. get behaviors(): Behavior<Node>[];
  33128. /**
  33129. * Gets an attached behavior by name
  33130. * @param name defines the name of the behavior to look for
  33131. * @see https://doc.babylonjs.com/features/behaviour
  33132. * @returns null if behavior was not found else the requested behavior
  33133. */
  33134. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33135. /**
  33136. * Returns the latest update of the World matrix
  33137. * @returns a Matrix
  33138. */
  33139. getWorldMatrix(): Matrix;
  33140. /** @hidden */
  33141. _getWorldMatrixDeterminant(): number;
  33142. /**
  33143. * Returns directly the latest state of the mesh World matrix.
  33144. * A Matrix is returned.
  33145. */
  33146. get worldMatrixFromCache(): Matrix;
  33147. /** @hidden */
  33148. _initCache(): void;
  33149. /** @hidden */
  33150. updateCache(force?: boolean): void;
  33151. /** @hidden */
  33152. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33153. /** @hidden */
  33154. _updateCache(ignoreParentClass?: boolean): void;
  33155. /** @hidden */
  33156. _isSynchronized(): boolean;
  33157. /** @hidden */
  33158. _markSyncedWithParent(): void;
  33159. /** @hidden */
  33160. isSynchronizedWithParent(): boolean;
  33161. /** @hidden */
  33162. isSynchronized(): boolean;
  33163. /**
  33164. * Is this node ready to be used/rendered
  33165. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33166. * @return true if the node is ready
  33167. */
  33168. isReady(completeCheck?: boolean): boolean;
  33169. /**
  33170. * Is this node enabled?
  33171. * 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
  33172. * @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
  33173. * @return whether this node (and its parent) is enabled
  33174. */
  33175. isEnabled(checkAncestors?: boolean): boolean;
  33176. /** @hidden */
  33177. protected _syncParentEnabledState(): void;
  33178. /**
  33179. * Set the enabled state of this node
  33180. * @param value defines the new enabled state
  33181. */
  33182. setEnabled(value: boolean): void;
  33183. /**
  33184. * Is this node a descendant of the given node?
  33185. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33186. * @param ancestor defines the parent node to inspect
  33187. * @returns a boolean indicating if this node is a descendant of the given node
  33188. */
  33189. isDescendantOf(ancestor: Node): boolean;
  33190. /** @hidden */
  33191. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33192. /**
  33193. * Will return all nodes that have this node as ascendant
  33194. * @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
  33195. * @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
  33196. * @return all children nodes of all types
  33197. */
  33198. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33199. /**
  33200. * Get all child-meshes of this node
  33201. * @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)
  33202. * @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
  33203. * @returns an array of AbstractMesh
  33204. */
  33205. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33206. /**
  33207. * Get all direct children of this node
  33208. * @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
  33209. * @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)
  33210. * @returns an array of Node
  33211. */
  33212. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33213. /** @hidden */
  33214. _setReady(state: boolean): void;
  33215. /**
  33216. * Get an animation by name
  33217. * @param name defines the name of the animation to look for
  33218. * @returns null if not found else the requested animation
  33219. */
  33220. getAnimationByName(name: string): Nullable<Animation>;
  33221. /**
  33222. * Creates an animation range for this node
  33223. * @param name defines the name of the range
  33224. * @param from defines the starting key
  33225. * @param to defines the end key
  33226. */
  33227. createAnimationRange(name: string, from: number, to: number): void;
  33228. /**
  33229. * Delete a specific animation range
  33230. * @param name defines the name of the range to delete
  33231. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33232. */
  33233. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33234. /**
  33235. * Get an animation range by name
  33236. * @param name defines the name of the animation range to look for
  33237. * @returns null if not found else the requested animation range
  33238. */
  33239. getAnimationRange(name: string): Nullable<AnimationRange>;
  33240. /**
  33241. * Gets the list of all animation ranges defined on this node
  33242. * @returns an array
  33243. */
  33244. getAnimationRanges(): Nullable<AnimationRange>[];
  33245. /**
  33246. * Will start the animation sequence
  33247. * @param name defines the range frames for animation sequence
  33248. * @param loop defines if the animation should loop (false by default)
  33249. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33250. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33251. * @returns the object created for this animation. If range does not exist, it will return null
  33252. */
  33253. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33254. /**
  33255. * Serialize animation ranges into a JSON compatible object
  33256. * @returns serialization object
  33257. */
  33258. serializeAnimationRanges(): any;
  33259. /**
  33260. * Computes the world matrix of the node
  33261. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33262. * @returns the world matrix
  33263. */
  33264. computeWorldMatrix(force?: boolean): Matrix;
  33265. /**
  33266. * Releases resources associated with this node.
  33267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33269. */
  33270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33271. /**
  33272. * Parse animation range data from a serialization object and store them into a given node
  33273. * @param node defines where to store the animation ranges
  33274. * @param parsedNode defines the serialization object to read data from
  33275. * @param scene defines the hosting scene
  33276. */
  33277. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33278. /**
  33279. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33280. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33281. * @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
  33282. * @returns the new bounding vectors
  33283. */
  33284. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33285. min: Vector3;
  33286. max: Vector3;
  33287. };
  33288. }
  33289. }
  33290. declare module BABYLON {
  33291. /**
  33292. * @hidden
  33293. */
  33294. export class _IAnimationState {
  33295. key: number;
  33296. repeatCount: number;
  33297. workValue?: any;
  33298. loopMode?: number;
  33299. offsetValue?: any;
  33300. highLimitValue?: any;
  33301. }
  33302. /**
  33303. * Class used to store any kind of animation
  33304. */
  33305. export class Animation {
  33306. /**Name of the animation */
  33307. name: string;
  33308. /**Property to animate */
  33309. targetProperty: string;
  33310. /**The frames per second of the animation */
  33311. framePerSecond: number;
  33312. /**The data type of the animation */
  33313. dataType: number;
  33314. /**The loop mode of the animation */
  33315. loopMode?: number | undefined;
  33316. /**Specifies if blending should be enabled */
  33317. enableBlending?: boolean | undefined;
  33318. /**
  33319. * Use matrix interpolation instead of using direct key value when animating matrices
  33320. */
  33321. static AllowMatricesInterpolation: boolean;
  33322. /**
  33323. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33324. */
  33325. static AllowMatrixDecomposeForInterpolation: boolean;
  33326. /** Define the Url to load snippets */
  33327. static SnippetUrl: string;
  33328. /** Snippet ID if the animation was created from the snippet server */
  33329. snippetId: string;
  33330. /**
  33331. * Stores the key frames of the animation
  33332. */
  33333. private _keys;
  33334. /**
  33335. * Stores the easing function of the animation
  33336. */
  33337. private _easingFunction;
  33338. /**
  33339. * @hidden Internal use only
  33340. */
  33341. _runtimeAnimations: RuntimeAnimation[];
  33342. /**
  33343. * The set of event that will be linked to this animation
  33344. */
  33345. private _events;
  33346. /**
  33347. * Stores an array of target property paths
  33348. */
  33349. targetPropertyPath: string[];
  33350. /**
  33351. * Stores the blending speed of the animation
  33352. */
  33353. blendingSpeed: number;
  33354. /**
  33355. * Stores the animation ranges for the animation
  33356. */
  33357. private _ranges;
  33358. /**
  33359. * @hidden Internal use
  33360. */
  33361. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33362. /**
  33363. * Sets up an animation
  33364. * @param property The property to animate
  33365. * @param animationType The animation type to apply
  33366. * @param framePerSecond The frames per second of the animation
  33367. * @param easingFunction The easing function used in the animation
  33368. * @returns The created animation
  33369. */
  33370. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33371. /**
  33372. * Create and start an animation on a node
  33373. * @param name defines the name of the global animation that will be run on all nodes
  33374. * @param node defines the root node where the animation will take place
  33375. * @param targetProperty defines property to animate
  33376. * @param framePerSecond defines the number of frame per second yo use
  33377. * @param totalFrame defines the number of frames in total
  33378. * @param from defines the initial value
  33379. * @param to defines the final value
  33380. * @param loopMode defines which loop mode you want to use (off by default)
  33381. * @param easingFunction defines the easing function to use (linear by default)
  33382. * @param onAnimationEnd defines the callback to call when animation end
  33383. * @returns the animatable created for this animation
  33384. */
  33385. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33386. /**
  33387. * Create and start an animation on a node and its descendants
  33388. * @param name defines the name of the global animation that will be run on all nodes
  33389. * @param node defines the root node where the animation will take place
  33390. * @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
  33391. * @param targetProperty defines property to animate
  33392. * @param framePerSecond defines the number of frame per second to use
  33393. * @param totalFrame defines the number of frames in total
  33394. * @param from defines the initial value
  33395. * @param to defines the final value
  33396. * @param loopMode defines which loop mode you want to use (off by default)
  33397. * @param easingFunction defines the easing function to use (linear by default)
  33398. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33399. * @returns the list of animatables created for all nodes
  33400. * @example https://www.babylonjs-playground.com/#MH0VLI
  33401. */
  33402. 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[]>;
  33403. /**
  33404. * Creates a new animation, merges it with the existing animations and starts it
  33405. * @param name Name of the animation
  33406. * @param node Node which contains the scene that begins the animations
  33407. * @param targetProperty Specifies which property to animate
  33408. * @param framePerSecond The frames per second of the animation
  33409. * @param totalFrame The total number of frames
  33410. * @param from The frame at the beginning of the animation
  33411. * @param to The frame at the end of the animation
  33412. * @param loopMode Specifies the loop mode of the animation
  33413. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33414. * @param onAnimationEnd Callback to run once the animation is complete
  33415. * @returns Nullable animation
  33416. */
  33417. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33418. /**
  33419. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33420. * @param sourceAnimation defines the Animation containing keyframes to convert
  33421. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33422. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33423. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33424. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33425. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33426. */
  33427. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33428. /**
  33429. * Transition property of an host to the target Value
  33430. * @param property The property to transition
  33431. * @param targetValue The target Value of the property
  33432. * @param host The object where the property to animate belongs
  33433. * @param scene Scene used to run the animation
  33434. * @param frameRate Framerate (in frame/s) to use
  33435. * @param transition The transition type we want to use
  33436. * @param duration The duration of the animation, in milliseconds
  33437. * @param onAnimationEnd Callback trigger at the end of the animation
  33438. * @returns Nullable animation
  33439. */
  33440. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33441. /**
  33442. * Return the array of runtime animations currently using this animation
  33443. */
  33444. get runtimeAnimations(): RuntimeAnimation[];
  33445. /**
  33446. * Specifies if any of the runtime animations are currently running
  33447. */
  33448. get hasRunningRuntimeAnimations(): boolean;
  33449. /**
  33450. * Initializes the animation
  33451. * @param name Name of the animation
  33452. * @param targetProperty Property to animate
  33453. * @param framePerSecond The frames per second of the animation
  33454. * @param dataType The data type of the animation
  33455. * @param loopMode The loop mode of the animation
  33456. * @param enableBlending Specifies if blending should be enabled
  33457. */
  33458. constructor(
  33459. /**Name of the animation */
  33460. name: string,
  33461. /**Property to animate */
  33462. targetProperty: string,
  33463. /**The frames per second of the animation */
  33464. framePerSecond: number,
  33465. /**The data type of the animation */
  33466. dataType: number,
  33467. /**The loop mode of the animation */
  33468. loopMode?: number | undefined,
  33469. /**Specifies if blending should be enabled */
  33470. enableBlending?: boolean | undefined);
  33471. /**
  33472. * Converts the animation to a string
  33473. * @param fullDetails support for multiple levels of logging within scene loading
  33474. * @returns String form of the animation
  33475. */
  33476. toString(fullDetails?: boolean): string;
  33477. /**
  33478. * Add an event to this animation
  33479. * @param event Event to add
  33480. */
  33481. addEvent(event: AnimationEvent): void;
  33482. /**
  33483. * Remove all events found at the given frame
  33484. * @param frame The frame to remove events from
  33485. */
  33486. removeEvents(frame: number): void;
  33487. /**
  33488. * Retrieves all the events from the animation
  33489. * @returns Events from the animation
  33490. */
  33491. getEvents(): AnimationEvent[];
  33492. /**
  33493. * Creates an animation range
  33494. * @param name Name of the animation range
  33495. * @param from Starting frame of the animation range
  33496. * @param to Ending frame of the animation
  33497. */
  33498. createRange(name: string, from: number, to: number): void;
  33499. /**
  33500. * Deletes an animation range by name
  33501. * @param name Name of the animation range to delete
  33502. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33503. */
  33504. deleteRange(name: string, deleteFrames?: boolean): void;
  33505. /**
  33506. * Gets the animation range by name, or null if not defined
  33507. * @param name Name of the animation range
  33508. * @returns Nullable animation range
  33509. */
  33510. getRange(name: string): Nullable<AnimationRange>;
  33511. /**
  33512. * Gets the key frames from the animation
  33513. * @returns The key frames of the animation
  33514. */
  33515. getKeys(): Array<IAnimationKey>;
  33516. /**
  33517. * Gets the highest frame rate of the animation
  33518. * @returns Highest frame rate of the animation
  33519. */
  33520. getHighestFrame(): number;
  33521. /**
  33522. * Gets the easing function of the animation
  33523. * @returns Easing function of the animation
  33524. */
  33525. getEasingFunction(): IEasingFunction;
  33526. /**
  33527. * Sets the easing function of the animation
  33528. * @param easingFunction A custom mathematical formula for animation
  33529. */
  33530. setEasingFunction(easingFunction: EasingFunction): void;
  33531. /**
  33532. * Interpolates a scalar linearly
  33533. * @param startValue Start value of the animation curve
  33534. * @param endValue End value of the animation curve
  33535. * @param gradient Scalar amount to interpolate
  33536. * @returns Interpolated scalar value
  33537. */
  33538. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33539. /**
  33540. * Interpolates a scalar cubically
  33541. * @param startValue Start value of the animation curve
  33542. * @param outTangent End tangent of the animation
  33543. * @param endValue End value of the animation curve
  33544. * @param inTangent Start tangent of the animation curve
  33545. * @param gradient Scalar amount to interpolate
  33546. * @returns Interpolated scalar value
  33547. */
  33548. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33549. /**
  33550. * Interpolates a quaternion using a spherical linear interpolation
  33551. * @param startValue Start value of the animation curve
  33552. * @param endValue End value of the animation curve
  33553. * @param gradient Scalar amount to interpolate
  33554. * @returns Interpolated quaternion value
  33555. */
  33556. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33557. /**
  33558. * Interpolates a quaternion cubically
  33559. * @param startValue Start value of the animation curve
  33560. * @param outTangent End tangent of the animation curve
  33561. * @param endValue End value of the animation curve
  33562. * @param inTangent Start tangent of the animation curve
  33563. * @param gradient Scalar amount to interpolate
  33564. * @returns Interpolated quaternion value
  33565. */
  33566. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33567. /**
  33568. * Interpolates a Vector3 linearl
  33569. * @param startValue Start value of the animation curve
  33570. * @param endValue End value of the animation curve
  33571. * @param gradient Scalar amount to interpolate
  33572. * @returns Interpolated scalar value
  33573. */
  33574. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33575. /**
  33576. * Interpolates a Vector3 cubically
  33577. * @param startValue Start value of the animation curve
  33578. * @param outTangent End tangent of the animation
  33579. * @param endValue End value of the animation curve
  33580. * @param inTangent Start tangent of the animation curve
  33581. * @param gradient Scalar amount to interpolate
  33582. * @returns InterpolatedVector3 value
  33583. */
  33584. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33585. /**
  33586. * Interpolates a Vector2 linearly
  33587. * @param startValue Start value of the animation curve
  33588. * @param endValue End value of the animation curve
  33589. * @param gradient Scalar amount to interpolate
  33590. * @returns Interpolated Vector2 value
  33591. */
  33592. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33593. /**
  33594. * Interpolates a Vector2 cubically
  33595. * @param startValue Start value of the animation curve
  33596. * @param outTangent End tangent of the animation
  33597. * @param endValue End value of the animation curve
  33598. * @param inTangent Start tangent of the animation curve
  33599. * @param gradient Scalar amount to interpolate
  33600. * @returns Interpolated Vector2 value
  33601. */
  33602. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33603. /**
  33604. * Interpolates a size linearly
  33605. * @param startValue Start value of the animation curve
  33606. * @param endValue End value of the animation curve
  33607. * @param gradient Scalar amount to interpolate
  33608. * @returns Interpolated Size value
  33609. */
  33610. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33611. /**
  33612. * Interpolates a Color3 linearly
  33613. * @param startValue Start value of the animation curve
  33614. * @param endValue End value of the animation curve
  33615. * @param gradient Scalar amount to interpolate
  33616. * @returns Interpolated Color3 value
  33617. */
  33618. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33619. /**
  33620. * Interpolates a Color4 linearly
  33621. * @param startValue Start value of the animation curve
  33622. * @param endValue End value of the animation curve
  33623. * @param gradient Scalar amount to interpolate
  33624. * @returns Interpolated Color3 value
  33625. */
  33626. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33627. /**
  33628. * @hidden Internal use only
  33629. */
  33630. _getKeyValue(value: any): any;
  33631. /**
  33632. * @hidden Internal use only
  33633. */
  33634. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33635. /**
  33636. * Defines the function to use to interpolate matrices
  33637. * @param startValue defines the start matrix
  33638. * @param endValue defines the end matrix
  33639. * @param gradient defines the gradient between both matrices
  33640. * @param result defines an optional target matrix where to store the interpolation
  33641. * @returns the interpolated matrix
  33642. */
  33643. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33644. /**
  33645. * Makes a copy of the animation
  33646. * @returns Cloned animation
  33647. */
  33648. clone(): Animation;
  33649. /**
  33650. * Sets the key frames of the animation
  33651. * @param values The animation key frames to set
  33652. */
  33653. setKeys(values: Array<IAnimationKey>): void;
  33654. /**
  33655. * Serializes the animation to an object
  33656. * @returns Serialized object
  33657. */
  33658. serialize(): any;
  33659. /**
  33660. * Float animation type
  33661. */
  33662. static readonly ANIMATIONTYPE_FLOAT: number;
  33663. /**
  33664. * Vector3 animation type
  33665. */
  33666. static readonly ANIMATIONTYPE_VECTOR3: number;
  33667. /**
  33668. * Quaternion animation type
  33669. */
  33670. static readonly ANIMATIONTYPE_QUATERNION: number;
  33671. /**
  33672. * Matrix animation type
  33673. */
  33674. static readonly ANIMATIONTYPE_MATRIX: number;
  33675. /**
  33676. * Color3 animation type
  33677. */
  33678. static readonly ANIMATIONTYPE_COLOR3: number;
  33679. /**
  33680. * Color3 animation type
  33681. */
  33682. static readonly ANIMATIONTYPE_COLOR4: number;
  33683. /**
  33684. * Vector2 animation type
  33685. */
  33686. static readonly ANIMATIONTYPE_VECTOR2: number;
  33687. /**
  33688. * Size animation type
  33689. */
  33690. static readonly ANIMATIONTYPE_SIZE: number;
  33691. /**
  33692. * Relative Loop Mode
  33693. */
  33694. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33695. /**
  33696. * Cycle Loop Mode
  33697. */
  33698. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33699. /**
  33700. * Constant Loop Mode
  33701. */
  33702. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33703. /** @hidden */
  33704. static _UniversalLerp(left: any, right: any, amount: number): any;
  33705. /**
  33706. * Parses an animation object and creates an animation
  33707. * @param parsedAnimation Parsed animation object
  33708. * @returns Animation object
  33709. */
  33710. static Parse(parsedAnimation: any): Animation;
  33711. /**
  33712. * Appends the serialized animations from the source animations
  33713. * @param source Source containing the animations
  33714. * @param destination Target to store the animations
  33715. */
  33716. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33717. /**
  33718. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33719. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33720. * @param url defines the url to load from
  33721. * @returns a promise that will resolve to the new animation or an array of animations
  33722. */
  33723. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33724. /**
  33725. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33726. * @param snippetId defines the snippet to load
  33727. * @returns a promise that will resolve to the new animation or a new array of animations
  33728. */
  33729. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33730. }
  33731. }
  33732. declare module BABYLON {
  33733. /**
  33734. * Interface containing an array of animations
  33735. */
  33736. export interface IAnimatable {
  33737. /**
  33738. * Array of animations
  33739. */
  33740. animations: Nullable<Array<Animation>>;
  33741. }
  33742. }
  33743. declare module BABYLON {
  33744. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33745. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33746. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33747. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33748. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33749. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33750. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33751. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33752. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33753. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33754. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33755. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33756. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33757. /**
  33758. * Decorator used to define property that can be serialized as reference to a camera
  33759. * @param sourceName defines the name of the property to decorate
  33760. */
  33761. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33762. /**
  33763. * Class used to help serialization objects
  33764. */
  33765. export class SerializationHelper {
  33766. /** @hidden */
  33767. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33768. /** @hidden */
  33769. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33770. /** @hidden */
  33771. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33772. /** @hidden */
  33773. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33774. /**
  33775. * Appends the serialized animations from the source animations
  33776. * @param source Source containing the animations
  33777. * @param destination Target to store the animations
  33778. */
  33779. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33780. /**
  33781. * Static function used to serialized a specific entity
  33782. * @param entity defines the entity to serialize
  33783. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33784. * @returns a JSON compatible object representing the serialization of the entity
  33785. */
  33786. static Serialize<T>(entity: T, serializationObject?: any): any;
  33787. /**
  33788. * Creates a new entity from a serialization data object
  33789. * @param creationFunction defines a function used to instanciated the new entity
  33790. * @param source defines the source serialization data
  33791. * @param scene defines the hosting scene
  33792. * @param rootUrl defines the root url for resources
  33793. * @returns a new entity
  33794. */
  33795. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33796. /**
  33797. * Clones an object
  33798. * @param creationFunction defines the function used to instanciate the new object
  33799. * @param source defines the source object
  33800. * @returns the cloned object
  33801. */
  33802. static Clone<T>(creationFunction: () => T, source: T): T;
  33803. /**
  33804. * Instanciates a new object based on a source one (some data will be shared between both object)
  33805. * @param creationFunction defines the function used to instanciate the new object
  33806. * @param source defines the source object
  33807. * @returns the new object
  33808. */
  33809. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33810. }
  33811. }
  33812. declare module BABYLON {
  33813. /**
  33814. * Base class of all the textures in babylon.
  33815. * It groups all the common properties the materials, post process, lights... might need
  33816. * in order to make a correct use of the texture.
  33817. */
  33818. export class BaseTexture implements IAnimatable {
  33819. /**
  33820. * Default anisotropic filtering level for the application.
  33821. * It is set to 4 as a good tradeoff between perf and quality.
  33822. */
  33823. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33824. /**
  33825. * Gets or sets the unique id of the texture
  33826. */
  33827. uniqueId: number;
  33828. /**
  33829. * Define the name of the texture.
  33830. */
  33831. name: string;
  33832. /**
  33833. * Gets or sets an object used to store user defined information.
  33834. */
  33835. metadata: any;
  33836. /**
  33837. * For internal use only. Please do not use.
  33838. */
  33839. reservedDataStore: any;
  33840. private _hasAlpha;
  33841. /**
  33842. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33843. */
  33844. set hasAlpha(value: boolean);
  33845. get hasAlpha(): boolean;
  33846. /**
  33847. * Defines if the alpha value should be determined via the rgb values.
  33848. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33849. */
  33850. getAlphaFromRGB: boolean;
  33851. /**
  33852. * Intensity or strength of the texture.
  33853. * It is commonly used by materials to fine tune the intensity of the texture
  33854. */
  33855. level: number;
  33856. /**
  33857. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33858. * This is part of the texture as textures usually maps to one uv set.
  33859. */
  33860. coordinatesIndex: number;
  33861. protected _coordinatesMode: number;
  33862. /**
  33863. * How a texture is mapped.
  33864. *
  33865. * | Value | Type | Description |
  33866. * | ----- | ----------------------------------- | ----------- |
  33867. * | 0 | EXPLICIT_MODE | |
  33868. * | 1 | SPHERICAL_MODE | |
  33869. * | 2 | PLANAR_MODE | |
  33870. * | 3 | CUBIC_MODE | |
  33871. * | 4 | PROJECTION_MODE | |
  33872. * | 5 | SKYBOX_MODE | |
  33873. * | 6 | INVCUBIC_MODE | |
  33874. * | 7 | EQUIRECTANGULAR_MODE | |
  33875. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33876. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33877. */
  33878. set coordinatesMode(value: number);
  33879. get coordinatesMode(): number;
  33880. private _wrapU;
  33881. /**
  33882. * | Value | Type | Description |
  33883. * | ----- | ------------------ | ----------- |
  33884. * | 0 | CLAMP_ADDRESSMODE | |
  33885. * | 1 | WRAP_ADDRESSMODE | |
  33886. * | 2 | MIRROR_ADDRESSMODE | |
  33887. */
  33888. get wrapU(): number;
  33889. set wrapU(value: number);
  33890. private _wrapV;
  33891. /**
  33892. * | Value | Type | Description |
  33893. * | ----- | ------------------ | ----------- |
  33894. * | 0 | CLAMP_ADDRESSMODE | |
  33895. * | 1 | WRAP_ADDRESSMODE | |
  33896. * | 2 | MIRROR_ADDRESSMODE | |
  33897. */
  33898. get wrapV(): number;
  33899. set wrapV(value: number);
  33900. /**
  33901. * | Value | Type | Description |
  33902. * | ----- | ------------------ | ----------- |
  33903. * | 0 | CLAMP_ADDRESSMODE | |
  33904. * | 1 | WRAP_ADDRESSMODE | |
  33905. * | 2 | MIRROR_ADDRESSMODE | |
  33906. */
  33907. wrapR: number;
  33908. /**
  33909. * With compliant hardware and browser (supporting anisotropic filtering)
  33910. * this defines the level of anisotropic filtering in the texture.
  33911. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33912. */
  33913. anisotropicFilteringLevel: number;
  33914. /**
  33915. * Define if the texture is a cube texture or if false a 2d texture.
  33916. */
  33917. get isCube(): boolean;
  33918. set isCube(value: boolean);
  33919. /**
  33920. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33921. */
  33922. get is3D(): boolean;
  33923. set is3D(value: boolean);
  33924. /**
  33925. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33926. */
  33927. get is2DArray(): boolean;
  33928. set is2DArray(value: boolean);
  33929. /**
  33930. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33931. * HDR texture are usually stored in linear space.
  33932. * This only impacts the PBR and Background materials
  33933. */
  33934. gammaSpace: boolean;
  33935. /**
  33936. * Gets or sets whether or not the texture contains RGBD data.
  33937. */
  33938. get isRGBD(): boolean;
  33939. set isRGBD(value: boolean);
  33940. /**
  33941. * Is Z inverted in the texture (useful in a cube texture).
  33942. */
  33943. invertZ: boolean;
  33944. /**
  33945. * Are mip maps generated for this texture or not.
  33946. */
  33947. get noMipmap(): boolean;
  33948. /**
  33949. * @hidden
  33950. */
  33951. lodLevelInAlpha: boolean;
  33952. /**
  33953. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33954. */
  33955. get lodGenerationOffset(): number;
  33956. set lodGenerationOffset(value: number);
  33957. /**
  33958. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33959. */
  33960. get lodGenerationScale(): number;
  33961. set lodGenerationScale(value: number);
  33962. /**
  33963. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33964. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33965. * average roughness values.
  33966. */
  33967. get linearSpecularLOD(): boolean;
  33968. set linearSpecularLOD(value: boolean);
  33969. /**
  33970. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33971. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33972. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33973. */
  33974. get irradianceTexture(): Nullable<BaseTexture>;
  33975. set irradianceTexture(value: Nullable<BaseTexture>);
  33976. /**
  33977. * Define if the texture is a render target.
  33978. */
  33979. isRenderTarget: boolean;
  33980. /**
  33981. * Define the unique id of the texture in the scene.
  33982. */
  33983. get uid(): string;
  33984. /** @hidden */
  33985. _prefiltered: boolean;
  33986. /**
  33987. * Return a string representation of the texture.
  33988. * @returns the texture as a string
  33989. */
  33990. toString(): string;
  33991. /**
  33992. * Get the class name of the texture.
  33993. * @returns "BaseTexture"
  33994. */
  33995. getClassName(): string;
  33996. /**
  33997. * Define the list of animation attached to the texture.
  33998. */
  33999. animations: Animation[];
  34000. /**
  34001. * An event triggered when the texture is disposed.
  34002. */
  34003. onDisposeObservable: Observable<BaseTexture>;
  34004. private _onDisposeObserver;
  34005. /**
  34006. * Callback triggered when the texture has been disposed.
  34007. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34008. */
  34009. set onDispose(callback: () => void);
  34010. /**
  34011. * Define the current state of the loading sequence when in delayed load mode.
  34012. */
  34013. delayLoadState: number;
  34014. protected _scene: Nullable<Scene>;
  34015. protected _engine: Nullable<ThinEngine>;
  34016. /** @hidden */
  34017. _texture: Nullable<InternalTexture>;
  34018. private _uid;
  34019. /**
  34020. * Define if the texture is preventinga material to render or not.
  34021. * If not and the texture is not ready, the engine will use a default black texture instead.
  34022. */
  34023. get isBlocking(): boolean;
  34024. /**
  34025. * Instantiates a new BaseTexture.
  34026. * Base class of all the textures in babylon.
  34027. * It groups all the common properties the materials, post process, lights... might need
  34028. * in order to make a correct use of the texture.
  34029. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34030. */
  34031. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34032. /**
  34033. * Get the scene the texture belongs to.
  34034. * @returns the scene or null if undefined
  34035. */
  34036. getScene(): Nullable<Scene>;
  34037. /** @hidden */
  34038. protected _getEngine(): Nullable<ThinEngine>;
  34039. /**
  34040. * Get the texture transform matrix used to offset tile the texture for istance.
  34041. * @returns the transformation matrix
  34042. */
  34043. getTextureMatrix(): Matrix;
  34044. /**
  34045. * Get the texture reflection matrix used to rotate/transform the reflection.
  34046. * @returns the reflection matrix
  34047. */
  34048. getReflectionTextureMatrix(): Matrix;
  34049. /**
  34050. * Get the underlying lower level texture from Babylon.
  34051. * @returns the insternal texture
  34052. */
  34053. getInternalTexture(): Nullable<InternalTexture>;
  34054. /**
  34055. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34056. * @returns true if ready or not blocking
  34057. */
  34058. isReadyOrNotBlocking(): boolean;
  34059. /**
  34060. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34061. * @returns true if fully ready
  34062. */
  34063. isReady(): boolean;
  34064. private _cachedSize;
  34065. /**
  34066. * Get the size of the texture.
  34067. * @returns the texture size.
  34068. */
  34069. getSize(): ISize;
  34070. /**
  34071. * Get the base size of the texture.
  34072. * It can be different from the size if the texture has been resized for POT for instance
  34073. * @returns the base size
  34074. */
  34075. getBaseSize(): ISize;
  34076. /**
  34077. * Update the sampling mode of the texture.
  34078. * Default is Trilinear mode.
  34079. *
  34080. * | Value | Type | Description |
  34081. * | ----- | ------------------ | ----------- |
  34082. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34083. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34084. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34085. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34086. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34087. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34088. * | 7 | NEAREST_LINEAR | |
  34089. * | 8 | NEAREST_NEAREST | |
  34090. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34091. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34092. * | 11 | LINEAR_LINEAR | |
  34093. * | 12 | LINEAR_NEAREST | |
  34094. *
  34095. * > _mag_: magnification filter (close to the viewer)
  34096. * > _min_: minification filter (far from the viewer)
  34097. * > _mip_: filter used between mip map levels
  34098. *@param samplingMode Define the new sampling mode of the texture
  34099. */
  34100. updateSamplingMode(samplingMode: number): void;
  34101. /**
  34102. * Scales the texture if is `canRescale()`
  34103. * @param ratio the resize factor we want to use to rescale
  34104. */
  34105. scale(ratio: number): void;
  34106. /**
  34107. * Get if the texture can rescale.
  34108. */
  34109. get canRescale(): boolean;
  34110. /** @hidden */
  34111. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34112. /** @hidden */
  34113. _rebuild(): void;
  34114. /**
  34115. * Triggers the load sequence in delayed load mode.
  34116. */
  34117. delayLoad(): void;
  34118. /**
  34119. * Clones the texture.
  34120. * @returns the cloned texture
  34121. */
  34122. clone(): Nullable<BaseTexture>;
  34123. /**
  34124. * Get the texture underlying type (INT, FLOAT...)
  34125. */
  34126. get textureType(): number;
  34127. /**
  34128. * Get the texture underlying format (RGB, RGBA...)
  34129. */
  34130. get textureFormat(): number;
  34131. /**
  34132. * Indicates that textures need to be re-calculated for all materials
  34133. */
  34134. protected _markAllSubMeshesAsTexturesDirty(): void;
  34135. /**
  34136. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34137. * This will returns an RGBA array buffer containing either in values (0-255) or
  34138. * float values (0-1) depending of the underlying buffer type.
  34139. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34140. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34141. * @param buffer defines a user defined buffer to fill with data (can be null)
  34142. * @returns The Array buffer containing the pixels data.
  34143. */
  34144. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34145. /**
  34146. * Release and destroy the underlying lower level texture aka internalTexture.
  34147. */
  34148. releaseInternalTexture(): void;
  34149. /** @hidden */
  34150. get _lodTextureHigh(): Nullable<BaseTexture>;
  34151. /** @hidden */
  34152. get _lodTextureMid(): Nullable<BaseTexture>;
  34153. /** @hidden */
  34154. get _lodTextureLow(): Nullable<BaseTexture>;
  34155. /**
  34156. * Dispose the texture and release its associated resources.
  34157. */
  34158. dispose(): void;
  34159. /**
  34160. * Serialize the texture into a JSON representation that can be parsed later on.
  34161. * @returns the JSON representation of the texture
  34162. */
  34163. serialize(): any;
  34164. /**
  34165. * Helper function to be called back once a list of texture contains only ready textures.
  34166. * @param textures Define the list of textures to wait for
  34167. * @param callback Define the callback triggered once the entire list will be ready
  34168. */
  34169. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34170. private static _isScene;
  34171. }
  34172. }
  34173. declare module BABYLON {
  34174. /**
  34175. * Options to be used when creating an effect.
  34176. */
  34177. export interface IEffectCreationOptions {
  34178. /**
  34179. * Atrributes that will be used in the shader.
  34180. */
  34181. attributes: string[];
  34182. /**
  34183. * Uniform varible names that will be set in the shader.
  34184. */
  34185. uniformsNames: string[];
  34186. /**
  34187. * Uniform buffer variable names that will be set in the shader.
  34188. */
  34189. uniformBuffersNames: string[];
  34190. /**
  34191. * Sampler texture variable names that will be set in the shader.
  34192. */
  34193. samplers: string[];
  34194. /**
  34195. * Define statements that will be set in the shader.
  34196. */
  34197. defines: any;
  34198. /**
  34199. * Possible fallbacks for this effect to improve performance when needed.
  34200. */
  34201. fallbacks: Nullable<IEffectFallbacks>;
  34202. /**
  34203. * Callback that will be called when the shader is compiled.
  34204. */
  34205. onCompiled: Nullable<(effect: Effect) => void>;
  34206. /**
  34207. * Callback that will be called if an error occurs during shader compilation.
  34208. */
  34209. onError: Nullable<(effect: Effect, errors: string) => void>;
  34210. /**
  34211. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34212. */
  34213. indexParameters?: any;
  34214. /**
  34215. * Max number of lights that can be used in the shader.
  34216. */
  34217. maxSimultaneousLights?: number;
  34218. /**
  34219. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34220. */
  34221. transformFeedbackVaryings?: Nullable<string[]>;
  34222. /**
  34223. * 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
  34224. */
  34225. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34226. /**
  34227. * Is this effect rendering to several color attachments ?
  34228. */
  34229. multiTarget?: boolean;
  34230. }
  34231. /**
  34232. * Effect containing vertex and fragment shader that can be executed on an object.
  34233. */
  34234. export class Effect implements IDisposable {
  34235. /**
  34236. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34237. */
  34238. static ShadersRepository: string;
  34239. /**
  34240. * Enable logging of the shader code when a compilation error occurs
  34241. */
  34242. static LogShaderCodeOnCompilationError: boolean;
  34243. /**
  34244. * Name of the effect.
  34245. */
  34246. name: any;
  34247. /**
  34248. * String container all the define statements that should be set on the shader.
  34249. */
  34250. defines: string;
  34251. /**
  34252. * Callback that will be called when the shader is compiled.
  34253. */
  34254. onCompiled: Nullable<(effect: Effect) => void>;
  34255. /**
  34256. * Callback that will be called if an error occurs during shader compilation.
  34257. */
  34258. onError: Nullable<(effect: Effect, errors: string) => void>;
  34259. /**
  34260. * Callback that will be called when effect is bound.
  34261. */
  34262. onBind: Nullable<(effect: Effect) => void>;
  34263. /**
  34264. * Unique ID of the effect.
  34265. */
  34266. uniqueId: number;
  34267. /**
  34268. * Observable that will be called when the shader is compiled.
  34269. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34270. */
  34271. onCompileObservable: Observable<Effect>;
  34272. /**
  34273. * Observable that will be called if an error occurs during shader compilation.
  34274. */
  34275. onErrorObservable: Observable<Effect>;
  34276. /** @hidden */
  34277. _onBindObservable: Nullable<Observable<Effect>>;
  34278. /**
  34279. * @hidden
  34280. * Specifies if the effect was previously ready
  34281. */
  34282. _wasPreviouslyReady: boolean;
  34283. /**
  34284. * Observable that will be called when effect is bound.
  34285. */
  34286. get onBindObservable(): Observable<Effect>;
  34287. /** @hidden */
  34288. _bonesComputationForcedToCPU: boolean;
  34289. /** @hidden */
  34290. _multiTarget: boolean;
  34291. private static _uniqueIdSeed;
  34292. private _engine;
  34293. private _uniformBuffersNames;
  34294. private _uniformBuffersNamesList;
  34295. private _uniformsNames;
  34296. private _samplerList;
  34297. private _samplers;
  34298. private _isReady;
  34299. private _compilationError;
  34300. private _allFallbacksProcessed;
  34301. private _attributesNames;
  34302. private _attributes;
  34303. private _attributeLocationByName;
  34304. private _uniforms;
  34305. /**
  34306. * Key for the effect.
  34307. * @hidden
  34308. */
  34309. _key: string;
  34310. private _indexParameters;
  34311. private _fallbacks;
  34312. private _vertexSourceCode;
  34313. private _fragmentSourceCode;
  34314. private _vertexSourceCodeOverride;
  34315. private _fragmentSourceCodeOverride;
  34316. private _transformFeedbackVaryings;
  34317. /**
  34318. * Compiled shader to webGL program.
  34319. * @hidden
  34320. */
  34321. _pipelineContext: Nullable<IPipelineContext>;
  34322. private _valueCache;
  34323. private static _baseCache;
  34324. /**
  34325. * Instantiates an effect.
  34326. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34327. * @param baseName Name of the effect.
  34328. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34329. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34330. * @param samplers List of sampler variables that will be passed to the shader.
  34331. * @param engine Engine to be used to render the effect
  34332. * @param defines Define statements to be added to the shader.
  34333. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34334. * @param onCompiled Callback that will be called when the shader is compiled.
  34335. * @param onError Callback that will be called if an error occurs during shader compilation.
  34336. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34337. */
  34338. 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);
  34339. private _useFinalCode;
  34340. /**
  34341. * Unique key for this effect
  34342. */
  34343. get key(): string;
  34344. /**
  34345. * If the effect has been compiled and prepared.
  34346. * @returns if the effect is compiled and prepared.
  34347. */
  34348. isReady(): boolean;
  34349. private _isReadyInternal;
  34350. /**
  34351. * The engine the effect was initialized with.
  34352. * @returns the engine.
  34353. */
  34354. getEngine(): Engine;
  34355. /**
  34356. * The pipeline context for this effect
  34357. * @returns the associated pipeline context
  34358. */
  34359. getPipelineContext(): Nullable<IPipelineContext>;
  34360. /**
  34361. * The set of names of attribute variables for the shader.
  34362. * @returns An array of attribute names.
  34363. */
  34364. getAttributesNames(): string[];
  34365. /**
  34366. * Returns the attribute at the given index.
  34367. * @param index The index of the attribute.
  34368. * @returns The location of the attribute.
  34369. */
  34370. getAttributeLocation(index: number): number;
  34371. /**
  34372. * Returns the attribute based on the name of the variable.
  34373. * @param name of the attribute to look up.
  34374. * @returns the attribute location.
  34375. */
  34376. getAttributeLocationByName(name: string): number;
  34377. /**
  34378. * The number of attributes.
  34379. * @returns the numnber of attributes.
  34380. */
  34381. getAttributesCount(): number;
  34382. /**
  34383. * Gets the index of a uniform variable.
  34384. * @param uniformName of the uniform to look up.
  34385. * @returns the index.
  34386. */
  34387. getUniformIndex(uniformName: string): number;
  34388. /**
  34389. * Returns the attribute based on the name of the variable.
  34390. * @param uniformName of the uniform to look up.
  34391. * @returns the location of the uniform.
  34392. */
  34393. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34394. /**
  34395. * Returns an array of sampler variable names
  34396. * @returns The array of sampler variable names.
  34397. */
  34398. getSamplers(): string[];
  34399. /**
  34400. * Returns an array of uniform variable names
  34401. * @returns The array of uniform variable names.
  34402. */
  34403. getUniformNames(): string[];
  34404. /**
  34405. * Returns an array of uniform buffer variable names
  34406. * @returns The array of uniform buffer variable names.
  34407. */
  34408. getUniformBuffersNames(): string[];
  34409. /**
  34410. * Returns the index parameters used to create the effect
  34411. * @returns The index parameters object
  34412. */
  34413. getIndexParameters(): any;
  34414. /**
  34415. * The error from the last compilation.
  34416. * @returns the error string.
  34417. */
  34418. getCompilationError(): string;
  34419. /**
  34420. * Gets a boolean indicating that all fallbacks were used during compilation
  34421. * @returns true if all fallbacks were used
  34422. */
  34423. allFallbacksProcessed(): boolean;
  34424. /**
  34425. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34426. * @param func The callback to be used.
  34427. */
  34428. executeWhenCompiled(func: (effect: Effect) => void): void;
  34429. private _checkIsReady;
  34430. private _loadShader;
  34431. /**
  34432. * Gets the vertex shader source code of this effect
  34433. */
  34434. get vertexSourceCode(): string;
  34435. /**
  34436. * Gets the fragment shader source code of this effect
  34437. */
  34438. get fragmentSourceCode(): string;
  34439. /**
  34440. * Recompiles the webGL program
  34441. * @param vertexSourceCode The source code for the vertex shader.
  34442. * @param fragmentSourceCode The source code for the fragment shader.
  34443. * @param onCompiled Callback called when completed.
  34444. * @param onError Callback called on error.
  34445. * @hidden
  34446. */
  34447. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34448. /**
  34449. * Prepares the effect
  34450. * @hidden
  34451. */
  34452. _prepareEffect(): void;
  34453. private _getShaderCodeAndErrorLine;
  34454. private _processCompilationErrors;
  34455. /**
  34456. * Checks if the effect is supported. (Must be called after compilation)
  34457. */
  34458. get isSupported(): boolean;
  34459. /**
  34460. * Binds a texture to the engine to be used as output of the shader.
  34461. * @param channel Name of the output variable.
  34462. * @param texture Texture to bind.
  34463. * @hidden
  34464. */
  34465. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34466. /**
  34467. * Sets a texture on the engine to be used in the shader.
  34468. * @param channel Name of the sampler variable.
  34469. * @param texture Texture to set.
  34470. */
  34471. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34472. /**
  34473. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34474. * @param channel Name of the sampler variable.
  34475. * @param texture Texture to set.
  34476. */
  34477. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34478. /**
  34479. * Sets an array of textures on the engine to be used in the shader.
  34480. * @param channel Name of the variable.
  34481. * @param textures Textures to set.
  34482. */
  34483. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34484. /**
  34485. * 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)
  34486. * @param channel Name of the sampler variable.
  34487. * @param postProcess Post process to get the input texture from.
  34488. */
  34489. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34490. /**
  34491. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34492. * 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)
  34493. * @param channel Name of the sampler variable.
  34494. * @param postProcess Post process to get the output texture from.
  34495. */
  34496. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34497. /** @hidden */
  34498. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34499. /** @hidden */
  34500. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34501. /** @hidden */
  34502. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34503. /** @hidden */
  34504. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34505. /**
  34506. * Binds a buffer to a uniform.
  34507. * @param buffer Buffer to bind.
  34508. * @param name Name of the uniform variable to bind to.
  34509. */
  34510. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34511. /**
  34512. * Binds block to a uniform.
  34513. * @param blockName Name of the block to bind.
  34514. * @param index Index to bind.
  34515. */
  34516. bindUniformBlock(blockName: string, index: number): void;
  34517. /**
  34518. * Sets an interger value on a uniform variable.
  34519. * @param uniformName Name of the variable.
  34520. * @param value Value to be set.
  34521. * @returns this effect.
  34522. */
  34523. setInt(uniformName: string, value: number): Effect;
  34524. /**
  34525. * Sets an int array on a uniform variable.
  34526. * @param uniformName Name of the variable.
  34527. * @param array array to be set.
  34528. * @returns this effect.
  34529. */
  34530. setIntArray(uniformName: string, array: Int32Array): Effect;
  34531. /**
  34532. * 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)
  34533. * @param uniformName Name of the variable.
  34534. * @param array array to be set.
  34535. * @returns this effect.
  34536. */
  34537. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34538. /**
  34539. * 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)
  34540. * @param uniformName Name of the variable.
  34541. * @param array array to be set.
  34542. * @returns this effect.
  34543. */
  34544. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34545. /**
  34546. * 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)
  34547. * @param uniformName Name of the variable.
  34548. * @param array array to be set.
  34549. * @returns this effect.
  34550. */
  34551. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34552. /**
  34553. * Sets an float array on a uniform variable.
  34554. * @param uniformName Name of the variable.
  34555. * @param array array to be set.
  34556. * @returns this effect.
  34557. */
  34558. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34559. /**
  34560. * 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)
  34561. * @param uniformName Name of the variable.
  34562. * @param array array to be set.
  34563. * @returns this effect.
  34564. */
  34565. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34566. /**
  34567. * 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)
  34568. * @param uniformName Name of the variable.
  34569. * @param array array to be set.
  34570. * @returns this effect.
  34571. */
  34572. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34573. /**
  34574. * 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)
  34575. * @param uniformName Name of the variable.
  34576. * @param array array to be set.
  34577. * @returns this effect.
  34578. */
  34579. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34580. /**
  34581. * Sets an array on a uniform variable.
  34582. * @param uniformName Name of the variable.
  34583. * @param array array to be set.
  34584. * @returns this effect.
  34585. */
  34586. setArray(uniformName: string, array: number[]): Effect;
  34587. /**
  34588. * 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)
  34589. * @param uniformName Name of the variable.
  34590. * @param array array to be set.
  34591. * @returns this effect.
  34592. */
  34593. setArray2(uniformName: string, array: number[]): Effect;
  34594. /**
  34595. * 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)
  34596. * @param uniformName Name of the variable.
  34597. * @param array array to be set.
  34598. * @returns this effect.
  34599. */
  34600. setArray3(uniformName: string, array: number[]): Effect;
  34601. /**
  34602. * 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)
  34603. * @param uniformName Name of the variable.
  34604. * @param array array to be set.
  34605. * @returns this effect.
  34606. */
  34607. setArray4(uniformName: string, array: number[]): Effect;
  34608. /**
  34609. * Sets matrices on a uniform variable.
  34610. * @param uniformName Name of the variable.
  34611. * @param matrices matrices to be set.
  34612. * @returns this effect.
  34613. */
  34614. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34615. /**
  34616. * Sets matrix on a uniform variable.
  34617. * @param uniformName Name of the variable.
  34618. * @param matrix matrix to be set.
  34619. * @returns this effect.
  34620. */
  34621. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34622. /**
  34623. * 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)
  34624. * @param uniformName Name of the variable.
  34625. * @param matrix matrix to be set.
  34626. * @returns this effect.
  34627. */
  34628. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34629. /**
  34630. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34631. * @param uniformName Name of the variable.
  34632. * @param matrix matrix to be set.
  34633. * @returns this effect.
  34634. */
  34635. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34636. /**
  34637. * Sets a float on a uniform variable.
  34638. * @param uniformName Name of the variable.
  34639. * @param value value to be set.
  34640. * @returns this effect.
  34641. */
  34642. setFloat(uniformName: string, value: number): Effect;
  34643. /**
  34644. * Sets a boolean on a uniform variable.
  34645. * @param uniformName Name of the variable.
  34646. * @param bool value to be set.
  34647. * @returns this effect.
  34648. */
  34649. setBool(uniformName: string, bool: boolean): Effect;
  34650. /**
  34651. * Sets a Vector2 on a uniform variable.
  34652. * @param uniformName Name of the variable.
  34653. * @param vector2 vector2 to be set.
  34654. * @returns this effect.
  34655. */
  34656. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34657. /**
  34658. * Sets a float2 on a uniform variable.
  34659. * @param uniformName Name of the variable.
  34660. * @param x First float in float2.
  34661. * @param y Second float in float2.
  34662. * @returns this effect.
  34663. */
  34664. setFloat2(uniformName: string, x: number, y: number): Effect;
  34665. /**
  34666. * Sets a Vector3 on a uniform variable.
  34667. * @param uniformName Name of the variable.
  34668. * @param vector3 Value to be set.
  34669. * @returns this effect.
  34670. */
  34671. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34672. /**
  34673. * Sets a float3 on a uniform variable.
  34674. * @param uniformName Name of the variable.
  34675. * @param x First float in float3.
  34676. * @param y Second float in float3.
  34677. * @param z Third float in float3.
  34678. * @returns this effect.
  34679. */
  34680. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34681. /**
  34682. * Sets a Vector4 on a uniform variable.
  34683. * @param uniformName Name of the variable.
  34684. * @param vector4 Value to be set.
  34685. * @returns this effect.
  34686. */
  34687. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34688. /**
  34689. * Sets a float4 on a uniform variable.
  34690. * @param uniformName Name of the variable.
  34691. * @param x First float in float4.
  34692. * @param y Second float in float4.
  34693. * @param z Third float in float4.
  34694. * @param w Fourth float in float4.
  34695. * @returns this effect.
  34696. */
  34697. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34698. /**
  34699. * Sets a Color3 on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param color3 Value to be set.
  34702. * @returns this effect.
  34703. */
  34704. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34705. /**
  34706. * Sets a Color4 on a uniform variable.
  34707. * @param uniformName Name of the variable.
  34708. * @param color3 Value to be set.
  34709. * @param alpha Alpha value to be set.
  34710. * @returns this effect.
  34711. */
  34712. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34713. /**
  34714. * Sets a Color4 on a uniform variable
  34715. * @param uniformName defines the name of the variable
  34716. * @param color4 defines the value to be set
  34717. * @returns this effect.
  34718. */
  34719. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34720. /** Release all associated resources */
  34721. dispose(): void;
  34722. /**
  34723. * This function will add a new shader to the shader store
  34724. * @param name the name of the shader
  34725. * @param pixelShader optional pixel shader content
  34726. * @param vertexShader optional vertex shader content
  34727. */
  34728. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34729. /**
  34730. * Store of each shader (The can be looked up using effect.key)
  34731. */
  34732. static ShadersStore: {
  34733. [key: string]: string;
  34734. };
  34735. /**
  34736. * Store of each included file for a shader (The can be looked up using effect.key)
  34737. */
  34738. static IncludesShadersStore: {
  34739. [key: string]: string;
  34740. };
  34741. /**
  34742. * Resets the cache of effects.
  34743. */
  34744. static ResetCache(): void;
  34745. }
  34746. }
  34747. declare module BABYLON {
  34748. /**
  34749. * Interface used to describe the capabilities of the engine relatively to the current browser
  34750. */
  34751. export interface EngineCapabilities {
  34752. /** Maximum textures units per fragment shader */
  34753. maxTexturesImageUnits: number;
  34754. /** Maximum texture units per vertex shader */
  34755. maxVertexTextureImageUnits: number;
  34756. /** Maximum textures units in the entire pipeline */
  34757. maxCombinedTexturesImageUnits: number;
  34758. /** Maximum texture size */
  34759. maxTextureSize: number;
  34760. /** Maximum texture samples */
  34761. maxSamples?: number;
  34762. /** Maximum cube texture size */
  34763. maxCubemapTextureSize: number;
  34764. /** Maximum render texture size */
  34765. maxRenderTextureSize: number;
  34766. /** Maximum number of vertex attributes */
  34767. maxVertexAttribs: number;
  34768. /** Maximum number of varyings */
  34769. maxVaryingVectors: number;
  34770. /** Maximum number of uniforms per vertex shader */
  34771. maxVertexUniformVectors: number;
  34772. /** Maximum number of uniforms per fragment shader */
  34773. maxFragmentUniformVectors: number;
  34774. /** Defines if standard derivates (dx/dy) are supported */
  34775. standardDerivatives: boolean;
  34776. /** Defines if s3tc texture compression is supported */
  34777. s3tc?: WEBGL_compressed_texture_s3tc;
  34778. /** Defines if pvrtc texture compression is supported */
  34779. pvrtc: any;
  34780. /** Defines if etc1 texture compression is supported */
  34781. etc1: any;
  34782. /** Defines if etc2 texture compression is supported */
  34783. etc2: any;
  34784. /** Defines if astc texture compression is supported */
  34785. astc: any;
  34786. /** Defines if float textures are supported */
  34787. textureFloat: boolean;
  34788. /** Defines if vertex array objects are supported */
  34789. vertexArrayObject: boolean;
  34790. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34791. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34792. /** Gets the maximum level of anisotropy supported */
  34793. maxAnisotropy: number;
  34794. /** Defines if instancing is supported */
  34795. instancedArrays: boolean;
  34796. /** Defines if 32 bits indices are supported */
  34797. uintIndices: boolean;
  34798. /** Defines if high precision shaders are supported */
  34799. highPrecisionShaderSupported: boolean;
  34800. /** Defines if depth reading in the fragment shader is supported */
  34801. fragmentDepthSupported: boolean;
  34802. /** Defines if float texture linear filtering is supported*/
  34803. textureFloatLinearFiltering: boolean;
  34804. /** Defines if rendering to float textures is supported */
  34805. textureFloatRender: boolean;
  34806. /** Defines if half float textures are supported*/
  34807. textureHalfFloat: boolean;
  34808. /** Defines if half float texture linear filtering is supported*/
  34809. textureHalfFloatLinearFiltering: boolean;
  34810. /** Defines if rendering to half float textures is supported */
  34811. textureHalfFloatRender: boolean;
  34812. /** Defines if textureLOD shader command is supported */
  34813. textureLOD: boolean;
  34814. /** Defines if draw buffers extension is supported */
  34815. drawBuffersExtension: boolean;
  34816. /** Defines if depth textures are supported */
  34817. depthTextureExtension: boolean;
  34818. /** Defines if float color buffer are supported */
  34819. colorBufferFloat: boolean;
  34820. /** Gets disjoint timer query extension (null if not supported) */
  34821. timerQuery?: EXT_disjoint_timer_query;
  34822. /** Defines if timestamp can be used with timer query */
  34823. canUseTimestampForTimerQuery: boolean;
  34824. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34825. multiview?: any;
  34826. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34827. oculusMultiview?: any;
  34828. /** Function used to let the system compiles shaders in background */
  34829. parallelShaderCompile?: {
  34830. COMPLETION_STATUS_KHR: number;
  34831. };
  34832. /** Max number of texture samples for MSAA */
  34833. maxMSAASamples: number;
  34834. /** Defines if the blend min max extension is supported */
  34835. blendMinMax: boolean;
  34836. }
  34837. }
  34838. declare module BABYLON {
  34839. /**
  34840. * @hidden
  34841. **/
  34842. export class DepthCullingState {
  34843. private _isDepthTestDirty;
  34844. private _isDepthMaskDirty;
  34845. private _isDepthFuncDirty;
  34846. private _isCullFaceDirty;
  34847. private _isCullDirty;
  34848. private _isZOffsetDirty;
  34849. private _isFrontFaceDirty;
  34850. private _depthTest;
  34851. private _depthMask;
  34852. private _depthFunc;
  34853. private _cull;
  34854. private _cullFace;
  34855. private _zOffset;
  34856. private _frontFace;
  34857. /**
  34858. * Initializes the state.
  34859. */
  34860. constructor();
  34861. get isDirty(): boolean;
  34862. get zOffset(): number;
  34863. set zOffset(value: number);
  34864. get cullFace(): Nullable<number>;
  34865. set cullFace(value: Nullable<number>);
  34866. get cull(): Nullable<boolean>;
  34867. set cull(value: Nullable<boolean>);
  34868. get depthFunc(): Nullable<number>;
  34869. set depthFunc(value: Nullable<number>);
  34870. get depthMask(): boolean;
  34871. set depthMask(value: boolean);
  34872. get depthTest(): boolean;
  34873. set depthTest(value: boolean);
  34874. get frontFace(): Nullable<number>;
  34875. set frontFace(value: Nullable<number>);
  34876. reset(): void;
  34877. apply(gl: WebGLRenderingContext): void;
  34878. }
  34879. }
  34880. declare module BABYLON {
  34881. /**
  34882. * @hidden
  34883. **/
  34884. export class StencilState {
  34885. /** 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 */
  34886. static readonly ALWAYS: number;
  34887. /** Passed to stencilOperation to specify that stencil value must be kept */
  34888. static readonly KEEP: number;
  34889. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34890. static readonly REPLACE: number;
  34891. private _isStencilTestDirty;
  34892. private _isStencilMaskDirty;
  34893. private _isStencilFuncDirty;
  34894. private _isStencilOpDirty;
  34895. private _stencilTest;
  34896. private _stencilMask;
  34897. private _stencilFunc;
  34898. private _stencilFuncRef;
  34899. private _stencilFuncMask;
  34900. private _stencilOpStencilFail;
  34901. private _stencilOpDepthFail;
  34902. private _stencilOpStencilDepthPass;
  34903. get isDirty(): boolean;
  34904. get stencilFunc(): number;
  34905. set stencilFunc(value: number);
  34906. get stencilFuncRef(): number;
  34907. set stencilFuncRef(value: number);
  34908. get stencilFuncMask(): number;
  34909. set stencilFuncMask(value: number);
  34910. get stencilOpStencilFail(): number;
  34911. set stencilOpStencilFail(value: number);
  34912. get stencilOpDepthFail(): number;
  34913. set stencilOpDepthFail(value: number);
  34914. get stencilOpStencilDepthPass(): number;
  34915. set stencilOpStencilDepthPass(value: number);
  34916. get stencilMask(): number;
  34917. set stencilMask(value: number);
  34918. get stencilTest(): boolean;
  34919. set stencilTest(value: boolean);
  34920. constructor();
  34921. reset(): void;
  34922. apply(gl: WebGLRenderingContext): void;
  34923. }
  34924. }
  34925. declare module BABYLON {
  34926. /**
  34927. * @hidden
  34928. **/
  34929. export class AlphaState {
  34930. private _isAlphaBlendDirty;
  34931. private _isBlendFunctionParametersDirty;
  34932. private _isBlendEquationParametersDirty;
  34933. private _isBlendConstantsDirty;
  34934. private _alphaBlend;
  34935. private _blendFunctionParameters;
  34936. private _blendEquationParameters;
  34937. private _blendConstants;
  34938. /**
  34939. * Initializes the state.
  34940. */
  34941. constructor();
  34942. get isDirty(): boolean;
  34943. get alphaBlend(): boolean;
  34944. set alphaBlend(value: boolean);
  34945. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34946. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34947. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34948. reset(): void;
  34949. apply(gl: WebGLRenderingContext): void;
  34950. }
  34951. }
  34952. declare module BABYLON {
  34953. /** @hidden */
  34954. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34955. attributeProcessor(attribute: string): string;
  34956. varyingProcessor(varying: string, isFragment: boolean): string;
  34957. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34958. }
  34959. }
  34960. declare module BABYLON {
  34961. /**
  34962. * Interface for attribute information associated with buffer instanciation
  34963. */
  34964. export interface InstancingAttributeInfo {
  34965. /**
  34966. * Name of the GLSL attribute
  34967. * if attribute index is not specified, this is used to retrieve the index from the effect
  34968. */
  34969. attributeName: string;
  34970. /**
  34971. * Index/offset of the attribute in the vertex shader
  34972. * if not specified, this will be computes from the name.
  34973. */
  34974. index?: number;
  34975. /**
  34976. * size of the attribute, 1, 2, 3 or 4
  34977. */
  34978. attributeSize: number;
  34979. /**
  34980. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34981. */
  34982. offset: number;
  34983. /**
  34984. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34985. * default to 1
  34986. */
  34987. divisor?: number;
  34988. /**
  34989. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34990. * default is FLOAT
  34991. */
  34992. attributeType?: number;
  34993. /**
  34994. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34995. */
  34996. normalized?: boolean;
  34997. }
  34998. }
  34999. declare module BABYLON {
  35000. interface ThinEngine {
  35001. /**
  35002. * Update a video texture
  35003. * @param texture defines the texture to update
  35004. * @param video defines the video element to use
  35005. * @param invertY defines if data must be stored with Y axis inverted
  35006. */
  35007. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35008. }
  35009. }
  35010. declare module BABYLON {
  35011. interface ThinEngine {
  35012. /**
  35013. * Creates a dynamic texture
  35014. * @param width defines the width of the texture
  35015. * @param height defines the height of the texture
  35016. * @param generateMipMaps defines if the engine should generate the mip levels
  35017. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35018. * @returns the dynamic texture inside an InternalTexture
  35019. */
  35020. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35021. /**
  35022. * Update the content of a dynamic texture
  35023. * @param texture defines the texture to update
  35024. * @param canvas defines the canvas containing the source
  35025. * @param invertY defines if data must be stored with Y axis inverted
  35026. * @param premulAlpha defines if alpha is stored as premultiplied
  35027. * @param format defines the format of the data
  35028. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35029. */
  35030. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35031. }
  35032. }
  35033. declare module BABYLON {
  35034. /**
  35035. * Settings for finer control over video usage
  35036. */
  35037. export interface VideoTextureSettings {
  35038. /**
  35039. * Applies `autoplay` to video, if specified
  35040. */
  35041. autoPlay?: boolean;
  35042. /**
  35043. * Applies `loop` to video, if specified
  35044. */
  35045. loop?: boolean;
  35046. /**
  35047. * Automatically updates internal texture from video at every frame in the render loop
  35048. */
  35049. autoUpdateTexture: boolean;
  35050. /**
  35051. * Image src displayed during the video loading or until the user interacts with the video.
  35052. */
  35053. poster?: string;
  35054. }
  35055. /**
  35056. * If you want to display a video in your scene, this is the special texture for that.
  35057. * This special texture works similar to other textures, with the exception of a few parameters.
  35058. * @see https://doc.babylonjs.com/how_to/video_texture
  35059. */
  35060. export class VideoTexture extends Texture {
  35061. /**
  35062. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35063. */
  35064. readonly autoUpdateTexture: boolean;
  35065. /**
  35066. * The video instance used by the texture internally
  35067. */
  35068. readonly video: HTMLVideoElement;
  35069. private _onUserActionRequestedObservable;
  35070. /**
  35071. * Event triggerd when a dom action is required by the user to play the video.
  35072. * This happens due to recent changes in browser policies preventing video to auto start.
  35073. */
  35074. get onUserActionRequestedObservable(): Observable<Texture>;
  35075. private _generateMipMaps;
  35076. private _stillImageCaptured;
  35077. private _displayingPosterTexture;
  35078. private _settings;
  35079. private _createInternalTextureOnEvent;
  35080. private _frameId;
  35081. private _currentSrc;
  35082. /**
  35083. * Creates a video texture.
  35084. * If you want to display a video in your scene, this is the special texture for that.
  35085. * This special texture works similar to other textures, with the exception of a few parameters.
  35086. * @see https://doc.babylonjs.com/how_to/video_texture
  35087. * @param name optional name, will detect from video source, if not defined
  35088. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35089. * @param scene is obviously the current scene.
  35090. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35091. * @param invertY is false by default but can be used to invert video on Y axis
  35092. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35093. * @param settings allows finer control over video usage
  35094. */
  35095. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35096. private _getName;
  35097. private _getVideo;
  35098. private _createInternalTexture;
  35099. private reset;
  35100. /**
  35101. * @hidden Internal method to initiate `update`.
  35102. */
  35103. _rebuild(): void;
  35104. /**
  35105. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35106. */
  35107. update(): void;
  35108. /**
  35109. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35110. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35111. */
  35112. updateTexture(isVisible: boolean): void;
  35113. protected _updateInternalTexture: () => void;
  35114. /**
  35115. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35116. * @param url New url.
  35117. */
  35118. updateURL(url: string): void;
  35119. /**
  35120. * Clones the texture.
  35121. * @returns the cloned texture
  35122. */
  35123. clone(): VideoTexture;
  35124. /**
  35125. * Dispose the texture and release its associated resources.
  35126. */
  35127. dispose(): void;
  35128. /**
  35129. * Creates a video texture straight from a stream.
  35130. * @param scene Define the scene the texture should be created in
  35131. * @param stream Define the stream the texture should be created from
  35132. * @returns The created video texture as a promise
  35133. */
  35134. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35135. /**
  35136. * Creates a video texture straight from your WebCam video feed.
  35137. * @param scene Define the scene the texture should be created in
  35138. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35139. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35140. * @returns The created video texture as a promise
  35141. */
  35142. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35143. minWidth: number;
  35144. maxWidth: number;
  35145. minHeight: number;
  35146. maxHeight: number;
  35147. deviceId: string;
  35148. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35149. /**
  35150. * Creates a video texture straight from your WebCam video feed.
  35151. * @param scene Define the scene the texture should be created in
  35152. * @param onReady Define a callback to triggered once the texture will be ready
  35153. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35154. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35155. */
  35156. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35157. minWidth: number;
  35158. maxWidth: number;
  35159. minHeight: number;
  35160. maxHeight: number;
  35161. deviceId: string;
  35162. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35163. }
  35164. }
  35165. declare module BABYLON {
  35166. /**
  35167. * Defines the interface used by objects working like Scene
  35168. * @hidden
  35169. */
  35170. export interface ISceneLike {
  35171. _addPendingData(data: any): void;
  35172. _removePendingData(data: any): void;
  35173. offlineProvider: IOfflineProvider;
  35174. }
  35175. /**
  35176. * Information about the current host
  35177. */
  35178. export interface HostInformation {
  35179. /**
  35180. * Defines if the current host is a mobile
  35181. */
  35182. isMobile: boolean;
  35183. }
  35184. /** Interface defining initialization parameters for Engine class */
  35185. export interface EngineOptions extends WebGLContextAttributes {
  35186. /**
  35187. * Defines if the engine should no exceed a specified device ratio
  35188. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35189. */
  35190. limitDeviceRatio?: number;
  35191. /**
  35192. * Defines if webvr should be enabled automatically
  35193. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35194. */
  35195. autoEnableWebVR?: boolean;
  35196. /**
  35197. * Defines if webgl2 should be turned off even if supported
  35198. * @see https://doc.babylonjs.com/features/webgl2
  35199. */
  35200. disableWebGL2Support?: boolean;
  35201. /**
  35202. * Defines if webaudio should be initialized as well
  35203. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35204. */
  35205. audioEngine?: boolean;
  35206. /**
  35207. * Defines if animations should run using a deterministic lock step
  35208. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35209. */
  35210. deterministicLockstep?: boolean;
  35211. /** Defines the maximum steps to use with deterministic lock step mode */
  35212. lockstepMaxSteps?: number;
  35213. /** Defines the seconds between each deterministic lock step */
  35214. timeStep?: number;
  35215. /**
  35216. * Defines that engine should ignore context lost events
  35217. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35218. */
  35219. doNotHandleContextLost?: boolean;
  35220. /**
  35221. * Defines that engine should ignore modifying touch action attribute and style
  35222. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35223. */
  35224. doNotHandleTouchAction?: boolean;
  35225. /**
  35226. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35227. */
  35228. useHighPrecisionFloats?: boolean;
  35229. /**
  35230. * Make the canvas XR Compatible for XR sessions
  35231. */
  35232. xrCompatible?: boolean;
  35233. /**
  35234. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35235. */
  35236. useHighPrecisionMatrix?: boolean;
  35237. }
  35238. /**
  35239. * The base engine class (root of all engines)
  35240. */
  35241. export class ThinEngine {
  35242. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35243. static ExceptionList: ({
  35244. key: string;
  35245. capture: string;
  35246. captureConstraint: number;
  35247. targets: string[];
  35248. } | {
  35249. key: string;
  35250. capture: null;
  35251. captureConstraint: null;
  35252. targets: string[];
  35253. })[];
  35254. /** @hidden */
  35255. static _TextureLoaders: IInternalTextureLoader[];
  35256. /**
  35257. * Returns the current npm package of the sdk
  35258. */
  35259. static get NpmPackage(): string;
  35260. /**
  35261. * Returns the current version of the framework
  35262. */
  35263. static get Version(): string;
  35264. /**
  35265. * Returns a string describing the current engine
  35266. */
  35267. get description(): string;
  35268. /**
  35269. * Gets or sets the epsilon value used by collision engine
  35270. */
  35271. static CollisionsEpsilon: number;
  35272. /**
  35273. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35274. */
  35275. static get ShadersRepository(): string;
  35276. static set ShadersRepository(value: string);
  35277. /** @hidden */
  35278. _shaderProcessor: IShaderProcessor;
  35279. /**
  35280. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35281. */
  35282. forcePOTTextures: boolean;
  35283. /**
  35284. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35285. */
  35286. isFullscreen: boolean;
  35287. /**
  35288. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35289. */
  35290. cullBackFaces: boolean;
  35291. /**
  35292. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35293. */
  35294. renderEvenInBackground: boolean;
  35295. /**
  35296. * Gets or sets a boolean indicating that cache can be kept between frames
  35297. */
  35298. preventCacheWipeBetweenFrames: boolean;
  35299. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35300. validateShaderPrograms: boolean;
  35301. /**
  35302. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35303. * This can provide greater z depth for distant objects.
  35304. */
  35305. useReverseDepthBuffer: boolean;
  35306. /**
  35307. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35308. */
  35309. disableUniformBuffers: boolean;
  35310. /** @hidden */
  35311. _uniformBuffers: UniformBuffer[];
  35312. /**
  35313. * Gets a boolean indicating that the engine supports uniform buffers
  35314. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35315. */
  35316. get supportsUniformBuffers(): boolean;
  35317. /** @hidden */
  35318. _gl: WebGLRenderingContext;
  35319. /** @hidden */
  35320. _webGLVersion: number;
  35321. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35322. protected _windowIsBackground: boolean;
  35323. protected _creationOptions: EngineOptions;
  35324. protected _highPrecisionShadersAllowed: boolean;
  35325. /** @hidden */
  35326. get _shouldUseHighPrecisionShader(): boolean;
  35327. /**
  35328. * Gets a boolean indicating that only power of 2 textures are supported
  35329. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35330. */
  35331. get needPOTTextures(): boolean;
  35332. /** @hidden */
  35333. _badOS: boolean;
  35334. /** @hidden */
  35335. _badDesktopOS: boolean;
  35336. private _hardwareScalingLevel;
  35337. /** @hidden */
  35338. _caps: EngineCapabilities;
  35339. private _isStencilEnable;
  35340. private _glVersion;
  35341. private _glRenderer;
  35342. private _glVendor;
  35343. /** @hidden */
  35344. _videoTextureSupported: boolean;
  35345. protected _renderingQueueLaunched: boolean;
  35346. protected _activeRenderLoops: (() => void)[];
  35347. /**
  35348. * Observable signaled when a context lost event is raised
  35349. */
  35350. onContextLostObservable: Observable<ThinEngine>;
  35351. /**
  35352. * Observable signaled when a context restored event is raised
  35353. */
  35354. onContextRestoredObservable: Observable<ThinEngine>;
  35355. private _onContextLost;
  35356. private _onContextRestored;
  35357. protected _contextWasLost: boolean;
  35358. /** @hidden */
  35359. _doNotHandleContextLost: boolean;
  35360. /**
  35361. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35363. */
  35364. get doNotHandleContextLost(): boolean;
  35365. set doNotHandleContextLost(value: boolean);
  35366. /**
  35367. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35368. */
  35369. disableVertexArrayObjects: boolean;
  35370. /** @hidden */
  35371. protected _colorWrite: boolean;
  35372. /** @hidden */
  35373. protected _colorWriteChanged: boolean;
  35374. /** @hidden */
  35375. protected _depthCullingState: DepthCullingState;
  35376. /** @hidden */
  35377. protected _stencilState: StencilState;
  35378. /** @hidden */
  35379. _alphaState: AlphaState;
  35380. /** @hidden */
  35381. _alphaMode: number;
  35382. /** @hidden */
  35383. _alphaEquation: number;
  35384. /** @hidden */
  35385. _internalTexturesCache: InternalTexture[];
  35386. /** @hidden */
  35387. protected _activeChannel: number;
  35388. private _currentTextureChannel;
  35389. /** @hidden */
  35390. protected _boundTexturesCache: {
  35391. [key: string]: Nullable<InternalTexture>;
  35392. };
  35393. /** @hidden */
  35394. protected _currentEffect: Nullable<Effect>;
  35395. /** @hidden */
  35396. protected _currentProgram: Nullable<WebGLProgram>;
  35397. private _compiledEffects;
  35398. private _vertexAttribArraysEnabled;
  35399. /** @hidden */
  35400. protected _cachedViewport: Nullable<IViewportLike>;
  35401. private _cachedVertexArrayObject;
  35402. /** @hidden */
  35403. protected _cachedVertexBuffers: any;
  35404. /** @hidden */
  35405. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35406. /** @hidden */
  35407. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35408. /** @hidden */
  35409. _currentRenderTarget: Nullable<InternalTexture>;
  35410. private _uintIndicesCurrentlySet;
  35411. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35412. /** @hidden */
  35413. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35414. /** @hidden */
  35415. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35416. private _currentBufferPointers;
  35417. private _currentInstanceLocations;
  35418. private _currentInstanceBuffers;
  35419. private _textureUnits;
  35420. /** @hidden */
  35421. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35422. /** @hidden */
  35423. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35424. /** @hidden */
  35425. _boundRenderFunction: any;
  35426. private _vaoRecordInProgress;
  35427. private _mustWipeVertexAttributes;
  35428. private _emptyTexture;
  35429. private _emptyCubeTexture;
  35430. private _emptyTexture3D;
  35431. private _emptyTexture2DArray;
  35432. /** @hidden */
  35433. _frameHandler: number;
  35434. private _nextFreeTextureSlots;
  35435. private _maxSimultaneousTextures;
  35436. private _activeRequests;
  35437. /** @hidden */
  35438. _transformTextureUrl: Nullable<(url: string) => string>;
  35439. /**
  35440. * Gets information about the current host
  35441. */
  35442. hostInformation: HostInformation;
  35443. protected get _supportsHardwareTextureRescaling(): boolean;
  35444. private _framebufferDimensionsObject;
  35445. /**
  35446. * sets the object from which width and height will be taken from when getting render width and height
  35447. * Will fallback to the gl object
  35448. * @param dimensions the framebuffer width and height that will be used.
  35449. */
  35450. set framebufferDimensionsObject(dimensions: Nullable<{
  35451. framebufferWidth: number;
  35452. framebufferHeight: number;
  35453. }>);
  35454. /**
  35455. * Gets the current viewport
  35456. */
  35457. get currentViewport(): Nullable<IViewportLike>;
  35458. /**
  35459. * Gets the default empty texture
  35460. */
  35461. get emptyTexture(): InternalTexture;
  35462. /**
  35463. * Gets the default empty 3D texture
  35464. */
  35465. get emptyTexture3D(): InternalTexture;
  35466. /**
  35467. * Gets the default empty 2D array texture
  35468. */
  35469. get emptyTexture2DArray(): InternalTexture;
  35470. /**
  35471. * Gets the default empty cube texture
  35472. */
  35473. get emptyCubeTexture(): InternalTexture;
  35474. /**
  35475. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35476. */
  35477. readonly premultipliedAlpha: boolean;
  35478. /**
  35479. * Observable event triggered before each texture is initialized
  35480. */
  35481. onBeforeTextureInitObservable: Observable<Texture>;
  35482. /**
  35483. * Creates a new engine
  35484. * @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
  35485. * @param antialias defines enable antialiasing (default: false)
  35486. * @param options defines further options to be sent to the getContext() function
  35487. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35488. */
  35489. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35490. private _rebuildInternalTextures;
  35491. private _rebuildEffects;
  35492. /**
  35493. * Gets a boolean indicating if all created effects are ready
  35494. * @returns true if all effects are ready
  35495. */
  35496. areAllEffectsReady(): boolean;
  35497. protected _rebuildBuffers(): void;
  35498. protected _initGLContext(): void;
  35499. /**
  35500. * Gets version of the current webGL context
  35501. */
  35502. get webGLVersion(): number;
  35503. /**
  35504. * Gets a string identifying the name of the class
  35505. * @returns "Engine" string
  35506. */
  35507. getClassName(): string;
  35508. /**
  35509. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35510. */
  35511. get isStencilEnable(): boolean;
  35512. /** @hidden */
  35513. _prepareWorkingCanvas(): void;
  35514. /**
  35515. * Reset the texture cache to empty state
  35516. */
  35517. resetTextureCache(): void;
  35518. /**
  35519. * Gets an object containing information about the current webGL context
  35520. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35521. */
  35522. getGlInfo(): {
  35523. vendor: string;
  35524. renderer: string;
  35525. version: string;
  35526. };
  35527. /**
  35528. * Defines the hardware scaling level.
  35529. * By default the hardware scaling level is computed from the window device ratio.
  35530. * 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.
  35531. * @param level defines the level to use
  35532. */
  35533. setHardwareScalingLevel(level: number): void;
  35534. /**
  35535. * Gets the current hardware scaling level.
  35536. * By default the hardware scaling level is computed from the window device ratio.
  35537. * 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.
  35538. * @returns a number indicating the current hardware scaling level
  35539. */
  35540. getHardwareScalingLevel(): number;
  35541. /**
  35542. * Gets the list of loaded textures
  35543. * @returns an array containing all loaded textures
  35544. */
  35545. getLoadedTexturesCache(): InternalTexture[];
  35546. /**
  35547. * Gets the object containing all engine capabilities
  35548. * @returns the EngineCapabilities object
  35549. */
  35550. getCaps(): EngineCapabilities;
  35551. /**
  35552. * stop executing a render loop function and remove it from the execution array
  35553. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35554. */
  35555. stopRenderLoop(renderFunction?: () => void): void;
  35556. /** @hidden */
  35557. _renderLoop(): void;
  35558. /**
  35559. * Gets the HTML canvas attached with the current webGL context
  35560. * @returns a HTML canvas
  35561. */
  35562. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35563. /**
  35564. * Gets host window
  35565. * @returns the host window object
  35566. */
  35567. getHostWindow(): Nullable<Window>;
  35568. /**
  35569. * Gets the current render width
  35570. * @param useScreen defines if screen size must be used (or the current render target if any)
  35571. * @returns a number defining the current render width
  35572. */
  35573. getRenderWidth(useScreen?: boolean): number;
  35574. /**
  35575. * Gets the current render height
  35576. * @param useScreen defines if screen size must be used (or the current render target if any)
  35577. * @returns a number defining the current render height
  35578. */
  35579. getRenderHeight(useScreen?: boolean): number;
  35580. /**
  35581. * Can be used to override the current requestAnimationFrame requester.
  35582. * @hidden
  35583. */
  35584. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35585. /**
  35586. * Register and execute a render loop. The engine can have more than one render function
  35587. * @param renderFunction defines the function to continuously execute
  35588. */
  35589. runRenderLoop(renderFunction: () => void): void;
  35590. /**
  35591. * Clear the current render buffer or the current render target (if any is set up)
  35592. * @param color defines the color to use
  35593. * @param backBuffer defines if the back buffer must be cleared
  35594. * @param depth defines if the depth buffer must be cleared
  35595. * @param stencil defines if the stencil buffer must be cleared
  35596. */
  35597. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35598. private _viewportCached;
  35599. /** @hidden */
  35600. _viewport(x: number, y: number, width: number, height: number): void;
  35601. /**
  35602. * Set the WebGL's viewport
  35603. * @param viewport defines the viewport element to be used
  35604. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35605. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35606. */
  35607. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35608. /**
  35609. * Begin a new frame
  35610. */
  35611. beginFrame(): void;
  35612. /**
  35613. * Enf the current frame
  35614. */
  35615. endFrame(): void;
  35616. /**
  35617. * Resize the view according to the canvas' size
  35618. */
  35619. resize(): void;
  35620. /**
  35621. * Force a specific size of the canvas
  35622. * @param width defines the new canvas' width
  35623. * @param height defines the new canvas' height
  35624. * @returns true if the size was changed
  35625. */
  35626. setSize(width: number, height: number): boolean;
  35627. /**
  35628. * Binds the frame buffer to the specified texture.
  35629. * @param texture The texture to render to or null for the default canvas
  35630. * @param faceIndex The face of the texture to render to in case of cube texture
  35631. * @param requiredWidth The width of the target to render to
  35632. * @param requiredHeight The height of the target to render to
  35633. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35634. * @param lodLevel defines the lod level to bind to the frame buffer
  35635. * @param layer defines the 2d array index to bind to frame buffer to
  35636. */
  35637. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35638. /** @hidden */
  35639. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35640. /**
  35641. * Unbind the current render target texture from the webGL context
  35642. * @param texture defines the render target texture to unbind
  35643. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35644. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35645. */
  35646. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35647. /**
  35648. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35649. */
  35650. flushFramebuffer(): void;
  35651. /**
  35652. * Unbind the current render target and bind the default framebuffer
  35653. */
  35654. restoreDefaultFramebuffer(): void;
  35655. /** @hidden */
  35656. protected _resetVertexBufferBinding(): void;
  35657. /**
  35658. * Creates a vertex buffer
  35659. * @param data the data for the vertex buffer
  35660. * @returns the new WebGL static buffer
  35661. */
  35662. createVertexBuffer(data: DataArray): DataBuffer;
  35663. private _createVertexBuffer;
  35664. /**
  35665. * Creates a dynamic vertex buffer
  35666. * @param data the data for the dynamic vertex buffer
  35667. * @returns the new WebGL dynamic buffer
  35668. */
  35669. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35670. protected _resetIndexBufferBinding(): void;
  35671. /**
  35672. * Creates a new index buffer
  35673. * @param indices defines the content of the index buffer
  35674. * @param updatable defines if the index buffer must be updatable
  35675. * @returns a new webGL buffer
  35676. */
  35677. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35678. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35679. /**
  35680. * Bind a webGL buffer to the webGL context
  35681. * @param buffer defines the buffer to bind
  35682. */
  35683. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35684. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35685. private bindBuffer;
  35686. /**
  35687. * update the bound buffer with the given data
  35688. * @param data defines the data to update
  35689. */
  35690. updateArrayBuffer(data: Float32Array): void;
  35691. private _vertexAttribPointer;
  35692. /** @hidden */
  35693. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35694. private _bindVertexBuffersAttributes;
  35695. /**
  35696. * Records a vertex array object
  35697. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35698. * @param vertexBuffers defines the list of vertex buffers to store
  35699. * @param indexBuffer defines the index buffer to store
  35700. * @param effect defines the effect to store
  35701. * @returns the new vertex array object
  35702. */
  35703. recordVertexArrayObject(vertexBuffers: {
  35704. [key: string]: VertexBuffer;
  35705. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35706. /**
  35707. * Bind a specific vertex array object
  35708. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35709. * @param vertexArrayObject defines the vertex array object to bind
  35710. * @param indexBuffer defines the index buffer to bind
  35711. */
  35712. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35713. /**
  35714. * Bind webGl buffers directly to the webGL context
  35715. * @param vertexBuffer defines the vertex buffer to bind
  35716. * @param indexBuffer defines the index buffer to bind
  35717. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35718. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35719. * @param effect defines the effect associated with the vertex buffer
  35720. */
  35721. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35722. private _unbindVertexArrayObject;
  35723. /**
  35724. * Bind a list of vertex buffers to the webGL context
  35725. * @param vertexBuffers defines the list of vertex buffers to bind
  35726. * @param indexBuffer defines the index buffer to bind
  35727. * @param effect defines the effect associated with the vertex buffers
  35728. */
  35729. bindBuffers(vertexBuffers: {
  35730. [key: string]: Nullable<VertexBuffer>;
  35731. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35732. /**
  35733. * Unbind all instance attributes
  35734. */
  35735. unbindInstanceAttributes(): void;
  35736. /**
  35737. * Release and free the memory of a vertex array object
  35738. * @param vao defines the vertex array object to delete
  35739. */
  35740. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35741. /** @hidden */
  35742. _releaseBuffer(buffer: DataBuffer): boolean;
  35743. protected _deleteBuffer(buffer: DataBuffer): void;
  35744. /**
  35745. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35746. * @param instancesBuffer defines the webGL buffer to update and bind
  35747. * @param data defines the data to store in the buffer
  35748. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35749. */
  35750. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35751. /**
  35752. * Bind the content of a webGL buffer used with instantiation
  35753. * @param instancesBuffer defines the webGL buffer to bind
  35754. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35755. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35756. */
  35757. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35758. /**
  35759. * Disable the instance attribute corresponding to the name in parameter
  35760. * @param name defines the name of the attribute to disable
  35761. */
  35762. disableInstanceAttributeByName(name: string): void;
  35763. /**
  35764. * Disable the instance attribute corresponding to the location in parameter
  35765. * @param attributeLocation defines the attribute location of the attribute to disable
  35766. */
  35767. disableInstanceAttribute(attributeLocation: number): void;
  35768. /**
  35769. * Disable the attribute corresponding to the location in parameter
  35770. * @param attributeLocation defines the attribute location of the attribute to disable
  35771. */
  35772. disableAttributeByIndex(attributeLocation: number): void;
  35773. /**
  35774. * Send a draw order
  35775. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35776. * @param indexStart defines the starting index
  35777. * @param indexCount defines the number of index to draw
  35778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35779. */
  35780. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35781. /**
  35782. * Draw a list of points
  35783. * @param verticesStart defines the index of first vertex to draw
  35784. * @param verticesCount defines the count of vertices to draw
  35785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35786. */
  35787. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35788. /**
  35789. * Draw a list of unindexed primitives
  35790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35791. * @param verticesStart defines the index of first vertex to draw
  35792. * @param verticesCount defines the count of vertices to draw
  35793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35794. */
  35795. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35796. /**
  35797. * Draw a list of indexed primitives
  35798. * @param fillMode defines the primitive to use
  35799. * @param indexStart defines the starting index
  35800. * @param indexCount defines the number of index to draw
  35801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35802. */
  35803. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35804. /**
  35805. * Draw a list of unindexed primitives
  35806. * @param fillMode defines the primitive to use
  35807. * @param verticesStart defines the index of first vertex to draw
  35808. * @param verticesCount defines the count of vertices to draw
  35809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35810. */
  35811. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35812. private _drawMode;
  35813. /** @hidden */
  35814. protected _reportDrawCall(): void;
  35815. /** @hidden */
  35816. _releaseEffect(effect: Effect): void;
  35817. /** @hidden */
  35818. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35819. /**
  35820. * Create a new effect (used to store vertex/fragment shaders)
  35821. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35822. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35823. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35824. * @param samplers defines an array of string used to represent textures
  35825. * @param defines defines the string containing the defines to use to compile the shaders
  35826. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35827. * @param onCompiled defines a function to call when the effect creation is successful
  35828. * @param onError defines a function to call when the effect creation has failed
  35829. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35830. * @returns the new Effect
  35831. */
  35832. 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;
  35833. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35834. private _compileShader;
  35835. private _compileRawShader;
  35836. /** @hidden */
  35837. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35838. /**
  35839. * Directly creates a webGL program
  35840. * @param pipelineContext defines the pipeline context to attach to
  35841. * @param vertexCode defines the vertex shader code to use
  35842. * @param fragmentCode defines the fragment shader code to use
  35843. * @param context defines the webGL context to use (if not set, the current one will be used)
  35844. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35845. * @returns the new webGL program
  35846. */
  35847. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35848. /**
  35849. * Creates a webGL program
  35850. * @param pipelineContext defines the pipeline context to attach to
  35851. * @param vertexCode defines the vertex shader code to use
  35852. * @param fragmentCode defines the fragment shader code to use
  35853. * @param defines defines the string containing the defines to use to compile the shaders
  35854. * @param context defines the webGL context to use (if not set, the current one will be used)
  35855. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35856. * @returns the new webGL program
  35857. */
  35858. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35859. /**
  35860. * Creates a new pipeline context
  35861. * @returns the new pipeline
  35862. */
  35863. createPipelineContext(): IPipelineContext;
  35864. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35865. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35866. /** @hidden */
  35867. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35868. /** @hidden */
  35869. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35870. /** @hidden */
  35871. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35872. /**
  35873. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35874. * @param pipelineContext defines the pipeline context to use
  35875. * @param uniformsNames defines the list of uniform names
  35876. * @returns an array of webGL uniform locations
  35877. */
  35878. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35879. /**
  35880. * Gets the lsit of active attributes for a given webGL program
  35881. * @param pipelineContext defines the pipeline context to use
  35882. * @param attributesNames defines the list of attribute names to get
  35883. * @returns an array of indices indicating the offset of each attribute
  35884. */
  35885. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35886. /**
  35887. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35888. * @param effect defines the effect to activate
  35889. */
  35890. enableEffect(effect: Nullable<Effect>): void;
  35891. /**
  35892. * Set the value of an uniform to a number (int)
  35893. * @param uniform defines the webGL uniform location where to store the value
  35894. * @param value defines the int number to store
  35895. */
  35896. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35897. /**
  35898. * Set the value of an uniform to an array of int32
  35899. * @param uniform defines the webGL uniform location where to store the value
  35900. * @param array defines the array of int32 to store
  35901. */
  35902. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35903. /**
  35904. * Set the value of an uniform to an array of int32 (stored as vec2)
  35905. * @param uniform defines the webGL uniform location where to store the value
  35906. * @param array defines the array of int32 to store
  35907. */
  35908. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35909. /**
  35910. * Set the value of an uniform to an array of int32 (stored as vec3)
  35911. * @param uniform defines the webGL uniform location where to store the value
  35912. * @param array defines the array of int32 to store
  35913. */
  35914. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35915. /**
  35916. * Set the value of an uniform to an array of int32 (stored as vec4)
  35917. * @param uniform defines the webGL uniform location where to store the value
  35918. * @param array defines the array of int32 to store
  35919. */
  35920. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35921. /**
  35922. * Set the value of an uniform to an array of number
  35923. * @param uniform defines the webGL uniform location where to store the value
  35924. * @param array defines the array of number to store
  35925. */
  35926. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35927. /**
  35928. * Set the value of an uniform to an array of number (stored as vec2)
  35929. * @param uniform defines the webGL uniform location where to store the value
  35930. * @param array defines the array of number to store
  35931. */
  35932. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35933. /**
  35934. * Set the value of an uniform to an array of number (stored as vec3)
  35935. * @param uniform defines the webGL uniform location where to store the value
  35936. * @param array defines the array of number to store
  35937. */
  35938. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35939. /**
  35940. * Set the value of an uniform to an array of number (stored as vec4)
  35941. * @param uniform defines the webGL uniform location where to store the value
  35942. * @param array defines the array of number to store
  35943. */
  35944. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35945. /**
  35946. * Set the value of an uniform to an array of float32 (stored as matrices)
  35947. * @param uniform defines the webGL uniform location where to store the value
  35948. * @param matrices defines the array of float32 to store
  35949. */
  35950. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35951. /**
  35952. * Set the value of an uniform to a matrix (3x3)
  35953. * @param uniform defines the webGL uniform location where to store the value
  35954. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35955. */
  35956. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35957. /**
  35958. * Set the value of an uniform to a matrix (2x2)
  35959. * @param uniform defines the webGL uniform location where to store the value
  35960. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35961. */
  35962. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35963. /**
  35964. * Set the value of an uniform to a number (float)
  35965. * @param uniform defines the webGL uniform location where to store the value
  35966. * @param value defines the float number to store
  35967. */
  35968. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35969. /**
  35970. * Set the value of an uniform to a vec2
  35971. * @param uniform defines the webGL uniform location where to store the value
  35972. * @param x defines the 1st component of the value
  35973. * @param y defines the 2nd component of the value
  35974. */
  35975. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35976. /**
  35977. * Set the value of an uniform to a vec3
  35978. * @param uniform defines the webGL uniform location where to store the value
  35979. * @param x defines the 1st component of the value
  35980. * @param y defines the 2nd component of the value
  35981. * @param z defines the 3rd component of the value
  35982. */
  35983. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35984. /**
  35985. * Set the value of an uniform to a vec4
  35986. * @param uniform defines the webGL uniform location where to store the value
  35987. * @param x defines the 1st component of the value
  35988. * @param y defines the 2nd component of the value
  35989. * @param z defines the 3rd component of the value
  35990. * @param w defines the 4th component of the value
  35991. */
  35992. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35993. /**
  35994. * Apply all cached states (depth, culling, stencil and alpha)
  35995. */
  35996. applyStates(): void;
  35997. /**
  35998. * Enable or disable color writing
  35999. * @param enable defines the state to set
  36000. */
  36001. setColorWrite(enable: boolean): void;
  36002. /**
  36003. * Gets a boolean indicating if color writing is enabled
  36004. * @returns the current color writing state
  36005. */
  36006. getColorWrite(): boolean;
  36007. /**
  36008. * Gets the depth culling state manager
  36009. */
  36010. get depthCullingState(): DepthCullingState;
  36011. /**
  36012. * Gets the alpha state manager
  36013. */
  36014. get alphaState(): AlphaState;
  36015. /**
  36016. * Gets the stencil state manager
  36017. */
  36018. get stencilState(): StencilState;
  36019. /**
  36020. * Clears the list of texture accessible through engine.
  36021. * This can help preventing texture load conflict due to name collision.
  36022. */
  36023. clearInternalTexturesCache(): void;
  36024. /**
  36025. * Force the entire cache to be cleared
  36026. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36027. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36028. */
  36029. wipeCaches(bruteForce?: boolean): void;
  36030. /** @hidden */
  36031. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36032. min: number;
  36033. mag: number;
  36034. };
  36035. /** @hidden */
  36036. _createTexture(): WebGLTexture;
  36037. /**
  36038. * Usually called from Texture.ts.
  36039. * Passed information to create a WebGLTexture
  36040. * @param url defines a value which contains one of the following:
  36041. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36042. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36043. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36044. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36045. * @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)
  36046. * @param scene needed for loading to the correct scene
  36047. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36048. * @param onLoad optional callback to be called upon successful completion
  36049. * @param onError optional callback to be called upon failure
  36050. * @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
  36051. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36052. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36053. * @param forcedExtension defines the extension to use to pick the right loader
  36054. * @param mimeType defines an optional mime type
  36055. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36056. */
  36057. 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;
  36058. /**
  36059. * Loads an image as an HTMLImageElement.
  36060. * @param input url string, ArrayBuffer, or Blob to load
  36061. * @param onLoad callback called when the image successfully loads
  36062. * @param onError callback called when the image fails to load
  36063. * @param offlineProvider offline provider for caching
  36064. * @param mimeType optional mime type
  36065. * @returns the HTMLImageElement of the loaded image
  36066. * @hidden
  36067. */
  36068. 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>;
  36069. /**
  36070. * @hidden
  36071. */
  36072. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36073. private _unpackFlipYCached;
  36074. /**
  36075. * In case you are sharing the context with other applications, it might
  36076. * be interested to not cache the unpack flip y state to ensure a consistent
  36077. * value would be set.
  36078. */
  36079. enableUnpackFlipYCached: boolean;
  36080. /** @hidden */
  36081. _unpackFlipY(value: boolean): void;
  36082. /** @hidden */
  36083. _getUnpackAlignement(): number;
  36084. private _getTextureTarget;
  36085. /**
  36086. * Update the sampling mode of a given texture
  36087. * @param samplingMode defines the required sampling mode
  36088. * @param texture defines the texture to update
  36089. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36090. */
  36091. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36092. /**
  36093. * Update the sampling mode of a given texture
  36094. * @param texture defines the texture to update
  36095. * @param wrapU defines the texture wrap mode of the u coordinates
  36096. * @param wrapV defines the texture wrap mode of the v coordinates
  36097. * @param wrapR defines the texture wrap mode of the r coordinates
  36098. */
  36099. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36100. /** @hidden */
  36101. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36102. width: number;
  36103. height: number;
  36104. layers?: number;
  36105. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36106. /** @hidden */
  36107. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36108. /** @hidden */
  36109. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36110. /**
  36111. * Update a portion of an internal texture
  36112. * @param texture defines the texture to update
  36113. * @param imageData defines the data to store into the texture
  36114. * @param xOffset defines the x coordinates of the update rectangle
  36115. * @param yOffset defines the y coordinates of the update rectangle
  36116. * @param width defines the width of the update rectangle
  36117. * @param height defines the height of the update rectangle
  36118. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36119. * @param lod defines the lod level to update (0 by default)
  36120. */
  36121. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36122. /** @hidden */
  36123. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36124. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36125. private _prepareWebGLTexture;
  36126. /** @hidden */
  36127. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36128. private _getDepthStencilBuffer;
  36129. /** @hidden */
  36130. _releaseFramebufferObjects(texture: InternalTexture): void;
  36131. /** @hidden */
  36132. _releaseTexture(texture: InternalTexture): void;
  36133. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36134. protected _setProgram(program: WebGLProgram): void;
  36135. protected _boundUniforms: {
  36136. [key: number]: WebGLUniformLocation;
  36137. };
  36138. /**
  36139. * Binds an effect to the webGL context
  36140. * @param effect defines the effect to bind
  36141. */
  36142. bindSamplers(effect: Effect): void;
  36143. private _activateCurrentTexture;
  36144. /** @hidden */
  36145. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36146. /** @hidden */
  36147. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36148. /**
  36149. * Unbind all textures from the webGL context
  36150. */
  36151. unbindAllTextures(): void;
  36152. /**
  36153. * Sets a texture to the according uniform.
  36154. * @param channel The texture channel
  36155. * @param uniform The uniform to set
  36156. * @param texture The texture to apply
  36157. */
  36158. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36159. private _bindSamplerUniformToChannel;
  36160. private _getTextureWrapMode;
  36161. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36162. /**
  36163. * Sets an array of texture to the webGL context
  36164. * @param channel defines the channel where the texture array must be set
  36165. * @param uniform defines the associated uniform location
  36166. * @param textures defines the array of textures to bind
  36167. */
  36168. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36169. /** @hidden */
  36170. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36171. private _setTextureParameterFloat;
  36172. private _setTextureParameterInteger;
  36173. /**
  36174. * Unbind all vertex attributes from the webGL context
  36175. */
  36176. unbindAllAttributes(): void;
  36177. /**
  36178. * 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
  36179. */
  36180. releaseEffects(): void;
  36181. /**
  36182. * Dispose and release all associated resources
  36183. */
  36184. dispose(): void;
  36185. /**
  36186. * Attach a new callback raised when context lost event is fired
  36187. * @param callback defines the callback to call
  36188. */
  36189. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36190. /**
  36191. * Attach a new callback raised when context restored event is fired
  36192. * @param callback defines the callback to call
  36193. */
  36194. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36195. /**
  36196. * Get the current error code of the webGL context
  36197. * @returns the error code
  36198. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36199. */
  36200. getError(): number;
  36201. private _canRenderToFloatFramebuffer;
  36202. private _canRenderToHalfFloatFramebuffer;
  36203. private _canRenderToFramebuffer;
  36204. /** @hidden */
  36205. _getWebGLTextureType(type: number): number;
  36206. /** @hidden */
  36207. _getInternalFormat(format: number): number;
  36208. /** @hidden */
  36209. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36210. /** @hidden */
  36211. _getRGBAMultiSampleBufferFormat(type: number): number;
  36212. /** @hidden */
  36213. _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;
  36214. /**
  36215. * Loads a file from a url
  36216. * @param url url to load
  36217. * @param onSuccess callback called when the file successfully loads
  36218. * @param onProgress callback called while file is loading (if the server supports this mode)
  36219. * @param offlineProvider defines the offline provider for caching
  36220. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36221. * @param onError callback called when the file fails to load
  36222. * @returns a file request object
  36223. * @hidden
  36224. */
  36225. 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;
  36226. /**
  36227. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36228. * @param x defines the x coordinate of the rectangle where pixels must be read
  36229. * @param y defines the y coordinate of the rectangle where pixels must be read
  36230. * @param width defines the width of the rectangle where pixels must be read
  36231. * @param height defines the height of the rectangle where pixels must be read
  36232. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36233. * @returns a Uint8Array containing RGBA colors
  36234. */
  36235. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36236. private static _isSupported;
  36237. /**
  36238. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36239. * @returns true if the engine can be created
  36240. * @ignorenaming
  36241. */
  36242. static isSupported(): boolean;
  36243. /**
  36244. * Find the next highest power of two.
  36245. * @param x Number to start search from.
  36246. * @return Next highest power of two.
  36247. */
  36248. static CeilingPOT(x: number): number;
  36249. /**
  36250. * Find the next lowest power of two.
  36251. * @param x Number to start search from.
  36252. * @return Next lowest power of two.
  36253. */
  36254. static FloorPOT(x: number): number;
  36255. /**
  36256. * Find the nearest power of two.
  36257. * @param x Number to start search from.
  36258. * @return Next nearest power of two.
  36259. */
  36260. static NearestPOT(x: number): number;
  36261. /**
  36262. * Get the closest exponent of two
  36263. * @param value defines the value to approximate
  36264. * @param max defines the maximum value to return
  36265. * @param mode defines how to define the closest value
  36266. * @returns closest exponent of two of the given value
  36267. */
  36268. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36269. /**
  36270. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36271. * @param func - the function to be called
  36272. * @param requester - the object that will request the next frame. Falls back to window.
  36273. * @returns frame number
  36274. */
  36275. static QueueNewFrame(func: () => void, requester?: any): number;
  36276. /**
  36277. * Gets host document
  36278. * @returns the host document object
  36279. */
  36280. getHostDocument(): Nullable<Document>;
  36281. }
  36282. }
  36283. declare module BABYLON {
  36284. /**
  36285. * Class representing spherical harmonics coefficients to the 3rd degree
  36286. */
  36287. export class SphericalHarmonics {
  36288. /**
  36289. * Defines whether or not the harmonics have been prescaled for rendering.
  36290. */
  36291. preScaled: boolean;
  36292. /**
  36293. * The l0,0 coefficients of the spherical harmonics
  36294. */
  36295. l00: Vector3;
  36296. /**
  36297. * The l1,-1 coefficients of the spherical harmonics
  36298. */
  36299. l1_1: Vector3;
  36300. /**
  36301. * The l1,0 coefficients of the spherical harmonics
  36302. */
  36303. l10: Vector3;
  36304. /**
  36305. * The l1,1 coefficients of the spherical harmonics
  36306. */
  36307. l11: Vector3;
  36308. /**
  36309. * The l2,-2 coefficients of the spherical harmonics
  36310. */
  36311. l2_2: Vector3;
  36312. /**
  36313. * The l2,-1 coefficients of the spherical harmonics
  36314. */
  36315. l2_1: Vector3;
  36316. /**
  36317. * The l2,0 coefficients of the spherical harmonics
  36318. */
  36319. l20: Vector3;
  36320. /**
  36321. * The l2,1 coefficients of the spherical harmonics
  36322. */
  36323. l21: Vector3;
  36324. /**
  36325. * The l2,2 coefficients of the spherical harmonics
  36326. */
  36327. l22: Vector3;
  36328. /**
  36329. * Adds a light to the spherical harmonics
  36330. * @param direction the direction of the light
  36331. * @param color the color of the light
  36332. * @param deltaSolidAngle the delta solid angle of the light
  36333. */
  36334. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36335. /**
  36336. * Scales the spherical harmonics by the given amount
  36337. * @param scale the amount to scale
  36338. */
  36339. scaleInPlace(scale: number): void;
  36340. /**
  36341. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36342. *
  36343. * ```
  36344. * E_lm = A_l * L_lm
  36345. * ```
  36346. *
  36347. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36348. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36349. * the scaling factors are given in equation 9.
  36350. */
  36351. convertIncidentRadianceToIrradiance(): void;
  36352. /**
  36353. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36354. *
  36355. * ```
  36356. * L = (1/pi) * E * rho
  36357. * ```
  36358. *
  36359. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36360. */
  36361. convertIrradianceToLambertianRadiance(): void;
  36362. /**
  36363. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36364. * required operations at run time.
  36365. *
  36366. * This is simply done by scaling back the SH with Ylm constants parameter.
  36367. * The trigonometric part being applied by the shader at run time.
  36368. */
  36369. preScaleForRendering(): void;
  36370. /**
  36371. * Constructs a spherical harmonics from an array.
  36372. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36373. * @returns the spherical harmonics
  36374. */
  36375. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36376. /**
  36377. * Gets the spherical harmonics from polynomial
  36378. * @param polynomial the spherical polynomial
  36379. * @returns the spherical harmonics
  36380. */
  36381. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36382. }
  36383. /**
  36384. * Class representing spherical polynomial coefficients to the 3rd degree
  36385. */
  36386. export class SphericalPolynomial {
  36387. private _harmonics;
  36388. /**
  36389. * The spherical harmonics used to create the polynomials.
  36390. */
  36391. get preScaledHarmonics(): SphericalHarmonics;
  36392. /**
  36393. * The x coefficients of the spherical polynomial
  36394. */
  36395. x: Vector3;
  36396. /**
  36397. * The y coefficients of the spherical polynomial
  36398. */
  36399. y: Vector3;
  36400. /**
  36401. * The z coefficients of the spherical polynomial
  36402. */
  36403. z: Vector3;
  36404. /**
  36405. * The xx coefficients of the spherical polynomial
  36406. */
  36407. xx: Vector3;
  36408. /**
  36409. * The yy coefficients of the spherical polynomial
  36410. */
  36411. yy: Vector3;
  36412. /**
  36413. * The zz coefficients of the spherical polynomial
  36414. */
  36415. zz: Vector3;
  36416. /**
  36417. * The xy coefficients of the spherical polynomial
  36418. */
  36419. xy: Vector3;
  36420. /**
  36421. * The yz coefficients of the spherical polynomial
  36422. */
  36423. yz: Vector3;
  36424. /**
  36425. * The zx coefficients of the spherical polynomial
  36426. */
  36427. zx: Vector3;
  36428. /**
  36429. * Adds an ambient color to the spherical polynomial
  36430. * @param color the color to add
  36431. */
  36432. addAmbient(color: Color3): void;
  36433. /**
  36434. * Scales the spherical polynomial by the given amount
  36435. * @param scale the amount to scale
  36436. */
  36437. scaleInPlace(scale: number): void;
  36438. /**
  36439. * Gets the spherical polynomial from harmonics
  36440. * @param harmonics the spherical harmonics
  36441. * @returns the spherical polynomial
  36442. */
  36443. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36444. /**
  36445. * Constructs a spherical polynomial from an array.
  36446. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36447. * @returns the spherical polynomial
  36448. */
  36449. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36450. }
  36451. }
  36452. declare module BABYLON {
  36453. /**
  36454. * Defines the source of the internal texture
  36455. */
  36456. export enum InternalTextureSource {
  36457. /**
  36458. * The source of the texture data is unknown
  36459. */
  36460. Unknown = 0,
  36461. /**
  36462. * Texture data comes from an URL
  36463. */
  36464. Url = 1,
  36465. /**
  36466. * Texture data is only used for temporary storage
  36467. */
  36468. Temp = 2,
  36469. /**
  36470. * Texture data comes from raw data (ArrayBuffer)
  36471. */
  36472. Raw = 3,
  36473. /**
  36474. * Texture content is dynamic (video or dynamic texture)
  36475. */
  36476. Dynamic = 4,
  36477. /**
  36478. * Texture content is generated by rendering to it
  36479. */
  36480. RenderTarget = 5,
  36481. /**
  36482. * Texture content is part of a multi render target process
  36483. */
  36484. MultiRenderTarget = 6,
  36485. /**
  36486. * Texture data comes from a cube data file
  36487. */
  36488. Cube = 7,
  36489. /**
  36490. * Texture data comes from a raw cube data
  36491. */
  36492. CubeRaw = 8,
  36493. /**
  36494. * Texture data come from a prefiltered cube data file
  36495. */
  36496. CubePrefiltered = 9,
  36497. /**
  36498. * Texture content is raw 3D data
  36499. */
  36500. Raw3D = 10,
  36501. /**
  36502. * Texture content is raw 2D array data
  36503. */
  36504. Raw2DArray = 11,
  36505. /**
  36506. * Texture content is a depth texture
  36507. */
  36508. Depth = 12,
  36509. /**
  36510. * Texture data comes from a raw cube data encoded with RGBD
  36511. */
  36512. CubeRawRGBD = 13
  36513. }
  36514. /**
  36515. * Class used to store data associated with WebGL texture data for the engine
  36516. * This class should not be used directly
  36517. */
  36518. export class InternalTexture {
  36519. /** @hidden */
  36520. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36521. /**
  36522. * Defines if the texture is ready
  36523. */
  36524. isReady: boolean;
  36525. /**
  36526. * Defines if the texture is a cube texture
  36527. */
  36528. isCube: boolean;
  36529. /**
  36530. * Defines if the texture contains 3D data
  36531. */
  36532. is3D: boolean;
  36533. /**
  36534. * Defines if the texture contains 2D array data
  36535. */
  36536. is2DArray: boolean;
  36537. /**
  36538. * Defines if the texture contains multiview data
  36539. */
  36540. isMultiview: boolean;
  36541. /**
  36542. * Gets the URL used to load this texture
  36543. */
  36544. url: string;
  36545. /**
  36546. * Gets the sampling mode of the texture
  36547. */
  36548. samplingMode: number;
  36549. /**
  36550. * Gets a boolean indicating if the texture needs mipmaps generation
  36551. */
  36552. generateMipMaps: boolean;
  36553. /**
  36554. * Gets the number of samples used by the texture (WebGL2+ only)
  36555. */
  36556. samples: number;
  36557. /**
  36558. * Gets the type of the texture (int, float...)
  36559. */
  36560. type: number;
  36561. /**
  36562. * Gets the format of the texture (RGB, RGBA...)
  36563. */
  36564. format: number;
  36565. /**
  36566. * Observable called when the texture is loaded
  36567. */
  36568. onLoadedObservable: Observable<InternalTexture>;
  36569. /**
  36570. * Gets the width of the texture
  36571. */
  36572. width: number;
  36573. /**
  36574. * Gets the height of the texture
  36575. */
  36576. height: number;
  36577. /**
  36578. * Gets the depth of the texture
  36579. */
  36580. depth: number;
  36581. /**
  36582. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36583. */
  36584. baseWidth: number;
  36585. /**
  36586. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36587. */
  36588. baseHeight: number;
  36589. /**
  36590. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36591. */
  36592. baseDepth: number;
  36593. /**
  36594. * Gets a boolean indicating if the texture is inverted on Y axis
  36595. */
  36596. invertY: boolean;
  36597. /** @hidden */
  36598. _invertVScale: boolean;
  36599. /** @hidden */
  36600. _associatedChannel: number;
  36601. /** @hidden */
  36602. _source: InternalTextureSource;
  36603. /** @hidden */
  36604. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36605. /** @hidden */
  36606. _bufferView: Nullable<ArrayBufferView>;
  36607. /** @hidden */
  36608. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36609. /** @hidden */
  36610. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36611. /** @hidden */
  36612. _size: number;
  36613. /** @hidden */
  36614. _extension: string;
  36615. /** @hidden */
  36616. _files: Nullable<string[]>;
  36617. /** @hidden */
  36618. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36619. /** @hidden */
  36620. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36621. /** @hidden */
  36622. _framebuffer: Nullable<WebGLFramebuffer>;
  36623. /** @hidden */
  36624. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36625. /** @hidden */
  36626. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36627. /** @hidden */
  36628. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36629. /** @hidden */
  36630. _attachments: Nullable<number[]>;
  36631. /** @hidden */
  36632. _textureArray: Nullable<InternalTexture[]>;
  36633. /** @hidden */
  36634. _cachedCoordinatesMode: Nullable<number>;
  36635. /** @hidden */
  36636. _cachedWrapU: Nullable<number>;
  36637. /** @hidden */
  36638. _cachedWrapV: Nullable<number>;
  36639. /** @hidden */
  36640. _cachedWrapR: Nullable<number>;
  36641. /** @hidden */
  36642. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36643. /** @hidden */
  36644. _isDisabled: boolean;
  36645. /** @hidden */
  36646. _compression: Nullable<string>;
  36647. /** @hidden */
  36648. _generateStencilBuffer: boolean;
  36649. /** @hidden */
  36650. _generateDepthBuffer: boolean;
  36651. /** @hidden */
  36652. _comparisonFunction: number;
  36653. /** @hidden */
  36654. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36655. /** @hidden */
  36656. _lodGenerationScale: number;
  36657. /** @hidden */
  36658. _lodGenerationOffset: number;
  36659. /** @hidden */
  36660. _depthStencilTexture: Nullable<InternalTexture>;
  36661. /** @hidden */
  36662. _colorTextureArray: Nullable<WebGLTexture>;
  36663. /** @hidden */
  36664. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36665. /** @hidden */
  36666. _lodTextureHigh: Nullable<BaseTexture>;
  36667. /** @hidden */
  36668. _lodTextureMid: Nullable<BaseTexture>;
  36669. /** @hidden */
  36670. _lodTextureLow: Nullable<BaseTexture>;
  36671. /** @hidden */
  36672. _isRGBD: boolean;
  36673. /** @hidden */
  36674. _linearSpecularLOD: boolean;
  36675. /** @hidden */
  36676. _irradianceTexture: Nullable<BaseTexture>;
  36677. /** @hidden */
  36678. _webGLTexture: Nullable<WebGLTexture>;
  36679. /** @hidden */
  36680. _references: number;
  36681. private _engine;
  36682. /**
  36683. * Gets the Engine the texture belongs to.
  36684. * @returns The babylon engine
  36685. */
  36686. getEngine(): ThinEngine;
  36687. /**
  36688. * Gets the data source type of the texture
  36689. */
  36690. get source(): InternalTextureSource;
  36691. /**
  36692. * Creates a new InternalTexture
  36693. * @param engine defines the engine to use
  36694. * @param source defines the type of data that will be used
  36695. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36696. */
  36697. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36698. /**
  36699. * Increments the number of references (ie. the number of Texture that point to it)
  36700. */
  36701. incrementReferences(): void;
  36702. /**
  36703. * Change the size of the texture (not the size of the content)
  36704. * @param width defines the new width
  36705. * @param height defines the new height
  36706. * @param depth defines the new depth (1 by default)
  36707. */
  36708. updateSize(width: int, height: int, depth?: int): void;
  36709. /** @hidden */
  36710. _rebuild(): void;
  36711. /** @hidden */
  36712. _swapAndDie(target: InternalTexture): void;
  36713. /**
  36714. * Dispose the current allocated resources
  36715. */
  36716. dispose(): void;
  36717. }
  36718. }
  36719. declare module BABYLON {
  36720. /**
  36721. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36723. */
  36724. export class Analyser {
  36725. /**
  36726. * Gets or sets the smoothing
  36727. * @ignorenaming
  36728. */
  36729. SMOOTHING: number;
  36730. /**
  36731. * Gets or sets the FFT table size
  36732. * @ignorenaming
  36733. */
  36734. FFT_SIZE: number;
  36735. /**
  36736. * Gets or sets the bar graph amplitude
  36737. * @ignorenaming
  36738. */
  36739. BARGRAPHAMPLITUDE: number;
  36740. /**
  36741. * Gets or sets the position of the debug canvas
  36742. * @ignorenaming
  36743. */
  36744. DEBUGCANVASPOS: {
  36745. x: number;
  36746. y: number;
  36747. };
  36748. /**
  36749. * Gets or sets the debug canvas size
  36750. * @ignorenaming
  36751. */
  36752. DEBUGCANVASSIZE: {
  36753. width: number;
  36754. height: number;
  36755. };
  36756. private _byteFreqs;
  36757. private _byteTime;
  36758. private _floatFreqs;
  36759. private _webAudioAnalyser;
  36760. private _debugCanvas;
  36761. private _debugCanvasContext;
  36762. private _scene;
  36763. private _registerFunc;
  36764. private _audioEngine;
  36765. /**
  36766. * Creates a new analyser
  36767. * @param scene defines hosting scene
  36768. */
  36769. constructor(scene: Scene);
  36770. /**
  36771. * Get the number of data values you will have to play with for the visualization
  36772. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36773. * @returns a number
  36774. */
  36775. getFrequencyBinCount(): number;
  36776. /**
  36777. * Gets the current frequency data as a byte array
  36778. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36779. * @returns a Uint8Array
  36780. */
  36781. getByteFrequencyData(): Uint8Array;
  36782. /**
  36783. * Gets the current waveform as a byte array
  36784. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36785. * @returns a Uint8Array
  36786. */
  36787. getByteTimeDomainData(): Uint8Array;
  36788. /**
  36789. * Gets the current frequency data as a float array
  36790. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36791. * @returns a Float32Array
  36792. */
  36793. getFloatFrequencyData(): Float32Array;
  36794. /**
  36795. * Renders the debug canvas
  36796. */
  36797. drawDebugCanvas(): void;
  36798. /**
  36799. * Stops rendering the debug canvas and removes it
  36800. */
  36801. stopDebugCanvas(): void;
  36802. /**
  36803. * Connects two audio nodes
  36804. * @param inputAudioNode defines first node to connect
  36805. * @param outputAudioNode defines second node to connect
  36806. */
  36807. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36808. /**
  36809. * Releases all associated resources
  36810. */
  36811. dispose(): void;
  36812. }
  36813. }
  36814. declare module BABYLON {
  36815. /**
  36816. * This represents an audio engine and it is responsible
  36817. * to play, synchronize and analyse sounds throughout the application.
  36818. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36819. */
  36820. export interface IAudioEngine extends IDisposable {
  36821. /**
  36822. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36823. */
  36824. readonly canUseWebAudio: boolean;
  36825. /**
  36826. * Gets the current AudioContext if available.
  36827. */
  36828. readonly audioContext: Nullable<AudioContext>;
  36829. /**
  36830. * The master gain node defines the global audio volume of your audio engine.
  36831. */
  36832. readonly masterGain: GainNode;
  36833. /**
  36834. * Gets whether or not mp3 are supported by your browser.
  36835. */
  36836. readonly isMP3supported: boolean;
  36837. /**
  36838. * Gets whether or not ogg are supported by your browser.
  36839. */
  36840. readonly isOGGsupported: boolean;
  36841. /**
  36842. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36843. * @ignoreNaming
  36844. */
  36845. WarnedWebAudioUnsupported: boolean;
  36846. /**
  36847. * Defines if the audio engine relies on a custom unlocked button.
  36848. * In this case, the embedded button will not be displayed.
  36849. */
  36850. useCustomUnlockedButton: boolean;
  36851. /**
  36852. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36853. */
  36854. readonly unlocked: boolean;
  36855. /**
  36856. * Event raised when audio has been unlocked on the browser.
  36857. */
  36858. onAudioUnlockedObservable: Observable<AudioEngine>;
  36859. /**
  36860. * Event raised when audio has been locked on the browser.
  36861. */
  36862. onAudioLockedObservable: Observable<AudioEngine>;
  36863. /**
  36864. * Flags the audio engine in Locked state.
  36865. * This happens due to new browser policies preventing audio to autoplay.
  36866. */
  36867. lock(): void;
  36868. /**
  36869. * Unlocks the audio engine once a user action has been done on the dom.
  36870. * This is helpful to resume play once browser policies have been satisfied.
  36871. */
  36872. unlock(): void;
  36873. /**
  36874. * Gets the global volume sets on the master gain.
  36875. * @returns the global volume if set or -1 otherwise
  36876. */
  36877. getGlobalVolume(): number;
  36878. /**
  36879. * Sets the global volume of your experience (sets on the master gain).
  36880. * @param newVolume Defines the new global volume of the application
  36881. */
  36882. setGlobalVolume(newVolume: number): void;
  36883. /**
  36884. * Connect the audio engine to an audio analyser allowing some amazing
  36885. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36886. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36887. * @param analyser The analyser to connect to the engine
  36888. */
  36889. connectToAnalyser(analyser: Analyser): void;
  36890. }
  36891. /**
  36892. * This represents the default audio engine used in babylon.
  36893. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36894. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36895. */
  36896. export class AudioEngine implements IAudioEngine {
  36897. private _audioContext;
  36898. private _audioContextInitialized;
  36899. private _muteButton;
  36900. private _hostElement;
  36901. /**
  36902. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36903. */
  36904. canUseWebAudio: boolean;
  36905. /**
  36906. * The master gain node defines the global audio volume of your audio engine.
  36907. */
  36908. masterGain: GainNode;
  36909. /**
  36910. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36911. * @ignoreNaming
  36912. */
  36913. WarnedWebAudioUnsupported: boolean;
  36914. /**
  36915. * Gets whether or not mp3 are supported by your browser.
  36916. */
  36917. isMP3supported: boolean;
  36918. /**
  36919. * Gets whether or not ogg are supported by your browser.
  36920. */
  36921. isOGGsupported: boolean;
  36922. /**
  36923. * Gets whether audio has been unlocked on the device.
  36924. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36925. * a user interaction has happened.
  36926. */
  36927. unlocked: boolean;
  36928. /**
  36929. * Defines if the audio engine relies on a custom unlocked button.
  36930. * In this case, the embedded button will not be displayed.
  36931. */
  36932. useCustomUnlockedButton: boolean;
  36933. /**
  36934. * Event raised when audio has been unlocked on the browser.
  36935. */
  36936. onAudioUnlockedObservable: Observable<AudioEngine>;
  36937. /**
  36938. * Event raised when audio has been locked on the browser.
  36939. */
  36940. onAudioLockedObservable: Observable<AudioEngine>;
  36941. /**
  36942. * Gets the current AudioContext if available.
  36943. */
  36944. get audioContext(): Nullable<AudioContext>;
  36945. private _connectedAnalyser;
  36946. /**
  36947. * Instantiates a new audio engine.
  36948. *
  36949. * There should be only one per page as some browsers restrict the number
  36950. * of audio contexts you can create.
  36951. * @param hostElement defines the host element where to display the mute icon if necessary
  36952. */
  36953. constructor(hostElement?: Nullable<HTMLElement>);
  36954. /**
  36955. * Flags the audio engine in Locked state.
  36956. * This happens due to new browser policies preventing audio to autoplay.
  36957. */
  36958. lock(): void;
  36959. /**
  36960. * Unlocks the audio engine once a user action has been done on the dom.
  36961. * This is helpful to resume play once browser policies have been satisfied.
  36962. */
  36963. unlock(): void;
  36964. private _resumeAudioContext;
  36965. private _initializeAudioContext;
  36966. private _tryToRun;
  36967. private _triggerRunningState;
  36968. private _triggerSuspendedState;
  36969. private _displayMuteButton;
  36970. private _moveButtonToTopLeft;
  36971. private _onResize;
  36972. private _hideMuteButton;
  36973. /**
  36974. * Destroy and release the resources associated with the audio ccontext.
  36975. */
  36976. dispose(): void;
  36977. /**
  36978. * Gets the global volume sets on the master gain.
  36979. * @returns the global volume if set or -1 otherwise
  36980. */
  36981. getGlobalVolume(): number;
  36982. /**
  36983. * Sets the global volume of your experience (sets on the master gain).
  36984. * @param newVolume Defines the new global volume of the application
  36985. */
  36986. setGlobalVolume(newVolume: number): void;
  36987. /**
  36988. * Connect the audio engine to an audio analyser allowing some amazing
  36989. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36990. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36991. * @param analyser The analyser to connect to the engine
  36992. */
  36993. connectToAnalyser(analyser: Analyser): void;
  36994. }
  36995. }
  36996. declare module BABYLON {
  36997. /**
  36998. * Interface used to present a loading screen while loading a scene
  36999. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37000. */
  37001. export interface ILoadingScreen {
  37002. /**
  37003. * Function called to display the loading screen
  37004. */
  37005. displayLoadingUI: () => void;
  37006. /**
  37007. * Function called to hide the loading screen
  37008. */
  37009. hideLoadingUI: () => void;
  37010. /**
  37011. * Gets or sets the color to use for the background
  37012. */
  37013. loadingUIBackgroundColor: string;
  37014. /**
  37015. * Gets or sets the text to display while loading
  37016. */
  37017. loadingUIText: string;
  37018. }
  37019. /**
  37020. * Class used for the default loading screen
  37021. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37022. */
  37023. export class DefaultLoadingScreen implements ILoadingScreen {
  37024. private _renderingCanvas;
  37025. private _loadingText;
  37026. private _loadingDivBackgroundColor;
  37027. private _loadingDiv;
  37028. private _loadingTextDiv;
  37029. /** Gets or sets the logo url to use for the default loading screen */
  37030. static DefaultLogoUrl: string;
  37031. /** Gets or sets the spinner url to use for the default loading screen */
  37032. static DefaultSpinnerUrl: string;
  37033. /**
  37034. * Creates a new default loading screen
  37035. * @param _renderingCanvas defines the canvas used to render the scene
  37036. * @param _loadingText defines the default text to display
  37037. * @param _loadingDivBackgroundColor defines the default background color
  37038. */
  37039. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37040. /**
  37041. * Function called to display the loading screen
  37042. */
  37043. displayLoadingUI(): void;
  37044. /**
  37045. * Function called to hide the loading screen
  37046. */
  37047. hideLoadingUI(): void;
  37048. /**
  37049. * Gets or sets the text to display while loading
  37050. */
  37051. set loadingUIText(text: string);
  37052. get loadingUIText(): string;
  37053. /**
  37054. * Gets or sets the color to use for the background
  37055. */
  37056. get loadingUIBackgroundColor(): string;
  37057. set loadingUIBackgroundColor(color: string);
  37058. private _resizeLoadingUI;
  37059. }
  37060. }
  37061. declare module BABYLON {
  37062. /**
  37063. * Interface for any object that can request an animation frame
  37064. */
  37065. export interface ICustomAnimationFrameRequester {
  37066. /**
  37067. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37068. */
  37069. renderFunction?: Function;
  37070. /**
  37071. * Called to request the next frame to render to
  37072. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37073. */
  37074. requestAnimationFrame: Function;
  37075. /**
  37076. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37077. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37078. */
  37079. requestID?: number;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. /**
  37084. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37085. */
  37086. export class PerformanceMonitor {
  37087. private _enabled;
  37088. private _rollingFrameTime;
  37089. private _lastFrameTimeMs;
  37090. /**
  37091. * constructor
  37092. * @param frameSampleSize The number of samples required to saturate the sliding window
  37093. */
  37094. constructor(frameSampleSize?: number);
  37095. /**
  37096. * Samples current frame
  37097. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37098. */
  37099. sampleFrame(timeMs?: number): void;
  37100. /**
  37101. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37102. */
  37103. get averageFrameTime(): number;
  37104. /**
  37105. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37106. */
  37107. get averageFrameTimeVariance(): number;
  37108. /**
  37109. * Returns the frame time of the most recent frame
  37110. */
  37111. get instantaneousFrameTime(): number;
  37112. /**
  37113. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37114. */
  37115. get averageFPS(): number;
  37116. /**
  37117. * Returns the average framerate in frames per second using the most recent frame time
  37118. */
  37119. get instantaneousFPS(): number;
  37120. /**
  37121. * Returns true if enough samples have been taken to completely fill the sliding window
  37122. */
  37123. get isSaturated(): boolean;
  37124. /**
  37125. * Enables contributions to the sliding window sample set
  37126. */
  37127. enable(): void;
  37128. /**
  37129. * Disables contributions to the sliding window sample set
  37130. * Samples will not be interpolated over the disabled period
  37131. */
  37132. disable(): void;
  37133. /**
  37134. * Returns true if sampling is enabled
  37135. */
  37136. get isEnabled(): boolean;
  37137. /**
  37138. * Resets performance monitor
  37139. */
  37140. reset(): void;
  37141. }
  37142. /**
  37143. * RollingAverage
  37144. *
  37145. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37146. */
  37147. export class RollingAverage {
  37148. /**
  37149. * Current average
  37150. */
  37151. average: number;
  37152. /**
  37153. * Current variance
  37154. */
  37155. variance: number;
  37156. protected _samples: Array<number>;
  37157. protected _sampleCount: number;
  37158. protected _pos: number;
  37159. protected _m2: number;
  37160. /**
  37161. * constructor
  37162. * @param length The number of samples required to saturate the sliding window
  37163. */
  37164. constructor(length: number);
  37165. /**
  37166. * Adds a sample to the sample set
  37167. * @param v The sample value
  37168. */
  37169. add(v: number): void;
  37170. /**
  37171. * Returns previously added values or null if outside of history or outside the sliding window domain
  37172. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37173. * @return Value previously recorded with add() or null if outside of range
  37174. */
  37175. history(i: number): number;
  37176. /**
  37177. * Returns true if enough samples have been taken to completely fill the sliding window
  37178. * @return true if sample-set saturated
  37179. */
  37180. isSaturated(): boolean;
  37181. /**
  37182. * Resets the rolling average (equivalent to 0 samples taken so far)
  37183. */
  37184. reset(): void;
  37185. /**
  37186. * Wraps a value around the sample range boundaries
  37187. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37188. * @return Wrapped position in sample range
  37189. */
  37190. protected _wrapPosition(i: number): number;
  37191. }
  37192. }
  37193. declare module BABYLON {
  37194. /**
  37195. * This class is used to track a performance counter which is number based.
  37196. * The user has access to many properties which give statistics of different nature.
  37197. *
  37198. * The implementer can track two kinds of Performance Counter: time and count.
  37199. * 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.
  37200. * 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.
  37201. */
  37202. export class PerfCounter {
  37203. /**
  37204. * Gets or sets a global boolean to turn on and off all the counters
  37205. */
  37206. static Enabled: boolean;
  37207. /**
  37208. * Returns the smallest value ever
  37209. */
  37210. get min(): number;
  37211. /**
  37212. * Returns the biggest value ever
  37213. */
  37214. get max(): number;
  37215. /**
  37216. * Returns the average value since the performance counter is running
  37217. */
  37218. get average(): number;
  37219. /**
  37220. * Returns the average value of the last second the counter was monitored
  37221. */
  37222. get lastSecAverage(): number;
  37223. /**
  37224. * Returns the current value
  37225. */
  37226. get current(): number;
  37227. /**
  37228. * Gets the accumulated total
  37229. */
  37230. get total(): number;
  37231. /**
  37232. * Gets the total value count
  37233. */
  37234. get count(): number;
  37235. /**
  37236. * Creates a new counter
  37237. */
  37238. constructor();
  37239. /**
  37240. * Call this method to start monitoring a new frame.
  37241. * 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.
  37242. */
  37243. fetchNewFrame(): void;
  37244. /**
  37245. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37246. * @param newCount the count value to add to the monitored count
  37247. * @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.
  37248. */
  37249. addCount(newCount: number, fetchResult: boolean): void;
  37250. /**
  37251. * Start monitoring this performance counter
  37252. */
  37253. beginMonitoring(): void;
  37254. /**
  37255. * Compute the time lapsed since the previous beginMonitoring() call.
  37256. * @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
  37257. */
  37258. endMonitoring(newFrame?: boolean): void;
  37259. private _fetchResult;
  37260. private _startMonitoringTime;
  37261. private _min;
  37262. private _max;
  37263. private _average;
  37264. private _current;
  37265. private _totalValueCount;
  37266. private _totalAccumulated;
  37267. private _lastSecAverage;
  37268. private _lastSecAccumulated;
  37269. private _lastSecTime;
  37270. private _lastSecValueCount;
  37271. }
  37272. }
  37273. declare module BABYLON {
  37274. interface ThinEngine {
  37275. /** @hidden */
  37276. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37277. }
  37278. }
  37279. declare module BABYLON {
  37280. /**
  37281. * Defines the interface used by display changed events
  37282. */
  37283. export interface IDisplayChangedEventArgs {
  37284. /** Gets the vrDisplay object (if any) */
  37285. vrDisplay: Nullable<any>;
  37286. /** Gets a boolean indicating if webVR is supported */
  37287. vrSupported: boolean;
  37288. }
  37289. /**
  37290. * Defines the interface used by objects containing a viewport (like a camera)
  37291. */
  37292. interface IViewportOwnerLike {
  37293. /**
  37294. * Gets or sets the viewport
  37295. */
  37296. viewport: IViewportLike;
  37297. }
  37298. /**
  37299. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37300. */
  37301. export class Engine extends ThinEngine {
  37302. /** Defines that alpha blending is disabled */
  37303. static readonly ALPHA_DISABLE: number;
  37304. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37305. static readonly ALPHA_ADD: number;
  37306. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37307. static readonly ALPHA_COMBINE: number;
  37308. /** Defines that alpha blending to DEST - SRC * DEST */
  37309. static readonly ALPHA_SUBTRACT: number;
  37310. /** Defines that alpha blending to SRC * DEST */
  37311. static readonly ALPHA_MULTIPLY: number;
  37312. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37313. static readonly ALPHA_MAXIMIZED: number;
  37314. /** Defines that alpha blending to SRC + DEST */
  37315. static readonly ALPHA_ONEONE: number;
  37316. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37317. static readonly ALPHA_PREMULTIPLIED: number;
  37318. /**
  37319. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37320. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37321. */
  37322. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37323. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37324. static readonly ALPHA_INTERPOLATE: number;
  37325. /**
  37326. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37327. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37328. */
  37329. static readonly ALPHA_SCREENMODE: number;
  37330. /** Defines that the ressource is not delayed*/
  37331. static readonly DELAYLOADSTATE_NONE: number;
  37332. /** Defines that the ressource was successfully delay loaded */
  37333. static readonly DELAYLOADSTATE_LOADED: number;
  37334. /** Defines that the ressource is currently delay loading */
  37335. static readonly DELAYLOADSTATE_LOADING: number;
  37336. /** Defines that the ressource is delayed and has not started loading */
  37337. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37339. static readonly NEVER: number;
  37340. /** 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 */
  37341. static readonly ALWAYS: number;
  37342. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37343. static readonly LESS: number;
  37344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37345. static readonly EQUAL: number;
  37346. /** 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 */
  37347. static readonly LEQUAL: number;
  37348. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37349. static readonly GREATER: number;
  37350. /** 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 */
  37351. static readonly GEQUAL: number;
  37352. /** 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 */
  37353. static readonly NOTEQUAL: number;
  37354. /** Passed to stencilOperation to specify that stencil value must be kept */
  37355. static readonly KEEP: number;
  37356. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37357. static readonly REPLACE: number;
  37358. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37359. static readonly INCR: number;
  37360. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37361. static readonly DECR: number;
  37362. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37363. static readonly INVERT: number;
  37364. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37365. static readonly INCR_WRAP: number;
  37366. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37367. static readonly DECR_WRAP: number;
  37368. /** Texture is not repeating outside of 0..1 UVs */
  37369. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37370. /** Texture is repeating outside of 0..1 UVs */
  37371. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37372. /** Texture is repeating and mirrored */
  37373. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37374. /** ALPHA */
  37375. static readonly TEXTUREFORMAT_ALPHA: number;
  37376. /** LUMINANCE */
  37377. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37378. /** LUMINANCE_ALPHA */
  37379. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37380. /** RGB */
  37381. static readonly TEXTUREFORMAT_RGB: number;
  37382. /** RGBA */
  37383. static readonly TEXTUREFORMAT_RGBA: number;
  37384. /** RED */
  37385. static readonly TEXTUREFORMAT_RED: number;
  37386. /** RED (2nd reference) */
  37387. static readonly TEXTUREFORMAT_R: number;
  37388. /** RG */
  37389. static readonly TEXTUREFORMAT_RG: number;
  37390. /** RED_INTEGER */
  37391. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37392. /** RED_INTEGER (2nd reference) */
  37393. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37394. /** RG_INTEGER */
  37395. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37396. /** RGB_INTEGER */
  37397. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37398. /** RGBA_INTEGER */
  37399. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37400. /** UNSIGNED_BYTE */
  37401. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37402. /** UNSIGNED_BYTE (2nd reference) */
  37403. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37404. /** FLOAT */
  37405. static readonly TEXTURETYPE_FLOAT: number;
  37406. /** HALF_FLOAT */
  37407. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37408. /** BYTE */
  37409. static readonly TEXTURETYPE_BYTE: number;
  37410. /** SHORT */
  37411. static readonly TEXTURETYPE_SHORT: number;
  37412. /** UNSIGNED_SHORT */
  37413. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37414. /** INT */
  37415. static readonly TEXTURETYPE_INT: number;
  37416. /** UNSIGNED_INT */
  37417. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37418. /** UNSIGNED_SHORT_4_4_4_4 */
  37419. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37420. /** UNSIGNED_SHORT_5_5_5_1 */
  37421. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37422. /** UNSIGNED_SHORT_5_6_5 */
  37423. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37424. /** UNSIGNED_INT_2_10_10_10_REV */
  37425. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37426. /** UNSIGNED_INT_24_8 */
  37427. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37428. /** UNSIGNED_INT_10F_11F_11F_REV */
  37429. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37430. /** UNSIGNED_INT_5_9_9_9_REV */
  37431. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37432. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37433. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37434. /** nearest is mag = nearest and min = nearest and mip = linear */
  37435. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37436. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37437. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37438. /** Trilinear is mag = linear and min = linear and mip = linear */
  37439. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37440. /** nearest is mag = nearest and min = nearest and mip = linear */
  37441. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37442. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37443. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37444. /** Trilinear is mag = linear and min = linear and mip = linear */
  37445. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37446. /** mag = nearest and min = nearest and mip = nearest */
  37447. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37448. /** mag = nearest and min = linear and mip = nearest */
  37449. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37450. /** mag = nearest and min = linear and mip = linear */
  37451. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37452. /** mag = nearest and min = linear and mip = none */
  37453. static readonly TEXTURE_NEAREST_LINEAR: number;
  37454. /** mag = nearest and min = nearest and mip = none */
  37455. static readonly TEXTURE_NEAREST_NEAREST: number;
  37456. /** mag = linear and min = nearest and mip = nearest */
  37457. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37458. /** mag = linear and min = nearest and mip = linear */
  37459. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37460. /** mag = linear and min = linear and mip = none */
  37461. static readonly TEXTURE_LINEAR_LINEAR: number;
  37462. /** mag = linear and min = nearest and mip = none */
  37463. static readonly TEXTURE_LINEAR_NEAREST: number;
  37464. /** Explicit coordinates mode */
  37465. static readonly TEXTURE_EXPLICIT_MODE: number;
  37466. /** Spherical coordinates mode */
  37467. static readonly TEXTURE_SPHERICAL_MODE: number;
  37468. /** Planar coordinates mode */
  37469. static readonly TEXTURE_PLANAR_MODE: number;
  37470. /** Cubic coordinates mode */
  37471. static readonly TEXTURE_CUBIC_MODE: number;
  37472. /** Projection coordinates mode */
  37473. static readonly TEXTURE_PROJECTION_MODE: number;
  37474. /** Skybox coordinates mode */
  37475. static readonly TEXTURE_SKYBOX_MODE: number;
  37476. /** Inverse Cubic coordinates mode */
  37477. static readonly TEXTURE_INVCUBIC_MODE: number;
  37478. /** Equirectangular coordinates mode */
  37479. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37480. /** Equirectangular Fixed coordinates mode */
  37481. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37482. /** Equirectangular Fixed Mirrored coordinates mode */
  37483. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37484. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37485. static readonly SCALEMODE_FLOOR: number;
  37486. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37487. static readonly SCALEMODE_NEAREST: number;
  37488. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37489. static readonly SCALEMODE_CEILING: number;
  37490. /**
  37491. * Returns the current npm package of the sdk
  37492. */
  37493. static get NpmPackage(): string;
  37494. /**
  37495. * Returns the current version of the framework
  37496. */
  37497. static get Version(): string;
  37498. /** Gets the list of created engines */
  37499. static get Instances(): Engine[];
  37500. /**
  37501. * Gets the latest created engine
  37502. */
  37503. static get LastCreatedEngine(): Nullable<Engine>;
  37504. /**
  37505. * Gets the latest created scene
  37506. */
  37507. static get LastCreatedScene(): Nullable<Scene>;
  37508. /**
  37509. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37510. * @param flag defines which part of the materials must be marked as dirty
  37511. * @param predicate defines a predicate used to filter which materials should be affected
  37512. */
  37513. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37514. /**
  37515. * Method called to create the default loading screen.
  37516. * This can be overriden in your own app.
  37517. * @param canvas The rendering canvas element
  37518. * @returns The loading screen
  37519. */
  37520. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37521. /**
  37522. * Method called to create the default rescale post process on each engine.
  37523. */
  37524. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37525. /**
  37526. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37527. **/
  37528. enableOfflineSupport: boolean;
  37529. /**
  37530. * 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)
  37531. **/
  37532. disableManifestCheck: boolean;
  37533. /**
  37534. * Gets the list of created scenes
  37535. */
  37536. scenes: Scene[];
  37537. /**
  37538. * Event raised when a new scene is created
  37539. */
  37540. onNewSceneAddedObservable: Observable<Scene>;
  37541. /**
  37542. * Gets the list of created postprocesses
  37543. */
  37544. postProcesses: PostProcess[];
  37545. /**
  37546. * Gets a boolean indicating if the pointer is currently locked
  37547. */
  37548. isPointerLock: boolean;
  37549. /**
  37550. * Observable event triggered each time the rendering canvas is resized
  37551. */
  37552. onResizeObservable: Observable<Engine>;
  37553. /**
  37554. * Observable event triggered each time the canvas loses focus
  37555. */
  37556. onCanvasBlurObservable: Observable<Engine>;
  37557. /**
  37558. * Observable event triggered each time the canvas gains focus
  37559. */
  37560. onCanvasFocusObservable: Observable<Engine>;
  37561. /**
  37562. * Observable event triggered each time the canvas receives pointerout event
  37563. */
  37564. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37565. /**
  37566. * Observable raised when the engine begins a new frame
  37567. */
  37568. onBeginFrameObservable: Observable<Engine>;
  37569. /**
  37570. * If set, will be used to request the next animation frame for the render loop
  37571. */
  37572. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37573. /**
  37574. * Observable raised when the engine ends the current frame
  37575. */
  37576. onEndFrameObservable: Observable<Engine>;
  37577. /**
  37578. * Observable raised when the engine is about to compile a shader
  37579. */
  37580. onBeforeShaderCompilationObservable: Observable<Engine>;
  37581. /**
  37582. * Observable raised when the engine has jsut compiled a shader
  37583. */
  37584. onAfterShaderCompilationObservable: Observable<Engine>;
  37585. /**
  37586. * Gets the audio engine
  37587. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37588. * @ignorenaming
  37589. */
  37590. static audioEngine: IAudioEngine;
  37591. /**
  37592. * Default AudioEngine factory responsible of creating the Audio Engine.
  37593. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37594. */
  37595. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37596. /**
  37597. * Default offline support factory responsible of creating a tool used to store data locally.
  37598. * By default, this will create a Database object if the workload has been embedded.
  37599. */
  37600. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37601. private _loadingScreen;
  37602. private _pointerLockRequested;
  37603. private _rescalePostProcess;
  37604. private _deterministicLockstep;
  37605. private _lockstepMaxSteps;
  37606. private _timeStep;
  37607. protected get _supportsHardwareTextureRescaling(): boolean;
  37608. private _fps;
  37609. private _deltaTime;
  37610. /** @hidden */
  37611. _drawCalls: PerfCounter;
  37612. /** 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 */
  37613. canvasTabIndex: number;
  37614. /**
  37615. * Turn this value on if you want to pause FPS computation when in background
  37616. */
  37617. disablePerformanceMonitorInBackground: boolean;
  37618. private _performanceMonitor;
  37619. /**
  37620. * Gets the performance monitor attached to this engine
  37621. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37622. */
  37623. get performanceMonitor(): PerformanceMonitor;
  37624. private _onFocus;
  37625. private _onBlur;
  37626. private _onCanvasPointerOut;
  37627. private _onCanvasBlur;
  37628. private _onCanvasFocus;
  37629. private _onFullscreenChange;
  37630. private _onPointerLockChange;
  37631. /**
  37632. * Gets the HTML element used to attach event listeners
  37633. * @returns a HTML element
  37634. */
  37635. getInputElement(): Nullable<HTMLElement>;
  37636. /**
  37637. * Creates a new engine
  37638. * @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
  37639. * @param antialias defines enable antialiasing (default: false)
  37640. * @param options defines further options to be sent to the getContext() function
  37641. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37642. */
  37643. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37644. /**
  37645. * Gets current aspect ratio
  37646. * @param viewportOwner defines the camera to use to get the aspect ratio
  37647. * @param useScreen defines if screen size must be used (or the current render target if any)
  37648. * @returns a number defining the aspect ratio
  37649. */
  37650. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37651. /**
  37652. * Gets current screen aspect ratio
  37653. * @returns a number defining the aspect ratio
  37654. */
  37655. getScreenAspectRatio(): number;
  37656. /**
  37657. * Gets the client rect of the HTML canvas attached with the current webGL context
  37658. * @returns a client rectanglee
  37659. */
  37660. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37661. /**
  37662. * Gets the client rect of the HTML element used for events
  37663. * @returns a client rectanglee
  37664. */
  37665. getInputElementClientRect(): Nullable<ClientRect>;
  37666. /**
  37667. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37668. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37669. * @returns true if engine is in deterministic lock step mode
  37670. */
  37671. isDeterministicLockStep(): boolean;
  37672. /**
  37673. * Gets the max steps when engine is running in deterministic lock step
  37674. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37675. * @returns the max steps
  37676. */
  37677. getLockstepMaxSteps(): number;
  37678. /**
  37679. * Returns the time in ms between steps when using deterministic lock step.
  37680. * @returns time step in (ms)
  37681. */
  37682. getTimeStep(): number;
  37683. /**
  37684. * Force the mipmap generation for the given render target texture
  37685. * @param texture defines the render target texture to use
  37686. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37687. */
  37688. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37689. /** States */
  37690. /**
  37691. * Set various states to the webGL context
  37692. * @param culling defines backface culling state
  37693. * @param zOffset defines the value to apply to zOffset (0 by default)
  37694. * @param force defines if states must be applied even if cache is up to date
  37695. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37696. */
  37697. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37698. /**
  37699. * Set the z offset to apply to current rendering
  37700. * @param value defines the offset to apply
  37701. */
  37702. setZOffset(value: number): void;
  37703. /**
  37704. * Gets the current value of the zOffset
  37705. * @returns the current zOffset state
  37706. */
  37707. getZOffset(): number;
  37708. /**
  37709. * Enable or disable depth buffering
  37710. * @param enable defines the state to set
  37711. */
  37712. setDepthBuffer(enable: boolean): void;
  37713. /**
  37714. * Gets a boolean indicating if depth writing is enabled
  37715. * @returns the current depth writing state
  37716. */
  37717. getDepthWrite(): boolean;
  37718. /**
  37719. * Enable or disable depth writing
  37720. * @param enable defines the state to set
  37721. */
  37722. setDepthWrite(enable: boolean): void;
  37723. /**
  37724. * Gets a boolean indicating if stencil buffer is enabled
  37725. * @returns the current stencil buffer state
  37726. */
  37727. getStencilBuffer(): boolean;
  37728. /**
  37729. * Enable or disable the stencil buffer
  37730. * @param enable defines if the stencil buffer must be enabled or disabled
  37731. */
  37732. setStencilBuffer(enable: boolean): void;
  37733. /**
  37734. * Gets the current stencil mask
  37735. * @returns a number defining the new stencil mask to use
  37736. */
  37737. getStencilMask(): number;
  37738. /**
  37739. * Sets the current stencil mask
  37740. * @param mask defines the new stencil mask to use
  37741. */
  37742. setStencilMask(mask: number): void;
  37743. /**
  37744. * Gets the current stencil function
  37745. * @returns a number defining the stencil function to use
  37746. */
  37747. getStencilFunction(): number;
  37748. /**
  37749. * Gets the current stencil reference value
  37750. * @returns a number defining the stencil reference value to use
  37751. */
  37752. getStencilFunctionReference(): number;
  37753. /**
  37754. * Gets the current stencil mask
  37755. * @returns a number defining the stencil mask to use
  37756. */
  37757. getStencilFunctionMask(): number;
  37758. /**
  37759. * Sets the current stencil function
  37760. * @param stencilFunc defines the new stencil function to use
  37761. */
  37762. setStencilFunction(stencilFunc: number): void;
  37763. /**
  37764. * Sets the current stencil reference
  37765. * @param reference defines the new stencil reference to use
  37766. */
  37767. setStencilFunctionReference(reference: number): void;
  37768. /**
  37769. * Sets the current stencil mask
  37770. * @param mask defines the new stencil mask to use
  37771. */
  37772. setStencilFunctionMask(mask: number): void;
  37773. /**
  37774. * Gets the current stencil operation when stencil fails
  37775. * @returns a number defining stencil operation to use when stencil fails
  37776. */
  37777. getStencilOperationFail(): number;
  37778. /**
  37779. * Gets the current stencil operation when depth fails
  37780. * @returns a number defining stencil operation to use when depth fails
  37781. */
  37782. getStencilOperationDepthFail(): number;
  37783. /**
  37784. * Gets the current stencil operation when stencil passes
  37785. * @returns a number defining stencil operation to use when stencil passes
  37786. */
  37787. getStencilOperationPass(): number;
  37788. /**
  37789. * Sets the stencil operation to use when stencil fails
  37790. * @param operation defines the stencil operation to use when stencil fails
  37791. */
  37792. setStencilOperationFail(operation: number): void;
  37793. /**
  37794. * Sets the stencil operation to use when depth fails
  37795. * @param operation defines the stencil operation to use when depth fails
  37796. */
  37797. setStencilOperationDepthFail(operation: number): void;
  37798. /**
  37799. * Sets the stencil operation to use when stencil passes
  37800. * @param operation defines the stencil operation to use when stencil passes
  37801. */
  37802. setStencilOperationPass(operation: number): void;
  37803. /**
  37804. * Sets a boolean indicating if the dithering state is enabled or disabled
  37805. * @param value defines the dithering state
  37806. */
  37807. setDitheringState(value: boolean): void;
  37808. /**
  37809. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37810. * @param value defines the rasterizer state
  37811. */
  37812. setRasterizerState(value: boolean): void;
  37813. /**
  37814. * Gets the current depth function
  37815. * @returns a number defining the depth function
  37816. */
  37817. getDepthFunction(): Nullable<number>;
  37818. /**
  37819. * Sets the current depth function
  37820. * @param depthFunc defines the function to use
  37821. */
  37822. setDepthFunction(depthFunc: number): void;
  37823. /**
  37824. * Sets the current depth function to GREATER
  37825. */
  37826. setDepthFunctionToGreater(): void;
  37827. /**
  37828. * Sets the current depth function to GEQUAL
  37829. */
  37830. setDepthFunctionToGreaterOrEqual(): void;
  37831. /**
  37832. * Sets the current depth function to LESS
  37833. */
  37834. setDepthFunctionToLess(): void;
  37835. /**
  37836. * Sets the current depth function to LEQUAL
  37837. */
  37838. setDepthFunctionToLessOrEqual(): void;
  37839. private _cachedStencilBuffer;
  37840. private _cachedStencilFunction;
  37841. private _cachedStencilMask;
  37842. private _cachedStencilOperationPass;
  37843. private _cachedStencilOperationFail;
  37844. private _cachedStencilOperationDepthFail;
  37845. private _cachedStencilReference;
  37846. /**
  37847. * Caches the the state of the stencil buffer
  37848. */
  37849. cacheStencilState(): void;
  37850. /**
  37851. * Restores the state of the stencil buffer
  37852. */
  37853. restoreStencilState(): void;
  37854. /**
  37855. * Directly set the WebGL Viewport
  37856. * @param x defines the x coordinate of the viewport (in screen space)
  37857. * @param y defines the y coordinate of the viewport (in screen space)
  37858. * @param width defines the width of the viewport (in screen space)
  37859. * @param height defines the height of the viewport (in screen space)
  37860. * @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
  37861. */
  37862. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37863. /**
  37864. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37865. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37866. * @param y defines the y-coordinate of the corner of the clear rectangle
  37867. * @param width defines the width of the clear rectangle
  37868. * @param height defines the height of the clear rectangle
  37869. * @param clearColor defines the clear color
  37870. */
  37871. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37872. /**
  37873. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37874. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37875. * @param y defines the y-coordinate of the corner of the clear rectangle
  37876. * @param width defines the width of the clear rectangle
  37877. * @param height defines the height of the clear rectangle
  37878. */
  37879. enableScissor(x: number, y: number, width: number, height: number): void;
  37880. /**
  37881. * Disable previously set scissor test rectangle
  37882. */
  37883. disableScissor(): void;
  37884. protected _reportDrawCall(): void;
  37885. /**
  37886. * Initializes a webVR display and starts listening to display change events
  37887. * The onVRDisplayChangedObservable will be notified upon these changes
  37888. * @returns The onVRDisplayChangedObservable
  37889. */
  37890. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37891. /** @hidden */
  37892. _prepareVRComponent(): void;
  37893. /** @hidden */
  37894. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37895. /** @hidden */
  37896. _submitVRFrame(): void;
  37897. /**
  37898. * Call this function to leave webVR mode
  37899. * Will do nothing if webVR is not supported or if there is no webVR device
  37900. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37901. */
  37902. disableVR(): void;
  37903. /**
  37904. * Gets a boolean indicating that the system is in VR mode and is presenting
  37905. * @returns true if VR mode is engaged
  37906. */
  37907. isVRPresenting(): boolean;
  37908. /** @hidden */
  37909. _requestVRFrame(): void;
  37910. /** @hidden */
  37911. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37912. /**
  37913. * Gets the source code of the vertex shader associated with a specific webGL program
  37914. * @param program defines the program to use
  37915. * @returns a string containing the source code of the vertex shader associated with the program
  37916. */
  37917. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37918. /**
  37919. * Gets the source code of the fragment shader associated with a specific webGL program
  37920. * @param program defines the program to use
  37921. * @returns a string containing the source code of the fragment shader associated with the program
  37922. */
  37923. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37924. /**
  37925. * Sets a depth stencil texture from a render target to the according uniform.
  37926. * @param channel The texture channel
  37927. * @param uniform The uniform to set
  37928. * @param texture The render target texture containing the depth stencil texture to apply
  37929. */
  37930. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37931. /**
  37932. * Sets a texture to the webGL context from a postprocess
  37933. * @param channel defines the channel to use
  37934. * @param postProcess defines the source postprocess
  37935. */
  37936. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37937. /**
  37938. * Binds the output of the passed in post process to the texture channel specified
  37939. * @param channel The channel the texture should be bound to
  37940. * @param postProcess The post process which's output should be bound
  37941. */
  37942. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37943. protected _rebuildBuffers(): void;
  37944. /** @hidden */
  37945. _renderFrame(): void;
  37946. _renderLoop(): void;
  37947. /** @hidden */
  37948. _renderViews(): boolean;
  37949. /**
  37950. * Toggle full screen mode
  37951. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37952. */
  37953. switchFullscreen(requestPointerLock: boolean): void;
  37954. /**
  37955. * Enters full screen mode
  37956. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37957. */
  37958. enterFullscreen(requestPointerLock: boolean): void;
  37959. /**
  37960. * Exits full screen mode
  37961. */
  37962. exitFullscreen(): void;
  37963. /**
  37964. * Enters Pointerlock mode
  37965. */
  37966. enterPointerlock(): void;
  37967. /**
  37968. * Exits Pointerlock mode
  37969. */
  37970. exitPointerlock(): void;
  37971. /**
  37972. * Begin a new frame
  37973. */
  37974. beginFrame(): void;
  37975. /**
  37976. * Enf the current frame
  37977. */
  37978. endFrame(): void;
  37979. resize(): void;
  37980. /**
  37981. * Force a specific size of the canvas
  37982. * @param width defines the new canvas' width
  37983. * @param height defines the new canvas' height
  37984. * @returns true if the size was changed
  37985. */
  37986. setSize(width: number, height: number): boolean;
  37987. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37988. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37989. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37990. _releaseTexture(texture: InternalTexture): void;
  37991. /**
  37992. * @hidden
  37993. * Rescales a texture
  37994. * @param source input texutre
  37995. * @param destination destination texture
  37996. * @param scene scene to use to render the resize
  37997. * @param internalFormat format to use when resizing
  37998. * @param onComplete callback to be called when resize has completed
  37999. */
  38000. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38001. /**
  38002. * Gets the current framerate
  38003. * @returns a number representing the framerate
  38004. */
  38005. getFps(): number;
  38006. /**
  38007. * Gets the time spent between current and previous frame
  38008. * @returns a number representing the delta time in ms
  38009. */
  38010. getDeltaTime(): number;
  38011. private _measureFps;
  38012. /** @hidden */
  38013. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38014. /**
  38015. * Updates the sample count of a render target texture
  38016. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38017. * @param texture defines the texture to update
  38018. * @param samples defines the sample count to set
  38019. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38020. */
  38021. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38022. /**
  38023. * Updates a depth texture Comparison Mode and Function.
  38024. * If the comparison Function is equal to 0, the mode will be set to none.
  38025. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38026. * @param texture The texture to set the comparison function for
  38027. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38028. */
  38029. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38030. /**
  38031. * Creates a webGL buffer to use with instanciation
  38032. * @param capacity defines the size of the buffer
  38033. * @returns the webGL buffer
  38034. */
  38035. createInstancesBuffer(capacity: number): DataBuffer;
  38036. /**
  38037. * Delete a webGL buffer used with instanciation
  38038. * @param buffer defines the webGL buffer to delete
  38039. */
  38040. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38041. private _clientWaitAsync;
  38042. /** @hidden */
  38043. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38044. dispose(): void;
  38045. private _disableTouchAction;
  38046. /**
  38047. * Display the loading screen
  38048. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38049. */
  38050. displayLoadingUI(): void;
  38051. /**
  38052. * Hide the loading screen
  38053. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38054. */
  38055. hideLoadingUI(): void;
  38056. /**
  38057. * Gets the current loading screen object
  38058. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38059. */
  38060. get loadingScreen(): ILoadingScreen;
  38061. /**
  38062. * Sets the current loading screen object
  38063. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38064. */
  38065. set loadingScreen(loadingScreen: ILoadingScreen);
  38066. /**
  38067. * Sets the current loading screen text
  38068. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38069. */
  38070. set loadingUIText(text: string);
  38071. /**
  38072. * Sets the current loading screen background color
  38073. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38074. */
  38075. set loadingUIBackgroundColor(color: string);
  38076. /** Pointerlock and fullscreen */
  38077. /**
  38078. * Ask the browser to promote the current element to pointerlock mode
  38079. * @param element defines the DOM element to promote
  38080. */
  38081. static _RequestPointerlock(element: HTMLElement): void;
  38082. /**
  38083. * Asks the browser to exit pointerlock mode
  38084. */
  38085. static _ExitPointerlock(): void;
  38086. /**
  38087. * Ask the browser to promote the current element to fullscreen rendering mode
  38088. * @param element defines the DOM element to promote
  38089. */
  38090. static _RequestFullscreen(element: HTMLElement): void;
  38091. /**
  38092. * Asks the browser to exit fullscreen mode
  38093. */
  38094. static _ExitFullscreen(): void;
  38095. }
  38096. }
  38097. declare module BABYLON {
  38098. /**
  38099. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38100. * during the life time of the application.
  38101. */
  38102. export class EngineStore {
  38103. /** Gets the list of created engines */
  38104. static Instances: Engine[];
  38105. /** @hidden */
  38106. static _LastCreatedScene: Nullable<Scene>;
  38107. /**
  38108. * Gets the latest created engine
  38109. */
  38110. static get LastCreatedEngine(): Nullable<Engine>;
  38111. /**
  38112. * Gets the latest created scene
  38113. */
  38114. static get LastCreatedScene(): Nullable<Scene>;
  38115. /**
  38116. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38117. * @ignorenaming
  38118. */
  38119. static UseFallbackTexture: boolean;
  38120. /**
  38121. * Texture content used if a texture cannot loaded
  38122. * @ignorenaming
  38123. */
  38124. static FallbackTexture: string;
  38125. }
  38126. }
  38127. declare module BABYLON {
  38128. /**
  38129. * Helper class that provides a small promise polyfill
  38130. */
  38131. export class PromisePolyfill {
  38132. /**
  38133. * Static function used to check if the polyfill is required
  38134. * If this is the case then the function will inject the polyfill to window.Promise
  38135. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38136. */
  38137. static Apply(force?: boolean): void;
  38138. }
  38139. }
  38140. declare module BABYLON {
  38141. /**
  38142. * Interface for screenshot methods with describe argument called `size` as object with options
  38143. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38144. */
  38145. export interface IScreenshotSize {
  38146. /**
  38147. * number in pixels for canvas height
  38148. */
  38149. height?: number;
  38150. /**
  38151. * multiplier allowing render at a higher or lower resolution
  38152. * If value is defined then height and width will be ignored and taken from camera
  38153. */
  38154. precision?: number;
  38155. /**
  38156. * number in pixels for canvas width
  38157. */
  38158. width?: number;
  38159. }
  38160. }
  38161. declare module BABYLON {
  38162. interface IColor4Like {
  38163. r: float;
  38164. g: float;
  38165. b: float;
  38166. a: float;
  38167. }
  38168. /**
  38169. * Class containing a set of static utilities functions
  38170. */
  38171. export class Tools {
  38172. /**
  38173. * Gets or sets the base URL to use to load assets
  38174. */
  38175. static get BaseUrl(): string;
  38176. static set BaseUrl(value: string);
  38177. /**
  38178. * Enable/Disable Custom HTTP Request Headers globally.
  38179. * default = false
  38180. * @see CustomRequestHeaders
  38181. */
  38182. static UseCustomRequestHeaders: boolean;
  38183. /**
  38184. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38185. * i.e. when loading files, where the server/service expects an Authorization header
  38186. */
  38187. static CustomRequestHeaders: {
  38188. [key: string]: string;
  38189. };
  38190. /**
  38191. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38192. */
  38193. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38194. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38195. /**
  38196. * Default behaviour for cors in the application.
  38197. * It can be a string if the expected behavior is identical in the entire app.
  38198. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38199. */
  38200. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38201. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38202. /**
  38203. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38204. * @ignorenaming
  38205. */
  38206. static get UseFallbackTexture(): boolean;
  38207. static set UseFallbackTexture(value: boolean);
  38208. /**
  38209. * Use this object to register external classes like custom textures or material
  38210. * to allow the laoders to instantiate them
  38211. */
  38212. static get RegisteredExternalClasses(): {
  38213. [key: string]: Object;
  38214. };
  38215. static set RegisteredExternalClasses(classes: {
  38216. [key: string]: Object;
  38217. });
  38218. /**
  38219. * Texture content used if a texture cannot loaded
  38220. * @ignorenaming
  38221. */
  38222. static get fallbackTexture(): string;
  38223. static set fallbackTexture(value: string);
  38224. /**
  38225. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38226. * @param u defines the coordinate on X axis
  38227. * @param v defines the coordinate on Y axis
  38228. * @param width defines the width of the source data
  38229. * @param height defines the height of the source data
  38230. * @param pixels defines the source byte array
  38231. * @param color defines the output color
  38232. */
  38233. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38234. /**
  38235. * Interpolates between a and b via alpha
  38236. * @param a The lower value (returned when alpha = 0)
  38237. * @param b The upper value (returned when alpha = 1)
  38238. * @param alpha The interpolation-factor
  38239. * @return The mixed value
  38240. */
  38241. static Mix(a: number, b: number, alpha: number): number;
  38242. /**
  38243. * Tries to instantiate a new object from a given class name
  38244. * @param className defines the class name to instantiate
  38245. * @returns the new object or null if the system was not able to do the instantiation
  38246. */
  38247. static Instantiate(className: string): any;
  38248. /**
  38249. * Provides a slice function that will work even on IE
  38250. * @param data defines the array to slice
  38251. * @param start defines the start of the data (optional)
  38252. * @param end defines the end of the data (optional)
  38253. * @returns the new sliced array
  38254. */
  38255. static Slice<T>(data: T, start?: number, end?: number): T;
  38256. /**
  38257. * Polyfill for setImmediate
  38258. * @param action defines the action to execute after the current execution block
  38259. */
  38260. static SetImmediate(action: () => void): void;
  38261. /**
  38262. * Function indicating if a number is an exponent of 2
  38263. * @param value defines the value to test
  38264. * @returns true if the value is an exponent of 2
  38265. */
  38266. static IsExponentOfTwo(value: number): boolean;
  38267. private static _tmpFloatArray;
  38268. /**
  38269. * Returns the nearest 32-bit single precision float representation of a Number
  38270. * @param value A Number. If the parameter is of a different type, it will get converted
  38271. * to a number or to NaN if it cannot be converted
  38272. * @returns number
  38273. */
  38274. static FloatRound(value: number): number;
  38275. /**
  38276. * Extracts the filename from a path
  38277. * @param path defines the path to use
  38278. * @returns the filename
  38279. */
  38280. static GetFilename(path: string): string;
  38281. /**
  38282. * Extracts the "folder" part of a path (everything before the filename).
  38283. * @param uri The URI to extract the info from
  38284. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38285. * @returns The "folder" part of the path
  38286. */
  38287. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38288. /**
  38289. * Extracts text content from a DOM element hierarchy
  38290. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38291. */
  38292. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38293. /**
  38294. * Convert an angle in radians to degrees
  38295. * @param angle defines the angle to convert
  38296. * @returns the angle in degrees
  38297. */
  38298. static ToDegrees(angle: number): number;
  38299. /**
  38300. * Convert an angle in degrees to radians
  38301. * @param angle defines the angle to convert
  38302. * @returns the angle in radians
  38303. */
  38304. static ToRadians(angle: number): number;
  38305. /**
  38306. * Returns an array if obj is not an array
  38307. * @param obj defines the object to evaluate as an array
  38308. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38309. * @returns either obj directly if obj is an array or a new array containing obj
  38310. */
  38311. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38312. /**
  38313. * Gets the pointer prefix to use
  38314. * @param engine defines the engine we are finding the prefix for
  38315. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38316. */
  38317. static GetPointerPrefix(engine: Engine): string;
  38318. /**
  38319. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38320. * @param url define the url we are trying
  38321. * @param element define the dom element where to configure the cors policy
  38322. */
  38323. static SetCorsBehavior(url: string | string[], element: {
  38324. crossOrigin: string | null;
  38325. }): void;
  38326. /**
  38327. * Removes unwanted characters from an url
  38328. * @param url defines the url to clean
  38329. * @returns the cleaned url
  38330. */
  38331. static CleanUrl(url: string): string;
  38332. /**
  38333. * Gets or sets a function used to pre-process url before using them to load assets
  38334. */
  38335. static get PreprocessUrl(): (url: string) => string;
  38336. static set PreprocessUrl(processor: (url: string) => string);
  38337. /**
  38338. * Loads an image as an HTMLImageElement.
  38339. * @param input url string, ArrayBuffer, or Blob to load
  38340. * @param onLoad callback called when the image successfully loads
  38341. * @param onError callback called when the image fails to load
  38342. * @param offlineProvider offline provider for caching
  38343. * @param mimeType optional mime type
  38344. * @returns the HTMLImageElement of the loaded image
  38345. */
  38346. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38347. /**
  38348. * Loads a file from a url
  38349. * @param url url string, ArrayBuffer, or Blob to load
  38350. * @param onSuccess callback called when the file successfully loads
  38351. * @param onProgress callback called while file is loading (if the server supports this mode)
  38352. * @param offlineProvider defines the offline provider for caching
  38353. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38354. * @param onError callback called when the file fails to load
  38355. * @returns a file request object
  38356. */
  38357. 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;
  38358. /**
  38359. * Loads a file from a url
  38360. * @param url the file url to load
  38361. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38362. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38363. */
  38364. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38365. /**
  38366. * Load a script (identified by an url). When the url returns, the
  38367. * content of this file is added into a new script element, attached to the DOM (body element)
  38368. * @param scriptUrl defines the url of the script to laod
  38369. * @param onSuccess defines the callback called when the script is loaded
  38370. * @param onError defines the callback to call if an error occurs
  38371. * @param scriptId defines the id of the script element
  38372. */
  38373. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38374. /**
  38375. * Load an asynchronous script (identified by an url). When the url returns, the
  38376. * content of this file is added into a new script element, attached to the DOM (body element)
  38377. * @param scriptUrl defines the url of the script to laod
  38378. * @param scriptId defines the id of the script element
  38379. * @returns a promise request object
  38380. */
  38381. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38382. /**
  38383. * Loads a file from a blob
  38384. * @param fileToLoad defines the blob to use
  38385. * @param callback defines the callback to call when data is loaded
  38386. * @param progressCallback defines the callback to call during loading process
  38387. * @returns a file request object
  38388. */
  38389. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38390. /**
  38391. * Reads a file from a File object
  38392. * @param file defines the file to load
  38393. * @param onSuccess defines the callback to call when data is loaded
  38394. * @param onProgress defines the callback to call during loading process
  38395. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38396. * @param onError defines the callback to call when an error occurs
  38397. * @returns a file request object
  38398. */
  38399. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38400. /**
  38401. * Creates a data url from a given string content
  38402. * @param content defines the content to convert
  38403. * @returns the new data url link
  38404. */
  38405. static FileAsURL(content: string): string;
  38406. /**
  38407. * Format the given number to a specific decimal format
  38408. * @param value defines the number to format
  38409. * @param decimals defines the number of decimals to use
  38410. * @returns the formatted string
  38411. */
  38412. static Format(value: number, decimals?: number): string;
  38413. /**
  38414. * Tries to copy an object by duplicating every property
  38415. * @param source defines the source object
  38416. * @param destination defines the target object
  38417. * @param doNotCopyList defines a list of properties to avoid
  38418. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38419. */
  38420. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38421. /**
  38422. * Gets a boolean indicating if the given object has no own property
  38423. * @param obj defines the object to test
  38424. * @returns true if object has no own property
  38425. */
  38426. static IsEmpty(obj: any): boolean;
  38427. /**
  38428. * Function used to register events at window level
  38429. * @param windowElement defines the Window object to use
  38430. * @param events defines the events to register
  38431. */
  38432. static RegisterTopRootEvents(windowElement: Window, events: {
  38433. name: string;
  38434. handler: Nullable<(e: FocusEvent) => any>;
  38435. }[]): void;
  38436. /**
  38437. * Function used to unregister events from window level
  38438. * @param windowElement defines the Window object to use
  38439. * @param events defines the events to unregister
  38440. */
  38441. static UnregisterTopRootEvents(windowElement: Window, events: {
  38442. name: string;
  38443. handler: Nullable<(e: FocusEvent) => any>;
  38444. }[]): void;
  38445. /**
  38446. * @ignore
  38447. */
  38448. static _ScreenshotCanvas: HTMLCanvasElement;
  38449. /**
  38450. * Dumps the current bound framebuffer
  38451. * @param width defines the rendering width
  38452. * @param height defines the rendering height
  38453. * @param engine defines the hosting engine
  38454. * @param successCallback defines the callback triggered once the data are available
  38455. * @param mimeType defines the mime type of the result
  38456. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38457. */
  38458. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38459. /**
  38460. * Converts the canvas data to blob.
  38461. * This acts as a polyfill for browsers not supporting the to blob function.
  38462. * @param canvas Defines the canvas to extract the data from
  38463. * @param successCallback Defines the callback triggered once the data are available
  38464. * @param mimeType Defines the mime type of the result
  38465. */
  38466. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38467. /**
  38468. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38469. * @param successCallback defines the callback triggered once the data are available
  38470. * @param mimeType defines the mime type of the result
  38471. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38472. */
  38473. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38474. /**
  38475. * Downloads a blob in the browser
  38476. * @param blob defines the blob to download
  38477. * @param fileName defines the name of the downloaded file
  38478. */
  38479. static Download(blob: Blob, fileName: string): void;
  38480. /**
  38481. * Captures a screenshot of the current rendering
  38482. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38483. * @param engine defines the rendering engine
  38484. * @param camera defines the source camera
  38485. * @param size This parameter can be set to a single number or to an object with the
  38486. * following (optional) properties: precision, width, height. If a single number is passed,
  38487. * it will be used for both width and height. If an object is passed, the screenshot size
  38488. * will be derived from the parameters. The precision property is a multiplier allowing
  38489. * rendering at a higher or lower resolution
  38490. * @param successCallback defines the callback receives a single parameter which contains the
  38491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38492. * src parameter of an <img> to display it
  38493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38494. * Check your browser for supported MIME types
  38495. */
  38496. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38497. /**
  38498. * Captures a screenshot of the current rendering
  38499. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38500. * @param engine defines the rendering engine
  38501. * @param camera defines the source camera
  38502. * @param size This parameter can be set to a single number or to an object with the
  38503. * following (optional) properties: precision, width, height. If a single number is passed,
  38504. * it will be used for both width and height. If an object is passed, the screenshot size
  38505. * will be derived from the parameters. The precision property is a multiplier allowing
  38506. * rendering at a higher or lower resolution
  38507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38508. * Check your browser for supported MIME types
  38509. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38510. * to the src parameter of an <img> to display it
  38511. */
  38512. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38513. /**
  38514. * Generates an image screenshot from the specified camera.
  38515. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38516. * @param engine The engine to use for rendering
  38517. * @param camera The camera to use for rendering
  38518. * @param size This parameter can be set to a single number or to an object with the
  38519. * following (optional) properties: precision, width, height. If a single number is passed,
  38520. * it will be used for both width and height. If an object is passed, the screenshot size
  38521. * will be derived from the parameters. The precision property is a multiplier allowing
  38522. * rendering at a higher or lower resolution
  38523. * @param successCallback The callback receives a single parameter which contains the
  38524. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38525. * src parameter of an <img> to display it
  38526. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38527. * Check your browser for supported MIME types
  38528. * @param samples Texture samples (default: 1)
  38529. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38530. * @param fileName A name for for the downloaded file.
  38531. */
  38532. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38533. /**
  38534. * Generates an image screenshot from the specified camera.
  38535. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38536. * @param engine The engine to use for rendering
  38537. * @param camera The camera to use for rendering
  38538. * @param size This parameter can be set to a single number or to an object with the
  38539. * following (optional) properties: precision, width, height. If a single number is passed,
  38540. * it will be used for both width and height. If an object is passed, the screenshot size
  38541. * will be derived from the parameters. The precision property is a multiplier allowing
  38542. * rendering at a higher or lower resolution
  38543. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38544. * Check your browser for supported MIME types
  38545. * @param samples Texture samples (default: 1)
  38546. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38547. * @param fileName A name for for the downloaded file.
  38548. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38549. * to the src parameter of an <img> to display it
  38550. */
  38551. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38552. /**
  38553. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38554. * Be aware Math.random() could cause collisions, but:
  38555. * "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"
  38556. * @returns a pseudo random id
  38557. */
  38558. static RandomId(): string;
  38559. /**
  38560. * Test if the given uri is a base64 string
  38561. * @param uri The uri to test
  38562. * @return True if the uri is a base64 string or false otherwise
  38563. */
  38564. static IsBase64(uri: string): boolean;
  38565. /**
  38566. * Decode the given base64 uri.
  38567. * @param uri The uri to decode
  38568. * @return The decoded base64 data.
  38569. */
  38570. static DecodeBase64(uri: string): ArrayBuffer;
  38571. /**
  38572. * Gets the absolute url.
  38573. * @param url the input url
  38574. * @return the absolute url
  38575. */
  38576. static GetAbsoluteUrl(url: string): string;
  38577. /**
  38578. * No log
  38579. */
  38580. static readonly NoneLogLevel: number;
  38581. /**
  38582. * Only message logs
  38583. */
  38584. static readonly MessageLogLevel: number;
  38585. /**
  38586. * Only warning logs
  38587. */
  38588. static readonly WarningLogLevel: number;
  38589. /**
  38590. * Only error logs
  38591. */
  38592. static readonly ErrorLogLevel: number;
  38593. /**
  38594. * All logs
  38595. */
  38596. static readonly AllLogLevel: number;
  38597. /**
  38598. * Gets a value indicating the number of loading errors
  38599. * @ignorenaming
  38600. */
  38601. static get errorsCount(): number;
  38602. /**
  38603. * Callback called when a new log is added
  38604. */
  38605. static OnNewCacheEntry: (entry: string) => void;
  38606. /**
  38607. * Log a message to the console
  38608. * @param message defines the message to log
  38609. */
  38610. static Log(message: string): void;
  38611. /**
  38612. * Write a warning message to the console
  38613. * @param message defines the message to log
  38614. */
  38615. static Warn(message: string): void;
  38616. /**
  38617. * Write an error message to the console
  38618. * @param message defines the message to log
  38619. */
  38620. static Error(message: string): void;
  38621. /**
  38622. * Gets current log cache (list of logs)
  38623. */
  38624. static get LogCache(): string;
  38625. /**
  38626. * Clears the log cache
  38627. */
  38628. static ClearLogCache(): void;
  38629. /**
  38630. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38631. */
  38632. static set LogLevels(level: number);
  38633. /**
  38634. * Checks if the window object exists
  38635. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38636. */
  38637. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38638. /**
  38639. * No performance log
  38640. */
  38641. static readonly PerformanceNoneLogLevel: number;
  38642. /**
  38643. * Use user marks to log performance
  38644. */
  38645. static readonly PerformanceUserMarkLogLevel: number;
  38646. /**
  38647. * Log performance to the console
  38648. */
  38649. static readonly PerformanceConsoleLogLevel: number;
  38650. private static _performance;
  38651. /**
  38652. * Sets the current performance log level
  38653. */
  38654. static set PerformanceLogLevel(level: number);
  38655. private static _StartPerformanceCounterDisabled;
  38656. private static _EndPerformanceCounterDisabled;
  38657. private static _StartUserMark;
  38658. private static _EndUserMark;
  38659. private static _StartPerformanceConsole;
  38660. private static _EndPerformanceConsole;
  38661. /**
  38662. * Starts a performance counter
  38663. */
  38664. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38665. /**
  38666. * Ends a specific performance coutner
  38667. */
  38668. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38669. /**
  38670. * Gets either window.performance.now() if supported or Date.now() else
  38671. */
  38672. static get Now(): number;
  38673. /**
  38674. * This method will return the name of the class used to create the instance of the given object.
  38675. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38676. * @param object the object to get the class name from
  38677. * @param isType defines if the object is actually a type
  38678. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38679. */
  38680. static GetClassName(object: any, isType?: boolean): string;
  38681. /**
  38682. * Gets the first element of an array satisfying a given predicate
  38683. * @param array defines the array to browse
  38684. * @param predicate defines the predicate to use
  38685. * @returns null if not found or the element
  38686. */
  38687. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38688. /**
  38689. * This method will return the name of the full name of the class, including its owning module (if any).
  38690. * 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).
  38691. * @param object the object to get the class name from
  38692. * @param isType defines if the object is actually a type
  38693. * @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.
  38694. * @ignorenaming
  38695. */
  38696. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38697. /**
  38698. * Returns a promise that resolves after the given amount of time.
  38699. * @param delay Number of milliseconds to delay
  38700. * @returns Promise that resolves after the given amount of time
  38701. */
  38702. static DelayAsync(delay: number): Promise<void>;
  38703. /**
  38704. * Utility function to detect if the current user agent is Safari
  38705. * @returns whether or not the current user agent is safari
  38706. */
  38707. static IsSafari(): boolean;
  38708. }
  38709. /**
  38710. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38711. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38712. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38713. * @param name The name of the class, case should be preserved
  38714. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38715. */
  38716. export function className(name: string, module?: string): (target: Object) => void;
  38717. /**
  38718. * An implementation of a loop for asynchronous functions.
  38719. */
  38720. export class AsyncLoop {
  38721. /**
  38722. * Defines the number of iterations for the loop
  38723. */
  38724. iterations: number;
  38725. /**
  38726. * Defines the current index of the loop.
  38727. */
  38728. index: number;
  38729. private _done;
  38730. private _fn;
  38731. private _successCallback;
  38732. /**
  38733. * Constructor.
  38734. * @param iterations the number of iterations.
  38735. * @param func the function to run each iteration
  38736. * @param successCallback the callback that will be called upon succesful execution
  38737. * @param offset starting offset.
  38738. */
  38739. constructor(
  38740. /**
  38741. * Defines the number of iterations for the loop
  38742. */
  38743. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38744. /**
  38745. * Execute the next iteration. Must be called after the last iteration was finished.
  38746. */
  38747. executeNext(): void;
  38748. /**
  38749. * Break the loop and run the success callback.
  38750. */
  38751. breakLoop(): void;
  38752. /**
  38753. * Create and run an async loop.
  38754. * @param iterations the number of iterations.
  38755. * @param fn the function to run each iteration
  38756. * @param successCallback the callback that will be called upon succesful execution
  38757. * @param offset starting offset.
  38758. * @returns the created async loop object
  38759. */
  38760. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38761. /**
  38762. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38763. * @param iterations total number of iterations
  38764. * @param syncedIterations number of synchronous iterations in each async iteration.
  38765. * @param fn the function to call each iteration.
  38766. * @param callback a success call back that will be called when iterating stops.
  38767. * @param breakFunction a break condition (optional)
  38768. * @param timeout timeout settings for the setTimeout function. default - 0.
  38769. * @returns the created async loop object
  38770. */
  38771. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38772. }
  38773. }
  38774. declare module BABYLON {
  38775. /**
  38776. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38777. * The underlying implementation relies on an associative array to ensure the best performances.
  38778. * The value can be anything including 'null' but except 'undefined'
  38779. */
  38780. export class StringDictionary<T> {
  38781. /**
  38782. * This will clear this dictionary and copy the content from the 'source' one.
  38783. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38784. * @param source the dictionary to take the content from and copy to this dictionary
  38785. */
  38786. copyFrom(source: StringDictionary<T>): void;
  38787. /**
  38788. * Get a value based from its key
  38789. * @param key the given key to get the matching value from
  38790. * @return the value if found, otherwise undefined is returned
  38791. */
  38792. get(key: string): T | undefined;
  38793. /**
  38794. * Get a value from its key or add it if it doesn't exist.
  38795. * This method will ensure you that a given key/data will be present in the dictionary.
  38796. * @param key the given key to get the matching value from
  38797. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38798. * The factory will only be invoked if there's no data for the given key.
  38799. * @return the value corresponding to the key.
  38800. */
  38801. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38802. /**
  38803. * Get a value from its key if present in the dictionary otherwise add it
  38804. * @param key the key to get the value from
  38805. * @param val if there's no such key/value pair in the dictionary add it with this value
  38806. * @return the value corresponding to the key
  38807. */
  38808. getOrAdd(key: string, val: T): T;
  38809. /**
  38810. * Check if there's a given key in the dictionary
  38811. * @param key the key to check for
  38812. * @return true if the key is present, false otherwise
  38813. */
  38814. contains(key: string): boolean;
  38815. /**
  38816. * Add a new key and its corresponding value
  38817. * @param key the key to add
  38818. * @param value the value corresponding to the key
  38819. * @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
  38820. */
  38821. add(key: string, value: T): boolean;
  38822. /**
  38823. * Update a specific value associated to a key
  38824. * @param key defines the key to use
  38825. * @param value defines the value to store
  38826. * @returns true if the value was updated (or false if the key was not found)
  38827. */
  38828. set(key: string, value: T): boolean;
  38829. /**
  38830. * Get the element of the given key and remove it from the dictionary
  38831. * @param key defines the key to search
  38832. * @returns the value associated with the key or null if not found
  38833. */
  38834. getAndRemove(key: string): Nullable<T>;
  38835. /**
  38836. * Remove a key/value from the dictionary.
  38837. * @param key the key to remove
  38838. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38839. */
  38840. remove(key: string): boolean;
  38841. /**
  38842. * Clear the whole content of the dictionary
  38843. */
  38844. clear(): void;
  38845. /**
  38846. * Gets the current count
  38847. */
  38848. get count(): number;
  38849. /**
  38850. * Execute a callback on each key/val of the dictionary.
  38851. * Note that you can remove any element in this dictionary in the callback implementation
  38852. * @param callback the callback to execute on a given key/value pair
  38853. */
  38854. forEach(callback: (key: string, val: T) => void): void;
  38855. /**
  38856. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38857. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38858. * Note that you can remove any element in this dictionary in the callback implementation
  38859. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38860. * @returns the first item
  38861. */
  38862. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38863. private _count;
  38864. private _data;
  38865. }
  38866. }
  38867. declare module BABYLON {
  38868. /** @hidden */
  38869. export interface ICollisionCoordinator {
  38870. createCollider(): Collider;
  38871. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38872. init(scene: Scene): void;
  38873. }
  38874. /** @hidden */
  38875. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38876. private _scene;
  38877. private _scaledPosition;
  38878. private _scaledVelocity;
  38879. private _finalPosition;
  38880. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38881. createCollider(): Collider;
  38882. init(scene: Scene): void;
  38883. private _collideWithWorld;
  38884. }
  38885. }
  38886. declare module BABYLON {
  38887. /**
  38888. * Class used to manage all inputs for the scene.
  38889. */
  38890. export class InputManager {
  38891. /** The distance in pixel that you have to move to prevent some events */
  38892. static DragMovementThreshold: number;
  38893. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38894. static LongPressDelay: number;
  38895. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38896. static DoubleClickDelay: number;
  38897. /** If you need to check double click without raising a single click at first click, enable this flag */
  38898. static ExclusiveDoubleClickMode: boolean;
  38899. /** 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. */
  38900. private _alreadyAttached;
  38901. private _wheelEventName;
  38902. private _onPointerMove;
  38903. private _onPointerDown;
  38904. private _onPointerUp;
  38905. private _initClickEvent;
  38906. private _initActionManager;
  38907. private _delayedSimpleClick;
  38908. private _delayedSimpleClickTimeout;
  38909. private _previousDelayedSimpleClickTimeout;
  38910. private _meshPickProceed;
  38911. private _previousButtonPressed;
  38912. private _currentPickResult;
  38913. private _previousPickResult;
  38914. private _totalPointersPressed;
  38915. private _doubleClickOccured;
  38916. private _pointerOverMesh;
  38917. private _pickedDownMesh;
  38918. private _pickedUpMesh;
  38919. private _pointerX;
  38920. private _pointerY;
  38921. private _unTranslatedPointerX;
  38922. private _unTranslatedPointerY;
  38923. private _startingPointerPosition;
  38924. private _previousStartingPointerPosition;
  38925. private _startingPointerTime;
  38926. private _previousStartingPointerTime;
  38927. private _pointerCaptures;
  38928. private _onKeyDown;
  38929. private _onKeyUp;
  38930. private _onCanvasFocusObserver;
  38931. private _onCanvasBlurObserver;
  38932. private _scene;
  38933. /**
  38934. * Creates a new InputManager
  38935. * @param scene defines the hosting scene
  38936. */
  38937. constructor(scene: Scene);
  38938. /**
  38939. * Gets the mesh that is currently under the pointer
  38940. */
  38941. get meshUnderPointer(): Nullable<AbstractMesh>;
  38942. /**
  38943. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38944. */
  38945. get unTranslatedPointer(): Vector2;
  38946. /**
  38947. * Gets or sets the current on-screen X position of the pointer
  38948. */
  38949. get pointerX(): number;
  38950. set pointerX(value: number);
  38951. /**
  38952. * Gets or sets the current on-screen Y position of the pointer
  38953. */
  38954. get pointerY(): number;
  38955. set pointerY(value: number);
  38956. private _updatePointerPosition;
  38957. private _processPointerMove;
  38958. private _setRayOnPointerInfo;
  38959. private _checkPrePointerObservable;
  38960. /**
  38961. * Use this method to simulate a pointer move on a mesh
  38962. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38963. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38964. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38965. */
  38966. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38967. /**
  38968. * Use this method to simulate a pointer down on a mesh
  38969. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38970. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38971. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38972. */
  38973. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38974. private _processPointerDown;
  38975. /** @hidden */
  38976. _isPointerSwiping(): boolean;
  38977. /**
  38978. * Use this method to simulate a pointer up on a mesh
  38979. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38980. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38981. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38982. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38983. */
  38984. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38985. private _processPointerUp;
  38986. /**
  38987. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38988. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38989. * @returns true if the pointer was captured
  38990. */
  38991. isPointerCaptured(pointerId?: number): boolean;
  38992. /**
  38993. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38994. * @param attachUp defines if you want to attach events to pointerup
  38995. * @param attachDown defines if you want to attach events to pointerdown
  38996. * @param attachMove defines if you want to attach events to pointermove
  38997. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38998. */
  38999. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39000. /**
  39001. * Detaches all event handlers
  39002. */
  39003. detachControl(): void;
  39004. /**
  39005. * Force the value of meshUnderPointer
  39006. * @param mesh defines the mesh to use
  39007. */
  39008. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39009. /**
  39010. * Gets the mesh under the pointer
  39011. * @returns a Mesh or null if no mesh is under the pointer
  39012. */
  39013. getPointerOverMesh(): Nullable<AbstractMesh>;
  39014. }
  39015. }
  39016. declare module BABYLON {
  39017. /**
  39018. * This class defines the direct association between an animation and a target
  39019. */
  39020. export class TargetedAnimation {
  39021. /**
  39022. * Animation to perform
  39023. */
  39024. animation: Animation;
  39025. /**
  39026. * Target to animate
  39027. */
  39028. target: any;
  39029. /**
  39030. * Returns the string "TargetedAnimation"
  39031. * @returns "TargetedAnimation"
  39032. */
  39033. getClassName(): string;
  39034. /**
  39035. * Serialize the object
  39036. * @returns the JSON object representing the current entity
  39037. */
  39038. serialize(): any;
  39039. }
  39040. /**
  39041. * Use this class to create coordinated animations on multiple targets
  39042. */
  39043. export class AnimationGroup implements IDisposable {
  39044. /** The name of the animation group */
  39045. name: string;
  39046. private _scene;
  39047. private _targetedAnimations;
  39048. private _animatables;
  39049. private _from;
  39050. private _to;
  39051. private _isStarted;
  39052. private _isPaused;
  39053. private _speedRatio;
  39054. private _loopAnimation;
  39055. private _isAdditive;
  39056. /**
  39057. * Gets or sets the unique id of the node
  39058. */
  39059. uniqueId: number;
  39060. /**
  39061. * This observable will notify when one animation have ended
  39062. */
  39063. onAnimationEndObservable: Observable<TargetedAnimation>;
  39064. /**
  39065. * Observer raised when one animation loops
  39066. */
  39067. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39068. /**
  39069. * Observer raised when all animations have looped
  39070. */
  39071. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39072. /**
  39073. * This observable will notify when all animations have ended.
  39074. */
  39075. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39076. /**
  39077. * This observable will notify when all animations have paused.
  39078. */
  39079. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39080. /**
  39081. * This observable will notify when all animations are playing.
  39082. */
  39083. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39084. /**
  39085. * Gets the first frame
  39086. */
  39087. get from(): number;
  39088. /**
  39089. * Gets the last frame
  39090. */
  39091. get to(): number;
  39092. /**
  39093. * Define if the animations are started
  39094. */
  39095. get isStarted(): boolean;
  39096. /**
  39097. * Gets a value indicating that the current group is playing
  39098. */
  39099. get isPlaying(): boolean;
  39100. /**
  39101. * Gets or sets the speed ratio to use for all animations
  39102. */
  39103. get speedRatio(): number;
  39104. /**
  39105. * Gets or sets the speed ratio to use for all animations
  39106. */
  39107. set speedRatio(value: number);
  39108. /**
  39109. * Gets or sets if all animations should loop or not
  39110. */
  39111. get loopAnimation(): boolean;
  39112. set loopAnimation(value: boolean);
  39113. /**
  39114. * Gets or sets if all animations should be evaluated additively
  39115. */
  39116. get isAdditive(): boolean;
  39117. set isAdditive(value: boolean);
  39118. /**
  39119. * Gets the targeted animations for this animation group
  39120. */
  39121. get targetedAnimations(): Array<TargetedAnimation>;
  39122. /**
  39123. * returning the list of animatables controlled by this animation group.
  39124. */
  39125. get animatables(): Array<Animatable>;
  39126. /**
  39127. * Gets the list of target animations
  39128. */
  39129. get children(): TargetedAnimation[];
  39130. /**
  39131. * Instantiates a new Animation Group.
  39132. * This helps managing several animations at once.
  39133. * @see https://doc.babylonjs.com/how_to/group
  39134. * @param name Defines the name of the group
  39135. * @param scene Defines the scene the group belongs to
  39136. */
  39137. constructor(
  39138. /** The name of the animation group */
  39139. name: string, scene?: Nullable<Scene>);
  39140. /**
  39141. * Add an animation (with its target) in the group
  39142. * @param animation defines the animation we want to add
  39143. * @param target defines the target of the animation
  39144. * @returns the TargetedAnimation object
  39145. */
  39146. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39147. /**
  39148. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39149. * It can add constant keys at begin or end
  39150. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39151. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39152. * @returns the animation group
  39153. */
  39154. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39155. private _animationLoopCount;
  39156. private _animationLoopFlags;
  39157. private _processLoop;
  39158. /**
  39159. * Start all animations on given targets
  39160. * @param loop defines if animations must loop
  39161. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39162. * @param from defines the from key (optional)
  39163. * @param to defines the to key (optional)
  39164. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39165. * @returns the current animation group
  39166. */
  39167. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39168. /**
  39169. * Pause all animations
  39170. * @returns the animation group
  39171. */
  39172. pause(): AnimationGroup;
  39173. /**
  39174. * Play all animations to initial state
  39175. * This function will start() the animations if they were not started or will restart() them if they were paused
  39176. * @param loop defines if animations must loop
  39177. * @returns the animation group
  39178. */
  39179. play(loop?: boolean): AnimationGroup;
  39180. /**
  39181. * Reset all animations to initial state
  39182. * @returns the animation group
  39183. */
  39184. reset(): AnimationGroup;
  39185. /**
  39186. * Restart animations from key 0
  39187. * @returns the animation group
  39188. */
  39189. restart(): AnimationGroup;
  39190. /**
  39191. * Stop all animations
  39192. * @returns the animation group
  39193. */
  39194. stop(): AnimationGroup;
  39195. /**
  39196. * Set animation weight for all animatables
  39197. * @param weight defines the weight to use
  39198. * @return the animationGroup
  39199. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39200. */
  39201. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39202. /**
  39203. * Synchronize and normalize all animatables with a source animatable
  39204. * @param root defines the root animatable to synchronize with
  39205. * @return the animationGroup
  39206. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39207. */
  39208. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39209. /**
  39210. * Goes to a specific frame in this animation group
  39211. * @param frame the frame number to go to
  39212. * @return the animationGroup
  39213. */
  39214. goToFrame(frame: number): AnimationGroup;
  39215. /**
  39216. * Dispose all associated resources
  39217. */
  39218. dispose(): void;
  39219. private _checkAnimationGroupEnded;
  39220. /**
  39221. * Clone the current animation group and returns a copy
  39222. * @param newName defines the name of the new group
  39223. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39224. * @returns the new aniamtion group
  39225. */
  39226. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39227. /**
  39228. * Serializes the animationGroup to an object
  39229. * @returns Serialized object
  39230. */
  39231. serialize(): any;
  39232. /**
  39233. * Returns a new AnimationGroup object parsed from the source provided.
  39234. * @param parsedAnimationGroup defines the source
  39235. * @param scene defines the scene that will receive the animationGroup
  39236. * @returns a new AnimationGroup
  39237. */
  39238. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39239. /**
  39240. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39241. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39242. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39243. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39244. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39245. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39246. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39247. */
  39248. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39249. /**
  39250. * Returns the string "AnimationGroup"
  39251. * @returns "AnimationGroup"
  39252. */
  39253. getClassName(): string;
  39254. /**
  39255. * Creates a detailled string about the object
  39256. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39257. * @returns a string representing the object
  39258. */
  39259. toString(fullDetails?: boolean): string;
  39260. }
  39261. }
  39262. declare module BABYLON {
  39263. /**
  39264. * Define an interface for all classes that will hold resources
  39265. */
  39266. export interface IDisposable {
  39267. /**
  39268. * Releases all held resources
  39269. */
  39270. dispose(): void;
  39271. }
  39272. /** Interface defining initialization parameters for Scene class */
  39273. export interface SceneOptions {
  39274. /**
  39275. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39276. * It will improve performance when the number of geometries becomes important.
  39277. */
  39278. useGeometryUniqueIdsMap?: boolean;
  39279. /**
  39280. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39281. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39282. */
  39283. useMaterialMeshMap?: boolean;
  39284. /**
  39285. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39286. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39287. */
  39288. useClonedMeshMap?: boolean;
  39289. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39290. virtual?: boolean;
  39291. }
  39292. /**
  39293. * Represents a scene to be rendered by the engine.
  39294. * @see https://doc.babylonjs.com/features/scene
  39295. */
  39296. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39297. /** The fog is deactivated */
  39298. static readonly FOGMODE_NONE: number;
  39299. /** The fog density is following an exponential function */
  39300. static readonly FOGMODE_EXP: number;
  39301. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39302. static readonly FOGMODE_EXP2: number;
  39303. /** The fog density is following a linear function. */
  39304. static readonly FOGMODE_LINEAR: number;
  39305. /**
  39306. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39308. */
  39309. static MinDeltaTime: number;
  39310. /**
  39311. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39312. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39313. */
  39314. static MaxDeltaTime: number;
  39315. /**
  39316. * Factory used to create the default material.
  39317. * @param name The name of the material to create
  39318. * @param scene The scene to create the material for
  39319. * @returns The default material
  39320. */
  39321. static DefaultMaterialFactory(scene: Scene): Material;
  39322. /**
  39323. * Factory used to create the a collision coordinator.
  39324. * @returns The collision coordinator
  39325. */
  39326. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39327. /** @hidden */
  39328. _inputManager: InputManager;
  39329. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39330. cameraToUseForPointers: Nullable<Camera>;
  39331. /** @hidden */
  39332. readonly _isScene: boolean;
  39333. /** @hidden */
  39334. _blockEntityCollection: boolean;
  39335. /**
  39336. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39337. */
  39338. autoClear: boolean;
  39339. /**
  39340. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39341. */
  39342. autoClearDepthAndStencil: boolean;
  39343. /**
  39344. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39345. */
  39346. clearColor: Color4;
  39347. /**
  39348. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39349. */
  39350. ambientColor: Color3;
  39351. /**
  39352. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39353. * It should only be one of the following (if not the default embedded one):
  39354. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39355. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39356. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39357. * The material properties need to be setup according to the type of texture in use.
  39358. */
  39359. environmentBRDFTexture: BaseTexture;
  39360. /**
  39361. * Texture used in all pbr material as the reflection texture.
  39362. * As in the majority of the scene they are the same (exception for multi room and so on),
  39363. * this is easier to reference from here than from all the materials.
  39364. */
  39365. get environmentTexture(): Nullable<BaseTexture>;
  39366. /**
  39367. * Texture used in all pbr material as the reflection texture.
  39368. * As in the majority of the scene they are the same (exception for multi room and so on),
  39369. * this is easier to set here than in all the materials.
  39370. */
  39371. set environmentTexture(value: Nullable<BaseTexture>);
  39372. /** @hidden */
  39373. protected _environmentIntensity: number;
  39374. /**
  39375. * Intensity of the environment in all pbr material.
  39376. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39377. * As in the majority of the scene they are the same (exception for multi room and so on),
  39378. * this is easier to reference from here than from all the materials.
  39379. */
  39380. get environmentIntensity(): number;
  39381. /**
  39382. * Intensity of the environment in all pbr material.
  39383. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39384. * As in the majority of the scene they are the same (exception for multi room and so on),
  39385. * this is easier to set here than in all the materials.
  39386. */
  39387. set environmentIntensity(value: number);
  39388. /** @hidden */
  39389. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39390. /**
  39391. * Default image processing configuration used either in the rendering
  39392. * Forward main pass or through the imageProcessingPostProcess if present.
  39393. * As in the majority of the scene they are the same (exception for multi camera),
  39394. * this is easier to reference from here than from all the materials and post process.
  39395. *
  39396. * No setter as we it is a shared configuration, you can set the values instead.
  39397. */
  39398. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39399. private _forceWireframe;
  39400. /**
  39401. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39402. */
  39403. set forceWireframe(value: boolean);
  39404. get forceWireframe(): boolean;
  39405. private _skipFrustumClipping;
  39406. /**
  39407. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39408. */
  39409. set skipFrustumClipping(value: boolean);
  39410. get skipFrustumClipping(): boolean;
  39411. private _forcePointsCloud;
  39412. /**
  39413. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39414. */
  39415. set forcePointsCloud(value: boolean);
  39416. get forcePointsCloud(): boolean;
  39417. /**
  39418. * Gets or sets the active clipplane 1
  39419. */
  39420. clipPlane: Nullable<Plane>;
  39421. /**
  39422. * Gets or sets the active clipplane 2
  39423. */
  39424. clipPlane2: Nullable<Plane>;
  39425. /**
  39426. * Gets or sets the active clipplane 3
  39427. */
  39428. clipPlane3: Nullable<Plane>;
  39429. /**
  39430. * Gets or sets the active clipplane 4
  39431. */
  39432. clipPlane4: Nullable<Plane>;
  39433. /**
  39434. * Gets or sets the active clipplane 5
  39435. */
  39436. clipPlane5: Nullable<Plane>;
  39437. /**
  39438. * Gets or sets the active clipplane 6
  39439. */
  39440. clipPlane6: Nullable<Plane>;
  39441. /**
  39442. * Gets or sets a boolean indicating if animations are enabled
  39443. */
  39444. animationsEnabled: boolean;
  39445. private _animationPropertiesOverride;
  39446. /**
  39447. * Gets or sets the animation properties override
  39448. */
  39449. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39450. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39451. /**
  39452. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39453. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39454. */
  39455. useConstantAnimationDeltaTime: boolean;
  39456. /**
  39457. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39458. * Please note that it requires to run a ray cast through the scene on every frame
  39459. */
  39460. constantlyUpdateMeshUnderPointer: boolean;
  39461. /**
  39462. * Defines the HTML cursor to use when hovering over interactive elements
  39463. */
  39464. hoverCursor: string;
  39465. /**
  39466. * Defines the HTML default cursor to use (empty by default)
  39467. */
  39468. defaultCursor: string;
  39469. /**
  39470. * Defines whether cursors are handled by the scene.
  39471. */
  39472. doNotHandleCursors: boolean;
  39473. /**
  39474. * This is used to call preventDefault() on pointer down
  39475. * in order to block unwanted artifacts like system double clicks
  39476. */
  39477. preventDefaultOnPointerDown: boolean;
  39478. /**
  39479. * This is used to call preventDefault() on pointer up
  39480. * in order to block unwanted artifacts like system double clicks
  39481. */
  39482. preventDefaultOnPointerUp: boolean;
  39483. /**
  39484. * Gets or sets user defined metadata
  39485. */
  39486. metadata: any;
  39487. /**
  39488. * For internal use only. Please do not use.
  39489. */
  39490. reservedDataStore: any;
  39491. /**
  39492. * Gets the name of the plugin used to load this scene (null by default)
  39493. */
  39494. loadingPluginName: string;
  39495. /**
  39496. * Use this array to add regular expressions used to disable offline support for specific urls
  39497. */
  39498. disableOfflineSupportExceptionRules: RegExp[];
  39499. /**
  39500. * An event triggered when the scene is disposed.
  39501. */
  39502. onDisposeObservable: Observable<Scene>;
  39503. private _onDisposeObserver;
  39504. /** Sets a function to be executed when this scene is disposed. */
  39505. set onDispose(callback: () => void);
  39506. /**
  39507. * An event triggered before rendering the scene (right after animations and physics)
  39508. */
  39509. onBeforeRenderObservable: Observable<Scene>;
  39510. private _onBeforeRenderObserver;
  39511. /** Sets a function to be executed before rendering this scene */
  39512. set beforeRender(callback: Nullable<() => void>);
  39513. /**
  39514. * An event triggered after rendering the scene
  39515. */
  39516. onAfterRenderObservable: Observable<Scene>;
  39517. /**
  39518. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39519. */
  39520. onAfterRenderCameraObservable: Observable<Camera>;
  39521. private _onAfterRenderObserver;
  39522. /** Sets a function to be executed after rendering this scene */
  39523. set afterRender(callback: Nullable<() => void>);
  39524. /**
  39525. * An event triggered before animating the scene
  39526. */
  39527. onBeforeAnimationsObservable: Observable<Scene>;
  39528. /**
  39529. * An event triggered after animations processing
  39530. */
  39531. onAfterAnimationsObservable: Observable<Scene>;
  39532. /**
  39533. * An event triggered before draw calls are ready to be sent
  39534. */
  39535. onBeforeDrawPhaseObservable: Observable<Scene>;
  39536. /**
  39537. * An event triggered after draw calls have been sent
  39538. */
  39539. onAfterDrawPhaseObservable: Observable<Scene>;
  39540. /**
  39541. * An event triggered when the scene is ready
  39542. */
  39543. onReadyObservable: Observable<Scene>;
  39544. /**
  39545. * An event triggered before rendering a camera
  39546. */
  39547. onBeforeCameraRenderObservable: Observable<Camera>;
  39548. private _onBeforeCameraRenderObserver;
  39549. /** Sets a function to be executed before rendering a camera*/
  39550. set beforeCameraRender(callback: () => void);
  39551. /**
  39552. * An event triggered after rendering a camera
  39553. */
  39554. onAfterCameraRenderObservable: Observable<Camera>;
  39555. private _onAfterCameraRenderObserver;
  39556. /** Sets a function to be executed after rendering a camera*/
  39557. set afterCameraRender(callback: () => void);
  39558. /**
  39559. * An event triggered when active meshes evaluation is about to start
  39560. */
  39561. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39562. /**
  39563. * An event triggered when active meshes evaluation is done
  39564. */
  39565. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39566. /**
  39567. * An event triggered when particles rendering is about to start
  39568. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39569. */
  39570. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39571. /**
  39572. * An event triggered when particles rendering is done
  39573. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39574. */
  39575. onAfterParticlesRenderingObservable: Observable<Scene>;
  39576. /**
  39577. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39578. */
  39579. onDataLoadedObservable: Observable<Scene>;
  39580. /**
  39581. * An event triggered when a camera is created
  39582. */
  39583. onNewCameraAddedObservable: Observable<Camera>;
  39584. /**
  39585. * An event triggered when a camera is removed
  39586. */
  39587. onCameraRemovedObservable: Observable<Camera>;
  39588. /**
  39589. * An event triggered when a light is created
  39590. */
  39591. onNewLightAddedObservable: Observable<Light>;
  39592. /**
  39593. * An event triggered when a light is removed
  39594. */
  39595. onLightRemovedObservable: Observable<Light>;
  39596. /**
  39597. * An event triggered when a geometry is created
  39598. */
  39599. onNewGeometryAddedObservable: Observable<Geometry>;
  39600. /**
  39601. * An event triggered when a geometry is removed
  39602. */
  39603. onGeometryRemovedObservable: Observable<Geometry>;
  39604. /**
  39605. * An event triggered when a transform node is created
  39606. */
  39607. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39608. /**
  39609. * An event triggered when a transform node is removed
  39610. */
  39611. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39612. /**
  39613. * An event triggered when a mesh is created
  39614. */
  39615. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39616. /**
  39617. * An event triggered when a mesh is removed
  39618. */
  39619. onMeshRemovedObservable: Observable<AbstractMesh>;
  39620. /**
  39621. * An event triggered when a skeleton is created
  39622. */
  39623. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39624. /**
  39625. * An event triggered when a skeleton is removed
  39626. */
  39627. onSkeletonRemovedObservable: Observable<Skeleton>;
  39628. /**
  39629. * An event triggered when a material is created
  39630. */
  39631. onNewMaterialAddedObservable: Observable<Material>;
  39632. /**
  39633. * An event triggered when a material is removed
  39634. */
  39635. onMaterialRemovedObservable: Observable<Material>;
  39636. /**
  39637. * An event triggered when a texture is created
  39638. */
  39639. onNewTextureAddedObservable: Observable<BaseTexture>;
  39640. /**
  39641. * An event triggered when a texture is removed
  39642. */
  39643. onTextureRemovedObservable: Observable<BaseTexture>;
  39644. /**
  39645. * An event triggered when render targets are about to be rendered
  39646. * Can happen multiple times per frame.
  39647. */
  39648. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39649. /**
  39650. * An event triggered when render targets were rendered.
  39651. * Can happen multiple times per frame.
  39652. */
  39653. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39654. /**
  39655. * An event triggered before calculating deterministic simulation step
  39656. */
  39657. onBeforeStepObservable: Observable<Scene>;
  39658. /**
  39659. * An event triggered after calculating deterministic simulation step
  39660. */
  39661. onAfterStepObservable: Observable<Scene>;
  39662. /**
  39663. * An event triggered when the activeCamera property is updated
  39664. */
  39665. onActiveCameraChanged: Observable<Scene>;
  39666. /**
  39667. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39668. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39669. * 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)
  39670. */
  39671. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39672. /**
  39673. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39674. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39675. * 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)
  39676. */
  39677. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39678. /**
  39679. * This Observable will when a mesh has been imported into the scene.
  39680. */
  39681. onMeshImportedObservable: Observable<AbstractMesh>;
  39682. /**
  39683. * This Observable will when an animation file has been imported into the scene.
  39684. */
  39685. onAnimationFileImportedObservable: Observable<Scene>;
  39686. /**
  39687. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39688. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39689. */
  39690. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39691. /** @hidden */
  39692. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39693. /**
  39694. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39695. */
  39696. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39697. /**
  39698. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39699. */
  39700. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39701. /**
  39702. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39703. */
  39704. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39705. /** Callback called when a pointer move is detected */
  39706. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39707. /** Callback called when a pointer down is detected */
  39708. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39709. /** Callback called when a pointer up is detected */
  39710. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39711. /** Callback called when a pointer pick is detected */
  39712. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39713. /**
  39714. * 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).
  39715. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39716. */
  39717. onPrePointerObservable: Observable<PointerInfoPre>;
  39718. /**
  39719. * Observable event triggered each time an input event is received from the rendering canvas
  39720. */
  39721. onPointerObservable: Observable<PointerInfo>;
  39722. /**
  39723. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39724. */
  39725. get unTranslatedPointer(): Vector2;
  39726. /**
  39727. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39728. */
  39729. static get DragMovementThreshold(): number;
  39730. static set DragMovementThreshold(value: number);
  39731. /**
  39732. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39733. */
  39734. static get LongPressDelay(): number;
  39735. static set LongPressDelay(value: number);
  39736. /**
  39737. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39738. */
  39739. static get DoubleClickDelay(): number;
  39740. static set DoubleClickDelay(value: number);
  39741. /** If you need to check double click without raising a single click at first click, enable this flag */
  39742. static get ExclusiveDoubleClickMode(): boolean;
  39743. static set ExclusiveDoubleClickMode(value: boolean);
  39744. /** @hidden */
  39745. _mirroredCameraPosition: Nullable<Vector3>;
  39746. /**
  39747. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39748. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39749. */
  39750. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39751. /**
  39752. * Observable event triggered each time an keyboard event is received from the hosting window
  39753. */
  39754. onKeyboardObservable: Observable<KeyboardInfo>;
  39755. private _useRightHandedSystem;
  39756. /**
  39757. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39758. */
  39759. set useRightHandedSystem(value: boolean);
  39760. get useRightHandedSystem(): boolean;
  39761. private _timeAccumulator;
  39762. private _currentStepId;
  39763. private _currentInternalStep;
  39764. /**
  39765. * Sets the step Id used by deterministic lock step
  39766. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39767. * @param newStepId defines the step Id
  39768. */
  39769. setStepId(newStepId: number): void;
  39770. /**
  39771. * Gets the step Id used by deterministic lock step
  39772. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39773. * @returns the step Id
  39774. */
  39775. getStepId(): number;
  39776. /**
  39777. * Gets the internal step used by deterministic lock step
  39778. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39779. * @returns the internal step
  39780. */
  39781. getInternalStep(): number;
  39782. private _fogEnabled;
  39783. /**
  39784. * Gets or sets a boolean indicating if fog is enabled on this scene
  39785. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39786. * (Default is true)
  39787. */
  39788. set fogEnabled(value: boolean);
  39789. get fogEnabled(): boolean;
  39790. private _fogMode;
  39791. /**
  39792. * Gets or sets the fog mode to use
  39793. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39794. * | mode | value |
  39795. * | --- | --- |
  39796. * | FOGMODE_NONE | 0 |
  39797. * | FOGMODE_EXP | 1 |
  39798. * | FOGMODE_EXP2 | 2 |
  39799. * | FOGMODE_LINEAR | 3 |
  39800. */
  39801. set fogMode(value: number);
  39802. get fogMode(): number;
  39803. /**
  39804. * Gets or sets the fog color to use
  39805. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39806. * (Default is Color3(0.2, 0.2, 0.3))
  39807. */
  39808. fogColor: Color3;
  39809. /**
  39810. * Gets or sets the fog density to use
  39811. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39812. * (Default is 0.1)
  39813. */
  39814. fogDensity: number;
  39815. /**
  39816. * Gets or sets the fog start distance to use
  39817. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39818. * (Default is 0)
  39819. */
  39820. fogStart: number;
  39821. /**
  39822. * Gets or sets the fog end distance to use
  39823. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39824. * (Default is 1000)
  39825. */
  39826. fogEnd: number;
  39827. /**
  39828. * Flag indicating that the frame buffer binding is handled by another component
  39829. */
  39830. prePass: boolean;
  39831. private _shadowsEnabled;
  39832. /**
  39833. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39834. */
  39835. set shadowsEnabled(value: boolean);
  39836. get shadowsEnabled(): boolean;
  39837. private _lightsEnabled;
  39838. /**
  39839. * Gets or sets a boolean indicating if lights are enabled on this scene
  39840. */
  39841. set lightsEnabled(value: boolean);
  39842. get lightsEnabled(): boolean;
  39843. /** All of the active cameras added to this scene. */
  39844. activeCameras: Camera[];
  39845. /** @hidden */
  39846. _activeCamera: Nullable<Camera>;
  39847. /** Gets or sets the current active camera */
  39848. get activeCamera(): Nullable<Camera>;
  39849. set activeCamera(value: Nullable<Camera>);
  39850. private _defaultMaterial;
  39851. /** The default material used on meshes when no material is affected */
  39852. get defaultMaterial(): Material;
  39853. /** The default material used on meshes when no material is affected */
  39854. set defaultMaterial(value: Material);
  39855. private _texturesEnabled;
  39856. /**
  39857. * Gets or sets a boolean indicating if textures are enabled on this scene
  39858. */
  39859. set texturesEnabled(value: boolean);
  39860. get texturesEnabled(): boolean;
  39861. /**
  39862. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39863. */
  39864. physicsEnabled: boolean;
  39865. /**
  39866. * Gets or sets a boolean indicating if particles are enabled on this scene
  39867. */
  39868. particlesEnabled: boolean;
  39869. /**
  39870. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39871. */
  39872. spritesEnabled: boolean;
  39873. private _skeletonsEnabled;
  39874. /**
  39875. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39876. */
  39877. set skeletonsEnabled(value: boolean);
  39878. get skeletonsEnabled(): boolean;
  39879. /**
  39880. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39881. */
  39882. lensFlaresEnabled: boolean;
  39883. /**
  39884. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39885. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39886. */
  39887. collisionsEnabled: boolean;
  39888. private _collisionCoordinator;
  39889. /** @hidden */
  39890. get collisionCoordinator(): ICollisionCoordinator;
  39891. /**
  39892. * Defines the gravity applied to this scene (used only for collisions)
  39893. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39894. */
  39895. gravity: Vector3;
  39896. /**
  39897. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39898. */
  39899. postProcessesEnabled: boolean;
  39900. /**
  39901. * Gets the current postprocess manager
  39902. */
  39903. postProcessManager: PostProcessManager;
  39904. /**
  39905. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39906. */
  39907. renderTargetsEnabled: boolean;
  39908. /**
  39909. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39910. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39911. */
  39912. dumpNextRenderTargets: boolean;
  39913. /**
  39914. * The list of user defined render targets added to the scene
  39915. */
  39916. customRenderTargets: RenderTargetTexture[];
  39917. /**
  39918. * Defines if texture loading must be delayed
  39919. * If true, textures will only be loaded when they need to be rendered
  39920. */
  39921. useDelayedTextureLoading: boolean;
  39922. /**
  39923. * Gets the list of meshes imported to the scene through SceneLoader
  39924. */
  39925. importedMeshesFiles: String[];
  39926. /**
  39927. * Gets or sets a boolean indicating if probes are enabled on this scene
  39928. */
  39929. probesEnabled: boolean;
  39930. /**
  39931. * Gets or sets the current offline provider to use to store scene data
  39932. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39933. */
  39934. offlineProvider: IOfflineProvider;
  39935. /**
  39936. * Gets or sets the action manager associated with the scene
  39937. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39938. */
  39939. actionManager: AbstractActionManager;
  39940. private _meshesForIntersections;
  39941. /**
  39942. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39943. */
  39944. proceduralTexturesEnabled: boolean;
  39945. private _engine;
  39946. private _totalVertices;
  39947. /** @hidden */
  39948. _activeIndices: PerfCounter;
  39949. /** @hidden */
  39950. _activeParticles: PerfCounter;
  39951. /** @hidden */
  39952. _activeBones: PerfCounter;
  39953. private _animationRatio;
  39954. /** @hidden */
  39955. _animationTimeLast: number;
  39956. /** @hidden */
  39957. _animationTime: number;
  39958. /**
  39959. * Gets or sets a general scale for animation speed
  39960. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39961. */
  39962. animationTimeScale: number;
  39963. /** @hidden */
  39964. _cachedMaterial: Nullable<Material>;
  39965. /** @hidden */
  39966. _cachedEffect: Nullable<Effect>;
  39967. /** @hidden */
  39968. _cachedVisibility: Nullable<number>;
  39969. private _renderId;
  39970. private _frameId;
  39971. private _executeWhenReadyTimeoutId;
  39972. private _intermediateRendering;
  39973. private _viewUpdateFlag;
  39974. private _projectionUpdateFlag;
  39975. /** @hidden */
  39976. _toBeDisposed: Nullable<IDisposable>[];
  39977. private _activeRequests;
  39978. /** @hidden */
  39979. _pendingData: any[];
  39980. private _isDisposed;
  39981. /**
  39982. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39983. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39984. */
  39985. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39986. private _activeMeshes;
  39987. private _processedMaterials;
  39988. private _renderTargets;
  39989. /** @hidden */
  39990. _activeParticleSystems: SmartArray<IParticleSystem>;
  39991. private _activeSkeletons;
  39992. private _softwareSkinnedMeshes;
  39993. private _renderingManager;
  39994. /** @hidden */
  39995. _activeAnimatables: Animatable[];
  39996. private _transformMatrix;
  39997. private _sceneUbo;
  39998. /** @hidden */
  39999. _viewMatrix: Matrix;
  40000. private _projectionMatrix;
  40001. /** @hidden */
  40002. _forcedViewPosition: Nullable<Vector3>;
  40003. /** @hidden */
  40004. _frustumPlanes: Plane[];
  40005. /**
  40006. * Gets the list of frustum planes (built from the active camera)
  40007. */
  40008. get frustumPlanes(): Plane[];
  40009. /**
  40010. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40011. * This is useful if there are more lights that the maximum simulteanous authorized
  40012. */
  40013. requireLightSorting: boolean;
  40014. /** @hidden */
  40015. readonly useMaterialMeshMap: boolean;
  40016. /** @hidden */
  40017. readonly useClonedMeshMap: boolean;
  40018. private _externalData;
  40019. private _uid;
  40020. /**
  40021. * @hidden
  40022. * Backing store of defined scene components.
  40023. */
  40024. _components: ISceneComponent[];
  40025. /**
  40026. * @hidden
  40027. * Backing store of defined scene components.
  40028. */
  40029. _serializableComponents: ISceneSerializableComponent[];
  40030. /**
  40031. * List of components to register on the next registration step.
  40032. */
  40033. private _transientComponents;
  40034. /**
  40035. * Registers the transient components if needed.
  40036. */
  40037. private _registerTransientComponents;
  40038. /**
  40039. * @hidden
  40040. * Add a component to the scene.
  40041. * Note that the ccomponent could be registered on th next frame if this is called after
  40042. * the register component stage.
  40043. * @param component Defines the component to add to the scene
  40044. */
  40045. _addComponent(component: ISceneComponent): void;
  40046. /**
  40047. * @hidden
  40048. * Gets a component from the scene.
  40049. * @param name defines the name of the component to retrieve
  40050. * @returns the component or null if not present
  40051. */
  40052. _getComponent(name: string): Nullable<ISceneComponent>;
  40053. /**
  40054. * @hidden
  40055. * Defines the actions happening before camera updates.
  40056. */
  40057. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40058. /**
  40059. * @hidden
  40060. * Defines the actions happening before clear the canvas.
  40061. */
  40062. _beforeClearStage: Stage<SimpleStageAction>;
  40063. /**
  40064. * @hidden
  40065. * Defines the actions when collecting render targets for the frame.
  40066. */
  40067. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40068. /**
  40069. * @hidden
  40070. * Defines the actions happening for one camera in the frame.
  40071. */
  40072. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40073. /**
  40074. * @hidden
  40075. * Defines the actions happening during the per mesh ready checks.
  40076. */
  40077. _isReadyForMeshStage: Stage<MeshStageAction>;
  40078. /**
  40079. * @hidden
  40080. * Defines the actions happening before evaluate active mesh checks.
  40081. */
  40082. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40083. /**
  40084. * @hidden
  40085. * Defines the actions happening during the evaluate sub mesh checks.
  40086. */
  40087. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40088. /**
  40089. * @hidden
  40090. * Defines the actions happening during the active mesh stage.
  40091. */
  40092. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40093. /**
  40094. * @hidden
  40095. * Defines the actions happening during the per camera render target step.
  40096. */
  40097. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40098. /**
  40099. * @hidden
  40100. * Defines the actions happening just before the active camera is drawing.
  40101. */
  40102. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40103. /**
  40104. * @hidden
  40105. * Defines the actions happening just before a render target is drawing.
  40106. */
  40107. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40108. /**
  40109. * @hidden
  40110. * Defines the actions happening just before a rendering group is drawing.
  40111. */
  40112. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40113. /**
  40114. * @hidden
  40115. * Defines the actions happening just before a mesh is drawing.
  40116. */
  40117. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40118. /**
  40119. * @hidden
  40120. * Defines the actions happening just after a mesh has been drawn.
  40121. */
  40122. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40123. /**
  40124. * @hidden
  40125. * Defines the actions happening just after a rendering group has been drawn.
  40126. */
  40127. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40128. /**
  40129. * @hidden
  40130. * Defines the actions happening just after the active camera has been drawn.
  40131. */
  40132. _afterCameraDrawStage: Stage<CameraStageAction>;
  40133. /**
  40134. * @hidden
  40135. * Defines the actions happening just after a render target has been drawn.
  40136. */
  40137. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40138. /**
  40139. * @hidden
  40140. * Defines the actions happening just after rendering all cameras and computing intersections.
  40141. */
  40142. _afterRenderStage: Stage<SimpleStageAction>;
  40143. /**
  40144. * @hidden
  40145. * Defines the actions happening when a pointer move event happens.
  40146. */
  40147. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40148. /**
  40149. * @hidden
  40150. * Defines the actions happening when a pointer down event happens.
  40151. */
  40152. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40153. /**
  40154. * @hidden
  40155. * Defines the actions happening when a pointer up event happens.
  40156. */
  40157. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40158. /**
  40159. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40160. */
  40161. private geometriesByUniqueId;
  40162. /**
  40163. * Creates a new Scene
  40164. * @param engine defines the engine to use to render this scene
  40165. * @param options defines the scene options
  40166. */
  40167. constructor(engine: Engine, options?: SceneOptions);
  40168. /**
  40169. * Gets a string identifying the name of the class
  40170. * @returns "Scene" string
  40171. */
  40172. getClassName(): string;
  40173. private _defaultMeshCandidates;
  40174. /**
  40175. * @hidden
  40176. */
  40177. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40178. private _defaultSubMeshCandidates;
  40179. /**
  40180. * @hidden
  40181. */
  40182. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40183. /**
  40184. * Sets the default candidate providers for the scene.
  40185. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40186. * and getCollidingSubMeshCandidates to their default function
  40187. */
  40188. setDefaultCandidateProviders(): void;
  40189. /**
  40190. * Gets the mesh that is currently under the pointer
  40191. */
  40192. get meshUnderPointer(): Nullable<AbstractMesh>;
  40193. /**
  40194. * Gets or sets the current on-screen X position of the pointer
  40195. */
  40196. get pointerX(): number;
  40197. set pointerX(value: number);
  40198. /**
  40199. * Gets or sets the current on-screen Y position of the pointer
  40200. */
  40201. get pointerY(): number;
  40202. set pointerY(value: number);
  40203. /**
  40204. * Gets the cached material (ie. the latest rendered one)
  40205. * @returns the cached material
  40206. */
  40207. getCachedMaterial(): Nullable<Material>;
  40208. /**
  40209. * Gets the cached effect (ie. the latest rendered one)
  40210. * @returns the cached effect
  40211. */
  40212. getCachedEffect(): Nullable<Effect>;
  40213. /**
  40214. * Gets the cached visibility state (ie. the latest rendered one)
  40215. * @returns the cached visibility state
  40216. */
  40217. getCachedVisibility(): Nullable<number>;
  40218. /**
  40219. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40220. * @param material defines the current material
  40221. * @param effect defines the current effect
  40222. * @param visibility defines the current visibility state
  40223. * @returns true if one parameter is not cached
  40224. */
  40225. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40226. /**
  40227. * Gets the engine associated with the scene
  40228. * @returns an Engine
  40229. */
  40230. getEngine(): Engine;
  40231. /**
  40232. * Gets the total number of vertices rendered per frame
  40233. * @returns the total number of vertices rendered per frame
  40234. */
  40235. getTotalVertices(): number;
  40236. /**
  40237. * Gets the performance counter for total vertices
  40238. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40239. */
  40240. get totalVerticesPerfCounter(): PerfCounter;
  40241. /**
  40242. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40243. * @returns the total number of active indices rendered per frame
  40244. */
  40245. getActiveIndices(): number;
  40246. /**
  40247. * Gets the performance counter for active indices
  40248. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40249. */
  40250. get totalActiveIndicesPerfCounter(): PerfCounter;
  40251. /**
  40252. * Gets the total number of active particles rendered per frame
  40253. * @returns the total number of active particles rendered per frame
  40254. */
  40255. getActiveParticles(): number;
  40256. /**
  40257. * Gets the performance counter for active particles
  40258. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40259. */
  40260. get activeParticlesPerfCounter(): PerfCounter;
  40261. /**
  40262. * Gets the total number of active bones rendered per frame
  40263. * @returns the total number of active bones rendered per frame
  40264. */
  40265. getActiveBones(): number;
  40266. /**
  40267. * Gets the performance counter for active bones
  40268. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40269. */
  40270. get activeBonesPerfCounter(): PerfCounter;
  40271. /**
  40272. * Gets the array of active meshes
  40273. * @returns an array of AbstractMesh
  40274. */
  40275. getActiveMeshes(): SmartArray<AbstractMesh>;
  40276. /**
  40277. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40278. * @returns a number
  40279. */
  40280. getAnimationRatio(): number;
  40281. /**
  40282. * Gets an unique Id for the current render phase
  40283. * @returns a number
  40284. */
  40285. getRenderId(): number;
  40286. /**
  40287. * Gets an unique Id for the current frame
  40288. * @returns a number
  40289. */
  40290. getFrameId(): number;
  40291. /** Call this function if you want to manually increment the render Id*/
  40292. incrementRenderId(): void;
  40293. private _createUbo;
  40294. /**
  40295. * Use this method to simulate a pointer move on a mesh
  40296. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40297. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40298. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40299. * @returns the current scene
  40300. */
  40301. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40302. /**
  40303. * Use this method to simulate a pointer down on a mesh
  40304. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40305. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40306. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40307. * @returns the current scene
  40308. */
  40309. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40310. /**
  40311. * Use this method to simulate a pointer up on a mesh
  40312. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40313. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40314. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40315. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40316. * @returns the current scene
  40317. */
  40318. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40319. /**
  40320. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40321. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40322. * @returns true if the pointer was captured
  40323. */
  40324. isPointerCaptured(pointerId?: number): boolean;
  40325. /**
  40326. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40327. * @param attachUp defines if you want to attach events to pointerup
  40328. * @param attachDown defines if you want to attach events to pointerdown
  40329. * @param attachMove defines if you want to attach events to pointermove
  40330. */
  40331. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40332. /** Detaches all event handlers*/
  40333. detachControl(): void;
  40334. /**
  40335. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40336. * Delay loaded resources are not taking in account
  40337. * @return true if all required resources are ready
  40338. */
  40339. isReady(): boolean;
  40340. /** Resets all cached information relative to material (including effect and visibility) */
  40341. resetCachedMaterial(): void;
  40342. /**
  40343. * Registers a function to be called before every frame render
  40344. * @param func defines the function to register
  40345. */
  40346. registerBeforeRender(func: () => void): void;
  40347. /**
  40348. * Unregisters a function called before every frame render
  40349. * @param func defines the function to unregister
  40350. */
  40351. unregisterBeforeRender(func: () => void): void;
  40352. /**
  40353. * Registers a function to be called after every frame render
  40354. * @param func defines the function to register
  40355. */
  40356. registerAfterRender(func: () => void): void;
  40357. /**
  40358. * Unregisters a function called after every frame render
  40359. * @param func defines the function to unregister
  40360. */
  40361. unregisterAfterRender(func: () => void): void;
  40362. private _executeOnceBeforeRender;
  40363. /**
  40364. * The provided function will run before render once and will be disposed afterwards.
  40365. * A timeout delay can be provided so that the function will be executed in N ms.
  40366. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40367. * @param func The function to be executed.
  40368. * @param timeout optional delay in ms
  40369. */
  40370. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40371. /** @hidden */
  40372. _addPendingData(data: any): void;
  40373. /** @hidden */
  40374. _removePendingData(data: any): void;
  40375. /**
  40376. * Returns the number of items waiting to be loaded
  40377. * @returns the number of items waiting to be loaded
  40378. */
  40379. getWaitingItemsCount(): number;
  40380. /**
  40381. * Returns a boolean indicating if the scene is still loading data
  40382. */
  40383. get isLoading(): boolean;
  40384. /**
  40385. * Registers a function to be executed when the scene is ready
  40386. * @param {Function} func - the function to be executed
  40387. */
  40388. executeWhenReady(func: () => void): void;
  40389. /**
  40390. * Returns a promise that resolves when the scene is ready
  40391. * @returns A promise that resolves when the scene is ready
  40392. */
  40393. whenReadyAsync(): Promise<void>;
  40394. /** @hidden */
  40395. _checkIsReady(): void;
  40396. /**
  40397. * Gets all animatable attached to the scene
  40398. */
  40399. get animatables(): Animatable[];
  40400. /**
  40401. * Resets the last animation time frame.
  40402. * Useful to override when animations start running when loading a scene for the first time.
  40403. */
  40404. resetLastAnimationTimeFrame(): void;
  40405. /**
  40406. * Gets the current view matrix
  40407. * @returns a Matrix
  40408. */
  40409. getViewMatrix(): Matrix;
  40410. /**
  40411. * Gets the current projection matrix
  40412. * @returns a Matrix
  40413. */
  40414. getProjectionMatrix(): Matrix;
  40415. /**
  40416. * Gets the current transform matrix
  40417. * @returns a Matrix made of View * Projection
  40418. */
  40419. getTransformMatrix(): Matrix;
  40420. /**
  40421. * Sets the current transform matrix
  40422. * @param viewL defines the View matrix to use
  40423. * @param projectionL defines the Projection matrix to use
  40424. * @param viewR defines the right View matrix to use (if provided)
  40425. * @param projectionR defines the right Projection matrix to use (if provided)
  40426. */
  40427. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40428. /**
  40429. * Gets the uniform buffer used to store scene data
  40430. * @returns a UniformBuffer
  40431. */
  40432. getSceneUniformBuffer(): UniformBuffer;
  40433. /**
  40434. * Gets an unique (relatively to the current scene) Id
  40435. * @returns an unique number for the scene
  40436. */
  40437. getUniqueId(): number;
  40438. /**
  40439. * Add a mesh to the list of scene's meshes
  40440. * @param newMesh defines the mesh to add
  40441. * @param recursive if all child meshes should also be added to the scene
  40442. */
  40443. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40444. /**
  40445. * Remove a mesh for the list of scene's meshes
  40446. * @param toRemove defines the mesh to remove
  40447. * @param recursive if all child meshes should also be removed from the scene
  40448. * @returns the index where the mesh was in the mesh list
  40449. */
  40450. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40451. /**
  40452. * Add a transform node to the list of scene's transform nodes
  40453. * @param newTransformNode defines the transform node to add
  40454. */
  40455. addTransformNode(newTransformNode: TransformNode): void;
  40456. /**
  40457. * Remove a transform node for the list of scene's transform nodes
  40458. * @param toRemove defines the transform node to remove
  40459. * @returns the index where the transform node was in the transform node list
  40460. */
  40461. removeTransformNode(toRemove: TransformNode): number;
  40462. /**
  40463. * Remove a skeleton for the list of scene's skeletons
  40464. * @param toRemove defines the skeleton to remove
  40465. * @returns the index where the skeleton was in the skeleton list
  40466. */
  40467. removeSkeleton(toRemove: Skeleton): number;
  40468. /**
  40469. * Remove a morph target for the list of scene's morph targets
  40470. * @param toRemove defines the morph target to remove
  40471. * @returns the index where the morph target was in the morph target list
  40472. */
  40473. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40474. /**
  40475. * Remove a light for the list of scene's lights
  40476. * @param toRemove defines the light to remove
  40477. * @returns the index where the light was in the light list
  40478. */
  40479. removeLight(toRemove: Light): number;
  40480. /**
  40481. * Remove a camera for the list of scene's cameras
  40482. * @param toRemove defines the camera to remove
  40483. * @returns the index where the camera was in the camera list
  40484. */
  40485. removeCamera(toRemove: Camera): number;
  40486. /**
  40487. * Remove a particle system for the list of scene's particle systems
  40488. * @param toRemove defines the particle system to remove
  40489. * @returns the index where the particle system was in the particle system list
  40490. */
  40491. removeParticleSystem(toRemove: IParticleSystem): number;
  40492. /**
  40493. * Remove a animation for the list of scene's animations
  40494. * @param toRemove defines the animation to remove
  40495. * @returns the index where the animation was in the animation list
  40496. */
  40497. removeAnimation(toRemove: Animation): number;
  40498. /**
  40499. * Will stop the animation of the given target
  40500. * @param target - the target
  40501. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40502. * @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)
  40503. */
  40504. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40505. /**
  40506. * Removes the given animation group from this scene.
  40507. * @param toRemove The animation group to remove
  40508. * @returns The index of the removed animation group
  40509. */
  40510. removeAnimationGroup(toRemove: AnimationGroup): number;
  40511. /**
  40512. * Removes the given multi-material from this scene.
  40513. * @param toRemove The multi-material to remove
  40514. * @returns The index of the removed multi-material
  40515. */
  40516. removeMultiMaterial(toRemove: MultiMaterial): number;
  40517. /**
  40518. * Removes the given material from this scene.
  40519. * @param toRemove The material to remove
  40520. * @returns The index of the removed material
  40521. */
  40522. removeMaterial(toRemove: Material): number;
  40523. /**
  40524. * Removes the given action manager from this scene.
  40525. * @param toRemove The action manager to remove
  40526. * @returns The index of the removed action manager
  40527. */
  40528. removeActionManager(toRemove: AbstractActionManager): number;
  40529. /**
  40530. * Removes the given texture from this scene.
  40531. * @param toRemove The texture to remove
  40532. * @returns The index of the removed texture
  40533. */
  40534. removeTexture(toRemove: BaseTexture): number;
  40535. /**
  40536. * Adds the given light to this scene
  40537. * @param newLight The light to add
  40538. */
  40539. addLight(newLight: Light): void;
  40540. /**
  40541. * Sorts the list list based on light priorities
  40542. */
  40543. sortLightsByPriority(): void;
  40544. /**
  40545. * Adds the given camera to this scene
  40546. * @param newCamera The camera to add
  40547. */
  40548. addCamera(newCamera: Camera): void;
  40549. /**
  40550. * Adds the given skeleton to this scene
  40551. * @param newSkeleton The skeleton to add
  40552. */
  40553. addSkeleton(newSkeleton: Skeleton): void;
  40554. /**
  40555. * Adds the given particle system to this scene
  40556. * @param newParticleSystem The particle system to add
  40557. */
  40558. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40559. /**
  40560. * Adds the given animation to this scene
  40561. * @param newAnimation The animation to add
  40562. */
  40563. addAnimation(newAnimation: Animation): void;
  40564. /**
  40565. * Adds the given animation group to this scene.
  40566. * @param newAnimationGroup The animation group to add
  40567. */
  40568. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40569. /**
  40570. * Adds the given multi-material to this scene
  40571. * @param newMultiMaterial The multi-material to add
  40572. */
  40573. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40574. /**
  40575. * Adds the given material to this scene
  40576. * @param newMaterial The material to add
  40577. */
  40578. addMaterial(newMaterial: Material): void;
  40579. /**
  40580. * Adds the given morph target to this scene
  40581. * @param newMorphTargetManager The morph target to add
  40582. */
  40583. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40584. /**
  40585. * Adds the given geometry to this scene
  40586. * @param newGeometry The geometry to add
  40587. */
  40588. addGeometry(newGeometry: Geometry): void;
  40589. /**
  40590. * Adds the given action manager to this scene
  40591. * @param newActionManager The action manager to add
  40592. */
  40593. addActionManager(newActionManager: AbstractActionManager): void;
  40594. /**
  40595. * Adds the given texture to this scene.
  40596. * @param newTexture The texture to add
  40597. */
  40598. addTexture(newTexture: BaseTexture): void;
  40599. /**
  40600. * Switch active camera
  40601. * @param newCamera defines the new active camera
  40602. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40603. */
  40604. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40605. /**
  40606. * sets the active camera of the scene using its ID
  40607. * @param id defines the camera's ID
  40608. * @return the new active camera or null if none found.
  40609. */
  40610. setActiveCameraByID(id: string): Nullable<Camera>;
  40611. /**
  40612. * sets the active camera of the scene using its name
  40613. * @param name defines the camera's name
  40614. * @returns the new active camera or null if none found.
  40615. */
  40616. setActiveCameraByName(name: string): Nullable<Camera>;
  40617. /**
  40618. * get an animation group using its name
  40619. * @param name defines the material's name
  40620. * @return the animation group or null if none found.
  40621. */
  40622. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40623. /**
  40624. * Get a material using its unique id
  40625. * @param uniqueId defines the material's unique id
  40626. * @return the material or null if none found.
  40627. */
  40628. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40629. /**
  40630. * get a material using its id
  40631. * @param id defines the material's ID
  40632. * @return the material or null if none found.
  40633. */
  40634. getMaterialByID(id: string): Nullable<Material>;
  40635. /**
  40636. * Gets a the last added material using a given id
  40637. * @param id defines the material's ID
  40638. * @return the last material with the given id or null if none found.
  40639. */
  40640. getLastMaterialByID(id: string): Nullable<Material>;
  40641. /**
  40642. * Gets a material using its name
  40643. * @param name defines the material's name
  40644. * @return the material or null if none found.
  40645. */
  40646. getMaterialByName(name: string): Nullable<Material>;
  40647. /**
  40648. * Get a texture using its unique id
  40649. * @param uniqueId defines the texture's unique id
  40650. * @return the texture or null if none found.
  40651. */
  40652. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40653. /**
  40654. * Gets a camera using its id
  40655. * @param id defines the id to look for
  40656. * @returns the camera or null if not found
  40657. */
  40658. getCameraByID(id: string): Nullable<Camera>;
  40659. /**
  40660. * Gets a camera using its unique id
  40661. * @param uniqueId defines the unique id to look for
  40662. * @returns the camera or null if not found
  40663. */
  40664. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40665. /**
  40666. * Gets a camera using its name
  40667. * @param name defines the camera's name
  40668. * @return the camera or null if none found.
  40669. */
  40670. getCameraByName(name: string): Nullable<Camera>;
  40671. /**
  40672. * Gets a bone using its id
  40673. * @param id defines the bone's id
  40674. * @return the bone or null if not found
  40675. */
  40676. getBoneByID(id: string): Nullable<Bone>;
  40677. /**
  40678. * Gets a bone using its id
  40679. * @param name defines the bone's name
  40680. * @return the bone or null if not found
  40681. */
  40682. getBoneByName(name: string): Nullable<Bone>;
  40683. /**
  40684. * Gets a light node using its name
  40685. * @param name defines the the light's name
  40686. * @return the light or null if none found.
  40687. */
  40688. getLightByName(name: string): Nullable<Light>;
  40689. /**
  40690. * Gets a light node using its id
  40691. * @param id defines the light's id
  40692. * @return the light or null if none found.
  40693. */
  40694. getLightByID(id: string): Nullable<Light>;
  40695. /**
  40696. * Gets a light node using its scene-generated unique ID
  40697. * @param uniqueId defines the light's unique id
  40698. * @return the light or null if none found.
  40699. */
  40700. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40701. /**
  40702. * Gets a particle system by id
  40703. * @param id defines the particle system id
  40704. * @return the corresponding system or null if none found
  40705. */
  40706. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40707. /**
  40708. * Gets a geometry using its ID
  40709. * @param id defines the geometry's id
  40710. * @return the geometry or null if none found.
  40711. */
  40712. getGeometryByID(id: string): Nullable<Geometry>;
  40713. private _getGeometryByUniqueID;
  40714. /**
  40715. * Add a new geometry to this scene
  40716. * @param geometry defines the geometry to be added to the scene.
  40717. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40718. * @return a boolean defining if the geometry was added or not
  40719. */
  40720. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40721. /**
  40722. * Removes an existing geometry
  40723. * @param geometry defines the geometry to be removed from the scene
  40724. * @return a boolean defining if the geometry was removed or not
  40725. */
  40726. removeGeometry(geometry: Geometry): boolean;
  40727. /**
  40728. * Gets the list of geometries attached to the scene
  40729. * @returns an array of Geometry
  40730. */
  40731. getGeometries(): Geometry[];
  40732. /**
  40733. * Gets the first added mesh found of a given ID
  40734. * @param id defines the id to search for
  40735. * @return the mesh found or null if not found at all
  40736. */
  40737. getMeshByID(id: string): Nullable<AbstractMesh>;
  40738. /**
  40739. * Gets a list of meshes using their id
  40740. * @param id defines the id to search for
  40741. * @returns a list of meshes
  40742. */
  40743. getMeshesByID(id: string): Array<AbstractMesh>;
  40744. /**
  40745. * Gets the first added transform node found of a given ID
  40746. * @param id defines the id to search for
  40747. * @return the found transform node or null if not found at all.
  40748. */
  40749. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40750. /**
  40751. * Gets a transform node with its auto-generated unique id
  40752. * @param uniqueId efines the unique id to search for
  40753. * @return the found transform node or null if not found at all.
  40754. */
  40755. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40756. /**
  40757. * Gets a list of transform nodes using their id
  40758. * @param id defines the id to search for
  40759. * @returns a list of transform nodes
  40760. */
  40761. getTransformNodesByID(id: string): Array<TransformNode>;
  40762. /**
  40763. * Gets a mesh with its auto-generated unique id
  40764. * @param uniqueId defines the unique id to search for
  40765. * @return the found mesh or null if not found at all.
  40766. */
  40767. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40768. /**
  40769. * Gets a the last added mesh using a given id
  40770. * @param id defines the id to search for
  40771. * @return the found mesh or null if not found at all.
  40772. */
  40773. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40774. /**
  40775. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40776. * @param id defines the id to search for
  40777. * @return the found node or null if not found at all
  40778. */
  40779. getLastEntryByID(id: string): Nullable<Node>;
  40780. /**
  40781. * Gets a node (Mesh, Camera, Light) using a given id
  40782. * @param id defines the id to search for
  40783. * @return the found node or null if not found at all
  40784. */
  40785. getNodeByID(id: string): Nullable<Node>;
  40786. /**
  40787. * Gets a node (Mesh, Camera, Light) using a given name
  40788. * @param name defines the name to search for
  40789. * @return the found node or null if not found at all.
  40790. */
  40791. getNodeByName(name: string): Nullable<Node>;
  40792. /**
  40793. * Gets a mesh using a given name
  40794. * @param name defines the name to search for
  40795. * @return the found mesh or null if not found at all.
  40796. */
  40797. getMeshByName(name: string): Nullable<AbstractMesh>;
  40798. /**
  40799. * Gets a transform node using a given name
  40800. * @param name defines the name to search for
  40801. * @return the found transform node or null if not found at all.
  40802. */
  40803. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40804. /**
  40805. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40806. * @param id defines the id to search for
  40807. * @return the found skeleton or null if not found at all.
  40808. */
  40809. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40810. /**
  40811. * Gets a skeleton using a given auto generated unique id
  40812. * @param uniqueId defines the unique id to search for
  40813. * @return the found skeleton or null if not found at all.
  40814. */
  40815. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40816. /**
  40817. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40818. * @param id defines the id to search for
  40819. * @return the found skeleton or null if not found at all.
  40820. */
  40821. getSkeletonById(id: string): Nullable<Skeleton>;
  40822. /**
  40823. * Gets a skeleton using a given name
  40824. * @param name defines the name to search for
  40825. * @return the found skeleton or null if not found at all.
  40826. */
  40827. getSkeletonByName(name: string): Nullable<Skeleton>;
  40828. /**
  40829. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40830. * @param id defines the id to search for
  40831. * @return the found morph target manager or null if not found at all.
  40832. */
  40833. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40834. /**
  40835. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40836. * @param id defines the id to search for
  40837. * @return the found morph target or null if not found at all.
  40838. */
  40839. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40840. /**
  40841. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40842. * @param name defines the name to search for
  40843. * @return the found morph target or null if not found at all.
  40844. */
  40845. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40846. /**
  40847. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40848. * @param name defines the name to search for
  40849. * @return the found post process or null if not found at all.
  40850. */
  40851. getPostProcessByName(name: string): Nullable<PostProcess>;
  40852. /**
  40853. * Gets a boolean indicating if the given mesh is active
  40854. * @param mesh defines the mesh to look for
  40855. * @returns true if the mesh is in the active list
  40856. */
  40857. isActiveMesh(mesh: AbstractMesh): boolean;
  40858. /**
  40859. * Return a unique id as a string which can serve as an identifier for the scene
  40860. */
  40861. get uid(): string;
  40862. /**
  40863. * Add an externaly attached data from its key.
  40864. * This method call will fail and return false, if such key already exists.
  40865. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40866. * @param key the unique key that identifies the data
  40867. * @param data the data object to associate to the key for this Engine instance
  40868. * @return true if no such key were already present and the data was added successfully, false otherwise
  40869. */
  40870. addExternalData<T>(key: string, data: T): boolean;
  40871. /**
  40872. * Get an externaly attached data from its key
  40873. * @param key the unique key that identifies the data
  40874. * @return the associated data, if present (can be null), or undefined if not present
  40875. */
  40876. getExternalData<T>(key: string): Nullable<T>;
  40877. /**
  40878. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40879. * @param key the unique key that identifies the data
  40880. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40881. * @return the associated data, can be null if the factory returned null.
  40882. */
  40883. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40884. /**
  40885. * Remove an externaly attached data from the Engine instance
  40886. * @param key the unique key that identifies the data
  40887. * @return true if the data was successfully removed, false if it doesn't exist
  40888. */
  40889. removeExternalData(key: string): boolean;
  40890. private _evaluateSubMesh;
  40891. /**
  40892. * Clear the processed materials smart array preventing retention point in material dispose.
  40893. */
  40894. freeProcessedMaterials(): void;
  40895. private _preventFreeActiveMeshesAndRenderingGroups;
  40896. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40897. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40898. * when disposing several meshes in a row or a hierarchy of meshes.
  40899. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40900. */
  40901. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40902. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40903. /**
  40904. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40905. */
  40906. freeActiveMeshes(): void;
  40907. /**
  40908. * Clear the info related to rendering groups preventing retention points during dispose.
  40909. */
  40910. freeRenderingGroups(): void;
  40911. /** @hidden */
  40912. _isInIntermediateRendering(): boolean;
  40913. /**
  40914. * Lambda returning the list of potentially active meshes.
  40915. */
  40916. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40917. /**
  40918. * Lambda returning the list of potentially active sub meshes.
  40919. */
  40920. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40921. /**
  40922. * Lambda returning the list of potentially intersecting sub meshes.
  40923. */
  40924. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40925. /**
  40926. * Lambda returning the list of potentially colliding sub meshes.
  40927. */
  40928. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40929. private _activeMeshesFrozen;
  40930. private _skipEvaluateActiveMeshesCompletely;
  40931. /**
  40932. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40933. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40934. * @returns the current scene
  40935. */
  40936. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40937. /**
  40938. * Use this function to restart evaluating active meshes on every frame
  40939. * @returns the current scene
  40940. */
  40941. unfreezeActiveMeshes(): Scene;
  40942. private _evaluateActiveMeshes;
  40943. private _activeMesh;
  40944. /**
  40945. * Update the transform matrix to update from the current active camera
  40946. * @param force defines a boolean used to force the update even if cache is up to date
  40947. */
  40948. updateTransformMatrix(force?: boolean): void;
  40949. private _bindFrameBuffer;
  40950. /** @hidden */
  40951. _allowPostProcessClearColor: boolean;
  40952. /** @hidden */
  40953. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40954. private _processSubCameras;
  40955. private _checkIntersections;
  40956. /** @hidden */
  40957. _advancePhysicsEngineStep(step: number): void;
  40958. /**
  40959. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40960. */
  40961. getDeterministicFrameTime: () => number;
  40962. /** @hidden */
  40963. _animate(): void;
  40964. /** Execute all animations (for a frame) */
  40965. animate(): void;
  40966. /**
  40967. * Render the scene
  40968. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40969. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40970. */
  40971. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40972. /**
  40973. * Freeze all materials
  40974. * A frozen material will not be updatable but should be faster to render
  40975. */
  40976. freezeMaterials(): void;
  40977. /**
  40978. * Unfreeze all materials
  40979. * A frozen material will not be updatable but should be faster to render
  40980. */
  40981. unfreezeMaterials(): void;
  40982. /**
  40983. * Releases all held ressources
  40984. */
  40985. dispose(): void;
  40986. /**
  40987. * Gets if the scene is already disposed
  40988. */
  40989. get isDisposed(): boolean;
  40990. /**
  40991. * Call this function to reduce memory footprint of the scene.
  40992. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40993. */
  40994. clearCachedVertexData(): void;
  40995. /**
  40996. * This function will remove the local cached buffer data from texture.
  40997. * It will save memory but will prevent the texture from being rebuilt
  40998. */
  40999. cleanCachedTextureBuffer(): void;
  41000. /**
  41001. * Get the world extend vectors with an optional filter
  41002. *
  41003. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41004. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41005. */
  41006. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41007. min: Vector3;
  41008. max: Vector3;
  41009. };
  41010. /**
  41011. * Creates a ray that can be used to pick in the scene
  41012. * @param x defines the x coordinate of the origin (on-screen)
  41013. * @param y defines the y coordinate of the origin (on-screen)
  41014. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41015. * @param camera defines the camera to use for the picking
  41016. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41017. * @returns a Ray
  41018. */
  41019. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41020. /**
  41021. * Creates a ray that can be used to pick in the scene
  41022. * @param x defines the x coordinate of the origin (on-screen)
  41023. * @param y defines the y coordinate of the origin (on-screen)
  41024. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41025. * @param result defines the ray where to store the picking ray
  41026. * @param camera defines the camera to use for the picking
  41027. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41028. * @returns the current scene
  41029. */
  41030. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41031. /**
  41032. * Creates a ray that can be used to pick in the scene
  41033. * @param x defines the x coordinate of the origin (on-screen)
  41034. * @param y defines the y coordinate of the origin (on-screen)
  41035. * @param camera defines the camera to use for the picking
  41036. * @returns a Ray
  41037. */
  41038. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41039. /**
  41040. * Creates a ray that can be used to pick in the scene
  41041. * @param x defines the x coordinate of the origin (on-screen)
  41042. * @param y defines the y coordinate of the origin (on-screen)
  41043. * @param result defines the ray where to store the picking ray
  41044. * @param camera defines the camera to use for the picking
  41045. * @returns the current scene
  41046. */
  41047. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41048. /** Launch a ray to try to pick a mesh in the scene
  41049. * @param x position on screen
  41050. * @param y position on screen
  41051. * @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
  41052. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41053. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41054. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41055. * @returns a PickingInfo
  41056. */
  41057. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41058. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41059. * @param x position on screen
  41060. * @param y position on screen
  41061. * @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
  41062. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41063. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41064. * @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)
  41065. */
  41066. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41067. /** Use the given ray to pick a mesh in the scene
  41068. * @param ray The ray to use to pick meshes
  41069. * @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
  41070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41071. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41072. * @returns a PickingInfo
  41073. */
  41074. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41075. /**
  41076. * Launch a ray to try to pick a mesh in the scene
  41077. * @param x X position on screen
  41078. * @param y Y position on screen
  41079. * @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
  41080. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41081. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41082. * @returns an array of PickingInfo
  41083. */
  41084. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41085. /**
  41086. * Launch a ray to try to pick a mesh in the scene
  41087. * @param ray Ray to use
  41088. * @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
  41089. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41090. * @returns an array of PickingInfo
  41091. */
  41092. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41093. /**
  41094. * Force the value of meshUnderPointer
  41095. * @param mesh defines the mesh to use
  41096. */
  41097. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41098. /**
  41099. * Gets the mesh under the pointer
  41100. * @returns a Mesh or null if no mesh is under the pointer
  41101. */
  41102. getPointerOverMesh(): Nullable<AbstractMesh>;
  41103. /** @hidden */
  41104. _rebuildGeometries(): void;
  41105. /** @hidden */
  41106. _rebuildTextures(): void;
  41107. private _getByTags;
  41108. /**
  41109. * Get a list of meshes by tags
  41110. * @param tagsQuery defines the tags query to use
  41111. * @param forEach defines a predicate used to filter results
  41112. * @returns an array of Mesh
  41113. */
  41114. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41115. /**
  41116. * Get a list of cameras by tags
  41117. * @param tagsQuery defines the tags query to use
  41118. * @param forEach defines a predicate used to filter results
  41119. * @returns an array of Camera
  41120. */
  41121. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41122. /**
  41123. * Get a list of lights by tags
  41124. * @param tagsQuery defines the tags query to use
  41125. * @param forEach defines a predicate used to filter results
  41126. * @returns an array of Light
  41127. */
  41128. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41129. /**
  41130. * Get a list of materials by tags
  41131. * @param tagsQuery defines the tags query to use
  41132. * @param forEach defines a predicate used to filter results
  41133. * @returns an array of Material
  41134. */
  41135. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41136. /**
  41137. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41138. * This allowed control for front to back rendering or reversly depending of the special needs.
  41139. *
  41140. * @param renderingGroupId The rendering group id corresponding to its index
  41141. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41142. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41143. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41144. */
  41145. 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;
  41146. /**
  41147. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41148. *
  41149. * @param renderingGroupId The rendering group id corresponding to its index
  41150. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41151. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41152. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41153. */
  41154. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41155. /**
  41156. * Gets the current auto clear configuration for one rendering group of the rendering
  41157. * manager.
  41158. * @param index the rendering group index to get the information for
  41159. * @returns The auto clear setup for the requested rendering group
  41160. */
  41161. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41162. private _blockMaterialDirtyMechanism;
  41163. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41164. get blockMaterialDirtyMechanism(): boolean;
  41165. set blockMaterialDirtyMechanism(value: boolean);
  41166. /**
  41167. * Will flag all materials as dirty to trigger new shader compilation
  41168. * @param flag defines the flag used to specify which material part must be marked as dirty
  41169. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41170. */
  41171. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41172. /** @hidden */
  41173. _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;
  41174. /** @hidden */
  41175. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41176. /** @hidden */
  41177. _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;
  41178. /** @hidden */
  41179. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41180. /** @hidden */
  41181. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41182. /** @hidden */
  41183. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41184. }
  41185. }
  41186. declare module BABYLON {
  41187. /**
  41188. * Set of assets to keep when moving a scene into an asset container.
  41189. */
  41190. export class KeepAssets extends AbstractScene {
  41191. }
  41192. /**
  41193. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41194. */
  41195. export class InstantiatedEntries {
  41196. /**
  41197. * List of new root nodes (eg. nodes with no parent)
  41198. */
  41199. rootNodes: TransformNode[];
  41200. /**
  41201. * List of new skeletons
  41202. */
  41203. skeletons: Skeleton[];
  41204. /**
  41205. * List of new animation groups
  41206. */
  41207. animationGroups: AnimationGroup[];
  41208. }
  41209. /**
  41210. * Container with a set of assets that can be added or removed from a scene.
  41211. */
  41212. export class AssetContainer extends AbstractScene {
  41213. private _wasAddedToScene;
  41214. /**
  41215. * The scene the AssetContainer belongs to.
  41216. */
  41217. scene: Scene;
  41218. /**
  41219. * Instantiates an AssetContainer.
  41220. * @param scene The scene the AssetContainer belongs to.
  41221. */
  41222. constructor(scene: Scene);
  41223. /**
  41224. * Instantiate or clone all meshes and add the new ones to the scene.
  41225. * Skeletons and animation groups will all be cloned
  41226. * @param nameFunction defines an optional function used to get new names for clones
  41227. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41228. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41229. */
  41230. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41231. /**
  41232. * Adds all the assets from the container to the scene.
  41233. */
  41234. addAllToScene(): void;
  41235. /**
  41236. * Removes all the assets in the container from the scene
  41237. */
  41238. removeAllFromScene(): void;
  41239. /**
  41240. * Disposes all the assets in the container
  41241. */
  41242. dispose(): void;
  41243. private _moveAssets;
  41244. /**
  41245. * Removes all the assets contained in the scene and adds them to the container.
  41246. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41247. */
  41248. moveAllFromScene(keepAssets?: KeepAssets): void;
  41249. /**
  41250. * 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.
  41251. * @returns the root mesh
  41252. */
  41253. createRootMesh(): Mesh;
  41254. /**
  41255. * Merge animations (direct and animation groups) from this asset container into a scene
  41256. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41257. * @param animatables set of animatables to retarget to a node from the scene
  41258. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41259. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41260. */
  41261. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41262. }
  41263. }
  41264. declare module BABYLON {
  41265. /**
  41266. * Defines how the parser contract is defined.
  41267. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41268. */
  41269. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41270. /**
  41271. * Defines how the individual parser contract is defined.
  41272. * These parser can parse an individual asset
  41273. */
  41274. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41275. /**
  41276. * Base class of the scene acting as a container for the different elements composing a scene.
  41277. * This class is dynamically extended by the different components of the scene increasing
  41278. * flexibility and reducing coupling
  41279. */
  41280. export abstract class AbstractScene {
  41281. /**
  41282. * Stores the list of available parsers in the application.
  41283. */
  41284. private static _BabylonFileParsers;
  41285. /**
  41286. * Stores the list of available individual parsers in the application.
  41287. */
  41288. private static _IndividualBabylonFileParsers;
  41289. /**
  41290. * Adds a parser in the list of available ones
  41291. * @param name Defines the name of the parser
  41292. * @param parser Defines the parser to add
  41293. */
  41294. static AddParser(name: string, parser: BabylonFileParser): void;
  41295. /**
  41296. * Gets a general parser from the list of avaialble ones
  41297. * @param name Defines the name of the parser
  41298. * @returns the requested parser or null
  41299. */
  41300. static GetParser(name: string): Nullable<BabylonFileParser>;
  41301. /**
  41302. * Adds n individual parser in the list of available ones
  41303. * @param name Defines the name of the parser
  41304. * @param parser Defines the parser to add
  41305. */
  41306. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41307. /**
  41308. * Gets an individual parser from the list of avaialble ones
  41309. * @param name Defines the name of the parser
  41310. * @returns the requested parser or null
  41311. */
  41312. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41313. /**
  41314. * Parser json data and populate both a scene and its associated container object
  41315. * @param jsonData Defines the data to parse
  41316. * @param scene Defines the scene to parse the data for
  41317. * @param container Defines the container attached to the parsing sequence
  41318. * @param rootUrl Defines the root url of the data
  41319. */
  41320. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41321. /**
  41322. * Gets the list of root nodes (ie. nodes with no parent)
  41323. */
  41324. rootNodes: Node[];
  41325. /** All of the cameras added to this scene
  41326. * @see https://doc.babylonjs.com/babylon101/cameras
  41327. */
  41328. cameras: Camera[];
  41329. /**
  41330. * All of the lights added to this scene
  41331. * @see https://doc.babylonjs.com/babylon101/lights
  41332. */
  41333. lights: Light[];
  41334. /**
  41335. * All of the (abstract) meshes added to this scene
  41336. */
  41337. meshes: AbstractMesh[];
  41338. /**
  41339. * The list of skeletons added to the scene
  41340. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41341. */
  41342. skeletons: Skeleton[];
  41343. /**
  41344. * All of the particle systems added to this scene
  41345. * @see https://doc.babylonjs.com/babylon101/particles
  41346. */
  41347. particleSystems: IParticleSystem[];
  41348. /**
  41349. * Gets a list of Animations associated with the scene
  41350. */
  41351. animations: Animation[];
  41352. /**
  41353. * All of the animation groups added to this scene
  41354. * @see https://doc.babylonjs.com/how_to/group
  41355. */
  41356. animationGroups: AnimationGroup[];
  41357. /**
  41358. * All of the multi-materials added to this scene
  41359. * @see https://doc.babylonjs.com/how_to/multi_materials
  41360. */
  41361. multiMaterials: MultiMaterial[];
  41362. /**
  41363. * All of the materials added to this scene
  41364. * In the context of a Scene, it is not supposed to be modified manually.
  41365. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41366. * Note also that the order of the Material within the array is not significant and might change.
  41367. * @see https://doc.babylonjs.com/babylon101/materials
  41368. */
  41369. materials: Material[];
  41370. /**
  41371. * The list of morph target managers added to the scene
  41372. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41373. */
  41374. morphTargetManagers: MorphTargetManager[];
  41375. /**
  41376. * The list of geometries used in the scene.
  41377. */
  41378. geometries: Geometry[];
  41379. /**
  41380. * All of the tranform nodes added to this scene
  41381. * In the context of a Scene, it is not supposed to be modified manually.
  41382. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41383. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41384. * @see https://doc.babylonjs.com/how_to/transformnode
  41385. */
  41386. transformNodes: TransformNode[];
  41387. /**
  41388. * ActionManagers available on the scene.
  41389. */
  41390. actionManagers: AbstractActionManager[];
  41391. /**
  41392. * Textures to keep.
  41393. */
  41394. textures: BaseTexture[];
  41395. /** @hidden */
  41396. protected _environmentTexture: Nullable<BaseTexture>;
  41397. /**
  41398. * Texture used in all pbr material as the reflection texture.
  41399. * As in the majority of the scene they are the same (exception for multi room and so on),
  41400. * this is easier to reference from here than from all the materials.
  41401. */
  41402. get environmentTexture(): Nullable<BaseTexture>;
  41403. set environmentTexture(value: Nullable<BaseTexture>);
  41404. /**
  41405. * The list of postprocesses added to the scene
  41406. */
  41407. postProcesses: PostProcess[];
  41408. /**
  41409. * @returns all meshes, lights, cameras, transformNodes and bones
  41410. */
  41411. getNodes(): Array<Node>;
  41412. }
  41413. }
  41414. declare module BABYLON {
  41415. /**
  41416. * Interface used to define options for Sound class
  41417. */
  41418. export interface ISoundOptions {
  41419. /**
  41420. * Does the sound autoplay once loaded.
  41421. */
  41422. autoplay?: boolean;
  41423. /**
  41424. * Does the sound loop after it finishes playing once.
  41425. */
  41426. loop?: boolean;
  41427. /**
  41428. * Sound's volume
  41429. */
  41430. volume?: number;
  41431. /**
  41432. * Is it a spatial sound?
  41433. */
  41434. spatialSound?: boolean;
  41435. /**
  41436. * Maximum distance to hear that sound
  41437. */
  41438. maxDistance?: number;
  41439. /**
  41440. * Uses user defined attenuation function
  41441. */
  41442. useCustomAttenuation?: boolean;
  41443. /**
  41444. * Define the roll off factor of spatial sounds.
  41445. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41446. */
  41447. rolloffFactor?: number;
  41448. /**
  41449. * Define the reference distance the sound should be heard perfectly.
  41450. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41451. */
  41452. refDistance?: number;
  41453. /**
  41454. * Define the distance attenuation model the sound will follow.
  41455. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41456. */
  41457. distanceModel?: string;
  41458. /**
  41459. * Defines the playback speed (1 by default)
  41460. */
  41461. playbackRate?: number;
  41462. /**
  41463. * Defines if the sound is from a streaming source
  41464. */
  41465. streaming?: boolean;
  41466. /**
  41467. * Defines an optional length (in seconds) inside the sound file
  41468. */
  41469. length?: number;
  41470. /**
  41471. * Defines an optional offset (in seconds) inside the sound file
  41472. */
  41473. offset?: number;
  41474. /**
  41475. * If true, URLs will not be required to state the audio file codec to use.
  41476. */
  41477. skipCodecCheck?: boolean;
  41478. }
  41479. /**
  41480. * Defines a sound that can be played in the application.
  41481. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41482. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41483. */
  41484. export class Sound {
  41485. /**
  41486. * The name of the sound in the scene.
  41487. */
  41488. name: string;
  41489. /**
  41490. * Does the sound autoplay once loaded.
  41491. */
  41492. autoplay: boolean;
  41493. /**
  41494. * Does the sound loop after it finishes playing once.
  41495. */
  41496. loop: boolean;
  41497. /**
  41498. * Does the sound use a custom attenuation curve to simulate the falloff
  41499. * happening when the source gets further away from the camera.
  41500. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41501. */
  41502. useCustomAttenuation: boolean;
  41503. /**
  41504. * The sound track id this sound belongs to.
  41505. */
  41506. soundTrackId: number;
  41507. /**
  41508. * Is this sound currently played.
  41509. */
  41510. isPlaying: boolean;
  41511. /**
  41512. * Is this sound currently paused.
  41513. */
  41514. isPaused: boolean;
  41515. /**
  41516. * Does this sound enables spatial sound.
  41517. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41518. */
  41519. spatialSound: boolean;
  41520. /**
  41521. * Define the reference distance the sound should be heard perfectly.
  41522. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41523. */
  41524. refDistance: number;
  41525. /**
  41526. * Define the roll off factor of spatial sounds.
  41527. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41528. */
  41529. rolloffFactor: number;
  41530. /**
  41531. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41532. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41533. */
  41534. maxDistance: number;
  41535. /**
  41536. * Define the distance attenuation model the sound will follow.
  41537. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41538. */
  41539. distanceModel: string;
  41540. /**
  41541. * @hidden
  41542. * Back Compat
  41543. **/
  41544. onended: () => any;
  41545. /**
  41546. * Gets or sets an object used to store user defined information for the sound.
  41547. */
  41548. metadata: any;
  41549. /**
  41550. * Observable event when the current playing sound finishes.
  41551. */
  41552. onEndedObservable: Observable<Sound>;
  41553. private _panningModel;
  41554. private _playbackRate;
  41555. private _streaming;
  41556. private _startTime;
  41557. private _startOffset;
  41558. private _position;
  41559. /** @hidden */
  41560. _positionInEmitterSpace: boolean;
  41561. private _localDirection;
  41562. private _volume;
  41563. private _isReadyToPlay;
  41564. private _isDirectional;
  41565. private _readyToPlayCallback;
  41566. private _audioBuffer;
  41567. private _soundSource;
  41568. private _streamingSource;
  41569. private _soundPanner;
  41570. private _soundGain;
  41571. private _inputAudioNode;
  41572. private _outputAudioNode;
  41573. private _coneInnerAngle;
  41574. private _coneOuterAngle;
  41575. private _coneOuterGain;
  41576. private _scene;
  41577. private _connectedTransformNode;
  41578. private _customAttenuationFunction;
  41579. private _registerFunc;
  41580. private _isOutputConnected;
  41581. private _htmlAudioElement;
  41582. private _urlType;
  41583. private _length?;
  41584. private _offset?;
  41585. /** @hidden */
  41586. static _SceneComponentInitialization: (scene: Scene) => void;
  41587. /**
  41588. * Create a sound and attach it to a scene
  41589. * @param name Name of your sound
  41590. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41591. * @param scene defines the scene the sound belongs to
  41592. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41593. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41594. */
  41595. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41596. /**
  41597. * Release the sound and its associated resources
  41598. */
  41599. dispose(): void;
  41600. /**
  41601. * Gets if the sounds is ready to be played or not.
  41602. * @returns true if ready, otherwise false
  41603. */
  41604. isReady(): boolean;
  41605. private _soundLoaded;
  41606. /**
  41607. * Sets the data of the sound from an audiobuffer
  41608. * @param audioBuffer The audioBuffer containing the data
  41609. */
  41610. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41611. /**
  41612. * Updates the current sounds options such as maxdistance, loop...
  41613. * @param options A JSON object containing values named as the object properties
  41614. */
  41615. updateOptions(options: ISoundOptions): void;
  41616. private _createSpatialParameters;
  41617. private _updateSpatialParameters;
  41618. /**
  41619. * Switch the panning model to HRTF:
  41620. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41621. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41622. */
  41623. switchPanningModelToHRTF(): void;
  41624. /**
  41625. * Switch the panning model to Equal Power:
  41626. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41627. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41628. */
  41629. switchPanningModelToEqualPower(): void;
  41630. private _switchPanningModel;
  41631. /**
  41632. * Connect this sound to a sound track audio node like gain...
  41633. * @param soundTrackAudioNode the sound track audio node to connect to
  41634. */
  41635. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41636. /**
  41637. * Transform this sound into a directional source
  41638. * @param coneInnerAngle Size of the inner cone in degree
  41639. * @param coneOuterAngle Size of the outer cone in degree
  41640. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41641. */
  41642. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41643. /**
  41644. * Gets or sets the inner angle for the directional cone.
  41645. */
  41646. get directionalConeInnerAngle(): number;
  41647. /**
  41648. * Gets or sets the inner angle for the directional cone.
  41649. */
  41650. set directionalConeInnerAngle(value: number);
  41651. /**
  41652. * Gets or sets the outer angle for the directional cone.
  41653. */
  41654. get directionalConeOuterAngle(): number;
  41655. /**
  41656. * Gets or sets the outer angle for the directional cone.
  41657. */
  41658. set directionalConeOuterAngle(value: number);
  41659. /**
  41660. * Sets the position of the emitter if spatial sound is enabled
  41661. * @param newPosition Defines the new posisiton
  41662. */
  41663. setPosition(newPosition: Vector3): void;
  41664. /**
  41665. * Sets the local direction of the emitter if spatial sound is enabled
  41666. * @param newLocalDirection Defines the new local direction
  41667. */
  41668. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41669. private _updateDirection;
  41670. /** @hidden */
  41671. updateDistanceFromListener(): void;
  41672. /**
  41673. * Sets a new custom attenuation function for the sound.
  41674. * @param callback Defines the function used for the attenuation
  41675. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41676. */
  41677. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41678. /**
  41679. * Play the sound
  41680. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41681. * @param offset (optional) Start the sound at a specific time in seconds
  41682. * @param length (optional) Sound duration (in seconds)
  41683. */
  41684. play(time?: number, offset?: number, length?: number): void;
  41685. private _onended;
  41686. /**
  41687. * Stop the sound
  41688. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41689. */
  41690. stop(time?: number): void;
  41691. /**
  41692. * Put the sound in pause
  41693. */
  41694. pause(): void;
  41695. /**
  41696. * Sets a dedicated volume for this sounds
  41697. * @param newVolume Define the new volume of the sound
  41698. * @param time Define time for gradual change to new volume
  41699. */
  41700. setVolume(newVolume: number, time?: number): void;
  41701. /**
  41702. * Set the sound play back rate
  41703. * @param newPlaybackRate Define the playback rate the sound should be played at
  41704. */
  41705. setPlaybackRate(newPlaybackRate: number): void;
  41706. /**
  41707. * Gets the volume of the sound.
  41708. * @returns the volume of the sound
  41709. */
  41710. getVolume(): number;
  41711. /**
  41712. * Attach the sound to a dedicated mesh
  41713. * @param transformNode The transform node to connect the sound with
  41714. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41715. */
  41716. attachToMesh(transformNode: TransformNode): void;
  41717. /**
  41718. * Detach the sound from the previously attached mesh
  41719. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41720. */
  41721. detachFromMesh(): void;
  41722. private _onRegisterAfterWorldMatrixUpdate;
  41723. /**
  41724. * Clone the current sound in the scene.
  41725. * @returns the new sound clone
  41726. */
  41727. clone(): Nullable<Sound>;
  41728. /**
  41729. * Gets the current underlying audio buffer containing the data
  41730. * @returns the audio buffer
  41731. */
  41732. getAudioBuffer(): Nullable<AudioBuffer>;
  41733. /**
  41734. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41735. * @returns the source node
  41736. */
  41737. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41738. /**
  41739. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41740. * @returns the gain node
  41741. */
  41742. getSoundGain(): Nullable<GainNode>;
  41743. /**
  41744. * Serializes the Sound in a JSON representation
  41745. * @returns the JSON representation of the sound
  41746. */
  41747. serialize(): any;
  41748. /**
  41749. * Parse a JSON representation of a sound to innstantiate in a given scene
  41750. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41751. * @param scene Define the scene the new parsed sound should be created in
  41752. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41753. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41754. * @returns the newly parsed sound
  41755. */
  41756. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41757. }
  41758. }
  41759. declare module BABYLON {
  41760. /**
  41761. * This defines an action helpful to play a defined sound on a triggered action.
  41762. */
  41763. export class PlaySoundAction extends Action {
  41764. private _sound;
  41765. /**
  41766. * Instantiate the action
  41767. * @param triggerOptions defines the trigger options
  41768. * @param sound defines the sound to play
  41769. * @param condition defines the trigger related conditions
  41770. */
  41771. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41772. /** @hidden */
  41773. _prepare(): void;
  41774. /**
  41775. * Execute the action and play the sound.
  41776. */
  41777. execute(): void;
  41778. /**
  41779. * Serializes the actions and its related information.
  41780. * @param parent defines the object to serialize in
  41781. * @returns the serialized object
  41782. */
  41783. serialize(parent: any): any;
  41784. }
  41785. /**
  41786. * This defines an action helpful to stop a defined sound on a triggered action.
  41787. */
  41788. export class StopSoundAction extends Action {
  41789. private _sound;
  41790. /**
  41791. * Instantiate the action
  41792. * @param triggerOptions defines the trigger options
  41793. * @param sound defines the sound to stop
  41794. * @param condition defines the trigger related conditions
  41795. */
  41796. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41797. /** @hidden */
  41798. _prepare(): void;
  41799. /**
  41800. * Execute the action and stop the sound.
  41801. */
  41802. execute(): void;
  41803. /**
  41804. * Serializes the actions and its related information.
  41805. * @param parent defines the object to serialize in
  41806. * @returns the serialized object
  41807. */
  41808. serialize(parent: any): any;
  41809. }
  41810. }
  41811. declare module BABYLON {
  41812. /**
  41813. * This defines an action responsible to change the value of a property
  41814. * by interpolating between its current value and the newly set one once triggered.
  41815. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41816. */
  41817. export class InterpolateValueAction extends Action {
  41818. /**
  41819. * Defines the path of the property where the value should be interpolated
  41820. */
  41821. propertyPath: string;
  41822. /**
  41823. * Defines the target value at the end of the interpolation.
  41824. */
  41825. value: any;
  41826. /**
  41827. * Defines the time it will take for the property to interpolate to the value.
  41828. */
  41829. duration: number;
  41830. /**
  41831. * Defines if the other scene animations should be stopped when the action has been triggered
  41832. */
  41833. stopOtherAnimations?: boolean;
  41834. /**
  41835. * Defines a callback raised once the interpolation animation has been done.
  41836. */
  41837. onInterpolationDone?: () => void;
  41838. /**
  41839. * Observable triggered once the interpolation animation has been done.
  41840. */
  41841. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41842. private _target;
  41843. private _effectiveTarget;
  41844. private _property;
  41845. /**
  41846. * Instantiate the action
  41847. * @param triggerOptions defines the trigger options
  41848. * @param target defines the object containing the value to interpolate
  41849. * @param propertyPath defines the path to the property in the target object
  41850. * @param value defines the target value at the end of the interpolation
  41851. * @param duration deines the time it will take for the property to interpolate to the value.
  41852. * @param condition defines the trigger related conditions
  41853. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41854. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41855. */
  41856. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41857. /** @hidden */
  41858. _prepare(): void;
  41859. /**
  41860. * Execute the action starts the value interpolation.
  41861. */
  41862. execute(): void;
  41863. /**
  41864. * Serializes the actions and its related information.
  41865. * @param parent defines the object to serialize in
  41866. * @returns the serialized object
  41867. */
  41868. serialize(parent: any): any;
  41869. }
  41870. }
  41871. declare module BABYLON {
  41872. /**
  41873. * Options allowed during the creation of a sound track.
  41874. */
  41875. export interface ISoundTrackOptions {
  41876. /**
  41877. * The volume the sound track should take during creation
  41878. */
  41879. volume?: number;
  41880. /**
  41881. * Define if the sound track is the main sound track of the scene
  41882. */
  41883. mainTrack?: boolean;
  41884. }
  41885. /**
  41886. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41887. * It will be also used in a future release to apply effects on a specific track.
  41888. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41889. */
  41890. export class SoundTrack {
  41891. /**
  41892. * The unique identifier of the sound track in the scene.
  41893. */
  41894. id: number;
  41895. /**
  41896. * The list of sounds included in the sound track.
  41897. */
  41898. soundCollection: Array<Sound>;
  41899. private _outputAudioNode;
  41900. private _scene;
  41901. private _connectedAnalyser;
  41902. private _options;
  41903. private _isInitialized;
  41904. /**
  41905. * Creates a new sound track.
  41906. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41907. * @param scene Define the scene the sound track belongs to
  41908. * @param options
  41909. */
  41910. constructor(scene: Scene, options?: ISoundTrackOptions);
  41911. private _initializeSoundTrackAudioGraph;
  41912. /**
  41913. * Release the sound track and its associated resources
  41914. */
  41915. dispose(): void;
  41916. /**
  41917. * Adds a sound to this sound track
  41918. * @param sound define the cound to add
  41919. * @ignoreNaming
  41920. */
  41921. AddSound(sound: Sound): void;
  41922. /**
  41923. * Removes a sound to this sound track
  41924. * @param sound define the cound to remove
  41925. * @ignoreNaming
  41926. */
  41927. RemoveSound(sound: Sound): void;
  41928. /**
  41929. * Set a global volume for the full sound track.
  41930. * @param newVolume Define the new volume of the sound track
  41931. */
  41932. setVolume(newVolume: number): void;
  41933. /**
  41934. * Switch the panning model to HRTF:
  41935. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41936. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41937. */
  41938. switchPanningModelToHRTF(): void;
  41939. /**
  41940. * Switch the panning model to Equal Power:
  41941. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41942. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41943. */
  41944. switchPanningModelToEqualPower(): void;
  41945. /**
  41946. * Connect the sound track to an audio analyser allowing some amazing
  41947. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41948. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41949. * @param analyser The analyser to connect to the engine
  41950. */
  41951. connectToAnalyser(analyser: Analyser): void;
  41952. }
  41953. }
  41954. declare module BABYLON {
  41955. interface AbstractScene {
  41956. /**
  41957. * The list of sounds used in the scene.
  41958. */
  41959. sounds: Nullable<Array<Sound>>;
  41960. }
  41961. interface Scene {
  41962. /**
  41963. * @hidden
  41964. * Backing field
  41965. */
  41966. _mainSoundTrack: SoundTrack;
  41967. /**
  41968. * The main sound track played by the scene.
  41969. * It cotains your primary collection of sounds.
  41970. */
  41971. mainSoundTrack: SoundTrack;
  41972. /**
  41973. * The list of sound tracks added to the scene
  41974. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41975. */
  41976. soundTracks: Nullable<Array<SoundTrack>>;
  41977. /**
  41978. * Gets a sound using a given name
  41979. * @param name defines the name to search for
  41980. * @return the found sound or null if not found at all.
  41981. */
  41982. getSoundByName(name: string): Nullable<Sound>;
  41983. /**
  41984. * Gets or sets if audio support is enabled
  41985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41986. */
  41987. audioEnabled: boolean;
  41988. /**
  41989. * Gets or sets if audio will be output to headphones
  41990. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41991. */
  41992. headphone: boolean;
  41993. /**
  41994. * Gets or sets custom audio listener position provider
  41995. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41996. */
  41997. audioListenerPositionProvider: Nullable<() => Vector3>;
  41998. /**
  41999. * Gets or sets a refresh rate when using 3D audio positioning
  42000. */
  42001. audioPositioningRefreshRate: number;
  42002. }
  42003. /**
  42004. * Defines the sound scene component responsible to manage any sounds
  42005. * in a given scene.
  42006. */
  42007. export class AudioSceneComponent implements ISceneSerializableComponent {
  42008. /**
  42009. * The component name helpfull to identify the component in the list of scene components.
  42010. */
  42011. readonly name: string;
  42012. /**
  42013. * The scene the component belongs to.
  42014. */
  42015. scene: Scene;
  42016. private _audioEnabled;
  42017. /**
  42018. * Gets whether audio is enabled or not.
  42019. * Please use related enable/disable method to switch state.
  42020. */
  42021. get audioEnabled(): boolean;
  42022. private _headphone;
  42023. /**
  42024. * Gets whether audio is outputing to headphone or not.
  42025. * Please use the according Switch methods to change output.
  42026. */
  42027. get headphone(): boolean;
  42028. /**
  42029. * Gets or sets a refresh rate when using 3D audio positioning
  42030. */
  42031. audioPositioningRefreshRate: number;
  42032. private _audioListenerPositionProvider;
  42033. /**
  42034. * Gets the current audio listener position provider
  42035. */
  42036. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42037. /**
  42038. * Sets a custom listener position for all sounds in the scene
  42039. * By default, this is the position of the first active camera
  42040. */
  42041. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42042. /**
  42043. * Creates a new instance of the component for the given scene
  42044. * @param scene Defines the scene to register the component in
  42045. */
  42046. constructor(scene: Scene);
  42047. /**
  42048. * Registers the component in a given scene
  42049. */
  42050. register(): void;
  42051. /**
  42052. * Rebuilds the elements related to this component in case of
  42053. * context lost for instance.
  42054. */
  42055. rebuild(): void;
  42056. /**
  42057. * Serializes the component data to the specified json object
  42058. * @param serializationObject The object to serialize to
  42059. */
  42060. serialize(serializationObject: any): void;
  42061. /**
  42062. * Adds all the elements from the container to the scene
  42063. * @param container the container holding the elements
  42064. */
  42065. addFromContainer(container: AbstractScene): void;
  42066. /**
  42067. * Removes all the elements in the container from the scene
  42068. * @param container contains the elements to remove
  42069. * @param dispose if the removed element should be disposed (default: false)
  42070. */
  42071. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42072. /**
  42073. * Disposes the component and the associated ressources.
  42074. */
  42075. dispose(): void;
  42076. /**
  42077. * Disables audio in the associated scene.
  42078. */
  42079. disableAudio(): void;
  42080. /**
  42081. * Enables audio in the associated scene.
  42082. */
  42083. enableAudio(): void;
  42084. /**
  42085. * Switch audio to headphone output.
  42086. */
  42087. switchAudioModeForHeadphones(): void;
  42088. /**
  42089. * Switch audio to normal speakers.
  42090. */
  42091. switchAudioModeForNormalSpeakers(): void;
  42092. private _cachedCameraDirection;
  42093. private _cachedCameraPosition;
  42094. private _lastCheck;
  42095. private _afterRender;
  42096. }
  42097. }
  42098. declare module BABYLON {
  42099. /**
  42100. * Wraps one or more Sound objects and selects one with random weight for playback.
  42101. */
  42102. export class WeightedSound {
  42103. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42104. loop: boolean;
  42105. private _coneInnerAngle;
  42106. private _coneOuterAngle;
  42107. private _volume;
  42108. /** A Sound is currently playing. */
  42109. isPlaying: boolean;
  42110. /** A Sound is currently paused. */
  42111. isPaused: boolean;
  42112. private _sounds;
  42113. private _weights;
  42114. private _currentIndex?;
  42115. /**
  42116. * Creates a new WeightedSound from the list of sounds given.
  42117. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42118. * @param sounds Array of Sounds that will be selected from.
  42119. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42120. */
  42121. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42122. /**
  42123. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42124. */
  42125. get directionalConeInnerAngle(): number;
  42126. /**
  42127. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42128. */
  42129. set directionalConeInnerAngle(value: number);
  42130. /**
  42131. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42132. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42133. */
  42134. get directionalConeOuterAngle(): number;
  42135. /**
  42136. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42137. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42138. */
  42139. set directionalConeOuterAngle(value: number);
  42140. /**
  42141. * Playback volume.
  42142. */
  42143. get volume(): number;
  42144. /**
  42145. * Playback volume.
  42146. */
  42147. set volume(value: number);
  42148. private _onended;
  42149. /**
  42150. * Suspend playback
  42151. */
  42152. pause(): void;
  42153. /**
  42154. * Stop playback
  42155. */
  42156. stop(): void;
  42157. /**
  42158. * Start playback.
  42159. * @param startOffset Position the clip head at a specific time in seconds.
  42160. */
  42161. play(startOffset?: number): void;
  42162. }
  42163. }
  42164. declare module BABYLON {
  42165. /**
  42166. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42167. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42168. */
  42169. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42170. /**
  42171. * Gets the name of the behavior.
  42172. */
  42173. get name(): string;
  42174. /**
  42175. * The easing function used by animations
  42176. */
  42177. static EasingFunction: BackEase;
  42178. /**
  42179. * The easing mode used by animations
  42180. */
  42181. static EasingMode: number;
  42182. /**
  42183. * The duration of the animation, in milliseconds
  42184. */
  42185. transitionDuration: number;
  42186. /**
  42187. * Length of the distance animated by the transition when lower radius is reached
  42188. */
  42189. lowerRadiusTransitionRange: number;
  42190. /**
  42191. * Length of the distance animated by the transition when upper radius is reached
  42192. */
  42193. upperRadiusTransitionRange: number;
  42194. private _autoTransitionRange;
  42195. /**
  42196. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42197. */
  42198. get autoTransitionRange(): boolean;
  42199. /**
  42200. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42201. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42202. */
  42203. set autoTransitionRange(value: boolean);
  42204. private _attachedCamera;
  42205. private _onAfterCheckInputsObserver;
  42206. private _onMeshTargetChangedObserver;
  42207. /**
  42208. * Initializes the behavior.
  42209. */
  42210. init(): void;
  42211. /**
  42212. * Attaches the behavior to its arc rotate camera.
  42213. * @param camera Defines the camera to attach the behavior to
  42214. */
  42215. attach(camera: ArcRotateCamera): void;
  42216. /**
  42217. * Detaches the behavior from its current arc rotate camera.
  42218. */
  42219. detach(): void;
  42220. private _radiusIsAnimating;
  42221. private _radiusBounceTransition;
  42222. private _animatables;
  42223. private _cachedWheelPrecision;
  42224. /**
  42225. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42226. * @param radiusLimit The limit to check against.
  42227. * @return Bool to indicate if at limit.
  42228. */
  42229. private _isRadiusAtLimit;
  42230. /**
  42231. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42232. * @param radiusDelta The delta by which to animate to. Can be negative.
  42233. */
  42234. private _applyBoundRadiusAnimation;
  42235. /**
  42236. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42237. */
  42238. protected _clearAnimationLocks(): void;
  42239. /**
  42240. * Stops and removes all animations that have been applied to the camera
  42241. */
  42242. stopAllAnimations(): void;
  42243. }
  42244. }
  42245. declare module BABYLON {
  42246. /**
  42247. * 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.
  42248. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42249. */
  42250. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42251. /**
  42252. * Gets the name of the behavior.
  42253. */
  42254. get name(): string;
  42255. private _mode;
  42256. private _radiusScale;
  42257. private _positionScale;
  42258. private _defaultElevation;
  42259. private _elevationReturnTime;
  42260. private _elevationReturnWaitTime;
  42261. private _zoomStopsAnimation;
  42262. private _framingTime;
  42263. /**
  42264. * The easing function used by animations
  42265. */
  42266. static EasingFunction: ExponentialEase;
  42267. /**
  42268. * The easing mode used by animations
  42269. */
  42270. static EasingMode: number;
  42271. /**
  42272. * Sets the current mode used by the behavior
  42273. */
  42274. set mode(mode: number);
  42275. /**
  42276. * Gets current mode used by the behavior.
  42277. */
  42278. get mode(): number;
  42279. /**
  42280. * Sets the scale applied to the radius (1 by default)
  42281. */
  42282. set radiusScale(radius: number);
  42283. /**
  42284. * Gets the scale applied to the radius
  42285. */
  42286. get radiusScale(): number;
  42287. /**
  42288. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42289. */
  42290. set positionScale(scale: number);
  42291. /**
  42292. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42293. */
  42294. get positionScale(): number;
  42295. /**
  42296. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42297. * behaviour is triggered, in radians.
  42298. */
  42299. set defaultElevation(elevation: number);
  42300. /**
  42301. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42302. * behaviour is triggered, in radians.
  42303. */
  42304. get defaultElevation(): number;
  42305. /**
  42306. * Sets the time (in milliseconds) taken to return to the default beta position.
  42307. * Negative value indicates camera should not return to default.
  42308. */
  42309. set elevationReturnTime(speed: number);
  42310. /**
  42311. * Gets the time (in milliseconds) taken to return to the default beta position.
  42312. * Negative value indicates camera should not return to default.
  42313. */
  42314. get elevationReturnTime(): number;
  42315. /**
  42316. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42317. */
  42318. set elevationReturnWaitTime(time: number);
  42319. /**
  42320. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42321. */
  42322. get elevationReturnWaitTime(): number;
  42323. /**
  42324. * Sets the flag that indicates if user zooming should stop animation.
  42325. */
  42326. set zoomStopsAnimation(flag: boolean);
  42327. /**
  42328. * Gets the flag that indicates if user zooming should stop animation.
  42329. */
  42330. get zoomStopsAnimation(): boolean;
  42331. /**
  42332. * Sets the transition time when framing the mesh, in milliseconds
  42333. */
  42334. set framingTime(time: number);
  42335. /**
  42336. * Gets the transition time when framing the mesh, in milliseconds
  42337. */
  42338. get framingTime(): number;
  42339. /**
  42340. * Define if the behavior should automatically change the configured
  42341. * camera limits and sensibilities.
  42342. */
  42343. autoCorrectCameraLimitsAndSensibility: boolean;
  42344. private _onPrePointerObservableObserver;
  42345. private _onAfterCheckInputsObserver;
  42346. private _onMeshTargetChangedObserver;
  42347. private _attachedCamera;
  42348. private _isPointerDown;
  42349. private _lastInteractionTime;
  42350. /**
  42351. * Initializes the behavior.
  42352. */
  42353. init(): void;
  42354. /**
  42355. * Attaches the behavior to its arc rotate camera.
  42356. * @param camera Defines the camera to attach the behavior to
  42357. */
  42358. attach(camera: ArcRotateCamera): void;
  42359. /**
  42360. * Detaches the behavior from its current arc rotate camera.
  42361. */
  42362. detach(): void;
  42363. private _animatables;
  42364. private _betaIsAnimating;
  42365. private _betaTransition;
  42366. private _radiusTransition;
  42367. private _vectorTransition;
  42368. /**
  42369. * Targets the given mesh and updates zoom level accordingly.
  42370. * @param mesh The mesh to target.
  42371. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42372. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42373. */
  42374. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42375. /**
  42376. * Targets the given mesh with its children and updates zoom level accordingly.
  42377. * @param mesh The mesh to target.
  42378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42380. */
  42381. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42382. /**
  42383. * Targets the given meshes with their children and updates zoom level accordingly.
  42384. * @param meshes The mesh to target.
  42385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42387. */
  42388. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42389. /**
  42390. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42391. * @param minimumWorld Determines the smaller position of the bounding box extend
  42392. * @param maximumWorld Determines the bigger position of the bounding box extend
  42393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42395. */
  42396. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42397. /**
  42398. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42399. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42400. * frustum width.
  42401. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42402. * to fully enclose the mesh in the viewing frustum.
  42403. */
  42404. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42405. /**
  42406. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42407. * is automatically returned to its default position (expected to be above ground plane).
  42408. */
  42409. private _maintainCameraAboveGround;
  42410. /**
  42411. * Returns the frustum slope based on the canvas ratio and camera FOV
  42412. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42413. */
  42414. private _getFrustumSlope;
  42415. /**
  42416. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42417. */
  42418. private _clearAnimationLocks;
  42419. /**
  42420. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42421. */
  42422. private _applyUserInteraction;
  42423. /**
  42424. * Stops and removes all animations that have been applied to the camera
  42425. */
  42426. stopAllAnimations(): void;
  42427. /**
  42428. * Gets a value indicating if the user is moving the camera
  42429. */
  42430. get isUserIsMoving(): boolean;
  42431. /**
  42432. * The camera can move all the way towards the mesh.
  42433. */
  42434. static IgnoreBoundsSizeMode: number;
  42435. /**
  42436. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42437. */
  42438. static FitFrustumSidesMode: number;
  42439. }
  42440. }
  42441. declare module BABYLON {
  42442. /**
  42443. * Base class for Camera Pointer Inputs.
  42444. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42445. * for example usage.
  42446. */
  42447. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42448. /**
  42449. * Defines the camera the input is attached to.
  42450. */
  42451. abstract camera: Camera;
  42452. /**
  42453. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42454. */
  42455. protected _altKey: boolean;
  42456. protected _ctrlKey: boolean;
  42457. protected _metaKey: boolean;
  42458. protected _shiftKey: boolean;
  42459. /**
  42460. * Which mouse buttons were pressed at time of last mouse event.
  42461. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42462. */
  42463. protected _buttonsPressed: number;
  42464. /**
  42465. * Defines the buttons associated with the input to handle camera move.
  42466. */
  42467. buttons: number[];
  42468. /**
  42469. * Attach the input controls to a specific dom element to get the input from.
  42470. * @param element Defines the element the controls should be listened from
  42471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42472. */
  42473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42474. /**
  42475. * Detach the current controls from the specified dom element.
  42476. * @param element Defines the element to stop listening the inputs from
  42477. */
  42478. detachControl(element: Nullable<HTMLElement>): void;
  42479. /**
  42480. * Gets the class name of the current input.
  42481. * @returns the class name
  42482. */
  42483. getClassName(): string;
  42484. /**
  42485. * Get the friendly name associated with the input class.
  42486. * @returns the input friendly name
  42487. */
  42488. getSimpleName(): string;
  42489. /**
  42490. * Called on pointer POINTERDOUBLETAP event.
  42491. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42492. */
  42493. protected onDoubleTap(type: string): void;
  42494. /**
  42495. * Called on pointer POINTERMOVE event if only a single touch is active.
  42496. * Override this method to provide functionality.
  42497. */
  42498. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42499. /**
  42500. * Called on pointer POINTERMOVE event if multiple touches are active.
  42501. * Override this method to provide functionality.
  42502. */
  42503. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42504. /**
  42505. * Called on JS contextmenu event.
  42506. * Override this method to provide functionality.
  42507. */
  42508. protected onContextMenu(evt: PointerEvent): void;
  42509. /**
  42510. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42511. * press.
  42512. * Override this method to provide functionality.
  42513. */
  42514. protected onButtonDown(evt: PointerEvent): void;
  42515. /**
  42516. * Called each time a new POINTERUP event occurs. Ie, for each button
  42517. * release.
  42518. * Override this method to provide functionality.
  42519. */
  42520. protected onButtonUp(evt: PointerEvent): void;
  42521. /**
  42522. * Called when window becomes inactive.
  42523. * Override this method to provide functionality.
  42524. */
  42525. protected onLostFocus(): void;
  42526. private _pointerInput;
  42527. private _observer;
  42528. private _onLostFocus;
  42529. private pointA;
  42530. private pointB;
  42531. }
  42532. }
  42533. declare module BABYLON {
  42534. /**
  42535. * Manage the pointers inputs to control an arc rotate camera.
  42536. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42537. */
  42538. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42539. /**
  42540. * Defines the camera the input is attached to.
  42541. */
  42542. camera: ArcRotateCamera;
  42543. /**
  42544. * Gets the class name of the current input.
  42545. * @returns the class name
  42546. */
  42547. getClassName(): string;
  42548. /**
  42549. * Defines the buttons associated with the input to handle camera move.
  42550. */
  42551. buttons: number[];
  42552. /**
  42553. * Defines the pointer angular sensibility along the X axis or how fast is
  42554. * the camera rotating.
  42555. */
  42556. angularSensibilityX: number;
  42557. /**
  42558. * Defines the pointer angular sensibility along the Y axis or how fast is
  42559. * the camera rotating.
  42560. */
  42561. angularSensibilityY: number;
  42562. /**
  42563. * Defines the pointer pinch precision or how fast is the camera zooming.
  42564. */
  42565. pinchPrecision: number;
  42566. /**
  42567. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42568. * from 0.
  42569. * It defines the percentage of current camera.radius to use as delta when
  42570. * pinch zoom is used.
  42571. */
  42572. pinchDeltaPercentage: number;
  42573. /**
  42574. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42575. * that any object in the plane at the camera's target point will scale
  42576. * perfectly with finger motion.
  42577. * Overrides pinchDeltaPercentage and pinchPrecision.
  42578. */
  42579. useNaturalPinchZoom: boolean;
  42580. /**
  42581. * Defines the pointer panning sensibility or how fast is the camera moving.
  42582. */
  42583. panningSensibility: number;
  42584. /**
  42585. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42586. */
  42587. multiTouchPanning: boolean;
  42588. /**
  42589. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42590. * zoom (pinch) through multitouch.
  42591. */
  42592. multiTouchPanAndZoom: boolean;
  42593. /**
  42594. * Revers pinch action direction.
  42595. */
  42596. pinchInwards: boolean;
  42597. private _isPanClick;
  42598. private _twoFingerActivityCount;
  42599. private _isPinching;
  42600. /**
  42601. * Called on pointer POINTERMOVE event if only a single touch is active.
  42602. */
  42603. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42604. /**
  42605. * Called on pointer POINTERDOUBLETAP event.
  42606. */
  42607. protected onDoubleTap(type: string): void;
  42608. /**
  42609. * Called on pointer POINTERMOVE event if multiple touches are active.
  42610. */
  42611. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42612. /**
  42613. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42614. * press.
  42615. */
  42616. protected onButtonDown(evt: PointerEvent): void;
  42617. /**
  42618. * Called each time a new POINTERUP event occurs. Ie, for each button
  42619. * release.
  42620. */
  42621. protected onButtonUp(evt: PointerEvent): void;
  42622. /**
  42623. * Called when window becomes inactive.
  42624. */
  42625. protected onLostFocus(): void;
  42626. }
  42627. }
  42628. declare module BABYLON {
  42629. /**
  42630. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42631. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42632. */
  42633. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42634. /**
  42635. * Defines the camera the input is attached to.
  42636. */
  42637. camera: ArcRotateCamera;
  42638. /**
  42639. * Defines the list of key codes associated with the up action (increase alpha)
  42640. */
  42641. keysUp: number[];
  42642. /**
  42643. * Defines the list of key codes associated with the down action (decrease alpha)
  42644. */
  42645. keysDown: number[];
  42646. /**
  42647. * Defines the list of key codes associated with the left action (increase beta)
  42648. */
  42649. keysLeft: number[];
  42650. /**
  42651. * Defines the list of key codes associated with the right action (decrease beta)
  42652. */
  42653. keysRight: number[];
  42654. /**
  42655. * Defines the list of key codes associated with the reset action.
  42656. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42657. */
  42658. keysReset: number[];
  42659. /**
  42660. * Defines the panning sensibility of the inputs.
  42661. * (How fast is the camera panning)
  42662. */
  42663. panningSensibility: number;
  42664. /**
  42665. * Defines the zooming sensibility of the inputs.
  42666. * (How fast is the camera zooming)
  42667. */
  42668. zoomingSensibility: number;
  42669. /**
  42670. * Defines whether maintaining the alt key down switch the movement mode from
  42671. * orientation to zoom.
  42672. */
  42673. useAltToZoom: boolean;
  42674. /**
  42675. * Rotation speed of the camera
  42676. */
  42677. angularSpeed: number;
  42678. private _keys;
  42679. private _ctrlPressed;
  42680. private _altPressed;
  42681. private _onCanvasBlurObserver;
  42682. private _onKeyboardObserver;
  42683. private _engine;
  42684. private _scene;
  42685. /**
  42686. * Attach the input controls to a specific dom element to get the input from.
  42687. * @param element Defines the element the controls should be listened from
  42688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42689. */
  42690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42691. /**
  42692. * Detach the current controls from the specified dom element.
  42693. * @param element Defines the element to stop listening the inputs from
  42694. */
  42695. detachControl(element: Nullable<HTMLElement>): void;
  42696. /**
  42697. * Update the current camera state depending on the inputs that have been used this frame.
  42698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42699. */
  42700. checkInputs(): void;
  42701. /**
  42702. * Gets the class name of the current intput.
  42703. * @returns the class name
  42704. */
  42705. getClassName(): string;
  42706. /**
  42707. * Get the friendly name associated with the input class.
  42708. * @returns the input friendly name
  42709. */
  42710. getSimpleName(): string;
  42711. }
  42712. }
  42713. declare module BABYLON {
  42714. /**
  42715. * Manage the mouse wheel inputs to control an arc rotate camera.
  42716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42717. */
  42718. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42719. /**
  42720. * Defines the camera the input is attached to.
  42721. */
  42722. camera: ArcRotateCamera;
  42723. /**
  42724. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42725. */
  42726. wheelPrecision: number;
  42727. /**
  42728. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42729. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42730. */
  42731. wheelDeltaPercentage: number;
  42732. private _wheel;
  42733. private _observer;
  42734. private computeDeltaFromMouseWheelLegacyEvent;
  42735. /**
  42736. * Attach the input controls to a specific dom element to get the input from.
  42737. * @param element Defines the element the controls should be listened from
  42738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42739. */
  42740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42741. /**
  42742. * Detach the current controls from the specified dom element.
  42743. * @param element Defines the element to stop listening the inputs from
  42744. */
  42745. detachControl(element: Nullable<HTMLElement>): void;
  42746. /**
  42747. * Gets the class name of the current intput.
  42748. * @returns the class name
  42749. */
  42750. getClassName(): string;
  42751. /**
  42752. * Get the friendly name associated with the input class.
  42753. * @returns the input friendly name
  42754. */
  42755. getSimpleName(): string;
  42756. }
  42757. }
  42758. declare module BABYLON {
  42759. /**
  42760. * Default Inputs manager for the ArcRotateCamera.
  42761. * It groups all the default supported inputs for ease of use.
  42762. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42763. */
  42764. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42765. /**
  42766. * Instantiates a new ArcRotateCameraInputsManager.
  42767. * @param camera Defines the camera the inputs belong to
  42768. */
  42769. constructor(camera: ArcRotateCamera);
  42770. /**
  42771. * Add mouse wheel input support to the input manager.
  42772. * @returns the current input manager
  42773. */
  42774. addMouseWheel(): ArcRotateCameraInputsManager;
  42775. /**
  42776. * Add pointers input support to the input manager.
  42777. * @returns the current input manager
  42778. */
  42779. addPointers(): ArcRotateCameraInputsManager;
  42780. /**
  42781. * Add keyboard input support to the input manager.
  42782. * @returns the current input manager
  42783. */
  42784. addKeyboard(): ArcRotateCameraInputsManager;
  42785. }
  42786. }
  42787. declare module BABYLON {
  42788. /**
  42789. * This represents an orbital type of camera.
  42790. *
  42791. * 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.
  42792. * 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.
  42793. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42794. */
  42795. export class ArcRotateCamera extends TargetCamera {
  42796. /**
  42797. * Defines the rotation angle of the camera along the longitudinal axis.
  42798. */
  42799. alpha: number;
  42800. /**
  42801. * Defines the rotation angle of the camera along the latitudinal axis.
  42802. */
  42803. beta: number;
  42804. /**
  42805. * Defines the radius of the camera from it s target point.
  42806. */
  42807. radius: number;
  42808. protected _target: Vector3;
  42809. protected _targetHost: Nullable<AbstractMesh>;
  42810. /**
  42811. * Defines the target point of the camera.
  42812. * The camera looks towards it form the radius distance.
  42813. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42814. */
  42815. get target(): Vector3;
  42816. set target(value: Vector3);
  42817. /**
  42818. * Define the current local position of the camera in the scene
  42819. */
  42820. get position(): Vector3;
  42821. set position(newPosition: Vector3);
  42822. protected _upToYMatrix: Matrix;
  42823. protected _YToUpMatrix: Matrix;
  42824. /**
  42825. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42826. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42827. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42828. */
  42829. set upVector(vec: Vector3);
  42830. get upVector(): Vector3;
  42831. /**
  42832. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42833. */
  42834. setMatUp(): void;
  42835. /**
  42836. * Current inertia value on the longitudinal axis.
  42837. * The bigger this number the longer it will take for the camera to stop.
  42838. */
  42839. inertialAlphaOffset: number;
  42840. /**
  42841. * Current inertia value on the latitudinal axis.
  42842. * The bigger this number the longer it will take for the camera to stop.
  42843. */
  42844. inertialBetaOffset: number;
  42845. /**
  42846. * Current inertia value on the radius axis.
  42847. * The bigger this number the longer it will take for the camera to stop.
  42848. */
  42849. inertialRadiusOffset: number;
  42850. /**
  42851. * Minimum allowed angle on the longitudinal axis.
  42852. * This can help limiting how the Camera is able to move in the scene.
  42853. */
  42854. lowerAlphaLimit: Nullable<number>;
  42855. /**
  42856. * Maximum allowed angle on the longitudinal axis.
  42857. * This can help limiting how the Camera is able to move in the scene.
  42858. */
  42859. upperAlphaLimit: Nullable<number>;
  42860. /**
  42861. * Minimum allowed angle on the latitudinal axis.
  42862. * This can help limiting how the Camera is able to move in the scene.
  42863. */
  42864. lowerBetaLimit: number;
  42865. /**
  42866. * Maximum allowed angle on the latitudinal axis.
  42867. * This can help limiting how the Camera is able to move in the scene.
  42868. */
  42869. upperBetaLimit: number;
  42870. /**
  42871. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42872. * This can help limiting how the Camera is able to move in the scene.
  42873. */
  42874. lowerRadiusLimit: Nullable<number>;
  42875. /**
  42876. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42877. * This can help limiting how the Camera is able to move in the scene.
  42878. */
  42879. upperRadiusLimit: Nullable<number>;
  42880. /**
  42881. * Defines the current inertia value used during panning of the camera along the X axis.
  42882. */
  42883. inertialPanningX: number;
  42884. /**
  42885. * Defines the current inertia value used during panning of the camera along the Y axis.
  42886. */
  42887. inertialPanningY: number;
  42888. /**
  42889. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42890. * Basically if your fingers moves away from more than this distance you will be considered
  42891. * in pinch mode.
  42892. */
  42893. pinchToPanMaxDistance: number;
  42894. /**
  42895. * Defines the maximum distance the camera can pan.
  42896. * This could help keeping the cammera always in your scene.
  42897. */
  42898. panningDistanceLimit: Nullable<number>;
  42899. /**
  42900. * Defines the target of the camera before paning.
  42901. */
  42902. panningOriginTarget: Vector3;
  42903. /**
  42904. * Defines the value of the inertia used during panning.
  42905. * 0 would mean stop inertia and one would mean no decelleration at all.
  42906. */
  42907. panningInertia: number;
  42908. /**
  42909. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42910. */
  42911. get angularSensibilityX(): number;
  42912. set angularSensibilityX(value: number);
  42913. /**
  42914. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42915. */
  42916. get angularSensibilityY(): number;
  42917. set angularSensibilityY(value: number);
  42918. /**
  42919. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42920. */
  42921. get pinchPrecision(): number;
  42922. set pinchPrecision(value: number);
  42923. /**
  42924. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42925. * It will be used instead of pinchDeltaPrecision if different from 0.
  42926. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42927. */
  42928. get pinchDeltaPercentage(): number;
  42929. set pinchDeltaPercentage(value: number);
  42930. /**
  42931. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42932. * and pinch delta percentage.
  42933. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42934. * that any object in the plane at the camera's target point will scale
  42935. * perfectly with finger motion.
  42936. */
  42937. get useNaturalPinchZoom(): boolean;
  42938. set useNaturalPinchZoom(value: boolean);
  42939. /**
  42940. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42941. */
  42942. get panningSensibility(): number;
  42943. set panningSensibility(value: number);
  42944. /**
  42945. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42946. */
  42947. get keysUp(): number[];
  42948. set keysUp(value: number[]);
  42949. /**
  42950. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42951. */
  42952. get keysDown(): number[];
  42953. set keysDown(value: number[]);
  42954. /**
  42955. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42956. */
  42957. get keysLeft(): number[];
  42958. set keysLeft(value: number[]);
  42959. /**
  42960. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42961. */
  42962. get keysRight(): number[];
  42963. set keysRight(value: number[]);
  42964. /**
  42965. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42966. */
  42967. get wheelPrecision(): number;
  42968. set wheelPrecision(value: number);
  42969. /**
  42970. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42971. * It will be used instead of pinchDeltaPrecision if different from 0.
  42972. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42973. */
  42974. get wheelDeltaPercentage(): number;
  42975. set wheelDeltaPercentage(value: number);
  42976. /**
  42977. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42978. */
  42979. zoomOnFactor: number;
  42980. /**
  42981. * Defines a screen offset for the camera position.
  42982. */
  42983. targetScreenOffset: Vector2;
  42984. /**
  42985. * Allows the camera to be completely reversed.
  42986. * If false the camera can not arrive upside down.
  42987. */
  42988. allowUpsideDown: boolean;
  42989. /**
  42990. * Define if double tap/click is used to restore the previously saved state of the camera.
  42991. */
  42992. useInputToRestoreState: boolean;
  42993. /** @hidden */
  42994. _viewMatrix: Matrix;
  42995. /** @hidden */
  42996. _useCtrlForPanning: boolean;
  42997. /** @hidden */
  42998. _panningMouseButton: number;
  42999. /**
  43000. * Defines the input associated to the camera.
  43001. */
  43002. inputs: ArcRotateCameraInputsManager;
  43003. /** @hidden */
  43004. _reset: () => void;
  43005. /**
  43006. * Defines the allowed panning axis.
  43007. */
  43008. panningAxis: Vector3;
  43009. protected _localDirection: Vector3;
  43010. protected _transformedDirection: Vector3;
  43011. private _bouncingBehavior;
  43012. /**
  43013. * Gets the bouncing behavior of the camera if it has been enabled.
  43014. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43015. */
  43016. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43017. /**
  43018. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43019. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43020. */
  43021. get useBouncingBehavior(): boolean;
  43022. set useBouncingBehavior(value: boolean);
  43023. private _framingBehavior;
  43024. /**
  43025. * Gets the framing behavior of the camera if it has been enabled.
  43026. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43027. */
  43028. get framingBehavior(): Nullable<FramingBehavior>;
  43029. /**
  43030. * Defines if the framing behavior of the camera is enabled on the camera.
  43031. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43032. */
  43033. get useFramingBehavior(): boolean;
  43034. set useFramingBehavior(value: boolean);
  43035. private _autoRotationBehavior;
  43036. /**
  43037. * Gets the auto rotation behavior of the camera if it has been enabled.
  43038. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43039. */
  43040. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43041. /**
  43042. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43043. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43044. */
  43045. get useAutoRotationBehavior(): boolean;
  43046. set useAutoRotationBehavior(value: boolean);
  43047. /**
  43048. * Observable triggered when the mesh target has been changed on the camera.
  43049. */
  43050. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43051. /**
  43052. * Event raised when the camera is colliding with a mesh.
  43053. */
  43054. onCollide: (collidedMesh: AbstractMesh) => void;
  43055. /**
  43056. * Defines whether the camera should check collision with the objects oh the scene.
  43057. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43058. */
  43059. checkCollisions: boolean;
  43060. /**
  43061. * Defines the collision radius of the camera.
  43062. * This simulates a sphere around the camera.
  43063. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43064. */
  43065. collisionRadius: Vector3;
  43066. protected _collider: Collider;
  43067. protected _previousPosition: Vector3;
  43068. protected _collisionVelocity: Vector3;
  43069. protected _newPosition: Vector3;
  43070. protected _previousAlpha: number;
  43071. protected _previousBeta: number;
  43072. protected _previousRadius: number;
  43073. protected _collisionTriggered: boolean;
  43074. protected _targetBoundingCenter: Nullable<Vector3>;
  43075. private _computationVector;
  43076. /**
  43077. * Instantiates a new ArcRotateCamera in a given scene
  43078. * @param name Defines the name of the camera
  43079. * @param alpha Defines the camera rotation along the logitudinal axis
  43080. * @param beta Defines the camera rotation along the latitudinal axis
  43081. * @param radius Defines the camera distance from its target
  43082. * @param target Defines the camera target
  43083. * @param scene Defines the scene the camera belongs to
  43084. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43085. */
  43086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43087. /** @hidden */
  43088. _initCache(): void;
  43089. /** @hidden */
  43090. _updateCache(ignoreParentClass?: boolean): void;
  43091. protected _getTargetPosition(): Vector3;
  43092. private _storedAlpha;
  43093. private _storedBeta;
  43094. private _storedRadius;
  43095. private _storedTarget;
  43096. private _storedTargetScreenOffset;
  43097. /**
  43098. * Stores the current state of the camera (alpha, beta, radius and target)
  43099. * @returns the camera itself
  43100. */
  43101. storeState(): Camera;
  43102. /**
  43103. * @hidden
  43104. * Restored camera state. You must call storeState() first
  43105. */
  43106. _restoreStateValues(): boolean;
  43107. /** @hidden */
  43108. _isSynchronizedViewMatrix(): boolean;
  43109. /**
  43110. * Attached controls to the current camera.
  43111. * @param element Defines the element the controls should be listened from
  43112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43113. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43114. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43115. */
  43116. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43117. /**
  43118. * Detach the current controls from the camera.
  43119. * The camera will stop reacting to inputs.
  43120. * @param element Defines the element to stop listening the inputs from
  43121. */
  43122. detachControl(element: HTMLElement): void;
  43123. /** @hidden */
  43124. _checkInputs(): void;
  43125. protected _checkLimits(): void;
  43126. /**
  43127. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43128. */
  43129. rebuildAnglesAndRadius(): void;
  43130. /**
  43131. * Use a position to define the current camera related information like alpha, beta and radius
  43132. * @param position Defines the position to set the camera at
  43133. */
  43134. setPosition(position: Vector3): void;
  43135. /**
  43136. * Defines the target the camera should look at.
  43137. * This will automatically adapt alpha beta and radius to fit within the new target.
  43138. * @param target Defines the new target as a Vector or a mesh
  43139. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43140. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43141. */
  43142. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43143. /** @hidden */
  43144. _getViewMatrix(): Matrix;
  43145. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43146. /**
  43147. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43148. * @param meshes Defines the mesh to zoom on
  43149. * @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)
  43150. */
  43151. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43152. /**
  43153. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43154. * The target will be changed but the radius
  43155. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43156. * @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)
  43157. */
  43158. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43159. min: Vector3;
  43160. max: Vector3;
  43161. distance: number;
  43162. }, doNotUpdateMaxZ?: boolean): void;
  43163. /**
  43164. * @override
  43165. * Override Camera.createRigCamera
  43166. */
  43167. createRigCamera(name: string, cameraIndex: number): Camera;
  43168. /**
  43169. * @hidden
  43170. * @override
  43171. * Override Camera._updateRigCameras
  43172. */
  43173. _updateRigCameras(): void;
  43174. /**
  43175. * Destroy the camera and release the current resources hold by it.
  43176. */
  43177. dispose(): void;
  43178. /**
  43179. * Gets the current object class name.
  43180. * @return the class name
  43181. */
  43182. getClassName(): string;
  43183. }
  43184. }
  43185. declare module BABYLON {
  43186. /**
  43187. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43188. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43189. */
  43190. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43191. /**
  43192. * Gets the name of the behavior.
  43193. */
  43194. get name(): string;
  43195. private _zoomStopsAnimation;
  43196. private _idleRotationSpeed;
  43197. private _idleRotationWaitTime;
  43198. private _idleRotationSpinupTime;
  43199. /**
  43200. * Sets the flag that indicates if user zooming should stop animation.
  43201. */
  43202. set zoomStopsAnimation(flag: boolean);
  43203. /**
  43204. * Gets the flag that indicates if user zooming should stop animation.
  43205. */
  43206. get zoomStopsAnimation(): boolean;
  43207. /**
  43208. * Sets the default speed at which the camera rotates around the model.
  43209. */
  43210. set idleRotationSpeed(speed: number);
  43211. /**
  43212. * Gets the default speed at which the camera rotates around the model.
  43213. */
  43214. get idleRotationSpeed(): number;
  43215. /**
  43216. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43217. */
  43218. set idleRotationWaitTime(time: number);
  43219. /**
  43220. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43221. */
  43222. get idleRotationWaitTime(): number;
  43223. /**
  43224. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43225. */
  43226. set idleRotationSpinupTime(time: number);
  43227. /**
  43228. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43229. */
  43230. get idleRotationSpinupTime(): number;
  43231. /**
  43232. * Gets a value indicating if the camera is currently rotating because of this behavior
  43233. */
  43234. get rotationInProgress(): boolean;
  43235. private _onPrePointerObservableObserver;
  43236. private _onAfterCheckInputsObserver;
  43237. private _attachedCamera;
  43238. private _isPointerDown;
  43239. private _lastFrameTime;
  43240. private _lastInteractionTime;
  43241. private _cameraRotationSpeed;
  43242. /**
  43243. * Initializes the behavior.
  43244. */
  43245. init(): void;
  43246. /**
  43247. * Attaches the behavior to its arc rotate camera.
  43248. * @param camera Defines the camera to attach the behavior to
  43249. */
  43250. attach(camera: ArcRotateCamera): void;
  43251. /**
  43252. * Detaches the behavior from its current arc rotate camera.
  43253. */
  43254. detach(): void;
  43255. /**
  43256. * Returns true if user is scrolling.
  43257. * @return true if user is scrolling.
  43258. */
  43259. private _userIsZooming;
  43260. private _lastFrameRadius;
  43261. private _shouldAnimationStopForInteraction;
  43262. /**
  43263. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43264. */
  43265. private _applyUserInteraction;
  43266. private _userIsMoving;
  43267. }
  43268. }
  43269. declare module BABYLON {
  43270. /**
  43271. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43272. */
  43273. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43274. private ui;
  43275. /**
  43276. * The name of the behavior
  43277. */
  43278. name: string;
  43279. /**
  43280. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43281. */
  43282. distanceAwayFromFace: number;
  43283. /**
  43284. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43285. */
  43286. distanceAwayFromBottomOfFace: number;
  43287. private _faceVectors;
  43288. private _target;
  43289. private _scene;
  43290. private _onRenderObserver;
  43291. private _tmpMatrix;
  43292. private _tmpVector;
  43293. /**
  43294. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43295. * @param ui The transform node that should be attched to the mesh
  43296. */
  43297. constructor(ui: TransformNode);
  43298. /**
  43299. * Initializes the behavior
  43300. */
  43301. init(): void;
  43302. private _closestFace;
  43303. private _zeroVector;
  43304. private _lookAtTmpMatrix;
  43305. private _lookAtToRef;
  43306. /**
  43307. * Attaches the AttachToBoxBehavior to the passed in mesh
  43308. * @param target The mesh that the specified node will be attached to
  43309. */
  43310. attach(target: Mesh): void;
  43311. /**
  43312. * Detaches the behavior from the mesh
  43313. */
  43314. detach(): void;
  43315. }
  43316. }
  43317. declare module BABYLON {
  43318. /**
  43319. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43320. */
  43321. export class FadeInOutBehavior implements Behavior<Mesh> {
  43322. /**
  43323. * Time in milliseconds to delay before fading in (Default: 0)
  43324. */
  43325. delay: number;
  43326. /**
  43327. * Time in milliseconds for the mesh to fade in (Default: 300)
  43328. */
  43329. fadeInTime: number;
  43330. private _millisecondsPerFrame;
  43331. private _hovered;
  43332. private _hoverValue;
  43333. private _ownerNode;
  43334. /**
  43335. * Instatiates the FadeInOutBehavior
  43336. */
  43337. constructor();
  43338. /**
  43339. * The name of the behavior
  43340. */
  43341. get name(): string;
  43342. /**
  43343. * Initializes the behavior
  43344. */
  43345. init(): void;
  43346. /**
  43347. * Attaches the fade behavior on the passed in mesh
  43348. * @param ownerNode The mesh that will be faded in/out once attached
  43349. */
  43350. attach(ownerNode: Mesh): void;
  43351. /**
  43352. * Detaches the behavior from the mesh
  43353. */
  43354. detach(): void;
  43355. /**
  43356. * Triggers the mesh to begin fading in or out
  43357. * @param value if the object should fade in or out (true to fade in)
  43358. */
  43359. fadeIn(value: boolean): void;
  43360. private _update;
  43361. private _setAllVisibility;
  43362. }
  43363. }
  43364. declare module BABYLON {
  43365. /**
  43366. * Class containing a set of static utilities functions for managing Pivots
  43367. * @hidden
  43368. */
  43369. export class PivotTools {
  43370. private static _PivotCached;
  43371. private static _OldPivotPoint;
  43372. private static _PivotTranslation;
  43373. private static _PivotTmpVector;
  43374. /** @hidden */
  43375. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43376. /** @hidden */
  43377. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43378. }
  43379. }
  43380. declare module BABYLON {
  43381. /**
  43382. * Class containing static functions to help procedurally build meshes
  43383. */
  43384. export class PlaneBuilder {
  43385. /**
  43386. * Creates a plane mesh
  43387. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43388. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43389. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43391. * * 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
  43392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43393. * @param name defines the name of the mesh
  43394. * @param options defines the options used to create the mesh
  43395. * @param scene defines the hosting scene
  43396. * @returns the plane mesh
  43397. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43398. */
  43399. static CreatePlane(name: string, options: {
  43400. size?: number;
  43401. width?: number;
  43402. height?: number;
  43403. sideOrientation?: number;
  43404. frontUVs?: Vector4;
  43405. backUVs?: Vector4;
  43406. updatable?: boolean;
  43407. sourcePlane?: Plane;
  43408. }, scene?: Nullable<Scene>): Mesh;
  43409. }
  43410. }
  43411. declare module BABYLON {
  43412. /**
  43413. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43414. */
  43415. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43416. private static _AnyMouseID;
  43417. /**
  43418. * Abstract mesh the behavior is set on
  43419. */
  43420. attachedNode: AbstractMesh;
  43421. private _dragPlane;
  43422. private _scene;
  43423. private _pointerObserver;
  43424. private _beforeRenderObserver;
  43425. private static _planeScene;
  43426. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43427. /**
  43428. * 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)
  43429. */
  43430. maxDragAngle: number;
  43431. /**
  43432. * @hidden
  43433. */
  43434. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43435. /**
  43436. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43437. */
  43438. currentDraggingPointerID: number;
  43439. /**
  43440. * The last position where the pointer hit the drag plane in world space
  43441. */
  43442. lastDragPosition: Vector3;
  43443. /**
  43444. * If the behavior is currently in a dragging state
  43445. */
  43446. dragging: boolean;
  43447. /**
  43448. * 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)
  43449. */
  43450. dragDeltaRatio: number;
  43451. /**
  43452. * If the drag plane orientation should be updated during the dragging (Default: true)
  43453. */
  43454. updateDragPlane: boolean;
  43455. private _debugMode;
  43456. private _moving;
  43457. /**
  43458. * Fires each time the attached mesh is dragged with the pointer
  43459. * * delta between last drag position and current drag position in world space
  43460. * * dragDistance along the drag axis
  43461. * * dragPlaneNormal normal of the current drag plane used during the drag
  43462. * * dragPlanePoint in world space where the drag intersects the drag plane
  43463. */
  43464. onDragObservable: Observable<{
  43465. delta: Vector3;
  43466. dragPlanePoint: Vector3;
  43467. dragPlaneNormal: Vector3;
  43468. dragDistance: number;
  43469. pointerId: number;
  43470. }>;
  43471. /**
  43472. * Fires each time a drag begins (eg. mouse down on mesh)
  43473. */
  43474. onDragStartObservable: Observable<{
  43475. dragPlanePoint: Vector3;
  43476. pointerId: number;
  43477. }>;
  43478. /**
  43479. * Fires each time a drag ends (eg. mouse release after drag)
  43480. */
  43481. onDragEndObservable: Observable<{
  43482. dragPlanePoint: Vector3;
  43483. pointerId: number;
  43484. }>;
  43485. /**
  43486. * If the attached mesh should be moved when dragged
  43487. */
  43488. moveAttached: boolean;
  43489. /**
  43490. * If the drag behavior will react to drag events (Default: true)
  43491. */
  43492. enabled: boolean;
  43493. /**
  43494. * If pointer events should start and release the drag (Default: true)
  43495. */
  43496. startAndReleaseDragOnPointerEvents: boolean;
  43497. /**
  43498. * If camera controls should be detached during the drag
  43499. */
  43500. detachCameraControls: boolean;
  43501. /**
  43502. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43503. */
  43504. useObjectOrientationForDragging: boolean;
  43505. private _options;
  43506. /**
  43507. * Gets the options used by the behavior
  43508. */
  43509. get options(): {
  43510. dragAxis?: Vector3;
  43511. dragPlaneNormal?: Vector3;
  43512. };
  43513. /**
  43514. * Sets the options used by the behavior
  43515. */
  43516. set options(options: {
  43517. dragAxis?: Vector3;
  43518. dragPlaneNormal?: Vector3;
  43519. });
  43520. /**
  43521. * Creates a pointer drag behavior that can be attached to a mesh
  43522. * @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)
  43523. */
  43524. constructor(options?: {
  43525. dragAxis?: Vector3;
  43526. dragPlaneNormal?: Vector3;
  43527. });
  43528. /**
  43529. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43530. */
  43531. validateDrag: (targetPosition: Vector3) => boolean;
  43532. /**
  43533. * The name of the behavior
  43534. */
  43535. get name(): string;
  43536. /**
  43537. * Initializes the behavior
  43538. */
  43539. init(): void;
  43540. private _tmpVector;
  43541. private _alternatePickedPoint;
  43542. private _worldDragAxis;
  43543. private _targetPosition;
  43544. private _attachedElement;
  43545. /**
  43546. * Attaches the drag behavior the passed in mesh
  43547. * @param ownerNode The mesh that will be dragged around once attached
  43548. * @param predicate Predicate to use for pick filtering
  43549. */
  43550. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43551. /**
  43552. * Force relase the drag action by code.
  43553. */
  43554. releaseDrag(): void;
  43555. private _startDragRay;
  43556. private _lastPointerRay;
  43557. /**
  43558. * Simulates the start of a pointer drag event on the behavior
  43559. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43560. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43561. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43562. */
  43563. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43564. private _startDrag;
  43565. private _dragDelta;
  43566. private _moveDrag;
  43567. private _pickWithRayOnDragPlane;
  43568. private _pointA;
  43569. private _pointC;
  43570. private _localAxis;
  43571. private _lookAt;
  43572. private _updateDragPlanePosition;
  43573. /**
  43574. * Detaches the behavior from the mesh
  43575. */
  43576. detach(): void;
  43577. }
  43578. }
  43579. declare module BABYLON {
  43580. /**
  43581. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43582. */
  43583. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43584. private _dragBehaviorA;
  43585. private _dragBehaviorB;
  43586. private _startDistance;
  43587. private _initialScale;
  43588. private _targetScale;
  43589. private _ownerNode;
  43590. private _sceneRenderObserver;
  43591. /**
  43592. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43593. */
  43594. constructor();
  43595. /**
  43596. * The name of the behavior
  43597. */
  43598. get name(): string;
  43599. /**
  43600. * Initializes the behavior
  43601. */
  43602. init(): void;
  43603. private _getCurrentDistance;
  43604. /**
  43605. * Attaches the scale behavior the passed in mesh
  43606. * @param ownerNode The mesh that will be scaled around once attached
  43607. */
  43608. attach(ownerNode: Mesh): void;
  43609. /**
  43610. * Detaches the behavior from the mesh
  43611. */
  43612. detach(): void;
  43613. }
  43614. }
  43615. declare module BABYLON {
  43616. /**
  43617. * 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
  43618. */
  43619. export class SixDofDragBehavior implements Behavior<Mesh> {
  43620. private static _virtualScene;
  43621. private _ownerNode;
  43622. private _sceneRenderObserver;
  43623. private _scene;
  43624. private _targetPosition;
  43625. private _virtualOriginMesh;
  43626. private _virtualDragMesh;
  43627. private _pointerObserver;
  43628. private _moving;
  43629. private _startingOrientation;
  43630. private _attachedElement;
  43631. /**
  43632. * 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)
  43633. */
  43634. private zDragFactor;
  43635. /**
  43636. * If the object should rotate to face the drag origin
  43637. */
  43638. rotateDraggedObject: boolean;
  43639. /**
  43640. * If the behavior is currently in a dragging state
  43641. */
  43642. dragging: boolean;
  43643. /**
  43644. * 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)
  43645. */
  43646. dragDeltaRatio: number;
  43647. /**
  43648. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43649. */
  43650. currentDraggingPointerID: number;
  43651. /**
  43652. * If camera controls should be detached during the drag
  43653. */
  43654. detachCameraControls: boolean;
  43655. /**
  43656. * Fires each time a drag starts
  43657. */
  43658. onDragStartObservable: Observable<{}>;
  43659. /**
  43660. * Fires each time a drag ends (eg. mouse release after drag)
  43661. */
  43662. onDragEndObservable: Observable<{}>;
  43663. /**
  43664. * 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
  43665. */
  43666. constructor();
  43667. /**
  43668. * The name of the behavior
  43669. */
  43670. get name(): string;
  43671. /**
  43672. * Initializes the behavior
  43673. */
  43674. init(): void;
  43675. /**
  43676. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43677. */
  43678. private get _pointerCamera();
  43679. /**
  43680. * Attaches the scale behavior the passed in mesh
  43681. * @param ownerNode The mesh that will be scaled around once attached
  43682. */
  43683. attach(ownerNode: Mesh): void;
  43684. /**
  43685. * Detaches the behavior from the mesh
  43686. */
  43687. detach(): void;
  43688. }
  43689. }
  43690. declare module BABYLON {
  43691. /**
  43692. * Class used to apply inverse kinematics to bones
  43693. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43694. */
  43695. export class BoneIKController {
  43696. private static _tmpVecs;
  43697. private static _tmpQuat;
  43698. private static _tmpMats;
  43699. /**
  43700. * Gets or sets the target mesh
  43701. */
  43702. targetMesh: AbstractMesh;
  43703. /** Gets or sets the mesh used as pole */
  43704. poleTargetMesh: AbstractMesh;
  43705. /**
  43706. * Gets or sets the bone used as pole
  43707. */
  43708. poleTargetBone: Nullable<Bone>;
  43709. /**
  43710. * Gets or sets the target position
  43711. */
  43712. targetPosition: Vector3;
  43713. /**
  43714. * Gets or sets the pole target position
  43715. */
  43716. poleTargetPosition: Vector3;
  43717. /**
  43718. * Gets or sets the pole target local offset
  43719. */
  43720. poleTargetLocalOffset: Vector3;
  43721. /**
  43722. * Gets or sets the pole angle
  43723. */
  43724. poleAngle: number;
  43725. /**
  43726. * Gets or sets the mesh associated with the controller
  43727. */
  43728. mesh: AbstractMesh;
  43729. /**
  43730. * 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)
  43731. */
  43732. slerpAmount: number;
  43733. private _bone1Quat;
  43734. private _bone1Mat;
  43735. private _bone2Ang;
  43736. private _bone1;
  43737. private _bone2;
  43738. private _bone1Length;
  43739. private _bone2Length;
  43740. private _maxAngle;
  43741. private _maxReach;
  43742. private _rightHandedSystem;
  43743. private _bendAxis;
  43744. private _slerping;
  43745. private _adjustRoll;
  43746. /**
  43747. * Gets or sets maximum allowed angle
  43748. */
  43749. get maxAngle(): number;
  43750. set maxAngle(value: number);
  43751. /**
  43752. * Creates a new BoneIKController
  43753. * @param mesh defines the mesh to control
  43754. * @param bone defines the bone to control
  43755. * @param options defines options to set up the controller
  43756. */
  43757. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43758. targetMesh?: AbstractMesh;
  43759. poleTargetMesh?: AbstractMesh;
  43760. poleTargetBone?: Bone;
  43761. poleTargetLocalOffset?: Vector3;
  43762. poleAngle?: number;
  43763. bendAxis?: Vector3;
  43764. maxAngle?: number;
  43765. slerpAmount?: number;
  43766. });
  43767. private _setMaxAngle;
  43768. /**
  43769. * Force the controller to update the bones
  43770. */
  43771. update(): void;
  43772. }
  43773. }
  43774. declare module BABYLON {
  43775. /**
  43776. * Class used to make a bone look toward a point in space
  43777. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43778. */
  43779. export class BoneLookController {
  43780. private static _tmpVecs;
  43781. private static _tmpQuat;
  43782. private static _tmpMats;
  43783. /**
  43784. * The target Vector3 that the bone will look at
  43785. */
  43786. target: Vector3;
  43787. /**
  43788. * The mesh that the bone is attached to
  43789. */
  43790. mesh: AbstractMesh;
  43791. /**
  43792. * The bone that will be looking to the target
  43793. */
  43794. bone: Bone;
  43795. /**
  43796. * The up axis of the coordinate system that is used when the bone is rotated
  43797. */
  43798. upAxis: Vector3;
  43799. /**
  43800. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43801. */
  43802. upAxisSpace: Space;
  43803. /**
  43804. * Used to make an adjustment to the yaw of the bone
  43805. */
  43806. adjustYaw: number;
  43807. /**
  43808. * Used to make an adjustment to the pitch of the bone
  43809. */
  43810. adjustPitch: number;
  43811. /**
  43812. * Used to make an adjustment to the roll of the bone
  43813. */
  43814. adjustRoll: number;
  43815. /**
  43816. * 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)
  43817. */
  43818. slerpAmount: number;
  43819. private _minYaw;
  43820. private _maxYaw;
  43821. private _minPitch;
  43822. private _maxPitch;
  43823. private _minYawSin;
  43824. private _minYawCos;
  43825. private _maxYawSin;
  43826. private _maxYawCos;
  43827. private _midYawConstraint;
  43828. private _minPitchTan;
  43829. private _maxPitchTan;
  43830. private _boneQuat;
  43831. private _slerping;
  43832. private _transformYawPitch;
  43833. private _transformYawPitchInv;
  43834. private _firstFrameSkipped;
  43835. private _yawRange;
  43836. private _fowardAxis;
  43837. /**
  43838. * Gets or sets the minimum yaw angle that the bone can look to
  43839. */
  43840. get minYaw(): number;
  43841. set minYaw(value: number);
  43842. /**
  43843. * Gets or sets the maximum yaw angle that the bone can look to
  43844. */
  43845. get maxYaw(): number;
  43846. set maxYaw(value: number);
  43847. /**
  43848. * Gets or sets the minimum pitch angle that the bone can look to
  43849. */
  43850. get minPitch(): number;
  43851. set minPitch(value: number);
  43852. /**
  43853. * Gets or sets the maximum pitch angle that the bone can look to
  43854. */
  43855. get maxPitch(): number;
  43856. set maxPitch(value: number);
  43857. /**
  43858. * Create a BoneLookController
  43859. * @param mesh the mesh that the bone belongs to
  43860. * @param bone the bone that will be looking to the target
  43861. * @param target the target Vector3 to look at
  43862. * @param options optional settings:
  43863. * * maxYaw: the maximum angle the bone will yaw to
  43864. * * minYaw: the minimum angle the bone will yaw to
  43865. * * maxPitch: the maximum angle the bone will pitch to
  43866. * * minPitch: the minimum angle the bone will yaw to
  43867. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43868. * * upAxis: the up axis of the coordinate system
  43869. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43870. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43871. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43872. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43873. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43874. * * adjustRoll: used to make an adjustment to the roll of the bone
  43875. **/
  43876. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43877. maxYaw?: number;
  43878. minYaw?: number;
  43879. maxPitch?: number;
  43880. minPitch?: number;
  43881. slerpAmount?: number;
  43882. upAxis?: Vector3;
  43883. upAxisSpace?: Space;
  43884. yawAxis?: Vector3;
  43885. pitchAxis?: Vector3;
  43886. adjustYaw?: number;
  43887. adjustPitch?: number;
  43888. adjustRoll?: number;
  43889. });
  43890. /**
  43891. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43892. */
  43893. update(): void;
  43894. private _getAngleDiff;
  43895. private _getAngleBetween;
  43896. private _isAngleBetween;
  43897. }
  43898. }
  43899. declare module BABYLON {
  43900. /**
  43901. * Manage the gamepad inputs to control an arc rotate camera.
  43902. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43903. */
  43904. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43905. /**
  43906. * Defines the camera the input is attached to.
  43907. */
  43908. camera: ArcRotateCamera;
  43909. /**
  43910. * Defines the gamepad the input is gathering event from.
  43911. */
  43912. gamepad: Nullable<Gamepad>;
  43913. /**
  43914. * Defines the gamepad rotation sensiblity.
  43915. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43916. */
  43917. gamepadRotationSensibility: number;
  43918. /**
  43919. * Defines the gamepad move sensiblity.
  43920. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43921. */
  43922. gamepadMoveSensibility: number;
  43923. private _yAxisScale;
  43924. /**
  43925. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43926. */
  43927. get invertYAxis(): boolean;
  43928. set invertYAxis(value: boolean);
  43929. private _onGamepadConnectedObserver;
  43930. private _onGamepadDisconnectedObserver;
  43931. /**
  43932. * Attach the input controls to a specific dom element to get the input from.
  43933. * @param element Defines the element the controls should be listened from
  43934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43935. */
  43936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43937. /**
  43938. * Detach the current controls from the specified dom element.
  43939. * @param element Defines the element to stop listening the inputs from
  43940. */
  43941. detachControl(element: Nullable<HTMLElement>): void;
  43942. /**
  43943. * Update the current camera state depending on the inputs that have been used this frame.
  43944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43945. */
  43946. checkInputs(): void;
  43947. /**
  43948. * Gets the class name of the current intput.
  43949. * @returns the class name
  43950. */
  43951. getClassName(): string;
  43952. /**
  43953. * Get the friendly name associated with the input class.
  43954. * @returns the input friendly name
  43955. */
  43956. getSimpleName(): string;
  43957. }
  43958. }
  43959. declare module BABYLON {
  43960. interface ArcRotateCameraInputsManager {
  43961. /**
  43962. * Add orientation input support to the input manager.
  43963. * @returns the current input manager
  43964. */
  43965. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43966. }
  43967. /**
  43968. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43969. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43970. */
  43971. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43972. /**
  43973. * Defines the camera the input is attached to.
  43974. */
  43975. camera: ArcRotateCamera;
  43976. /**
  43977. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43978. */
  43979. alphaCorrection: number;
  43980. /**
  43981. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43982. */
  43983. gammaCorrection: number;
  43984. private _alpha;
  43985. private _gamma;
  43986. private _dirty;
  43987. private _deviceOrientationHandler;
  43988. /**
  43989. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43990. */
  43991. constructor();
  43992. /**
  43993. * Attach the input controls to a specific dom element to get the input from.
  43994. * @param element Defines the element the controls should be listened from
  43995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43996. */
  43997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43998. /** @hidden */
  43999. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44000. /**
  44001. * Update the current camera state depending on the inputs that have been used this frame.
  44002. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44003. */
  44004. checkInputs(): void;
  44005. /**
  44006. * Detach the current controls from the specified dom element.
  44007. * @param element Defines the element to stop listening the inputs from
  44008. */
  44009. detachControl(element: Nullable<HTMLElement>): void;
  44010. /**
  44011. * Gets the class name of the current intput.
  44012. * @returns the class name
  44013. */
  44014. getClassName(): string;
  44015. /**
  44016. * Get the friendly name associated with the input class.
  44017. * @returns the input friendly name
  44018. */
  44019. getSimpleName(): string;
  44020. }
  44021. }
  44022. declare module BABYLON {
  44023. /**
  44024. * Listen to mouse events to control the camera.
  44025. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44026. */
  44027. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44028. /**
  44029. * Defines the camera the input is attached to.
  44030. */
  44031. camera: FlyCamera;
  44032. /**
  44033. * Defines if touch is enabled. (Default is true.)
  44034. */
  44035. touchEnabled: boolean;
  44036. /**
  44037. * Defines the buttons associated with the input to handle camera rotation.
  44038. */
  44039. buttons: number[];
  44040. /**
  44041. * Assign buttons for Yaw control.
  44042. */
  44043. buttonsYaw: number[];
  44044. /**
  44045. * Assign buttons for Pitch control.
  44046. */
  44047. buttonsPitch: number[];
  44048. /**
  44049. * Assign buttons for Roll control.
  44050. */
  44051. buttonsRoll: number[];
  44052. /**
  44053. * Detect if any button is being pressed while mouse is moved.
  44054. * -1 = Mouse locked.
  44055. * 0 = Left button.
  44056. * 1 = Middle Button.
  44057. * 2 = Right Button.
  44058. */
  44059. activeButton: number;
  44060. /**
  44061. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44062. * Higher values reduce its sensitivity.
  44063. */
  44064. angularSensibility: number;
  44065. private _mousemoveCallback;
  44066. private _observer;
  44067. private _rollObserver;
  44068. private previousPosition;
  44069. private noPreventDefault;
  44070. private element;
  44071. /**
  44072. * Listen to mouse events to control the camera.
  44073. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44075. */
  44076. constructor(touchEnabled?: boolean);
  44077. /**
  44078. * Attach the mouse control to the HTML DOM element.
  44079. * @param element Defines the element that listens to the input events.
  44080. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44081. */
  44082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44083. /**
  44084. * Detach the current controls from the specified dom element.
  44085. * @param element Defines the element to stop listening the inputs from
  44086. */
  44087. detachControl(element: Nullable<HTMLElement>): void;
  44088. /**
  44089. * Gets the class name of the current input.
  44090. * @returns the class name.
  44091. */
  44092. getClassName(): string;
  44093. /**
  44094. * Get the friendly name associated with the input class.
  44095. * @returns the input's friendly name.
  44096. */
  44097. getSimpleName(): string;
  44098. private _pointerInput;
  44099. private _onMouseMove;
  44100. /**
  44101. * Rotate camera by mouse offset.
  44102. */
  44103. private rotateCamera;
  44104. }
  44105. }
  44106. declare module BABYLON {
  44107. /**
  44108. * Default Inputs manager for the FlyCamera.
  44109. * It groups all the default supported inputs for ease of use.
  44110. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44111. */
  44112. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44113. /**
  44114. * Instantiates a new FlyCameraInputsManager.
  44115. * @param camera Defines the camera the inputs belong to.
  44116. */
  44117. constructor(camera: FlyCamera);
  44118. /**
  44119. * Add keyboard input support to the input manager.
  44120. * @returns the new FlyCameraKeyboardMoveInput().
  44121. */
  44122. addKeyboard(): FlyCameraInputsManager;
  44123. /**
  44124. * Add mouse input support to the input manager.
  44125. * @param touchEnabled Enable touch screen support.
  44126. * @returns the new FlyCameraMouseInput().
  44127. */
  44128. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44129. }
  44130. }
  44131. declare module BABYLON {
  44132. /**
  44133. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44134. * such as in a 3D Space Shooter or a Flight Simulator.
  44135. */
  44136. export class FlyCamera extends TargetCamera {
  44137. /**
  44138. * Define the collision ellipsoid of the camera.
  44139. * This is helpful for simulating a camera body, like a player's body.
  44140. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44141. */
  44142. ellipsoid: Vector3;
  44143. /**
  44144. * Define an offset for the position of the ellipsoid around the camera.
  44145. * This can be helpful if the camera is attached away from the player's body center,
  44146. * such as at its head.
  44147. */
  44148. ellipsoidOffset: Vector3;
  44149. /**
  44150. * Enable or disable collisions of the camera with the rest of the scene objects.
  44151. */
  44152. checkCollisions: boolean;
  44153. /**
  44154. * Enable or disable gravity on the camera.
  44155. */
  44156. applyGravity: boolean;
  44157. /**
  44158. * Define the current direction the camera is moving to.
  44159. */
  44160. cameraDirection: Vector3;
  44161. /**
  44162. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44163. * This overrides and empties cameraRotation.
  44164. */
  44165. rotationQuaternion: Quaternion;
  44166. /**
  44167. * Track Roll to maintain the wanted Rolling when looking around.
  44168. */
  44169. _trackRoll: number;
  44170. /**
  44171. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44172. */
  44173. rollCorrect: number;
  44174. /**
  44175. * Mimic a banked turn, Rolling the camera when Yawing.
  44176. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44177. */
  44178. bankedTurn: boolean;
  44179. /**
  44180. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44181. */
  44182. bankedTurnLimit: number;
  44183. /**
  44184. * Value of 0 disables the banked Roll.
  44185. * Value of 1 is equal to the Yaw angle in radians.
  44186. */
  44187. bankedTurnMultiplier: number;
  44188. /**
  44189. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44190. */
  44191. inputs: FlyCameraInputsManager;
  44192. /**
  44193. * Gets the input sensibility for mouse input.
  44194. * Higher values reduce sensitivity.
  44195. */
  44196. get angularSensibility(): number;
  44197. /**
  44198. * Sets the input sensibility for a mouse input.
  44199. * Higher values reduce sensitivity.
  44200. */
  44201. set angularSensibility(value: number);
  44202. /**
  44203. * Get the keys for camera movement forward.
  44204. */
  44205. get keysForward(): number[];
  44206. /**
  44207. * Set the keys for camera movement forward.
  44208. */
  44209. set keysForward(value: number[]);
  44210. /**
  44211. * Get the keys for camera movement backward.
  44212. */
  44213. get keysBackward(): number[];
  44214. set keysBackward(value: number[]);
  44215. /**
  44216. * Get the keys for camera movement up.
  44217. */
  44218. get keysUp(): number[];
  44219. /**
  44220. * Set the keys for camera movement up.
  44221. */
  44222. set keysUp(value: number[]);
  44223. /**
  44224. * Get the keys for camera movement down.
  44225. */
  44226. get keysDown(): number[];
  44227. /**
  44228. * Set the keys for camera movement down.
  44229. */
  44230. set keysDown(value: number[]);
  44231. /**
  44232. * Get the keys for camera movement left.
  44233. */
  44234. get keysLeft(): number[];
  44235. /**
  44236. * Set the keys for camera movement left.
  44237. */
  44238. set keysLeft(value: number[]);
  44239. /**
  44240. * Set the keys for camera movement right.
  44241. */
  44242. get keysRight(): number[];
  44243. /**
  44244. * Set the keys for camera movement right.
  44245. */
  44246. set keysRight(value: number[]);
  44247. /**
  44248. * Event raised when the camera collides with a mesh in the scene.
  44249. */
  44250. onCollide: (collidedMesh: AbstractMesh) => void;
  44251. private _collider;
  44252. private _needMoveForGravity;
  44253. private _oldPosition;
  44254. private _diffPosition;
  44255. private _newPosition;
  44256. /** @hidden */
  44257. _localDirection: Vector3;
  44258. /** @hidden */
  44259. _transformedDirection: Vector3;
  44260. /**
  44261. * Instantiates a FlyCamera.
  44262. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44263. * such as in a 3D Space Shooter or a Flight Simulator.
  44264. * @param name Define the name of the camera in the scene.
  44265. * @param position Define the starting position of the camera in the scene.
  44266. * @param scene Define the scene the camera belongs to.
  44267. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44268. */
  44269. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44270. /**
  44271. * Attach a control to the HTML DOM element.
  44272. * @param element Defines the element that listens to the input events.
  44273. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44274. */
  44275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44276. /**
  44277. * Detach a control from the HTML DOM element.
  44278. * The camera will stop reacting to that input.
  44279. * @param element Defines the element that listens to the input events.
  44280. */
  44281. detachControl(element: HTMLElement): void;
  44282. private _collisionMask;
  44283. /**
  44284. * Get the mask that the camera ignores in collision events.
  44285. */
  44286. get collisionMask(): number;
  44287. /**
  44288. * Set the mask that the camera ignores in collision events.
  44289. */
  44290. set collisionMask(mask: number);
  44291. /** @hidden */
  44292. _collideWithWorld(displacement: Vector3): void;
  44293. /** @hidden */
  44294. private _onCollisionPositionChange;
  44295. /** @hidden */
  44296. _checkInputs(): void;
  44297. /** @hidden */
  44298. _decideIfNeedsToMove(): boolean;
  44299. /** @hidden */
  44300. _updatePosition(): void;
  44301. /**
  44302. * Restore the Roll to its target value at the rate specified.
  44303. * @param rate - Higher means slower restoring.
  44304. * @hidden
  44305. */
  44306. restoreRoll(rate: number): void;
  44307. /**
  44308. * Destroy the camera and release the current resources held by it.
  44309. */
  44310. dispose(): void;
  44311. /**
  44312. * Get the current object class name.
  44313. * @returns the class name.
  44314. */
  44315. getClassName(): string;
  44316. }
  44317. }
  44318. declare module BABYLON {
  44319. /**
  44320. * Listen to keyboard events to control the camera.
  44321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44322. */
  44323. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44324. /**
  44325. * Defines the camera the input is attached to.
  44326. */
  44327. camera: FlyCamera;
  44328. /**
  44329. * The list of keyboard keys used to control the forward move of the camera.
  44330. */
  44331. keysForward: number[];
  44332. /**
  44333. * The list of keyboard keys used to control the backward move of the camera.
  44334. */
  44335. keysBackward: number[];
  44336. /**
  44337. * The list of keyboard keys used to control the forward move of the camera.
  44338. */
  44339. keysUp: number[];
  44340. /**
  44341. * The list of keyboard keys used to control the backward move of the camera.
  44342. */
  44343. keysDown: number[];
  44344. /**
  44345. * The list of keyboard keys used to control the right strafe move of the camera.
  44346. */
  44347. keysRight: number[];
  44348. /**
  44349. * The list of keyboard keys used to control the left strafe move of the camera.
  44350. */
  44351. keysLeft: number[];
  44352. private _keys;
  44353. private _onCanvasBlurObserver;
  44354. private _onKeyboardObserver;
  44355. private _engine;
  44356. private _scene;
  44357. /**
  44358. * Attach the input controls to a specific dom element to get the input from.
  44359. * @param element Defines the element the controls should be listened from
  44360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44361. */
  44362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44363. /**
  44364. * Detach the current controls from the specified dom element.
  44365. * @param element Defines the element to stop listening the inputs from
  44366. */
  44367. detachControl(element: Nullable<HTMLElement>): void;
  44368. /**
  44369. * Gets the class name of the current intput.
  44370. * @returns the class name
  44371. */
  44372. getClassName(): string;
  44373. /** @hidden */
  44374. _onLostFocus(e: FocusEvent): void;
  44375. /**
  44376. * Get the friendly name associated with the input class.
  44377. * @returns the input friendly name
  44378. */
  44379. getSimpleName(): string;
  44380. /**
  44381. * Update the current camera state depending on the inputs that have been used this frame.
  44382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44383. */
  44384. checkInputs(): void;
  44385. }
  44386. }
  44387. declare module BABYLON {
  44388. /**
  44389. * Manage the mouse wheel inputs to control a follow camera.
  44390. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44391. */
  44392. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44393. /**
  44394. * Defines the camera the input is attached to.
  44395. */
  44396. camera: FollowCamera;
  44397. /**
  44398. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44399. */
  44400. axisControlRadius: boolean;
  44401. /**
  44402. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44403. */
  44404. axisControlHeight: boolean;
  44405. /**
  44406. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44407. */
  44408. axisControlRotation: boolean;
  44409. /**
  44410. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44411. * relation to mouseWheel events.
  44412. */
  44413. wheelPrecision: number;
  44414. /**
  44415. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44416. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44417. */
  44418. wheelDeltaPercentage: number;
  44419. private _wheel;
  44420. private _observer;
  44421. /**
  44422. * Attach the input controls to a specific dom element to get the input from.
  44423. * @param element Defines the element the controls should be listened from
  44424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44425. */
  44426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44427. /**
  44428. * Detach the current controls from the specified dom element.
  44429. * @param element Defines the element to stop listening the inputs from
  44430. */
  44431. detachControl(element: Nullable<HTMLElement>): void;
  44432. /**
  44433. * Gets the class name of the current intput.
  44434. * @returns the class name
  44435. */
  44436. getClassName(): string;
  44437. /**
  44438. * Get the friendly name associated with the input class.
  44439. * @returns the input friendly name
  44440. */
  44441. getSimpleName(): string;
  44442. }
  44443. }
  44444. declare module BABYLON {
  44445. /**
  44446. * Manage the pointers inputs to control an follow camera.
  44447. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44448. */
  44449. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44450. /**
  44451. * Defines the camera the input is attached to.
  44452. */
  44453. camera: FollowCamera;
  44454. /**
  44455. * Gets the class name of the current input.
  44456. * @returns the class name
  44457. */
  44458. getClassName(): string;
  44459. /**
  44460. * Defines the pointer angular sensibility along the X axis or how fast is
  44461. * the camera rotating.
  44462. * A negative number will reverse the axis direction.
  44463. */
  44464. angularSensibilityX: number;
  44465. /**
  44466. * Defines the pointer angular sensibility along the Y axis or how fast is
  44467. * the camera rotating.
  44468. * A negative number will reverse the axis direction.
  44469. */
  44470. angularSensibilityY: number;
  44471. /**
  44472. * Defines the pointer pinch precision or how fast is the camera zooming.
  44473. * A negative number will reverse the axis direction.
  44474. */
  44475. pinchPrecision: number;
  44476. /**
  44477. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44478. * from 0.
  44479. * It defines the percentage of current camera.radius to use as delta when
  44480. * pinch zoom is used.
  44481. */
  44482. pinchDeltaPercentage: number;
  44483. /**
  44484. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44485. */
  44486. axisXControlRadius: boolean;
  44487. /**
  44488. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44489. */
  44490. axisXControlHeight: boolean;
  44491. /**
  44492. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44493. */
  44494. axisXControlRotation: boolean;
  44495. /**
  44496. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44497. */
  44498. axisYControlRadius: boolean;
  44499. /**
  44500. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44501. */
  44502. axisYControlHeight: boolean;
  44503. /**
  44504. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44505. */
  44506. axisYControlRotation: boolean;
  44507. /**
  44508. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44509. */
  44510. axisPinchControlRadius: boolean;
  44511. /**
  44512. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44513. */
  44514. axisPinchControlHeight: boolean;
  44515. /**
  44516. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44517. */
  44518. axisPinchControlRotation: boolean;
  44519. /**
  44520. * Log error messages if basic misconfiguration has occurred.
  44521. */
  44522. warningEnable: boolean;
  44523. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44524. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44525. private _warningCounter;
  44526. private _warning;
  44527. }
  44528. }
  44529. declare module BABYLON {
  44530. /**
  44531. * Default Inputs manager for the FollowCamera.
  44532. * It groups all the default supported inputs for ease of use.
  44533. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44534. */
  44535. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44536. /**
  44537. * Instantiates a new FollowCameraInputsManager.
  44538. * @param camera Defines the camera the inputs belong to
  44539. */
  44540. constructor(camera: FollowCamera);
  44541. /**
  44542. * Add keyboard input support to the input manager.
  44543. * @returns the current input manager
  44544. */
  44545. addKeyboard(): FollowCameraInputsManager;
  44546. /**
  44547. * Add mouse wheel input support to the input manager.
  44548. * @returns the current input manager
  44549. */
  44550. addMouseWheel(): FollowCameraInputsManager;
  44551. /**
  44552. * Add pointers input support to the input manager.
  44553. * @returns the current input manager
  44554. */
  44555. addPointers(): FollowCameraInputsManager;
  44556. /**
  44557. * Add orientation input support to the input manager.
  44558. * @returns the current input manager
  44559. */
  44560. addVRDeviceOrientation(): FollowCameraInputsManager;
  44561. }
  44562. }
  44563. declare module BABYLON {
  44564. /**
  44565. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44566. * an arc rotate version arcFollowCamera are available.
  44567. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44568. */
  44569. export class FollowCamera extends TargetCamera {
  44570. /**
  44571. * Distance the follow camera should follow an object at
  44572. */
  44573. radius: number;
  44574. /**
  44575. * Minimum allowed distance of the camera to the axis of rotation
  44576. * (The camera can not get closer).
  44577. * This can help limiting how the Camera is able to move in the scene.
  44578. */
  44579. lowerRadiusLimit: Nullable<number>;
  44580. /**
  44581. * Maximum allowed distance of the camera to the axis of rotation
  44582. * (The camera can not get further).
  44583. * This can help limiting how the Camera is able to move in the scene.
  44584. */
  44585. upperRadiusLimit: Nullable<number>;
  44586. /**
  44587. * Define a rotation offset between the camera and the object it follows
  44588. */
  44589. rotationOffset: number;
  44590. /**
  44591. * Minimum allowed angle to camera position relative to target object.
  44592. * This can help limiting how the Camera is able to move in the scene.
  44593. */
  44594. lowerRotationOffsetLimit: Nullable<number>;
  44595. /**
  44596. * Maximum allowed angle to camera position relative to target object.
  44597. * This can help limiting how the Camera is able to move in the scene.
  44598. */
  44599. upperRotationOffsetLimit: Nullable<number>;
  44600. /**
  44601. * Define a height offset between the camera and the object it follows.
  44602. * It can help following an object from the top (like a car chaing a plane)
  44603. */
  44604. heightOffset: number;
  44605. /**
  44606. * Minimum allowed height of camera position relative to target object.
  44607. * This can help limiting how the Camera is able to move in the scene.
  44608. */
  44609. lowerHeightOffsetLimit: Nullable<number>;
  44610. /**
  44611. * Maximum allowed height of camera position relative to target object.
  44612. * This can help limiting how the Camera is able to move in the scene.
  44613. */
  44614. upperHeightOffsetLimit: Nullable<number>;
  44615. /**
  44616. * Define how fast the camera can accelerate to follow it s target.
  44617. */
  44618. cameraAcceleration: number;
  44619. /**
  44620. * Define the speed limit of the camera following an object.
  44621. */
  44622. maxCameraSpeed: number;
  44623. /**
  44624. * Define the target of the camera.
  44625. */
  44626. lockedTarget: Nullable<AbstractMesh>;
  44627. /**
  44628. * Defines the input associated with the camera.
  44629. */
  44630. inputs: FollowCameraInputsManager;
  44631. /**
  44632. * Instantiates the follow camera.
  44633. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44634. * @param name Define the name of the camera in the scene
  44635. * @param position Define the position of the camera
  44636. * @param scene Define the scene the camera belong to
  44637. * @param lockedTarget Define the target of the camera
  44638. */
  44639. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44640. private _follow;
  44641. /**
  44642. * Attached controls to the current camera.
  44643. * @param element Defines the element the controls should be listened from
  44644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44645. */
  44646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44647. /**
  44648. * Detach the current controls from the camera.
  44649. * The camera will stop reacting to inputs.
  44650. * @param element Defines the element to stop listening the inputs from
  44651. */
  44652. detachControl(element: HTMLElement): void;
  44653. /** @hidden */
  44654. _checkInputs(): void;
  44655. private _checkLimits;
  44656. /**
  44657. * Gets the camera class name.
  44658. * @returns the class name
  44659. */
  44660. getClassName(): string;
  44661. }
  44662. /**
  44663. * Arc Rotate version of the follow camera.
  44664. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44665. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44666. */
  44667. export class ArcFollowCamera extends TargetCamera {
  44668. /** The longitudinal angle of the camera */
  44669. alpha: number;
  44670. /** The latitudinal angle of the camera */
  44671. beta: number;
  44672. /** The radius of the camera from its target */
  44673. radius: number;
  44674. private _cartesianCoordinates;
  44675. /** Define the camera target (the mesh it should follow) */
  44676. private _meshTarget;
  44677. /**
  44678. * Instantiates a new ArcFollowCamera
  44679. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44680. * @param name Define the name of the camera
  44681. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44682. * @param beta Define the rotation angle of the camera around the elevation axis
  44683. * @param radius Define the radius of the camera from its target point
  44684. * @param target Define the target of the camera
  44685. * @param scene Define the scene the camera belongs to
  44686. */
  44687. constructor(name: string,
  44688. /** The longitudinal angle of the camera */
  44689. alpha: number,
  44690. /** The latitudinal angle of the camera */
  44691. beta: number,
  44692. /** The radius of the camera from its target */
  44693. radius: number,
  44694. /** Define the camera target (the mesh it should follow) */
  44695. target: Nullable<AbstractMesh>, scene: Scene);
  44696. private _follow;
  44697. /** @hidden */
  44698. _checkInputs(): void;
  44699. /**
  44700. * Returns the class name of the object.
  44701. * It is mostly used internally for serialization purposes.
  44702. */
  44703. getClassName(): string;
  44704. }
  44705. }
  44706. declare module BABYLON {
  44707. /**
  44708. * Manage the keyboard inputs to control the movement of a follow camera.
  44709. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44710. */
  44711. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44712. /**
  44713. * Defines the camera the input is attached to.
  44714. */
  44715. camera: FollowCamera;
  44716. /**
  44717. * Defines the list of key codes associated with the up action (increase heightOffset)
  44718. */
  44719. keysHeightOffsetIncr: number[];
  44720. /**
  44721. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44722. */
  44723. keysHeightOffsetDecr: number[];
  44724. /**
  44725. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44726. */
  44727. keysHeightOffsetModifierAlt: boolean;
  44728. /**
  44729. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44730. */
  44731. keysHeightOffsetModifierCtrl: boolean;
  44732. /**
  44733. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44734. */
  44735. keysHeightOffsetModifierShift: boolean;
  44736. /**
  44737. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44738. */
  44739. keysRotationOffsetIncr: number[];
  44740. /**
  44741. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44742. */
  44743. keysRotationOffsetDecr: number[];
  44744. /**
  44745. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44746. */
  44747. keysRotationOffsetModifierAlt: boolean;
  44748. /**
  44749. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44750. */
  44751. keysRotationOffsetModifierCtrl: boolean;
  44752. /**
  44753. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44754. */
  44755. keysRotationOffsetModifierShift: boolean;
  44756. /**
  44757. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44758. */
  44759. keysRadiusIncr: number[];
  44760. /**
  44761. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44762. */
  44763. keysRadiusDecr: number[];
  44764. /**
  44765. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44766. */
  44767. keysRadiusModifierAlt: boolean;
  44768. /**
  44769. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44770. */
  44771. keysRadiusModifierCtrl: boolean;
  44772. /**
  44773. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44774. */
  44775. keysRadiusModifierShift: boolean;
  44776. /**
  44777. * Defines the rate of change of heightOffset.
  44778. */
  44779. heightSensibility: number;
  44780. /**
  44781. * Defines the rate of change of rotationOffset.
  44782. */
  44783. rotationSensibility: number;
  44784. /**
  44785. * Defines the rate of change of radius.
  44786. */
  44787. radiusSensibility: number;
  44788. private _keys;
  44789. private _ctrlPressed;
  44790. private _altPressed;
  44791. private _shiftPressed;
  44792. private _onCanvasBlurObserver;
  44793. private _onKeyboardObserver;
  44794. private _engine;
  44795. private _scene;
  44796. /**
  44797. * Attach the input controls to a specific dom element to get the input from.
  44798. * @param element Defines the element the controls should be listened from
  44799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44800. */
  44801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44802. /**
  44803. * Detach the current controls from the specified dom element.
  44804. * @param element Defines the element to stop listening the inputs from
  44805. */
  44806. detachControl(element: Nullable<HTMLElement>): void;
  44807. /**
  44808. * Update the current camera state depending on the inputs that have been used this frame.
  44809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44810. */
  44811. checkInputs(): void;
  44812. /**
  44813. * Gets the class name of the current input.
  44814. * @returns the class name
  44815. */
  44816. getClassName(): string;
  44817. /**
  44818. * Get the friendly name associated with the input class.
  44819. * @returns the input friendly name
  44820. */
  44821. getSimpleName(): string;
  44822. /**
  44823. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44824. * allow modification of the heightOffset value.
  44825. */
  44826. private _modifierHeightOffset;
  44827. /**
  44828. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44829. * allow modification of the rotationOffset value.
  44830. */
  44831. private _modifierRotationOffset;
  44832. /**
  44833. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44834. * allow modification of the radius value.
  44835. */
  44836. private _modifierRadius;
  44837. }
  44838. }
  44839. declare module BABYLON {
  44840. interface FreeCameraInputsManager {
  44841. /**
  44842. * @hidden
  44843. */
  44844. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44845. /**
  44846. * Add orientation input support to the input manager.
  44847. * @returns the current input manager
  44848. */
  44849. addDeviceOrientation(): FreeCameraInputsManager;
  44850. }
  44851. /**
  44852. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44853. * Screen rotation is taken into account.
  44854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44855. */
  44856. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44857. private _camera;
  44858. private _screenOrientationAngle;
  44859. private _constantTranform;
  44860. private _screenQuaternion;
  44861. private _alpha;
  44862. private _beta;
  44863. private _gamma;
  44864. /**
  44865. * Can be used to detect if a device orientation sensor is available on a device
  44866. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44867. * @returns a promise that will resolve on orientation change
  44868. */
  44869. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44870. /**
  44871. * @hidden
  44872. */
  44873. _onDeviceOrientationChangedObservable: Observable<void>;
  44874. /**
  44875. * Instantiates a new input
  44876. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44877. */
  44878. constructor();
  44879. /**
  44880. * Define the camera controlled by the input.
  44881. */
  44882. get camera(): FreeCamera;
  44883. set camera(camera: FreeCamera);
  44884. /**
  44885. * Attach the input controls to a specific dom element to get the input from.
  44886. * @param element Defines the element the controls should be listened from
  44887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44888. */
  44889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44890. private _orientationChanged;
  44891. private _deviceOrientation;
  44892. /**
  44893. * Detach the current controls from the specified dom element.
  44894. * @param element Defines the element to stop listening the inputs from
  44895. */
  44896. detachControl(element: Nullable<HTMLElement>): void;
  44897. /**
  44898. * Update the current camera state depending on the inputs that have been used this frame.
  44899. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44900. */
  44901. checkInputs(): void;
  44902. /**
  44903. * Gets the class name of the current intput.
  44904. * @returns the class name
  44905. */
  44906. getClassName(): string;
  44907. /**
  44908. * Get the friendly name associated with the input class.
  44909. * @returns the input friendly name
  44910. */
  44911. getSimpleName(): string;
  44912. }
  44913. }
  44914. declare module BABYLON {
  44915. /**
  44916. * Manage the gamepad inputs to control a free camera.
  44917. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44918. */
  44919. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44920. /**
  44921. * Define the camera the input is attached to.
  44922. */
  44923. camera: FreeCamera;
  44924. /**
  44925. * Define the Gamepad controlling the input
  44926. */
  44927. gamepad: Nullable<Gamepad>;
  44928. /**
  44929. * Defines the gamepad rotation sensiblity.
  44930. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44931. */
  44932. gamepadAngularSensibility: number;
  44933. /**
  44934. * Defines the gamepad move sensiblity.
  44935. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44936. */
  44937. gamepadMoveSensibility: number;
  44938. private _yAxisScale;
  44939. /**
  44940. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44941. */
  44942. get invertYAxis(): boolean;
  44943. set invertYAxis(value: boolean);
  44944. private _onGamepadConnectedObserver;
  44945. private _onGamepadDisconnectedObserver;
  44946. private _cameraTransform;
  44947. private _deltaTransform;
  44948. private _vector3;
  44949. private _vector2;
  44950. /**
  44951. * Attach the input controls to a specific dom element to get the input from.
  44952. * @param element Defines the element the controls should be listened from
  44953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44954. */
  44955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44956. /**
  44957. * Detach the current controls from the specified dom element.
  44958. * @param element Defines the element to stop listening the inputs from
  44959. */
  44960. detachControl(element: Nullable<HTMLElement>): void;
  44961. /**
  44962. * Update the current camera state depending on the inputs that have been used this frame.
  44963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44964. */
  44965. checkInputs(): void;
  44966. /**
  44967. * Gets the class name of the current intput.
  44968. * @returns the class name
  44969. */
  44970. getClassName(): string;
  44971. /**
  44972. * Get the friendly name associated with the input class.
  44973. * @returns the input friendly name
  44974. */
  44975. getSimpleName(): string;
  44976. }
  44977. }
  44978. declare module BABYLON {
  44979. /**
  44980. * Defines the potential axis of a Joystick
  44981. */
  44982. export enum JoystickAxis {
  44983. /** X axis */
  44984. X = 0,
  44985. /** Y axis */
  44986. Y = 1,
  44987. /** Z axis */
  44988. Z = 2
  44989. }
  44990. /**
  44991. * Represents the different customization options available
  44992. * for VirtualJoystick
  44993. */
  44994. interface VirtualJoystickCustomizations {
  44995. /**
  44996. * Size of the joystick's puck
  44997. */
  44998. puckSize: number;
  44999. /**
  45000. * Size of the joystick's container
  45001. */
  45002. containerSize: number;
  45003. /**
  45004. * Color of the joystick && puck
  45005. */
  45006. color: string;
  45007. /**
  45008. * Image URL for the joystick's puck
  45009. */
  45010. puckImage?: string;
  45011. /**
  45012. * Image URL for the joystick's container
  45013. */
  45014. containerImage?: string;
  45015. /**
  45016. * Defines the unmoving position of the joystick container
  45017. */
  45018. position?: {
  45019. x: number;
  45020. y: number;
  45021. };
  45022. /**
  45023. * Defines whether or not the joystick container is always visible
  45024. */
  45025. alwaysVisible: boolean;
  45026. /**
  45027. * Defines whether or not to limit the movement of the puck to the joystick's container
  45028. */
  45029. limitToContainer: boolean;
  45030. }
  45031. /**
  45032. * Class used to define virtual joystick (used in touch mode)
  45033. */
  45034. export class VirtualJoystick {
  45035. /**
  45036. * Gets or sets a boolean indicating that left and right values must be inverted
  45037. */
  45038. reverseLeftRight: boolean;
  45039. /**
  45040. * Gets or sets a boolean indicating that up and down values must be inverted
  45041. */
  45042. reverseUpDown: boolean;
  45043. /**
  45044. * Gets the offset value for the position (ie. the change of the position value)
  45045. */
  45046. deltaPosition: Vector3;
  45047. /**
  45048. * Gets a boolean indicating if the virtual joystick was pressed
  45049. */
  45050. pressed: boolean;
  45051. /**
  45052. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45053. */
  45054. static Canvas: Nullable<HTMLCanvasElement>;
  45055. /**
  45056. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45057. */
  45058. limitToContainer: boolean;
  45059. private static _globalJoystickIndex;
  45060. private static _alwaysVisibleSticks;
  45061. private static vjCanvasContext;
  45062. private static vjCanvasWidth;
  45063. private static vjCanvasHeight;
  45064. private static halfWidth;
  45065. private static _GetDefaultOptions;
  45066. private _action;
  45067. private _axisTargetedByLeftAndRight;
  45068. private _axisTargetedByUpAndDown;
  45069. private _joystickSensibility;
  45070. private _inversedSensibility;
  45071. private _joystickPointerID;
  45072. private _joystickColor;
  45073. private _joystickPointerPos;
  45074. private _joystickPreviousPointerPos;
  45075. private _joystickPointerStartPos;
  45076. private _deltaJoystickVector;
  45077. private _leftJoystick;
  45078. private _touches;
  45079. private _joystickPosition;
  45080. private _alwaysVisible;
  45081. private _puckImage;
  45082. private _containerImage;
  45083. private _joystickPuckSize;
  45084. private _joystickContainerSize;
  45085. private _clearPuckSize;
  45086. private _clearContainerSize;
  45087. private _clearPuckSizeOffset;
  45088. private _clearContainerSizeOffset;
  45089. private _onPointerDownHandlerRef;
  45090. private _onPointerMoveHandlerRef;
  45091. private _onPointerUpHandlerRef;
  45092. private _onResize;
  45093. /**
  45094. * Creates a new virtual joystick
  45095. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45096. * @param customizations Defines the options we want to customize the VirtualJoystick
  45097. */
  45098. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45099. /**
  45100. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45101. * @param newJoystickSensibility defines the new sensibility
  45102. */
  45103. setJoystickSensibility(newJoystickSensibility: number): void;
  45104. private _onPointerDown;
  45105. private _onPointerMove;
  45106. private _onPointerUp;
  45107. /**
  45108. * Change the color of the virtual joystick
  45109. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45110. */
  45111. setJoystickColor(newColor: string): void;
  45112. /**
  45113. * Size of the joystick's container
  45114. */
  45115. set containerSize(newSize: number);
  45116. get containerSize(): number;
  45117. /**
  45118. * Size of the joystick's puck
  45119. */
  45120. set puckSize(newSize: number);
  45121. get puckSize(): number;
  45122. /**
  45123. * Clears the set position of the joystick
  45124. */
  45125. clearPosition(): void;
  45126. /**
  45127. * Defines whether or not the joystick container is always visible
  45128. */
  45129. set alwaysVisible(value: boolean);
  45130. get alwaysVisible(): boolean;
  45131. /**
  45132. * Sets the constant position of the Joystick container
  45133. * @param x X axis coordinate
  45134. * @param y Y axis coordinate
  45135. */
  45136. setPosition(x: number, y: number): void;
  45137. /**
  45138. * Defines a callback to call when the joystick is touched
  45139. * @param action defines the callback
  45140. */
  45141. setActionOnTouch(action: () => any): void;
  45142. /**
  45143. * Defines which axis you'd like to control for left & right
  45144. * @param axis defines the axis to use
  45145. */
  45146. setAxisForLeftRight(axis: JoystickAxis): void;
  45147. /**
  45148. * Defines which axis you'd like to control for up & down
  45149. * @param axis defines the axis to use
  45150. */
  45151. setAxisForUpDown(axis: JoystickAxis): void;
  45152. /**
  45153. * Clears the canvas from the previous puck / container draw
  45154. */
  45155. private _clearPreviousDraw;
  45156. /**
  45157. * Loads `urlPath` to be used for the container's image
  45158. * @param urlPath defines the urlPath of an image to use
  45159. */
  45160. setContainerImage(urlPath: string): void;
  45161. /**
  45162. * Loads `urlPath` to be used for the puck's image
  45163. * @param urlPath defines the urlPath of an image to use
  45164. */
  45165. setPuckImage(urlPath: string): void;
  45166. /**
  45167. * Draws the Virtual Joystick's container
  45168. */
  45169. private _drawContainer;
  45170. /**
  45171. * Draws the Virtual Joystick's puck
  45172. */
  45173. private _drawPuck;
  45174. private _drawVirtualJoystick;
  45175. /**
  45176. * Release internal HTML canvas
  45177. */
  45178. releaseCanvas(): void;
  45179. }
  45180. }
  45181. declare module BABYLON {
  45182. interface FreeCameraInputsManager {
  45183. /**
  45184. * Add virtual joystick input support to the input manager.
  45185. * @returns the current input manager
  45186. */
  45187. addVirtualJoystick(): FreeCameraInputsManager;
  45188. }
  45189. /**
  45190. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45191. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45192. */
  45193. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45194. /**
  45195. * Defines the camera the input is attached to.
  45196. */
  45197. camera: FreeCamera;
  45198. private _leftjoystick;
  45199. private _rightjoystick;
  45200. /**
  45201. * Gets the left stick of the virtual joystick.
  45202. * @returns The virtual Joystick
  45203. */
  45204. getLeftJoystick(): VirtualJoystick;
  45205. /**
  45206. * Gets the right stick of the virtual joystick.
  45207. * @returns The virtual Joystick
  45208. */
  45209. getRightJoystick(): VirtualJoystick;
  45210. /**
  45211. * Update the current camera state depending on the inputs that have been used this frame.
  45212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45213. */
  45214. checkInputs(): void;
  45215. /**
  45216. * Attach the input controls to a specific dom element to get the input from.
  45217. * @param element Defines the element the controls should be listened from
  45218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45219. */
  45220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45221. /**
  45222. * Detach the current controls from the specified dom element.
  45223. * @param element Defines the element to stop listening the inputs from
  45224. */
  45225. detachControl(element: Nullable<HTMLElement>): void;
  45226. /**
  45227. * Gets the class name of the current intput.
  45228. * @returns the class name
  45229. */
  45230. getClassName(): string;
  45231. /**
  45232. * Get the friendly name associated with the input class.
  45233. * @returns the input friendly name
  45234. */
  45235. getSimpleName(): string;
  45236. }
  45237. }
  45238. declare module BABYLON {
  45239. /**
  45240. * This represents a FPS type of camera controlled by touch.
  45241. * This is like a universal camera minus the Gamepad controls.
  45242. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45243. */
  45244. export class TouchCamera extends FreeCamera {
  45245. /**
  45246. * Defines the touch sensibility for rotation.
  45247. * The higher the faster.
  45248. */
  45249. get touchAngularSensibility(): number;
  45250. set touchAngularSensibility(value: number);
  45251. /**
  45252. * Defines the touch sensibility for move.
  45253. * The higher the faster.
  45254. */
  45255. get touchMoveSensibility(): number;
  45256. set touchMoveSensibility(value: number);
  45257. /**
  45258. * Instantiates a new touch camera.
  45259. * This represents a FPS type of camera controlled by touch.
  45260. * This is like a universal camera minus the Gamepad controls.
  45261. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45262. * @param name Define the name of the camera in the scene
  45263. * @param position Define the start position of the camera in the scene
  45264. * @param scene Define the scene the camera belongs to
  45265. */
  45266. constructor(name: string, position: Vector3, scene: Scene);
  45267. /**
  45268. * Gets the current object class name.
  45269. * @return the class name
  45270. */
  45271. getClassName(): string;
  45272. /** @hidden */
  45273. _setupInputs(): void;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /**
  45278. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45279. * being tilted forward or back and left or right.
  45280. */
  45281. export class DeviceOrientationCamera extends FreeCamera {
  45282. private _initialQuaternion;
  45283. private _quaternionCache;
  45284. private _tmpDragQuaternion;
  45285. private _disablePointerInputWhenUsingDeviceOrientation;
  45286. /**
  45287. * Creates a new device orientation camera
  45288. * @param name The name of the camera
  45289. * @param position The start position camera
  45290. * @param scene The scene the camera belongs to
  45291. */
  45292. constructor(name: string, position: Vector3, scene: Scene);
  45293. /**
  45294. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45295. */
  45296. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45297. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45298. private _dragFactor;
  45299. /**
  45300. * Enabled turning on the y axis when the orientation sensor is active
  45301. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45302. */
  45303. enableHorizontalDragging(dragFactor?: number): void;
  45304. /**
  45305. * Gets the current instance class name ("DeviceOrientationCamera").
  45306. * This helps avoiding instanceof at run time.
  45307. * @returns the class name
  45308. */
  45309. getClassName(): string;
  45310. /**
  45311. * @hidden
  45312. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45313. */
  45314. _checkInputs(): void;
  45315. /**
  45316. * Reset the camera to its default orientation on the specified axis only.
  45317. * @param axis The axis to reset
  45318. */
  45319. resetToCurrentRotation(axis?: Axis): void;
  45320. }
  45321. }
  45322. declare module BABYLON {
  45323. /**
  45324. * Defines supported buttons for XBox360 compatible gamepads
  45325. */
  45326. export enum Xbox360Button {
  45327. /** A */
  45328. A = 0,
  45329. /** B */
  45330. B = 1,
  45331. /** X */
  45332. X = 2,
  45333. /** Y */
  45334. Y = 3,
  45335. /** Left button */
  45336. LB = 4,
  45337. /** Right button */
  45338. RB = 5,
  45339. /** Back */
  45340. Back = 8,
  45341. /** Start */
  45342. Start = 9,
  45343. /** Left stick */
  45344. LeftStick = 10,
  45345. /** Right stick */
  45346. RightStick = 11
  45347. }
  45348. /** Defines values for XBox360 DPad */
  45349. export enum Xbox360Dpad {
  45350. /** Up */
  45351. Up = 12,
  45352. /** Down */
  45353. Down = 13,
  45354. /** Left */
  45355. Left = 14,
  45356. /** Right */
  45357. Right = 15
  45358. }
  45359. /**
  45360. * Defines a XBox360 gamepad
  45361. */
  45362. export class Xbox360Pad extends Gamepad {
  45363. private _leftTrigger;
  45364. private _rightTrigger;
  45365. private _onlefttriggerchanged;
  45366. private _onrighttriggerchanged;
  45367. private _onbuttondown;
  45368. private _onbuttonup;
  45369. private _ondpaddown;
  45370. private _ondpadup;
  45371. /** Observable raised when a button is pressed */
  45372. onButtonDownObservable: Observable<Xbox360Button>;
  45373. /** Observable raised when a button is released */
  45374. onButtonUpObservable: Observable<Xbox360Button>;
  45375. /** Observable raised when a pad is pressed */
  45376. onPadDownObservable: Observable<Xbox360Dpad>;
  45377. /** Observable raised when a pad is released */
  45378. onPadUpObservable: Observable<Xbox360Dpad>;
  45379. private _buttonA;
  45380. private _buttonB;
  45381. private _buttonX;
  45382. private _buttonY;
  45383. private _buttonBack;
  45384. private _buttonStart;
  45385. private _buttonLB;
  45386. private _buttonRB;
  45387. private _buttonLeftStick;
  45388. private _buttonRightStick;
  45389. private _dPadUp;
  45390. private _dPadDown;
  45391. private _dPadLeft;
  45392. private _dPadRight;
  45393. private _isXboxOnePad;
  45394. /**
  45395. * Creates a new XBox360 gamepad object
  45396. * @param id defines the id of this gamepad
  45397. * @param index defines its index
  45398. * @param gamepad defines the internal HTML gamepad object
  45399. * @param xboxOne defines if it is a XBox One gamepad
  45400. */
  45401. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45402. /**
  45403. * Defines the callback to call when left trigger is pressed
  45404. * @param callback defines the callback to use
  45405. */
  45406. onlefttriggerchanged(callback: (value: number) => void): void;
  45407. /**
  45408. * Defines the callback to call when right trigger is pressed
  45409. * @param callback defines the callback to use
  45410. */
  45411. onrighttriggerchanged(callback: (value: number) => void): void;
  45412. /**
  45413. * Gets the left trigger value
  45414. */
  45415. get leftTrigger(): number;
  45416. /**
  45417. * Sets the left trigger value
  45418. */
  45419. set leftTrigger(newValue: number);
  45420. /**
  45421. * Gets the right trigger value
  45422. */
  45423. get rightTrigger(): number;
  45424. /**
  45425. * Sets the right trigger value
  45426. */
  45427. set rightTrigger(newValue: number);
  45428. /**
  45429. * Defines the callback to call when a button is pressed
  45430. * @param callback defines the callback to use
  45431. */
  45432. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45433. /**
  45434. * Defines the callback to call when a button is released
  45435. * @param callback defines the callback to use
  45436. */
  45437. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45438. /**
  45439. * Defines the callback to call when a pad is pressed
  45440. * @param callback defines the callback to use
  45441. */
  45442. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45443. /**
  45444. * Defines the callback to call when a pad is released
  45445. * @param callback defines the callback to use
  45446. */
  45447. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45448. private _setButtonValue;
  45449. private _setDPadValue;
  45450. /**
  45451. * Gets the value of the `A` button
  45452. */
  45453. get buttonA(): number;
  45454. /**
  45455. * Sets the value of the `A` button
  45456. */
  45457. set buttonA(value: number);
  45458. /**
  45459. * Gets the value of the `B` button
  45460. */
  45461. get buttonB(): number;
  45462. /**
  45463. * Sets the value of the `B` button
  45464. */
  45465. set buttonB(value: number);
  45466. /**
  45467. * Gets the value of the `X` button
  45468. */
  45469. get buttonX(): number;
  45470. /**
  45471. * Sets the value of the `X` button
  45472. */
  45473. set buttonX(value: number);
  45474. /**
  45475. * Gets the value of the `Y` button
  45476. */
  45477. get buttonY(): number;
  45478. /**
  45479. * Sets the value of the `Y` button
  45480. */
  45481. set buttonY(value: number);
  45482. /**
  45483. * Gets the value of the `Start` button
  45484. */
  45485. get buttonStart(): number;
  45486. /**
  45487. * Sets the value of the `Start` button
  45488. */
  45489. set buttonStart(value: number);
  45490. /**
  45491. * Gets the value of the `Back` button
  45492. */
  45493. get buttonBack(): number;
  45494. /**
  45495. * Sets the value of the `Back` button
  45496. */
  45497. set buttonBack(value: number);
  45498. /**
  45499. * Gets the value of the `Left` button
  45500. */
  45501. get buttonLB(): number;
  45502. /**
  45503. * Sets the value of the `Left` button
  45504. */
  45505. set buttonLB(value: number);
  45506. /**
  45507. * Gets the value of the `Right` button
  45508. */
  45509. get buttonRB(): number;
  45510. /**
  45511. * Sets the value of the `Right` button
  45512. */
  45513. set buttonRB(value: number);
  45514. /**
  45515. * Gets the value of the Left joystick
  45516. */
  45517. get buttonLeftStick(): number;
  45518. /**
  45519. * Sets the value of the Left joystick
  45520. */
  45521. set buttonLeftStick(value: number);
  45522. /**
  45523. * Gets the value of the Right joystick
  45524. */
  45525. get buttonRightStick(): number;
  45526. /**
  45527. * Sets the value of the Right joystick
  45528. */
  45529. set buttonRightStick(value: number);
  45530. /**
  45531. * Gets the value of D-pad up
  45532. */
  45533. get dPadUp(): number;
  45534. /**
  45535. * Sets the value of D-pad up
  45536. */
  45537. set dPadUp(value: number);
  45538. /**
  45539. * Gets the value of D-pad down
  45540. */
  45541. get dPadDown(): number;
  45542. /**
  45543. * Sets the value of D-pad down
  45544. */
  45545. set dPadDown(value: number);
  45546. /**
  45547. * Gets the value of D-pad left
  45548. */
  45549. get dPadLeft(): number;
  45550. /**
  45551. * Sets the value of D-pad left
  45552. */
  45553. set dPadLeft(value: number);
  45554. /**
  45555. * Gets the value of D-pad right
  45556. */
  45557. get dPadRight(): number;
  45558. /**
  45559. * Sets the value of D-pad right
  45560. */
  45561. set dPadRight(value: number);
  45562. /**
  45563. * Force the gamepad to synchronize with device values
  45564. */
  45565. update(): void;
  45566. /**
  45567. * Disposes the gamepad
  45568. */
  45569. dispose(): void;
  45570. }
  45571. }
  45572. declare module BABYLON {
  45573. /**
  45574. * Defines supported buttons for DualShock compatible gamepads
  45575. */
  45576. export enum DualShockButton {
  45577. /** Cross */
  45578. Cross = 0,
  45579. /** Circle */
  45580. Circle = 1,
  45581. /** Square */
  45582. Square = 2,
  45583. /** Triangle */
  45584. Triangle = 3,
  45585. /** L1 */
  45586. L1 = 4,
  45587. /** R1 */
  45588. R1 = 5,
  45589. /** Share */
  45590. Share = 8,
  45591. /** Options */
  45592. Options = 9,
  45593. /** Left stick */
  45594. LeftStick = 10,
  45595. /** Right stick */
  45596. RightStick = 11
  45597. }
  45598. /** Defines values for DualShock DPad */
  45599. export enum DualShockDpad {
  45600. /** Up */
  45601. Up = 12,
  45602. /** Down */
  45603. Down = 13,
  45604. /** Left */
  45605. Left = 14,
  45606. /** Right */
  45607. Right = 15
  45608. }
  45609. /**
  45610. * Defines a DualShock gamepad
  45611. */
  45612. export class DualShockPad extends Gamepad {
  45613. private _leftTrigger;
  45614. private _rightTrigger;
  45615. private _onlefttriggerchanged;
  45616. private _onrighttriggerchanged;
  45617. private _onbuttondown;
  45618. private _onbuttonup;
  45619. private _ondpaddown;
  45620. private _ondpadup;
  45621. /** Observable raised when a button is pressed */
  45622. onButtonDownObservable: Observable<DualShockButton>;
  45623. /** Observable raised when a button is released */
  45624. onButtonUpObservable: Observable<DualShockButton>;
  45625. /** Observable raised when a pad is pressed */
  45626. onPadDownObservable: Observable<DualShockDpad>;
  45627. /** Observable raised when a pad is released */
  45628. onPadUpObservable: Observable<DualShockDpad>;
  45629. private _buttonCross;
  45630. private _buttonCircle;
  45631. private _buttonSquare;
  45632. private _buttonTriangle;
  45633. private _buttonShare;
  45634. private _buttonOptions;
  45635. private _buttonL1;
  45636. private _buttonR1;
  45637. private _buttonLeftStick;
  45638. private _buttonRightStick;
  45639. private _dPadUp;
  45640. private _dPadDown;
  45641. private _dPadLeft;
  45642. private _dPadRight;
  45643. /**
  45644. * Creates a new DualShock gamepad object
  45645. * @param id defines the id of this gamepad
  45646. * @param index defines its index
  45647. * @param gamepad defines the internal HTML gamepad object
  45648. */
  45649. constructor(id: string, index: number, gamepad: any);
  45650. /**
  45651. * Defines the callback to call when left trigger is pressed
  45652. * @param callback defines the callback to use
  45653. */
  45654. onlefttriggerchanged(callback: (value: number) => void): void;
  45655. /**
  45656. * Defines the callback to call when right trigger is pressed
  45657. * @param callback defines the callback to use
  45658. */
  45659. onrighttriggerchanged(callback: (value: number) => void): void;
  45660. /**
  45661. * Gets the left trigger value
  45662. */
  45663. get leftTrigger(): number;
  45664. /**
  45665. * Sets the left trigger value
  45666. */
  45667. set leftTrigger(newValue: number);
  45668. /**
  45669. * Gets the right trigger value
  45670. */
  45671. get rightTrigger(): number;
  45672. /**
  45673. * Sets the right trigger value
  45674. */
  45675. set rightTrigger(newValue: number);
  45676. /**
  45677. * Defines the callback to call when a button is pressed
  45678. * @param callback defines the callback to use
  45679. */
  45680. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45681. /**
  45682. * Defines the callback to call when a button is released
  45683. * @param callback defines the callback to use
  45684. */
  45685. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45686. /**
  45687. * Defines the callback to call when a pad is pressed
  45688. * @param callback defines the callback to use
  45689. */
  45690. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45691. /**
  45692. * Defines the callback to call when a pad is released
  45693. * @param callback defines the callback to use
  45694. */
  45695. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45696. private _setButtonValue;
  45697. private _setDPadValue;
  45698. /**
  45699. * Gets the value of the `Cross` button
  45700. */
  45701. get buttonCross(): number;
  45702. /**
  45703. * Sets the value of the `Cross` button
  45704. */
  45705. set buttonCross(value: number);
  45706. /**
  45707. * Gets the value of the `Circle` button
  45708. */
  45709. get buttonCircle(): number;
  45710. /**
  45711. * Sets the value of the `Circle` button
  45712. */
  45713. set buttonCircle(value: number);
  45714. /**
  45715. * Gets the value of the `Square` button
  45716. */
  45717. get buttonSquare(): number;
  45718. /**
  45719. * Sets the value of the `Square` button
  45720. */
  45721. set buttonSquare(value: number);
  45722. /**
  45723. * Gets the value of the `Triangle` button
  45724. */
  45725. get buttonTriangle(): number;
  45726. /**
  45727. * Sets the value of the `Triangle` button
  45728. */
  45729. set buttonTriangle(value: number);
  45730. /**
  45731. * Gets the value of the `Options` button
  45732. */
  45733. get buttonOptions(): number;
  45734. /**
  45735. * Sets the value of the `Options` button
  45736. */
  45737. set buttonOptions(value: number);
  45738. /**
  45739. * Gets the value of the `Share` button
  45740. */
  45741. get buttonShare(): number;
  45742. /**
  45743. * Sets the value of the `Share` button
  45744. */
  45745. set buttonShare(value: number);
  45746. /**
  45747. * Gets the value of the `L1` button
  45748. */
  45749. get buttonL1(): number;
  45750. /**
  45751. * Sets the value of the `L1` button
  45752. */
  45753. set buttonL1(value: number);
  45754. /**
  45755. * Gets the value of the `R1` button
  45756. */
  45757. get buttonR1(): number;
  45758. /**
  45759. * Sets the value of the `R1` button
  45760. */
  45761. set buttonR1(value: number);
  45762. /**
  45763. * Gets the value of the Left joystick
  45764. */
  45765. get buttonLeftStick(): number;
  45766. /**
  45767. * Sets the value of the Left joystick
  45768. */
  45769. set buttonLeftStick(value: number);
  45770. /**
  45771. * Gets the value of the Right joystick
  45772. */
  45773. get buttonRightStick(): number;
  45774. /**
  45775. * Sets the value of the Right joystick
  45776. */
  45777. set buttonRightStick(value: number);
  45778. /**
  45779. * Gets the value of D-pad up
  45780. */
  45781. get dPadUp(): number;
  45782. /**
  45783. * Sets the value of D-pad up
  45784. */
  45785. set dPadUp(value: number);
  45786. /**
  45787. * Gets the value of D-pad down
  45788. */
  45789. get dPadDown(): number;
  45790. /**
  45791. * Sets the value of D-pad down
  45792. */
  45793. set dPadDown(value: number);
  45794. /**
  45795. * Gets the value of D-pad left
  45796. */
  45797. get dPadLeft(): number;
  45798. /**
  45799. * Sets the value of D-pad left
  45800. */
  45801. set dPadLeft(value: number);
  45802. /**
  45803. * Gets the value of D-pad right
  45804. */
  45805. get dPadRight(): number;
  45806. /**
  45807. * Sets the value of D-pad right
  45808. */
  45809. set dPadRight(value: number);
  45810. /**
  45811. * Force the gamepad to synchronize with device values
  45812. */
  45813. update(): void;
  45814. /**
  45815. * Disposes the gamepad
  45816. */
  45817. dispose(): void;
  45818. }
  45819. }
  45820. declare module BABYLON {
  45821. /**
  45822. * Manager for handling gamepads
  45823. */
  45824. export class GamepadManager {
  45825. private _scene?;
  45826. private _babylonGamepads;
  45827. private _oneGamepadConnected;
  45828. /** @hidden */
  45829. _isMonitoring: boolean;
  45830. private _gamepadEventSupported;
  45831. private _gamepadSupport?;
  45832. /**
  45833. * observable to be triggered when the gamepad controller has been connected
  45834. */
  45835. onGamepadConnectedObservable: Observable<Gamepad>;
  45836. /**
  45837. * observable to be triggered when the gamepad controller has been disconnected
  45838. */
  45839. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45840. private _onGamepadConnectedEvent;
  45841. private _onGamepadDisconnectedEvent;
  45842. /**
  45843. * Initializes the gamepad manager
  45844. * @param _scene BabylonJS scene
  45845. */
  45846. constructor(_scene?: Scene | undefined);
  45847. /**
  45848. * The gamepads in the game pad manager
  45849. */
  45850. get gamepads(): Gamepad[];
  45851. /**
  45852. * Get the gamepad controllers based on type
  45853. * @param type The type of gamepad controller
  45854. * @returns Nullable gamepad
  45855. */
  45856. getGamepadByType(type?: number): Nullable<Gamepad>;
  45857. /**
  45858. * Disposes the gamepad manager
  45859. */
  45860. dispose(): void;
  45861. private _addNewGamepad;
  45862. private _startMonitoringGamepads;
  45863. private _stopMonitoringGamepads;
  45864. /** @hidden */
  45865. _checkGamepadsStatus(): void;
  45866. private _updateGamepadObjects;
  45867. }
  45868. }
  45869. declare module BABYLON {
  45870. interface Scene {
  45871. /** @hidden */
  45872. _gamepadManager: Nullable<GamepadManager>;
  45873. /**
  45874. * Gets the gamepad manager associated with the scene
  45875. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45876. */
  45877. gamepadManager: GamepadManager;
  45878. }
  45879. /**
  45880. * Interface representing a free camera inputs manager
  45881. */
  45882. interface FreeCameraInputsManager {
  45883. /**
  45884. * Adds gamepad input support to the FreeCameraInputsManager.
  45885. * @returns the FreeCameraInputsManager
  45886. */
  45887. addGamepad(): FreeCameraInputsManager;
  45888. }
  45889. /**
  45890. * Interface representing an arc rotate camera inputs manager
  45891. */
  45892. interface ArcRotateCameraInputsManager {
  45893. /**
  45894. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45895. * @returns the camera inputs manager
  45896. */
  45897. addGamepad(): ArcRotateCameraInputsManager;
  45898. }
  45899. /**
  45900. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45901. */
  45902. export class GamepadSystemSceneComponent implements ISceneComponent {
  45903. /**
  45904. * The component name helpfull to identify the component in the list of scene components.
  45905. */
  45906. readonly name: string;
  45907. /**
  45908. * The scene the component belongs to.
  45909. */
  45910. scene: Scene;
  45911. /**
  45912. * Creates a new instance of the component for the given scene
  45913. * @param scene Defines the scene to register the component in
  45914. */
  45915. constructor(scene: Scene);
  45916. /**
  45917. * Registers the component in a given scene
  45918. */
  45919. register(): void;
  45920. /**
  45921. * Rebuilds the elements related to this component in case of
  45922. * context lost for instance.
  45923. */
  45924. rebuild(): void;
  45925. /**
  45926. * Disposes the component and the associated ressources
  45927. */
  45928. dispose(): void;
  45929. private _beforeCameraUpdate;
  45930. }
  45931. }
  45932. declare module BABYLON {
  45933. /**
  45934. * 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,
  45935. * which still works and will still be found in many Playgrounds.
  45936. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45937. */
  45938. export class UniversalCamera extends TouchCamera {
  45939. /**
  45940. * Defines the gamepad rotation sensiblity.
  45941. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45942. */
  45943. get gamepadAngularSensibility(): number;
  45944. set gamepadAngularSensibility(value: number);
  45945. /**
  45946. * Defines the gamepad move sensiblity.
  45947. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45948. */
  45949. get gamepadMoveSensibility(): number;
  45950. set gamepadMoveSensibility(value: number);
  45951. /**
  45952. * 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,
  45953. * which still works and will still be found in many Playgrounds.
  45954. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45955. * @param name Define the name of the camera in the scene
  45956. * @param position Define the start position of the camera in the scene
  45957. * @param scene Define the scene the camera belongs to
  45958. */
  45959. constructor(name: string, position: Vector3, scene: Scene);
  45960. /**
  45961. * Gets the current object class name.
  45962. * @return the class name
  45963. */
  45964. getClassName(): string;
  45965. }
  45966. }
  45967. declare module BABYLON {
  45968. /**
  45969. * This represents a FPS type of camera. This is only here for back compat purpose.
  45970. * Please use the UniversalCamera instead as both are identical.
  45971. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45972. */
  45973. export class GamepadCamera extends UniversalCamera {
  45974. /**
  45975. * Instantiates a new Gamepad Camera
  45976. * This represents a FPS type of camera. This is only here for back compat purpose.
  45977. * Please use the UniversalCamera instead as both are identical.
  45978. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45979. * @param name Define the name of the camera in the scene
  45980. * @param position Define the start position of the camera in the scene
  45981. * @param scene Define the scene the camera belongs to
  45982. */
  45983. constructor(name: string, position: Vector3, scene: Scene);
  45984. /**
  45985. * Gets the current object class name.
  45986. * @return the class name
  45987. */
  45988. getClassName(): string;
  45989. }
  45990. }
  45991. declare module BABYLON {
  45992. /** @hidden */
  45993. export var passPixelShader: {
  45994. name: string;
  45995. shader: string;
  45996. };
  45997. }
  45998. declare module BABYLON {
  45999. /** @hidden */
  46000. export var passCubePixelShader: {
  46001. name: string;
  46002. shader: string;
  46003. };
  46004. }
  46005. declare module BABYLON {
  46006. /**
  46007. * PassPostProcess which produces an output the same as it's input
  46008. */
  46009. export class PassPostProcess extends PostProcess {
  46010. /**
  46011. * Gets a string identifying the name of the class
  46012. * @returns "PassPostProcess" string
  46013. */
  46014. getClassName(): string;
  46015. /**
  46016. * Creates the PassPostProcess
  46017. * @param name The name of the effect.
  46018. * @param options The required width/height ratio to downsize to before computing the render pass.
  46019. * @param camera The camera to apply the render pass to.
  46020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46021. * @param engine The engine which the post process will be applied. (default: current engine)
  46022. * @param reusable If the post process can be reused on the same frame. (default: false)
  46023. * @param textureType The type of texture to be used when performing the post processing.
  46024. * @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)
  46025. */
  46026. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46027. /** @hidden */
  46028. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46029. }
  46030. /**
  46031. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46032. */
  46033. export class PassCubePostProcess extends PostProcess {
  46034. private _face;
  46035. /**
  46036. * Gets or sets the cube face to display.
  46037. * * 0 is +X
  46038. * * 1 is -X
  46039. * * 2 is +Y
  46040. * * 3 is -Y
  46041. * * 4 is +Z
  46042. * * 5 is -Z
  46043. */
  46044. get face(): number;
  46045. set face(value: number);
  46046. /**
  46047. * Gets a string identifying the name of the class
  46048. * @returns "PassCubePostProcess" string
  46049. */
  46050. getClassName(): string;
  46051. /**
  46052. * Creates the PassCubePostProcess
  46053. * @param name The name of the effect.
  46054. * @param options The required width/height ratio to downsize to before computing the render pass.
  46055. * @param camera The camera to apply the render pass to.
  46056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46057. * @param engine The engine which the post process will be applied. (default: current engine)
  46058. * @param reusable If the post process can be reused on the same frame. (default: false)
  46059. * @param textureType The type of texture to be used when performing the post processing.
  46060. * @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)
  46061. */
  46062. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46063. /** @hidden */
  46064. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46065. }
  46066. }
  46067. declare module BABYLON {
  46068. /** @hidden */
  46069. export var anaglyphPixelShader: {
  46070. name: string;
  46071. shader: string;
  46072. };
  46073. }
  46074. declare module BABYLON {
  46075. /**
  46076. * Postprocess used to generate anaglyphic rendering
  46077. */
  46078. export class AnaglyphPostProcess extends PostProcess {
  46079. private _passedProcess;
  46080. /**
  46081. * Gets a string identifying the name of the class
  46082. * @returns "AnaglyphPostProcess" string
  46083. */
  46084. getClassName(): string;
  46085. /**
  46086. * Creates a new AnaglyphPostProcess
  46087. * @param name defines postprocess name
  46088. * @param options defines creation options or target ratio scale
  46089. * @param rigCameras defines cameras using this postprocess
  46090. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46091. * @param engine defines hosting engine
  46092. * @param reusable defines if the postprocess will be reused multiple times per frame
  46093. */
  46094. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46095. }
  46096. }
  46097. declare module BABYLON {
  46098. /**
  46099. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46100. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46101. */
  46102. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46103. /**
  46104. * Creates a new AnaglyphArcRotateCamera
  46105. * @param name defines camera name
  46106. * @param alpha defines alpha angle (in radians)
  46107. * @param beta defines beta angle (in radians)
  46108. * @param radius defines radius
  46109. * @param target defines camera target
  46110. * @param interaxialDistance defines distance between each color axis
  46111. * @param scene defines the hosting scene
  46112. */
  46113. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46114. /**
  46115. * Gets camera class name
  46116. * @returns AnaglyphArcRotateCamera
  46117. */
  46118. getClassName(): string;
  46119. }
  46120. }
  46121. declare module BABYLON {
  46122. /**
  46123. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46124. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46125. */
  46126. export class AnaglyphFreeCamera extends FreeCamera {
  46127. /**
  46128. * Creates a new AnaglyphFreeCamera
  46129. * @param name defines camera name
  46130. * @param position defines initial position
  46131. * @param interaxialDistance defines distance between each color axis
  46132. * @param scene defines the hosting scene
  46133. */
  46134. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46135. /**
  46136. * Gets camera class name
  46137. * @returns AnaglyphFreeCamera
  46138. */
  46139. getClassName(): string;
  46140. }
  46141. }
  46142. declare module BABYLON {
  46143. /**
  46144. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46145. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46146. */
  46147. export class AnaglyphGamepadCamera extends GamepadCamera {
  46148. /**
  46149. * Creates a new AnaglyphGamepadCamera
  46150. * @param name defines camera name
  46151. * @param position defines initial position
  46152. * @param interaxialDistance defines distance between each color axis
  46153. * @param scene defines the hosting scene
  46154. */
  46155. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46156. /**
  46157. * Gets camera class name
  46158. * @returns AnaglyphGamepadCamera
  46159. */
  46160. getClassName(): string;
  46161. }
  46162. }
  46163. declare module BABYLON {
  46164. /**
  46165. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46166. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46167. */
  46168. export class AnaglyphUniversalCamera extends UniversalCamera {
  46169. /**
  46170. * Creates a new AnaglyphUniversalCamera
  46171. * @param name defines camera name
  46172. * @param position defines initial position
  46173. * @param interaxialDistance defines distance between each color axis
  46174. * @param scene defines the hosting scene
  46175. */
  46176. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46177. /**
  46178. * Gets camera class name
  46179. * @returns AnaglyphUniversalCamera
  46180. */
  46181. getClassName(): string;
  46182. }
  46183. }
  46184. declare module BABYLON {
  46185. /**
  46186. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46187. * @see https://doc.babylonjs.com/features/cameras
  46188. */
  46189. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46190. /**
  46191. * Creates a new StereoscopicArcRotateCamera
  46192. * @param name defines camera name
  46193. * @param alpha defines alpha angle (in radians)
  46194. * @param beta defines beta angle (in radians)
  46195. * @param radius defines radius
  46196. * @param target defines camera target
  46197. * @param interaxialDistance defines distance between each color axis
  46198. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46199. * @param scene defines the hosting scene
  46200. */
  46201. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46202. /**
  46203. * Gets camera class name
  46204. * @returns StereoscopicArcRotateCamera
  46205. */
  46206. getClassName(): string;
  46207. }
  46208. }
  46209. declare module BABYLON {
  46210. /**
  46211. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46212. * @see https://doc.babylonjs.com/features/cameras
  46213. */
  46214. export class StereoscopicFreeCamera extends FreeCamera {
  46215. /**
  46216. * Creates a new StereoscopicFreeCamera
  46217. * @param name defines camera name
  46218. * @param position defines initial position
  46219. * @param interaxialDistance defines distance between each color axis
  46220. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46221. * @param scene defines the hosting scene
  46222. */
  46223. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46224. /**
  46225. * Gets camera class name
  46226. * @returns StereoscopicFreeCamera
  46227. */
  46228. getClassName(): string;
  46229. }
  46230. }
  46231. declare module BABYLON {
  46232. /**
  46233. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46234. * @see https://doc.babylonjs.com/features/cameras
  46235. */
  46236. export class StereoscopicGamepadCamera extends GamepadCamera {
  46237. /**
  46238. * Creates a new StereoscopicGamepadCamera
  46239. * @param name defines camera name
  46240. * @param position defines initial position
  46241. * @param interaxialDistance defines distance between each color axis
  46242. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46243. * @param scene defines the hosting scene
  46244. */
  46245. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46246. /**
  46247. * Gets camera class name
  46248. * @returns StereoscopicGamepadCamera
  46249. */
  46250. getClassName(): string;
  46251. }
  46252. }
  46253. declare module BABYLON {
  46254. /**
  46255. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46256. * @see https://doc.babylonjs.com/features/cameras
  46257. */
  46258. export class StereoscopicUniversalCamera extends UniversalCamera {
  46259. /**
  46260. * Creates a new StereoscopicUniversalCamera
  46261. * @param name defines camera name
  46262. * @param position defines initial position
  46263. * @param interaxialDistance defines distance between each color axis
  46264. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46265. * @param scene defines the hosting scene
  46266. */
  46267. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46268. /**
  46269. * Gets camera class name
  46270. * @returns StereoscopicUniversalCamera
  46271. */
  46272. getClassName(): string;
  46273. }
  46274. }
  46275. declare module BABYLON {
  46276. /**
  46277. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46278. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46279. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46280. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46281. */
  46282. export class VirtualJoysticksCamera extends FreeCamera {
  46283. /**
  46284. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46285. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46286. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46287. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46288. * @param name Define the name of the camera in the scene
  46289. * @param position Define the start position of the camera in the scene
  46290. * @param scene Define the scene the camera belongs to
  46291. */
  46292. constructor(name: string, position: Vector3, scene: Scene);
  46293. /**
  46294. * Gets the current object class name.
  46295. * @return the class name
  46296. */
  46297. getClassName(): string;
  46298. }
  46299. }
  46300. declare module BABYLON {
  46301. /**
  46302. * This represents all the required metrics to create a VR camera.
  46303. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46304. */
  46305. export class VRCameraMetrics {
  46306. /**
  46307. * Define the horizontal resolution off the screen.
  46308. */
  46309. hResolution: number;
  46310. /**
  46311. * Define the vertical resolution off the screen.
  46312. */
  46313. vResolution: number;
  46314. /**
  46315. * Define the horizontal screen size.
  46316. */
  46317. hScreenSize: number;
  46318. /**
  46319. * Define the vertical screen size.
  46320. */
  46321. vScreenSize: number;
  46322. /**
  46323. * Define the vertical screen center position.
  46324. */
  46325. vScreenCenter: number;
  46326. /**
  46327. * Define the distance of the eyes to the screen.
  46328. */
  46329. eyeToScreenDistance: number;
  46330. /**
  46331. * Define the distance between both lenses
  46332. */
  46333. lensSeparationDistance: number;
  46334. /**
  46335. * Define the distance between both viewer's eyes.
  46336. */
  46337. interpupillaryDistance: number;
  46338. /**
  46339. * Define the distortion factor of the VR postprocess.
  46340. * Please, touch with care.
  46341. */
  46342. distortionK: number[];
  46343. /**
  46344. * Define the chromatic aberration correction factors for the VR post process.
  46345. */
  46346. chromaAbCorrection: number[];
  46347. /**
  46348. * Define the scale factor of the post process.
  46349. * The smaller the better but the slower.
  46350. */
  46351. postProcessScaleFactor: number;
  46352. /**
  46353. * Define an offset for the lens center.
  46354. */
  46355. lensCenterOffset: number;
  46356. /**
  46357. * Define if the current vr camera should compensate the distortion of the lense or not.
  46358. */
  46359. compensateDistortion: boolean;
  46360. /**
  46361. * Defines if multiview should be enabled when rendering (Default: false)
  46362. */
  46363. multiviewEnabled: boolean;
  46364. /**
  46365. * Gets the rendering aspect ratio based on the provided resolutions.
  46366. */
  46367. get aspectRatio(): number;
  46368. /**
  46369. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46370. */
  46371. get aspectRatioFov(): number;
  46372. /**
  46373. * @hidden
  46374. */
  46375. get leftHMatrix(): Matrix;
  46376. /**
  46377. * @hidden
  46378. */
  46379. get rightHMatrix(): Matrix;
  46380. /**
  46381. * @hidden
  46382. */
  46383. get leftPreViewMatrix(): Matrix;
  46384. /**
  46385. * @hidden
  46386. */
  46387. get rightPreViewMatrix(): Matrix;
  46388. /**
  46389. * Get the default VRMetrics based on the most generic setup.
  46390. * @returns the default vr metrics
  46391. */
  46392. static GetDefault(): VRCameraMetrics;
  46393. }
  46394. }
  46395. declare module BABYLON {
  46396. /** @hidden */
  46397. export var vrDistortionCorrectionPixelShader: {
  46398. name: string;
  46399. shader: string;
  46400. };
  46401. }
  46402. declare module BABYLON {
  46403. /**
  46404. * VRDistortionCorrectionPostProcess used for mobile VR
  46405. */
  46406. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46407. private _isRightEye;
  46408. private _distortionFactors;
  46409. private _postProcessScaleFactor;
  46410. private _lensCenterOffset;
  46411. private _scaleIn;
  46412. private _scaleFactor;
  46413. private _lensCenter;
  46414. /**
  46415. * Gets a string identifying the name of the class
  46416. * @returns "VRDistortionCorrectionPostProcess" string
  46417. */
  46418. getClassName(): string;
  46419. /**
  46420. * Initializes the VRDistortionCorrectionPostProcess
  46421. * @param name The name of the effect.
  46422. * @param camera The camera to apply the render pass to.
  46423. * @param isRightEye If this is for the right eye distortion
  46424. * @param vrMetrics All the required metrics for the VR camera
  46425. */
  46426. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46427. }
  46428. }
  46429. declare module BABYLON {
  46430. /**
  46431. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46432. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46433. */
  46434. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46435. /**
  46436. * Creates a new VRDeviceOrientationArcRotateCamera
  46437. * @param name defines camera name
  46438. * @param alpha defines the camera rotation along the logitudinal axis
  46439. * @param beta defines the camera rotation along the latitudinal axis
  46440. * @param radius defines the camera distance from its target
  46441. * @param target defines the camera target
  46442. * @param scene defines the scene the camera belongs to
  46443. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46444. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46445. */
  46446. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46447. /**
  46448. * Gets camera class name
  46449. * @returns VRDeviceOrientationArcRotateCamera
  46450. */
  46451. getClassName(): string;
  46452. }
  46453. }
  46454. declare module BABYLON {
  46455. /**
  46456. * Camera used to simulate VR rendering (based on FreeCamera)
  46457. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46458. */
  46459. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46460. /**
  46461. * Creates a new VRDeviceOrientationFreeCamera
  46462. * @param name defines camera name
  46463. * @param position defines the start position of the camera
  46464. * @param scene defines the scene the camera belongs to
  46465. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46466. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46467. */
  46468. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46469. /**
  46470. * Gets camera class name
  46471. * @returns VRDeviceOrientationFreeCamera
  46472. */
  46473. getClassName(): string;
  46474. }
  46475. }
  46476. declare module BABYLON {
  46477. /**
  46478. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46479. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46480. */
  46481. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46482. /**
  46483. * Creates a new VRDeviceOrientationGamepadCamera
  46484. * @param name defines camera name
  46485. * @param position defines the start position of the camera
  46486. * @param scene defines the scene the camera belongs to
  46487. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46488. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46489. */
  46490. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46491. /**
  46492. * Gets camera class name
  46493. * @returns VRDeviceOrientationGamepadCamera
  46494. */
  46495. getClassName(): string;
  46496. }
  46497. }
  46498. declare module BABYLON {
  46499. /**
  46500. * A class extending Texture allowing drawing on a texture
  46501. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46502. */
  46503. export class DynamicTexture extends Texture {
  46504. private _generateMipMaps;
  46505. private _canvas;
  46506. private _context;
  46507. /**
  46508. * Creates a DynamicTexture
  46509. * @param name defines the name of the texture
  46510. * @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
  46511. * @param scene defines the scene where you want the texture
  46512. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46513. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46514. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46515. */
  46516. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46517. /**
  46518. * Get the current class name of the texture useful for serialization or dynamic coding.
  46519. * @returns "DynamicTexture"
  46520. */
  46521. getClassName(): string;
  46522. /**
  46523. * Gets the current state of canRescale
  46524. */
  46525. get canRescale(): boolean;
  46526. private _recreate;
  46527. /**
  46528. * Scales the texture
  46529. * @param ratio the scale factor to apply to both width and height
  46530. */
  46531. scale(ratio: number): void;
  46532. /**
  46533. * Resizes the texture
  46534. * @param width the new width
  46535. * @param height the new height
  46536. */
  46537. scaleTo(width: number, height: number): void;
  46538. /**
  46539. * Gets the context of the canvas used by the texture
  46540. * @returns the canvas context of the dynamic texture
  46541. */
  46542. getContext(): CanvasRenderingContext2D;
  46543. /**
  46544. * Clears the texture
  46545. */
  46546. clear(): void;
  46547. /**
  46548. * Updates the texture
  46549. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46550. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46551. */
  46552. update(invertY?: boolean, premulAlpha?: boolean): void;
  46553. /**
  46554. * Draws text onto the texture
  46555. * @param text defines the text to be drawn
  46556. * @param x defines the placement of the text from the left
  46557. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46558. * @param font defines the font to be used with font-style, font-size, font-name
  46559. * @param color defines the color used for the text
  46560. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46561. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46562. * @param update defines whether texture is immediately update (default is true)
  46563. */
  46564. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46565. /**
  46566. * Clones the texture
  46567. * @returns the clone of the texture.
  46568. */
  46569. clone(): DynamicTexture;
  46570. /**
  46571. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46572. * @returns a serialized dynamic texture object
  46573. */
  46574. serialize(): any;
  46575. private _IsCanvasElement;
  46576. /** @hidden */
  46577. _rebuild(): void;
  46578. }
  46579. }
  46580. declare module BABYLON {
  46581. /**
  46582. * Class containing static functions to help procedurally build meshes
  46583. */
  46584. export class GroundBuilder {
  46585. /**
  46586. * Creates a ground mesh
  46587. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46588. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46590. * @param name defines the name of the mesh
  46591. * @param options defines the options used to create the mesh
  46592. * @param scene defines the hosting scene
  46593. * @returns the ground mesh
  46594. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46595. */
  46596. static CreateGround(name: string, options: {
  46597. width?: number;
  46598. height?: number;
  46599. subdivisions?: number;
  46600. subdivisionsX?: number;
  46601. subdivisionsY?: number;
  46602. updatable?: boolean;
  46603. }, scene: any): Mesh;
  46604. /**
  46605. * Creates a tiled ground mesh
  46606. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46607. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46608. * * 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
  46609. * * 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
  46610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46611. * @param name defines the name of the mesh
  46612. * @param options defines the options used to create the mesh
  46613. * @param scene defines the hosting scene
  46614. * @returns the tiled ground mesh
  46615. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46616. */
  46617. static CreateTiledGround(name: string, options: {
  46618. xmin: number;
  46619. zmin: number;
  46620. xmax: number;
  46621. zmax: number;
  46622. subdivisions?: {
  46623. w: number;
  46624. h: number;
  46625. };
  46626. precision?: {
  46627. w: number;
  46628. h: number;
  46629. };
  46630. updatable?: boolean;
  46631. }, scene?: Nullable<Scene>): Mesh;
  46632. /**
  46633. * Creates a ground mesh from a height map
  46634. * * The parameter `url` sets the URL of the height map image resource.
  46635. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46636. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46637. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46638. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46639. * * 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.
  46640. * * 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).
  46641. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46643. * @param name defines the name of the mesh
  46644. * @param url defines the url to the height map
  46645. * @param options defines the options used to create the mesh
  46646. * @param scene defines the hosting scene
  46647. * @returns the ground mesh
  46648. * @see https://doc.babylonjs.com/babylon101/height_map
  46649. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46650. */
  46651. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46652. width?: number;
  46653. height?: number;
  46654. subdivisions?: number;
  46655. minHeight?: number;
  46656. maxHeight?: number;
  46657. colorFilter?: Color3;
  46658. alphaFilter?: number;
  46659. updatable?: boolean;
  46660. onReady?: (mesh: GroundMesh) => void;
  46661. }, scene?: Nullable<Scene>): GroundMesh;
  46662. }
  46663. }
  46664. declare module BABYLON {
  46665. /**
  46666. * Class containing static functions to help procedurally build meshes
  46667. */
  46668. export class TorusBuilder {
  46669. /**
  46670. * Creates a torus mesh
  46671. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46672. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46673. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46675. * * 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
  46676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46677. * @param name defines the name of the mesh
  46678. * @param options defines the options used to create the mesh
  46679. * @param scene defines the hosting scene
  46680. * @returns the torus mesh
  46681. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46682. */
  46683. static CreateTorus(name: string, options: {
  46684. diameter?: number;
  46685. thickness?: number;
  46686. tessellation?: number;
  46687. updatable?: boolean;
  46688. sideOrientation?: number;
  46689. frontUVs?: Vector4;
  46690. backUVs?: Vector4;
  46691. }, scene: any): Mesh;
  46692. }
  46693. }
  46694. declare module BABYLON {
  46695. /**
  46696. * Class containing static functions to help procedurally build meshes
  46697. */
  46698. export class CylinderBuilder {
  46699. /**
  46700. * Creates a cylinder or a cone mesh
  46701. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46702. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46703. * * 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.
  46704. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46705. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46706. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46707. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46708. * * 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).
  46709. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46710. * * 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).
  46711. * * 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
  46712. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46713. * * 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
  46714. * * 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.
  46715. * * If `enclose` is false, a ring surface is one element.
  46716. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46717. * * 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
  46718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46719. * * 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
  46720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46721. * @param name defines the name of the mesh
  46722. * @param options defines the options used to create the mesh
  46723. * @param scene defines the hosting scene
  46724. * @returns the cylinder mesh
  46725. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46726. */
  46727. static CreateCylinder(name: string, options: {
  46728. height?: number;
  46729. diameterTop?: number;
  46730. diameterBottom?: number;
  46731. diameter?: number;
  46732. tessellation?: number;
  46733. subdivisions?: number;
  46734. arc?: number;
  46735. faceColors?: Color4[];
  46736. faceUV?: Vector4[];
  46737. updatable?: boolean;
  46738. hasRings?: boolean;
  46739. enclose?: boolean;
  46740. cap?: number;
  46741. sideOrientation?: number;
  46742. frontUVs?: Vector4;
  46743. backUVs?: Vector4;
  46744. }, scene: any): Mesh;
  46745. }
  46746. }
  46747. declare module BABYLON {
  46748. /**
  46749. * States of the webXR experience
  46750. */
  46751. export enum WebXRState {
  46752. /**
  46753. * Transitioning to being in XR mode
  46754. */
  46755. ENTERING_XR = 0,
  46756. /**
  46757. * Transitioning to non XR mode
  46758. */
  46759. EXITING_XR = 1,
  46760. /**
  46761. * In XR mode and presenting
  46762. */
  46763. IN_XR = 2,
  46764. /**
  46765. * Not entered XR mode
  46766. */
  46767. NOT_IN_XR = 3
  46768. }
  46769. /**
  46770. * Abstraction of the XR render target
  46771. */
  46772. export interface WebXRRenderTarget extends IDisposable {
  46773. /**
  46774. * xrpresent context of the canvas which can be used to display/mirror xr content
  46775. */
  46776. canvasContext: WebGLRenderingContext;
  46777. /**
  46778. * xr layer for the canvas
  46779. */
  46780. xrLayer: Nullable<XRWebGLLayer>;
  46781. /**
  46782. * Initializes the xr layer for the session
  46783. * @param xrSession xr session
  46784. * @returns a promise that will resolve once the XR Layer has been created
  46785. */
  46786. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46787. }
  46788. }
  46789. declare module BABYLON {
  46790. /**
  46791. * COnfiguration object for WebXR output canvas
  46792. */
  46793. export class WebXRManagedOutputCanvasOptions {
  46794. /**
  46795. * An optional canvas in case you wish to create it yourself and provide it here.
  46796. * If not provided, a new canvas will be created
  46797. */
  46798. canvasElement?: HTMLCanvasElement;
  46799. /**
  46800. * Options for this XR Layer output
  46801. */
  46802. canvasOptions?: XRWebGLLayerOptions;
  46803. /**
  46804. * CSS styling for a newly created canvas (if not provided)
  46805. */
  46806. newCanvasCssStyle?: string;
  46807. /**
  46808. * Get the default values of the configuration object
  46809. * @param engine defines the engine to use (can be null)
  46810. * @returns default values of this configuration object
  46811. */
  46812. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46813. }
  46814. /**
  46815. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46816. */
  46817. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46818. private _options;
  46819. private _canvas;
  46820. private _engine;
  46821. private _originalCanvasSize;
  46822. /**
  46823. * Rendering context of the canvas which can be used to display/mirror xr content
  46824. */
  46825. canvasContext: WebGLRenderingContext;
  46826. /**
  46827. * xr layer for the canvas
  46828. */
  46829. xrLayer: Nullable<XRWebGLLayer>;
  46830. /**
  46831. * Obseervers registered here will be triggered when the xr layer was initialized
  46832. */
  46833. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46834. /**
  46835. * Initializes the canvas to be added/removed upon entering/exiting xr
  46836. * @param _xrSessionManager The XR Session manager
  46837. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46838. */
  46839. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46840. /**
  46841. * Disposes of the object
  46842. */
  46843. dispose(): void;
  46844. /**
  46845. * Initializes the xr layer for the session
  46846. * @param xrSession xr session
  46847. * @returns a promise that will resolve once the XR Layer has been created
  46848. */
  46849. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46850. private _addCanvas;
  46851. private _removeCanvas;
  46852. private _setCanvasSize;
  46853. private _setManagedOutputCanvas;
  46854. }
  46855. }
  46856. declare module BABYLON {
  46857. /**
  46858. * Manages an XRSession to work with Babylon's engine
  46859. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46860. */
  46861. export class WebXRSessionManager implements IDisposable {
  46862. /** The scene which the session should be created for */
  46863. scene: Scene;
  46864. private _referenceSpace;
  46865. private _rttProvider;
  46866. private _sessionEnded;
  46867. private _xrNavigator;
  46868. private baseLayer;
  46869. /**
  46870. * The base reference space from which the session started. good if you want to reset your
  46871. * reference space
  46872. */
  46873. baseReferenceSpace: XRReferenceSpace;
  46874. /**
  46875. * Current XR frame
  46876. */
  46877. currentFrame: Nullable<XRFrame>;
  46878. /** WebXR timestamp updated every frame */
  46879. currentTimestamp: number;
  46880. /**
  46881. * Used just in case of a failure to initialize an immersive session.
  46882. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46883. */
  46884. defaultHeightCompensation: number;
  46885. /**
  46886. * Fires every time a new xrFrame arrives which can be used to update the camera
  46887. */
  46888. onXRFrameObservable: Observable<XRFrame>;
  46889. /**
  46890. * Fires when the reference space changed
  46891. */
  46892. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46893. /**
  46894. * Fires when the xr session is ended either by the device or manually done
  46895. */
  46896. onXRSessionEnded: Observable<any>;
  46897. /**
  46898. * Fires when the xr session is ended either by the device or manually done
  46899. */
  46900. onXRSessionInit: Observable<XRSession>;
  46901. /**
  46902. * Underlying xr session
  46903. */
  46904. session: XRSession;
  46905. /**
  46906. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46907. * or get the offset the player is currently at.
  46908. */
  46909. viewerReferenceSpace: XRReferenceSpace;
  46910. /**
  46911. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46912. * @param scene The scene which the session should be created for
  46913. */
  46914. constructor(
  46915. /** The scene which the session should be created for */
  46916. scene: Scene);
  46917. /**
  46918. * The current reference space used in this session. This reference space can constantly change!
  46919. * It is mainly used to offset the camera's position.
  46920. */
  46921. get referenceSpace(): XRReferenceSpace;
  46922. /**
  46923. * Set a new reference space and triggers the observable
  46924. */
  46925. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46926. /**
  46927. * Disposes of the session manager
  46928. */
  46929. dispose(): void;
  46930. /**
  46931. * Stops the xrSession and restores the render loop
  46932. * @returns Promise which resolves after it exits XR
  46933. */
  46934. exitXRAsync(): Promise<void>;
  46935. /**
  46936. * Gets the correct render target texture to be rendered this frame for this eye
  46937. * @param eye the eye for which to get the render target
  46938. * @returns the render target for the specified eye
  46939. */
  46940. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46941. /**
  46942. * Creates a WebXRRenderTarget object for the XR session
  46943. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46944. * @param options optional options to provide when creating a new render target
  46945. * @returns a WebXR render target to which the session can render
  46946. */
  46947. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46948. /**
  46949. * Initializes the manager
  46950. * After initialization enterXR can be called to start an XR session
  46951. * @returns Promise which resolves after it is initialized
  46952. */
  46953. initializeAsync(): Promise<void>;
  46954. /**
  46955. * Initializes an xr session
  46956. * @param xrSessionMode mode to initialize
  46957. * @param xrSessionInit defines optional and required values to pass to the session builder
  46958. * @returns a promise which will resolve once the session has been initialized
  46959. */
  46960. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46961. /**
  46962. * Checks if a session would be supported for the creation options specified
  46963. * @param sessionMode session mode to check if supported eg. immersive-vr
  46964. * @returns A Promise that resolves to true if supported and false if not
  46965. */
  46966. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46967. /**
  46968. * Resets the reference space to the one started the session
  46969. */
  46970. resetReferenceSpace(): void;
  46971. /**
  46972. * Starts rendering to the xr layer
  46973. */
  46974. runXRRenderLoop(): void;
  46975. /**
  46976. * Sets the reference space on the xr session
  46977. * @param referenceSpaceType space to set
  46978. * @returns a promise that will resolve once the reference space has been set
  46979. */
  46980. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46981. /**
  46982. * Updates the render state of the session
  46983. * @param state state to set
  46984. * @returns a promise that resolves once the render state has been updated
  46985. */
  46986. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46987. /**
  46988. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46989. * @param sessionMode defines the session to test
  46990. * @returns a promise with boolean as final value
  46991. */
  46992. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46993. private _createRenderTargetTexture;
  46994. }
  46995. }
  46996. declare module BABYLON {
  46997. /**
  46998. * WebXR Camera which holds the views for the xrSession
  46999. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47000. */
  47001. export class WebXRCamera extends FreeCamera {
  47002. private _xrSessionManager;
  47003. private _firstFrame;
  47004. private _referenceQuaternion;
  47005. private _referencedPosition;
  47006. private _xrInvPositionCache;
  47007. private _xrInvQuaternionCache;
  47008. /**
  47009. * Observable raised before camera teleportation
  47010. */
  47011. onBeforeCameraTeleport: Observable<Vector3>;
  47012. /**
  47013. * Observable raised after camera teleportation
  47014. */
  47015. onAfterCameraTeleport: Observable<Vector3>;
  47016. /**
  47017. * Should position compensation execute on first frame.
  47018. * This is used when copying the position from a native (non XR) camera
  47019. */
  47020. compensateOnFirstFrame: boolean;
  47021. /**
  47022. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47023. * @param name the name of the camera
  47024. * @param scene the scene to add the camera to
  47025. * @param _xrSessionManager a constructed xr session manager
  47026. */
  47027. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47028. /**
  47029. * Return the user's height, unrelated to the current ground.
  47030. * This will be the y position of this camera, when ground level is 0.
  47031. */
  47032. get realWorldHeight(): number;
  47033. /** @hidden */
  47034. _updateForDualEyeDebugging(): void;
  47035. /**
  47036. * Sets this camera's transformation based on a non-vr camera
  47037. * @param otherCamera the non-vr camera to copy the transformation from
  47038. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47039. */
  47040. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47041. /**
  47042. * Gets the current instance class name ("WebXRCamera").
  47043. * @returns the class name
  47044. */
  47045. getClassName(): string;
  47046. private _rotate180;
  47047. private _updateFromXRSession;
  47048. private _updateNumberOfRigCameras;
  47049. private _updateReferenceSpace;
  47050. private _updateReferenceSpaceOffset;
  47051. }
  47052. }
  47053. declare module BABYLON {
  47054. /**
  47055. * Defining the interface required for a (webxr) feature
  47056. */
  47057. export interface IWebXRFeature extends IDisposable {
  47058. /**
  47059. * Is this feature attached
  47060. */
  47061. attached: boolean;
  47062. /**
  47063. * Should auto-attach be disabled?
  47064. */
  47065. disableAutoAttach: boolean;
  47066. /**
  47067. * Attach the feature to the session
  47068. * Will usually be called by the features manager
  47069. *
  47070. * @param force should attachment be forced (even when already attached)
  47071. * @returns true if successful.
  47072. */
  47073. attach(force?: boolean): boolean;
  47074. /**
  47075. * Detach the feature from the session
  47076. * Will usually be called by the features manager
  47077. *
  47078. * @returns true if successful.
  47079. */
  47080. detach(): boolean;
  47081. /**
  47082. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47083. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47084. *
  47085. * @returns whether or not the feature is compatible in this environment
  47086. */
  47087. isCompatible(): boolean;
  47088. /**
  47089. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47090. */
  47091. xrNativeFeatureName?: string;
  47092. /**
  47093. * A list of (Babylon WebXR) features this feature depends on
  47094. */
  47095. dependsOn?: string[];
  47096. }
  47097. /**
  47098. * A list of the currently available features without referencing them
  47099. */
  47100. export class WebXRFeatureName {
  47101. /**
  47102. * The name of the anchor system feature
  47103. */
  47104. static readonly ANCHOR_SYSTEM: string;
  47105. /**
  47106. * The name of the background remover feature
  47107. */
  47108. static readonly BACKGROUND_REMOVER: string;
  47109. /**
  47110. * The name of the hit test feature
  47111. */
  47112. static readonly HIT_TEST: string;
  47113. /**
  47114. * physics impostors for xr controllers feature
  47115. */
  47116. static readonly PHYSICS_CONTROLLERS: string;
  47117. /**
  47118. * The name of the plane detection feature
  47119. */
  47120. static readonly PLANE_DETECTION: string;
  47121. /**
  47122. * The name of the pointer selection feature
  47123. */
  47124. static readonly POINTER_SELECTION: string;
  47125. /**
  47126. * The name of the teleportation feature
  47127. */
  47128. static readonly TELEPORTATION: string;
  47129. /**
  47130. * The name of the feature points feature.
  47131. */
  47132. static readonly FEATURE_POINTS: string;
  47133. /**
  47134. * The name of the hand tracking feature.
  47135. */
  47136. static readonly HAND_TRACKING: string;
  47137. }
  47138. /**
  47139. * Defining the constructor of a feature. Used to register the modules.
  47140. */
  47141. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47142. /**
  47143. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47144. * It is mainly used in AR sessions.
  47145. *
  47146. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47147. */
  47148. export class WebXRFeaturesManager implements IDisposable {
  47149. private _xrSessionManager;
  47150. private static readonly _AvailableFeatures;
  47151. private _features;
  47152. /**
  47153. * constructs a new features manages.
  47154. *
  47155. * @param _xrSessionManager an instance of WebXRSessionManager
  47156. */
  47157. constructor(_xrSessionManager: WebXRSessionManager);
  47158. /**
  47159. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47160. * Mainly used internally.
  47161. *
  47162. * @param featureName the name of the feature to register
  47163. * @param constructorFunction the function used to construct the module
  47164. * @param version the (babylon) version of the module
  47165. * @param stable is that a stable version of this module
  47166. */
  47167. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47168. /**
  47169. * Returns a constructor of a specific feature.
  47170. *
  47171. * @param featureName the name of the feature to construct
  47172. * @param version the version of the feature to load
  47173. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47174. * @param options optional options provided to the module.
  47175. * @returns a function that, when called, will return a new instance of this feature
  47176. */
  47177. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47178. /**
  47179. * Can be used to return the list of features currently registered
  47180. *
  47181. * @returns an Array of available features
  47182. */
  47183. static GetAvailableFeatures(): string[];
  47184. /**
  47185. * Gets the versions available for a specific feature
  47186. * @param featureName the name of the feature
  47187. * @returns an array with the available versions
  47188. */
  47189. static GetAvailableVersions(featureName: string): string[];
  47190. /**
  47191. * Return the latest unstable version of this feature
  47192. * @param featureName the name of the feature to search
  47193. * @returns the version number. if not found will return -1
  47194. */
  47195. static GetLatestVersionOfFeature(featureName: string): number;
  47196. /**
  47197. * Return the latest stable version of this feature
  47198. * @param featureName the name of the feature to search
  47199. * @returns the version number. if not found will return -1
  47200. */
  47201. static GetStableVersionOfFeature(featureName: string): number;
  47202. /**
  47203. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47204. * Can be used during a session to start a feature
  47205. * @param featureName the name of feature to attach
  47206. */
  47207. attachFeature(featureName: string): void;
  47208. /**
  47209. * Can be used inside a session or when the session ends to detach a specific feature
  47210. * @param featureName the name of the feature to detach
  47211. */
  47212. detachFeature(featureName: string): void;
  47213. /**
  47214. * Used to disable an already-enabled feature
  47215. * The feature will be disposed and will be recreated once enabled.
  47216. * @param featureName the feature to disable
  47217. * @returns true if disable was successful
  47218. */
  47219. disableFeature(featureName: string | {
  47220. Name: string;
  47221. }): boolean;
  47222. /**
  47223. * dispose this features manager
  47224. */
  47225. dispose(): void;
  47226. /**
  47227. * 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.
  47228. * 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.
  47229. *
  47230. * @param featureName the name of the feature to load or the class of the feature
  47231. * @param version optional version to load. if not provided the latest version will be enabled
  47232. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47233. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47234. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47235. * @returns a new constructed feature or throws an error if feature not found.
  47236. */
  47237. enableFeature(featureName: string | {
  47238. Name: string;
  47239. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47240. /**
  47241. * get the implementation of an enabled feature.
  47242. * @param featureName the name of the feature to load
  47243. * @returns the feature class, if found
  47244. */
  47245. getEnabledFeature(featureName: string): IWebXRFeature;
  47246. /**
  47247. * Get the list of enabled features
  47248. * @returns an array of enabled features
  47249. */
  47250. getEnabledFeatures(): string[];
  47251. /**
  47252. * This function will exten the session creation configuration object with enabled features.
  47253. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47254. * according to the defined "required" variable, provided during enableFeature call
  47255. * @param xrSessionInit the xr Session init object to extend
  47256. *
  47257. * @returns an extended XRSessionInit object
  47258. */
  47259. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47260. }
  47261. }
  47262. declare module BABYLON {
  47263. /**
  47264. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47265. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47266. */
  47267. export class WebXRExperienceHelper implements IDisposable {
  47268. private scene;
  47269. private _nonVRCamera;
  47270. private _originalSceneAutoClear;
  47271. private _supported;
  47272. /**
  47273. * Camera used to render xr content
  47274. */
  47275. camera: WebXRCamera;
  47276. /** A features manager for this xr session */
  47277. featuresManager: WebXRFeaturesManager;
  47278. /**
  47279. * Observers registered here will be triggered after the camera's initial transformation is set
  47280. * This can be used to set a different ground level or an extra rotation.
  47281. *
  47282. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47283. * to the position set after this observable is done executing.
  47284. */
  47285. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47286. /**
  47287. * Fires when the state of the experience helper has changed
  47288. */
  47289. onStateChangedObservable: Observable<WebXRState>;
  47290. /** Session manager used to keep track of xr session */
  47291. sessionManager: WebXRSessionManager;
  47292. /**
  47293. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47294. */
  47295. state: WebXRState;
  47296. /**
  47297. * Creates a WebXRExperienceHelper
  47298. * @param scene The scene the helper should be created in
  47299. */
  47300. private constructor();
  47301. /**
  47302. * Creates the experience helper
  47303. * @param scene the scene to attach the experience helper to
  47304. * @returns a promise for the experience helper
  47305. */
  47306. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47307. /**
  47308. * Disposes of the experience helper
  47309. */
  47310. dispose(): void;
  47311. /**
  47312. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47313. * @param sessionMode options for the XR session
  47314. * @param referenceSpaceType frame of reference of the XR session
  47315. * @param renderTarget the output canvas that will be used to enter XR mode
  47316. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47317. * @returns promise that resolves after xr mode has entered
  47318. */
  47319. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47320. /**
  47321. * Exits XR mode and returns the scene to its original state
  47322. * @returns promise that resolves after xr mode has exited
  47323. */
  47324. exitXRAsync(): Promise<void>;
  47325. private _nonXRToXRCamera;
  47326. private _setState;
  47327. }
  47328. }
  47329. declare module BABYLON {
  47330. /**
  47331. * X-Y values for axes in WebXR
  47332. */
  47333. export interface IWebXRMotionControllerAxesValue {
  47334. /**
  47335. * The value of the x axis
  47336. */
  47337. x: number;
  47338. /**
  47339. * The value of the y-axis
  47340. */
  47341. y: number;
  47342. }
  47343. /**
  47344. * changed / previous values for the values of this component
  47345. */
  47346. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47347. /**
  47348. * current (this frame) value
  47349. */
  47350. current: T;
  47351. /**
  47352. * previous (last change) value
  47353. */
  47354. previous: T;
  47355. }
  47356. /**
  47357. * Represents changes in the component between current frame and last values recorded
  47358. */
  47359. export interface IWebXRMotionControllerComponentChanges {
  47360. /**
  47361. * will be populated with previous and current values if axes changed
  47362. */
  47363. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47364. /**
  47365. * will be populated with previous and current values if pressed changed
  47366. */
  47367. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47368. /**
  47369. * will be populated with previous and current values if touched changed
  47370. */
  47371. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47372. /**
  47373. * will be populated with previous and current values if value changed
  47374. */
  47375. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47376. }
  47377. /**
  47378. * This class represents a single component (for example button or thumbstick) of a motion controller
  47379. */
  47380. export class WebXRControllerComponent implements IDisposable {
  47381. /**
  47382. * the id of this component
  47383. */
  47384. id: string;
  47385. /**
  47386. * the type of the component
  47387. */
  47388. type: MotionControllerComponentType;
  47389. private _buttonIndex;
  47390. private _axesIndices;
  47391. private _axes;
  47392. private _changes;
  47393. private _currentValue;
  47394. private _hasChanges;
  47395. private _pressed;
  47396. private _touched;
  47397. /**
  47398. * button component type
  47399. */
  47400. static BUTTON_TYPE: MotionControllerComponentType;
  47401. /**
  47402. * squeeze component type
  47403. */
  47404. static SQUEEZE_TYPE: MotionControllerComponentType;
  47405. /**
  47406. * Thumbstick component type
  47407. */
  47408. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47409. /**
  47410. * Touchpad component type
  47411. */
  47412. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47413. /**
  47414. * trigger component type
  47415. */
  47416. static TRIGGER_TYPE: MotionControllerComponentType;
  47417. /**
  47418. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47419. * the axes data changes
  47420. */
  47421. onAxisValueChangedObservable: Observable<{
  47422. x: number;
  47423. y: number;
  47424. }>;
  47425. /**
  47426. * Observers registered here will be triggered when the state of a button changes
  47427. * State change is either pressed / touched / value
  47428. */
  47429. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47430. /**
  47431. * Creates a new component for a motion controller.
  47432. * It is created by the motion controller itself
  47433. *
  47434. * @param id the id of this component
  47435. * @param type the type of the component
  47436. * @param _buttonIndex index in the buttons array of the gamepad
  47437. * @param _axesIndices indices of the values in the axes array of the gamepad
  47438. */
  47439. constructor(
  47440. /**
  47441. * the id of this component
  47442. */
  47443. id: string,
  47444. /**
  47445. * the type of the component
  47446. */
  47447. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47448. /**
  47449. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47450. */
  47451. get axes(): IWebXRMotionControllerAxesValue;
  47452. /**
  47453. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47454. */
  47455. get changes(): IWebXRMotionControllerComponentChanges;
  47456. /**
  47457. * Return whether or not the component changed the last frame
  47458. */
  47459. get hasChanges(): boolean;
  47460. /**
  47461. * is the button currently pressed
  47462. */
  47463. get pressed(): boolean;
  47464. /**
  47465. * is the button currently touched
  47466. */
  47467. get touched(): boolean;
  47468. /**
  47469. * Get the current value of this component
  47470. */
  47471. get value(): number;
  47472. /**
  47473. * Dispose this component
  47474. */
  47475. dispose(): void;
  47476. /**
  47477. * Are there axes correlating to this component
  47478. * @return true is axes data is available
  47479. */
  47480. isAxes(): boolean;
  47481. /**
  47482. * Is this component a button (hence - pressable)
  47483. * @returns true if can be pressed
  47484. */
  47485. isButton(): boolean;
  47486. /**
  47487. * update this component using the gamepad object it is in. Called on every frame
  47488. * @param nativeController the native gamepad controller object
  47489. */
  47490. update(nativeController: IMinimalMotionControllerObject): void;
  47491. }
  47492. }
  47493. declare module BABYLON {
  47494. /**
  47495. * Interface used to represent data loading progression
  47496. */
  47497. export interface ISceneLoaderProgressEvent {
  47498. /**
  47499. * Defines if data length to load can be evaluated
  47500. */
  47501. readonly lengthComputable: boolean;
  47502. /**
  47503. * Defines the loaded data length
  47504. */
  47505. readonly loaded: number;
  47506. /**
  47507. * Defines the data length to load
  47508. */
  47509. readonly total: number;
  47510. }
  47511. /**
  47512. * Interface used by SceneLoader plugins to define supported file extensions
  47513. */
  47514. export interface ISceneLoaderPluginExtensions {
  47515. /**
  47516. * Defines the list of supported extensions
  47517. */
  47518. [extension: string]: {
  47519. isBinary: boolean;
  47520. };
  47521. }
  47522. /**
  47523. * Interface used by SceneLoader plugin factory
  47524. */
  47525. export interface ISceneLoaderPluginFactory {
  47526. /**
  47527. * Defines the name of the factory
  47528. */
  47529. name: string;
  47530. /**
  47531. * Function called to create a new plugin
  47532. * @return the new plugin
  47533. */
  47534. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47535. /**
  47536. * The callback that returns true if the data can be directly loaded.
  47537. * @param data string containing the file data
  47538. * @returns if the data can be loaded directly
  47539. */
  47540. canDirectLoad?(data: string): boolean;
  47541. }
  47542. /**
  47543. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47544. */
  47545. export interface ISceneLoaderPluginBase {
  47546. /**
  47547. * The friendly name of this plugin.
  47548. */
  47549. name: string;
  47550. /**
  47551. * The file extensions supported by this plugin.
  47552. */
  47553. extensions: string | ISceneLoaderPluginExtensions;
  47554. /**
  47555. * The callback called when loading from a url.
  47556. * @param scene scene loading this url
  47557. * @param url url to load
  47558. * @param onSuccess callback called when the file successfully loads
  47559. * @param onProgress callback called while file is loading (if the server supports this mode)
  47560. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47561. * @param onError callback called when the file fails to load
  47562. * @returns a file request object
  47563. */
  47564. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47565. /**
  47566. * The callback called when loading from a file object.
  47567. * @param scene scene loading this file
  47568. * @param file defines the file to load
  47569. * @param onSuccess defines the callback to call when data is loaded
  47570. * @param onProgress defines the callback to call during loading process
  47571. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47572. * @param onError defines the callback to call when an error occurs
  47573. * @returns a file request object
  47574. */
  47575. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47576. /**
  47577. * The callback that returns true if the data can be directly loaded.
  47578. * @param data string containing the file data
  47579. * @returns if the data can be loaded directly
  47580. */
  47581. canDirectLoad?(data: string): boolean;
  47582. /**
  47583. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47584. * @param scene scene loading this data
  47585. * @param data string containing the data
  47586. * @returns data to pass to the plugin
  47587. */
  47588. directLoad?(scene: Scene, data: string): any;
  47589. /**
  47590. * The callback that allows custom handling of the root url based on the response url.
  47591. * @param rootUrl the original root url
  47592. * @param responseURL the response url if available
  47593. * @returns the new root url
  47594. */
  47595. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47596. }
  47597. /**
  47598. * Interface used to define a SceneLoader plugin
  47599. */
  47600. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47601. /**
  47602. * Import meshes into a scene.
  47603. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47604. * @param scene The scene to import into
  47605. * @param data The data to import
  47606. * @param rootUrl The root url for scene and resources
  47607. * @param meshes The meshes array to import into
  47608. * @param particleSystems The particle systems array to import into
  47609. * @param skeletons The skeletons array to import into
  47610. * @param onError The callback when import fails
  47611. * @returns True if successful or false otherwise
  47612. */
  47613. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47614. /**
  47615. * Load into a scene.
  47616. * @param scene The scene to load into
  47617. * @param data The data to import
  47618. * @param rootUrl The root url for scene and resources
  47619. * @param onError The callback when import fails
  47620. * @returns True if successful or false otherwise
  47621. */
  47622. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47623. /**
  47624. * Load into an asset container.
  47625. * @param scene The scene to load into
  47626. * @param data The data to import
  47627. * @param rootUrl The root url for scene and resources
  47628. * @param onError The callback when import fails
  47629. * @returns The loaded asset container
  47630. */
  47631. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47632. }
  47633. /**
  47634. * Interface used to define an async SceneLoader plugin
  47635. */
  47636. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47637. /**
  47638. * Import meshes into a scene.
  47639. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47640. * @param scene The scene to import into
  47641. * @param data The data to import
  47642. * @param rootUrl The root url for scene and resources
  47643. * @param onProgress The callback when the load progresses
  47644. * @param fileName Defines the name of the file to load
  47645. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47646. */
  47647. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47648. meshes: AbstractMesh[];
  47649. particleSystems: IParticleSystem[];
  47650. skeletons: Skeleton[];
  47651. animationGroups: AnimationGroup[];
  47652. }>;
  47653. /**
  47654. * Load into a scene.
  47655. * @param scene The scene to load into
  47656. * @param data The data to import
  47657. * @param rootUrl The root url for scene and resources
  47658. * @param onProgress The callback when the load progresses
  47659. * @param fileName Defines the name of the file to load
  47660. * @returns Nothing
  47661. */
  47662. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47663. /**
  47664. * Load into an asset container.
  47665. * @param scene The scene to load into
  47666. * @param data The data to import
  47667. * @param rootUrl The root url for scene and resources
  47668. * @param onProgress The callback when the load progresses
  47669. * @param fileName Defines the name of the file to load
  47670. * @returns The loaded asset container
  47671. */
  47672. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47673. }
  47674. /**
  47675. * Mode that determines how to handle old animation groups before loading new ones.
  47676. */
  47677. export enum SceneLoaderAnimationGroupLoadingMode {
  47678. /**
  47679. * Reset all old animations to initial state then dispose them.
  47680. */
  47681. Clean = 0,
  47682. /**
  47683. * Stop all old animations.
  47684. */
  47685. Stop = 1,
  47686. /**
  47687. * Restart old animations from first frame.
  47688. */
  47689. Sync = 2,
  47690. /**
  47691. * Old animations remains untouched.
  47692. */
  47693. NoSync = 3
  47694. }
  47695. /**
  47696. * Defines a plugin registered by the SceneLoader
  47697. */
  47698. interface IRegisteredPlugin {
  47699. /**
  47700. * Defines the plugin to use
  47701. */
  47702. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47703. /**
  47704. * Defines if the plugin supports binary data
  47705. */
  47706. isBinary: boolean;
  47707. }
  47708. /**
  47709. * Class used to load scene from various file formats using registered plugins
  47710. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47711. */
  47712. export class SceneLoader {
  47713. /**
  47714. * No logging while loading
  47715. */
  47716. static readonly NO_LOGGING: number;
  47717. /**
  47718. * Minimal logging while loading
  47719. */
  47720. static readonly MINIMAL_LOGGING: number;
  47721. /**
  47722. * Summary logging while loading
  47723. */
  47724. static readonly SUMMARY_LOGGING: number;
  47725. /**
  47726. * Detailled logging while loading
  47727. */
  47728. static readonly DETAILED_LOGGING: number;
  47729. /**
  47730. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47731. */
  47732. static get ForceFullSceneLoadingForIncremental(): boolean;
  47733. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47734. /**
  47735. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47736. */
  47737. static get ShowLoadingScreen(): boolean;
  47738. static set ShowLoadingScreen(value: boolean);
  47739. /**
  47740. * Defines the current logging level (while loading the scene)
  47741. * @ignorenaming
  47742. */
  47743. static get loggingLevel(): number;
  47744. static set loggingLevel(value: number);
  47745. /**
  47746. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47747. */
  47748. static get CleanBoneMatrixWeights(): boolean;
  47749. static set CleanBoneMatrixWeights(value: boolean);
  47750. /**
  47751. * Event raised when a plugin is used to load a scene
  47752. */
  47753. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47754. private static _registeredPlugins;
  47755. private static _showingLoadingScreen;
  47756. /**
  47757. * Gets the default plugin (used to load Babylon files)
  47758. * @returns the .babylon plugin
  47759. */
  47760. static GetDefaultPlugin(): IRegisteredPlugin;
  47761. private static _GetPluginForExtension;
  47762. private static _GetPluginForDirectLoad;
  47763. private static _GetPluginForFilename;
  47764. private static _GetDirectLoad;
  47765. private static _LoadData;
  47766. private static _GetFileInfo;
  47767. /**
  47768. * Gets a plugin that can load the given extension
  47769. * @param extension defines the extension to load
  47770. * @returns a plugin or null if none works
  47771. */
  47772. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47773. /**
  47774. * Gets a boolean indicating that the given extension can be loaded
  47775. * @param extension defines the extension to load
  47776. * @returns true if the extension is supported
  47777. */
  47778. static IsPluginForExtensionAvailable(extension: string): boolean;
  47779. /**
  47780. * Adds a new plugin to the list of registered plugins
  47781. * @param plugin defines the plugin to add
  47782. */
  47783. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47784. /**
  47785. * Import meshes into a scene
  47786. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47787. * @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)
  47788. * @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)
  47789. * @param scene the instance of BABYLON.Scene to append to
  47790. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47791. * @param onProgress a callback with a progress event for each file being loaded
  47792. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47793. * @param pluginExtension the extension used to determine the plugin
  47794. * @returns The loaded plugin
  47795. */
  47796. 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>;
  47797. /**
  47798. * Import meshes into a scene
  47799. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47800. * @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)
  47801. * @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)
  47802. * @param scene the instance of BABYLON.Scene to append to
  47803. * @param onProgress a callback with a progress event for each file being loaded
  47804. * @param pluginExtension the extension used to determine the plugin
  47805. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47806. */
  47807. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47808. meshes: AbstractMesh[];
  47809. particleSystems: IParticleSystem[];
  47810. skeletons: Skeleton[];
  47811. animationGroups: AnimationGroup[];
  47812. }>;
  47813. /**
  47814. * Load a scene
  47815. * @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)
  47816. * @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)
  47817. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47818. * @param onSuccess a callback with the scene when import succeeds
  47819. * @param onProgress a callback with a progress event for each file being loaded
  47820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47821. * @param pluginExtension the extension used to determine the plugin
  47822. * @returns The loaded plugin
  47823. */
  47824. 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>;
  47825. /**
  47826. * Load a scene
  47827. * @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)
  47828. * @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)
  47829. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47830. * @param onProgress a callback with a progress event for each file being loaded
  47831. * @param pluginExtension the extension used to determine the plugin
  47832. * @returns The loaded scene
  47833. */
  47834. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47835. /**
  47836. * Append a scene
  47837. * @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)
  47838. * @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)
  47839. * @param scene is the instance of BABYLON.Scene to append to
  47840. * @param onSuccess a callback with the scene when import succeeds
  47841. * @param onProgress a callback with a progress event for each file being loaded
  47842. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47843. * @param pluginExtension the extension used to determine the plugin
  47844. * @returns The loaded plugin
  47845. */
  47846. 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>;
  47847. /**
  47848. * Append a scene
  47849. * @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)
  47850. * @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)
  47851. * @param scene is the instance of BABYLON.Scene to append to
  47852. * @param onProgress a callback with a progress event for each file being loaded
  47853. * @param pluginExtension the extension used to determine the plugin
  47854. * @returns The given scene
  47855. */
  47856. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47857. /**
  47858. * Load a scene into an asset container
  47859. * @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)
  47860. * @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)
  47861. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47862. * @param onSuccess a callback with the scene when import succeeds
  47863. * @param onProgress a callback with a progress event for each file being loaded
  47864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47865. * @param pluginExtension the extension used to determine the plugin
  47866. * @returns The loaded plugin
  47867. */
  47868. 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>;
  47869. /**
  47870. * Load a scene into an asset container
  47871. * @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)
  47872. * @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)
  47873. * @param scene is the instance of Scene to append to
  47874. * @param onProgress a callback with a progress event for each file being loaded
  47875. * @param pluginExtension the extension used to determine the plugin
  47876. * @returns The loaded asset container
  47877. */
  47878. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47879. /**
  47880. * Import animations from a file into a scene
  47881. * @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)
  47882. * @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)
  47883. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47884. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47885. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47886. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47887. * @param onSuccess a callback with the scene when import succeeds
  47888. * @param onProgress a callback with a progress event for each file being loaded
  47889. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47890. * @param pluginExtension the extension used to determine the plugin
  47891. */
  47892. 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;
  47893. /**
  47894. * Import animations from a file into a scene
  47895. * @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)
  47896. * @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)
  47897. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47898. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47899. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47900. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47901. * @param onSuccess a callback with the scene when import succeeds
  47902. * @param onProgress a callback with a progress event for each file being loaded
  47903. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47904. * @param pluginExtension the extension used to determine the plugin
  47905. * @returns the updated scene with imported animations
  47906. */
  47907. 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>;
  47908. }
  47909. }
  47910. declare module BABYLON {
  47911. /**
  47912. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47913. */
  47914. export type MotionControllerHandedness = "none" | "left" | "right";
  47915. /**
  47916. * The type of components available in motion controllers.
  47917. * This is not the name of the component.
  47918. */
  47919. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47920. /**
  47921. * The state of a controller component
  47922. */
  47923. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47924. /**
  47925. * The schema of motion controller layout.
  47926. * No object will be initialized using this interface
  47927. * This is used just to define the profile.
  47928. */
  47929. export interface IMotionControllerLayout {
  47930. /**
  47931. * Path to load the assets. Usually relative to the base path
  47932. */
  47933. assetPath: string;
  47934. /**
  47935. * Available components (unsorted)
  47936. */
  47937. components: {
  47938. /**
  47939. * A map of component Ids
  47940. */
  47941. [componentId: string]: {
  47942. /**
  47943. * The type of input the component outputs
  47944. */
  47945. type: MotionControllerComponentType;
  47946. /**
  47947. * The indices of this component in the gamepad object
  47948. */
  47949. gamepadIndices: {
  47950. /**
  47951. * Index of button
  47952. */
  47953. button?: number;
  47954. /**
  47955. * If available, index of x-axis
  47956. */
  47957. xAxis?: number;
  47958. /**
  47959. * If available, index of y-axis
  47960. */
  47961. yAxis?: number;
  47962. };
  47963. /**
  47964. * The mesh's root node name
  47965. */
  47966. rootNodeName: string;
  47967. /**
  47968. * Animation definitions for this model
  47969. */
  47970. visualResponses: {
  47971. [stateKey: string]: {
  47972. /**
  47973. * What property will be animated
  47974. */
  47975. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47976. /**
  47977. * What states influence this visual response
  47978. */
  47979. states: MotionControllerComponentStateType[];
  47980. /**
  47981. * Type of animation - movement or visibility
  47982. */
  47983. valueNodeProperty: "transform" | "visibility";
  47984. /**
  47985. * Base node name to move. Its position will be calculated according to the min and max nodes
  47986. */
  47987. valueNodeName?: string;
  47988. /**
  47989. * Minimum movement node
  47990. */
  47991. minNodeName?: string;
  47992. /**
  47993. * Max movement node
  47994. */
  47995. maxNodeName?: string;
  47996. };
  47997. };
  47998. /**
  47999. * If touch enabled, what is the name of node to display user feedback
  48000. */
  48001. touchPointNodeName?: string;
  48002. };
  48003. };
  48004. /**
  48005. * Is it xr standard mapping or not
  48006. */
  48007. gamepadMapping: "" | "xr-standard";
  48008. /**
  48009. * Base root node of this entire model
  48010. */
  48011. rootNodeName: string;
  48012. /**
  48013. * Defines the main button component id
  48014. */
  48015. selectComponentId: string;
  48016. }
  48017. /**
  48018. * A definition for the layout map in the input profile
  48019. */
  48020. export interface IMotionControllerLayoutMap {
  48021. /**
  48022. * Layouts with handedness type as a key
  48023. */
  48024. [handedness: string]: IMotionControllerLayout;
  48025. }
  48026. /**
  48027. * The XR Input profile schema
  48028. * Profiles can be found here:
  48029. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48030. */
  48031. export interface IMotionControllerProfile {
  48032. /**
  48033. * fallback profiles for this profileId
  48034. */
  48035. fallbackProfileIds: string[];
  48036. /**
  48037. * The layout map, with handedness as key
  48038. */
  48039. layouts: IMotionControllerLayoutMap;
  48040. /**
  48041. * The id of this profile
  48042. * correlates to the profile(s) in the xrInput.profiles array
  48043. */
  48044. profileId: string;
  48045. }
  48046. /**
  48047. * A helper-interface for the 3 meshes needed for controller button animation
  48048. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48049. */
  48050. export interface IMotionControllerButtonMeshMap {
  48051. /**
  48052. * the mesh that defines the pressed value mesh position.
  48053. * This is used to find the max-position of this button
  48054. */
  48055. pressedMesh: AbstractMesh;
  48056. /**
  48057. * the mesh that defines the unpressed value mesh position.
  48058. * This is used to find the min (or initial) position of this button
  48059. */
  48060. unpressedMesh: AbstractMesh;
  48061. /**
  48062. * The mesh that will be changed when value changes
  48063. */
  48064. valueMesh: AbstractMesh;
  48065. }
  48066. /**
  48067. * A helper-interface for the 3 meshes needed for controller axis animation.
  48068. * This will be expanded when touchpad animations are fully supported
  48069. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48070. */
  48071. export interface IMotionControllerMeshMap {
  48072. /**
  48073. * the mesh that defines the maximum value mesh position.
  48074. */
  48075. maxMesh?: AbstractMesh;
  48076. /**
  48077. * the mesh that defines the minimum value mesh position.
  48078. */
  48079. minMesh?: AbstractMesh;
  48080. /**
  48081. * The mesh that will be changed when axis value changes
  48082. */
  48083. valueMesh?: AbstractMesh;
  48084. }
  48085. /**
  48086. * The elements needed for change-detection of the gamepad objects in motion controllers
  48087. */
  48088. export interface IMinimalMotionControllerObject {
  48089. /**
  48090. * Available axes of this controller
  48091. */
  48092. axes: number[];
  48093. /**
  48094. * An array of available buttons
  48095. */
  48096. buttons: Array<{
  48097. /**
  48098. * Value of the button/trigger
  48099. */
  48100. value: number;
  48101. /**
  48102. * If the button/trigger is currently touched
  48103. */
  48104. touched: boolean;
  48105. /**
  48106. * If the button/trigger is currently pressed
  48107. */
  48108. pressed: boolean;
  48109. }>;
  48110. /**
  48111. * EXPERIMENTAL haptic support.
  48112. */
  48113. hapticActuators?: Array<{
  48114. pulse: (value: number, duration: number) => Promise<boolean>;
  48115. }>;
  48116. }
  48117. /**
  48118. * An Abstract Motion controller
  48119. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48120. * Each component has an observable to check for changes in value and state
  48121. */
  48122. export abstract class WebXRAbstractMotionController implements IDisposable {
  48123. protected scene: Scene;
  48124. protected layout: IMotionControllerLayout;
  48125. /**
  48126. * The gamepad object correlating to this controller
  48127. */
  48128. gamepadObject: IMinimalMotionControllerObject;
  48129. /**
  48130. * handedness (left/right/none) of this controller
  48131. */
  48132. handedness: MotionControllerHandedness;
  48133. private _initComponent;
  48134. private _modelReady;
  48135. /**
  48136. * A map of components (WebXRControllerComponent) in this motion controller
  48137. * Components have a ComponentType and can also have both button and axis definitions
  48138. */
  48139. readonly components: {
  48140. [id: string]: WebXRControllerComponent;
  48141. };
  48142. /**
  48143. * Disable the model's animation. Can be set at any time.
  48144. */
  48145. disableAnimation: boolean;
  48146. /**
  48147. * Observers registered here will be triggered when the model of this controller is done loading
  48148. */
  48149. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48150. /**
  48151. * The profile id of this motion controller
  48152. */
  48153. abstract profileId: string;
  48154. /**
  48155. * The root mesh of the model. It is null if the model was not yet initialized
  48156. */
  48157. rootMesh: Nullable<AbstractMesh>;
  48158. /**
  48159. * constructs a new abstract motion controller
  48160. * @param scene the scene to which the model of the controller will be added
  48161. * @param layout The profile layout to load
  48162. * @param gamepadObject The gamepad object correlating to this controller
  48163. * @param handedness handedness (left/right/none) of this controller
  48164. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48165. */
  48166. constructor(scene: Scene, layout: IMotionControllerLayout,
  48167. /**
  48168. * The gamepad object correlating to this controller
  48169. */
  48170. gamepadObject: IMinimalMotionControllerObject,
  48171. /**
  48172. * handedness (left/right/none) of this controller
  48173. */
  48174. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48175. /**
  48176. * Dispose this controller, the model mesh and all its components
  48177. */
  48178. dispose(): void;
  48179. /**
  48180. * Returns all components of specific type
  48181. * @param type the type to search for
  48182. * @return an array of components with this type
  48183. */
  48184. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48185. /**
  48186. * get a component based an its component id as defined in layout.components
  48187. * @param id the id of the component
  48188. * @returns the component correlates to the id or undefined if not found
  48189. */
  48190. getComponent(id: string): WebXRControllerComponent;
  48191. /**
  48192. * Get the list of components available in this motion controller
  48193. * @returns an array of strings correlating to available components
  48194. */
  48195. getComponentIds(): string[];
  48196. /**
  48197. * Get the first component of specific type
  48198. * @param type type of component to find
  48199. * @return a controller component or null if not found
  48200. */
  48201. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48202. /**
  48203. * Get the main (Select) component of this controller as defined in the layout
  48204. * @returns the main component of this controller
  48205. */
  48206. getMainComponent(): WebXRControllerComponent;
  48207. /**
  48208. * Loads the model correlating to this controller
  48209. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48210. * @returns A promise fulfilled with the result of the model loading
  48211. */
  48212. loadModel(): Promise<boolean>;
  48213. /**
  48214. * Update this model using the current XRFrame
  48215. * @param xrFrame the current xr frame to use and update the model
  48216. */
  48217. updateFromXRFrame(xrFrame: XRFrame): void;
  48218. /**
  48219. * Backwards compatibility due to a deeply-integrated typo
  48220. */
  48221. get handness(): XREye;
  48222. /**
  48223. * Pulse (vibrate) this controller
  48224. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48225. * Consecutive calls to this function will cancel the last pulse call
  48226. *
  48227. * @param value the strength of the pulse in 0.0...1.0 range
  48228. * @param duration Duration of the pulse in milliseconds
  48229. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48230. * @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
  48231. */
  48232. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48233. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48234. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48235. /**
  48236. * Moves the axis on the controller mesh based on its current state
  48237. * @param axis the index of the axis
  48238. * @param axisValue the value of the axis which determines the meshes new position
  48239. * @hidden
  48240. */
  48241. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48242. /**
  48243. * Update the model itself with the current frame data
  48244. * @param xrFrame the frame to use for updating the model mesh
  48245. */
  48246. protected updateModel(xrFrame: XRFrame): void;
  48247. /**
  48248. * Get the filename and path for this controller's model
  48249. * @returns a map of filename and path
  48250. */
  48251. protected abstract _getFilenameAndPath(): {
  48252. filename: string;
  48253. path: string;
  48254. };
  48255. /**
  48256. * This function is called before the mesh is loaded. It checks for loading constraints.
  48257. * For example, this function can check if the GLB loader is available
  48258. * If this function returns false, the generic controller will be loaded instead
  48259. * @returns Is the client ready to load the mesh
  48260. */
  48261. protected abstract _getModelLoadingConstraints(): boolean;
  48262. /**
  48263. * This function will be called after the model was successfully loaded and can be used
  48264. * for mesh transformations before it is available for the user
  48265. * @param meshes the loaded meshes
  48266. */
  48267. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48268. /**
  48269. * Set the root mesh for this controller. Important for the WebXR controller class
  48270. * @param meshes the loaded meshes
  48271. */
  48272. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48273. /**
  48274. * A function executed each frame that updates the mesh (if needed)
  48275. * @param xrFrame the current xrFrame
  48276. */
  48277. protected abstract _updateModel(xrFrame: XRFrame): void;
  48278. private _getGenericFilenameAndPath;
  48279. private _getGenericParentMesh;
  48280. }
  48281. }
  48282. declare module BABYLON {
  48283. /**
  48284. * A generic trigger-only motion controller for WebXR
  48285. */
  48286. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48287. /**
  48288. * Static version of the profile id of this controller
  48289. */
  48290. static ProfileId: string;
  48291. profileId: string;
  48292. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48293. protected _getFilenameAndPath(): {
  48294. filename: string;
  48295. path: string;
  48296. };
  48297. protected _getModelLoadingConstraints(): boolean;
  48298. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48299. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48300. protected _updateModel(): void;
  48301. }
  48302. }
  48303. declare module BABYLON {
  48304. /**
  48305. * Class containing static functions to help procedurally build meshes
  48306. */
  48307. export class SphereBuilder {
  48308. /**
  48309. * Creates a sphere mesh
  48310. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48311. * * 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`)
  48312. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48313. * * 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
  48314. * * 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)
  48315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48316. * * 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
  48317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48318. * @param name defines the name of the mesh
  48319. * @param options defines the options used to create the mesh
  48320. * @param scene defines the hosting scene
  48321. * @returns the sphere mesh
  48322. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48323. */
  48324. static CreateSphere(name: string, options: {
  48325. segments?: number;
  48326. diameter?: number;
  48327. diameterX?: number;
  48328. diameterY?: number;
  48329. diameterZ?: number;
  48330. arc?: number;
  48331. slice?: number;
  48332. sideOrientation?: number;
  48333. frontUVs?: Vector4;
  48334. backUVs?: Vector4;
  48335. updatable?: boolean;
  48336. }, scene?: Nullable<Scene>): Mesh;
  48337. }
  48338. }
  48339. declare module BABYLON {
  48340. /**
  48341. * A profiled motion controller has its profile loaded from an online repository.
  48342. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48343. */
  48344. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48345. private _repositoryUrl;
  48346. private _buttonMeshMapping;
  48347. private _touchDots;
  48348. /**
  48349. * The profile ID of this controller. Will be populated when the controller initializes.
  48350. */
  48351. profileId: string;
  48352. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48353. dispose(): void;
  48354. protected _getFilenameAndPath(): {
  48355. filename: string;
  48356. path: string;
  48357. };
  48358. protected _getModelLoadingConstraints(): boolean;
  48359. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48360. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48361. protected _updateModel(_xrFrame: XRFrame): void;
  48362. }
  48363. }
  48364. declare module BABYLON {
  48365. /**
  48366. * A construction function type to create a new controller based on an xrInput object
  48367. */
  48368. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48369. /**
  48370. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48371. *
  48372. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48373. * it should be replaced with auto-loaded controllers.
  48374. *
  48375. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48376. */
  48377. export class WebXRMotionControllerManager {
  48378. private static _AvailableControllers;
  48379. private static _Fallbacks;
  48380. private static _ProfileLoadingPromises;
  48381. private static _ProfilesList;
  48382. /**
  48383. * The base URL of the online controller repository. Can be changed at any time.
  48384. */
  48385. static BaseRepositoryUrl: string;
  48386. /**
  48387. * Which repository gets priority - local or online
  48388. */
  48389. static PrioritizeOnlineRepository: boolean;
  48390. /**
  48391. * Use the online repository, or use only locally-defined controllers
  48392. */
  48393. static UseOnlineRepository: boolean;
  48394. /**
  48395. * Clear the cache used for profile loading and reload when requested again
  48396. */
  48397. static ClearProfilesCache(): void;
  48398. /**
  48399. * Register the default fallbacks.
  48400. * This function is called automatically when this file is imported.
  48401. */
  48402. static DefaultFallbacks(): void;
  48403. /**
  48404. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48405. * @param profileId the profile to which a fallback needs to be found
  48406. * @return an array with corresponding fallback profiles
  48407. */
  48408. static FindFallbackWithProfileId(profileId: string): string[];
  48409. /**
  48410. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48411. * The order of search:
  48412. *
  48413. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48414. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48415. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48416. * 4) return the generic trigger controller if none were found
  48417. *
  48418. * @param xrInput the xrInput to which a new controller is initialized
  48419. * @param scene the scene to which the model will be added
  48420. * @param forceProfile force a certain profile for this controller
  48421. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48422. */
  48423. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48424. /**
  48425. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48426. *
  48427. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48428. *
  48429. * @param type the profile type to register
  48430. * @param constructFunction the function to be called when loading this profile
  48431. */
  48432. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48433. /**
  48434. * Register a fallback to a specific profile.
  48435. * @param profileId the profileId that will receive the fallbacks
  48436. * @param fallbacks A list of fallback profiles
  48437. */
  48438. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48439. /**
  48440. * Will update the list of profiles available in the repository
  48441. * @return a promise that resolves to a map of profiles available online
  48442. */
  48443. static UpdateProfilesList(): Promise<{
  48444. [profile: string]: string;
  48445. }>;
  48446. private static _LoadProfileFromRepository;
  48447. private static _LoadProfilesFromAvailableControllers;
  48448. }
  48449. }
  48450. declare module BABYLON {
  48451. /**
  48452. * Configuration options for the WebXR controller creation
  48453. */
  48454. export interface IWebXRControllerOptions {
  48455. /**
  48456. * Should the controller mesh be animated when a user interacts with it
  48457. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48458. */
  48459. disableMotionControllerAnimation?: boolean;
  48460. /**
  48461. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48462. */
  48463. doNotLoadControllerMesh?: boolean;
  48464. /**
  48465. * Force a specific controller type for this controller.
  48466. * This can be used when creating your own profile or when testing different controllers
  48467. */
  48468. forceControllerProfile?: string;
  48469. /**
  48470. * Defines a rendering group ID for meshes that will be loaded.
  48471. * This is for the default controllers only.
  48472. */
  48473. renderingGroupId?: number;
  48474. }
  48475. /**
  48476. * Represents an XR controller
  48477. */
  48478. export class WebXRInputSource {
  48479. private _scene;
  48480. /** The underlying input source for the controller */
  48481. inputSource: XRInputSource;
  48482. private _options;
  48483. private _tmpVector;
  48484. private _uniqueId;
  48485. private _disposed;
  48486. /**
  48487. * 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
  48488. */
  48489. grip?: AbstractMesh;
  48490. /**
  48491. * If available, this is the gamepad object related to this controller.
  48492. * Using this object it is possible to get click events and trackpad changes of the
  48493. * webxr controller that is currently being used.
  48494. */
  48495. motionController?: WebXRAbstractMotionController;
  48496. /**
  48497. * Event that fires when the controller is removed/disposed.
  48498. * The object provided as event data is this controller, after associated assets were disposed.
  48499. * uniqueId is still available.
  48500. */
  48501. onDisposeObservable: Observable<WebXRInputSource>;
  48502. /**
  48503. * Will be triggered when the mesh associated with the motion controller is done loading.
  48504. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48505. * A shortened version of controller -> motion controller -> on mesh loaded.
  48506. */
  48507. onMeshLoadedObservable: Observable<AbstractMesh>;
  48508. /**
  48509. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48510. */
  48511. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48512. /**
  48513. * Pointer which can be used to select objects or attach a visible laser to
  48514. */
  48515. pointer: AbstractMesh;
  48516. /**
  48517. * Creates the input source object
  48518. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48519. * @param _scene the scene which the controller should be associated to
  48520. * @param inputSource the underlying input source for the controller
  48521. * @param _options options for this controller creation
  48522. */
  48523. constructor(_scene: Scene,
  48524. /** The underlying input source for the controller */
  48525. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48526. /**
  48527. * Get this controllers unique id
  48528. */
  48529. get uniqueId(): string;
  48530. /**
  48531. * Disposes of the object
  48532. */
  48533. dispose(): void;
  48534. /**
  48535. * Gets a world space ray coming from the pointer or grip
  48536. * @param result the resulting ray
  48537. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48538. */
  48539. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48540. /**
  48541. * Updates the controller pose based on the given XRFrame
  48542. * @param xrFrame xr frame to update the pose with
  48543. * @param referenceSpace reference space to use
  48544. */
  48545. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48546. }
  48547. }
  48548. declare module BABYLON {
  48549. /**
  48550. * The schema for initialization options of the XR Input class
  48551. */
  48552. export interface IWebXRInputOptions {
  48553. /**
  48554. * If set to true no model will be automatically loaded
  48555. */
  48556. doNotLoadControllerMeshes?: boolean;
  48557. /**
  48558. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48559. * If not found, the xr input profile data will be used.
  48560. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48561. */
  48562. forceInputProfile?: string;
  48563. /**
  48564. * Do not send a request to the controller repository to load the profile.
  48565. *
  48566. * Instead, use the controllers available in babylon itself.
  48567. */
  48568. disableOnlineControllerRepository?: boolean;
  48569. /**
  48570. * A custom URL for the controllers repository
  48571. */
  48572. customControllersRepositoryURL?: string;
  48573. /**
  48574. * Should the controller model's components not move according to the user input
  48575. */
  48576. disableControllerAnimation?: boolean;
  48577. /**
  48578. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48579. */
  48580. controllerOptions?: IWebXRControllerOptions;
  48581. }
  48582. /**
  48583. * XR input used to track XR inputs such as controllers/rays
  48584. */
  48585. export class WebXRInput implements IDisposable {
  48586. /**
  48587. * the xr session manager for this session
  48588. */
  48589. xrSessionManager: WebXRSessionManager;
  48590. /**
  48591. * the WebXR camera for this session. Mainly used for teleportation
  48592. */
  48593. xrCamera: WebXRCamera;
  48594. private readonly options;
  48595. /**
  48596. * XR controllers being tracked
  48597. */
  48598. controllers: Array<WebXRInputSource>;
  48599. private _frameObserver;
  48600. private _sessionEndedObserver;
  48601. private _sessionInitObserver;
  48602. /**
  48603. * Event when a controller has been connected/added
  48604. */
  48605. onControllerAddedObservable: Observable<WebXRInputSource>;
  48606. /**
  48607. * Event when a controller has been removed/disconnected
  48608. */
  48609. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48610. /**
  48611. * Initializes the WebXRInput
  48612. * @param xrSessionManager the xr session manager for this session
  48613. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48614. * @param options = initialization options for this xr input
  48615. */
  48616. constructor(
  48617. /**
  48618. * the xr session manager for this session
  48619. */
  48620. xrSessionManager: WebXRSessionManager,
  48621. /**
  48622. * the WebXR camera for this session. Mainly used for teleportation
  48623. */
  48624. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48625. private _onInputSourcesChange;
  48626. private _addAndRemoveControllers;
  48627. /**
  48628. * Disposes of the object
  48629. */
  48630. dispose(): void;
  48631. }
  48632. }
  48633. declare module BABYLON {
  48634. /**
  48635. * This is the base class for all WebXR features.
  48636. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48637. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48638. */
  48639. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48640. protected _xrSessionManager: WebXRSessionManager;
  48641. private _attached;
  48642. private _removeOnDetach;
  48643. /**
  48644. * Should auto-attach be disabled?
  48645. */
  48646. disableAutoAttach: boolean;
  48647. /**
  48648. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48649. */
  48650. xrNativeFeatureName: string;
  48651. /**
  48652. * Construct a new (abstract) WebXR feature
  48653. * @param _xrSessionManager the xr session manager for this feature
  48654. */
  48655. constructor(_xrSessionManager: WebXRSessionManager);
  48656. /**
  48657. * Is this feature attached
  48658. */
  48659. get attached(): boolean;
  48660. /**
  48661. * attach this feature
  48662. *
  48663. * @param force should attachment be forced (even when already attached)
  48664. * @returns true if successful, false is failed or already attached
  48665. */
  48666. attach(force?: boolean): boolean;
  48667. /**
  48668. * detach this feature.
  48669. *
  48670. * @returns true if successful, false if failed or already detached
  48671. */
  48672. detach(): boolean;
  48673. /**
  48674. * Dispose this feature and all of the resources attached
  48675. */
  48676. dispose(): void;
  48677. /**
  48678. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48679. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48680. *
  48681. * @returns whether or not the feature is compatible in this environment
  48682. */
  48683. isCompatible(): boolean;
  48684. /**
  48685. * This is used to register callbacks that will automatically be removed when detach is called.
  48686. * @param observable the observable to which the observer will be attached
  48687. * @param callback the callback to register
  48688. */
  48689. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48690. /**
  48691. * Code in this function will be executed on each xrFrame received from the browser.
  48692. * This function will not execute after the feature is detached.
  48693. * @param _xrFrame the current frame
  48694. */
  48695. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48696. }
  48697. }
  48698. declare module BABYLON {
  48699. /**
  48700. * Renders a layer on top of an existing scene
  48701. */
  48702. export class UtilityLayerRenderer implements IDisposable {
  48703. /** the original scene that will be rendered on top of */
  48704. originalScene: Scene;
  48705. private _pointerCaptures;
  48706. private _lastPointerEvents;
  48707. private static _DefaultUtilityLayer;
  48708. private static _DefaultKeepDepthUtilityLayer;
  48709. private _sharedGizmoLight;
  48710. private _renderCamera;
  48711. /**
  48712. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48713. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48714. * @returns the camera that is used when rendering the utility layer
  48715. */
  48716. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48717. /**
  48718. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48719. * @param cam the camera that should be used when rendering the utility layer
  48720. */
  48721. setRenderCamera(cam: Nullable<Camera>): void;
  48722. /**
  48723. * @hidden
  48724. * Light which used by gizmos to get light shading
  48725. */
  48726. _getSharedGizmoLight(): HemisphericLight;
  48727. /**
  48728. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48729. */
  48730. pickUtilitySceneFirst: boolean;
  48731. /**
  48732. * 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)
  48733. */
  48734. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48735. /**
  48736. * 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)
  48737. */
  48738. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48739. /**
  48740. * The scene that is rendered on top of the original scene
  48741. */
  48742. utilityLayerScene: Scene;
  48743. /**
  48744. * If the utility layer should automatically be rendered on top of existing scene
  48745. */
  48746. shouldRender: boolean;
  48747. /**
  48748. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48749. */
  48750. onlyCheckPointerDownEvents: boolean;
  48751. /**
  48752. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48753. */
  48754. processAllEvents: boolean;
  48755. /**
  48756. * Observable raised when the pointer move from the utility layer scene to the main scene
  48757. */
  48758. onPointerOutObservable: Observable<number>;
  48759. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48760. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48761. private _afterRenderObserver;
  48762. private _sceneDisposeObserver;
  48763. private _originalPointerObserver;
  48764. /**
  48765. * Instantiates a UtilityLayerRenderer
  48766. * @param originalScene the original scene that will be rendered on top of
  48767. * @param handleEvents boolean indicating if the utility layer should handle events
  48768. */
  48769. constructor(
  48770. /** the original scene that will be rendered on top of */
  48771. originalScene: Scene, handleEvents?: boolean);
  48772. private _notifyObservers;
  48773. /**
  48774. * Renders the utility layers scene on top of the original scene
  48775. */
  48776. render(): void;
  48777. /**
  48778. * Disposes of the renderer
  48779. */
  48780. dispose(): void;
  48781. private _updateCamera;
  48782. }
  48783. }
  48784. declare module BABYLON {
  48785. /**
  48786. * Options interface for the pointer selection module
  48787. */
  48788. export interface IWebXRControllerPointerSelectionOptions {
  48789. /**
  48790. * if provided, this scene will be used to render meshes.
  48791. */
  48792. customUtilityLayerScene?: Scene;
  48793. /**
  48794. * 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)
  48795. * If not disabled, the last picked point will be used to execute a pointer up event
  48796. * If disabled, pointer up event will be triggered right after the pointer down event.
  48797. * Used in screen and gaze target ray mode only
  48798. */
  48799. disablePointerUpOnTouchOut: boolean;
  48800. /**
  48801. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48802. */
  48803. forceGazeMode: boolean;
  48804. /**
  48805. * 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
  48806. * to start a new countdown to the pointer down event.
  48807. * Defaults to 1.
  48808. */
  48809. gazeModePointerMovedFactor?: number;
  48810. /**
  48811. * Different button type to use instead of the main component
  48812. */
  48813. overrideButtonId?: string;
  48814. /**
  48815. * use this rendering group id for the meshes (optional)
  48816. */
  48817. renderingGroupId?: number;
  48818. /**
  48819. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48820. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48821. * 3000 means 3 seconds between pointing at something and selecting it
  48822. */
  48823. timeToSelect?: number;
  48824. /**
  48825. * Should meshes created here be added to a utility layer or the main scene
  48826. */
  48827. useUtilityLayer?: boolean;
  48828. /**
  48829. * Optional WebXR camera to be used for gaze selection
  48830. */
  48831. gazeCamera?: WebXRCamera;
  48832. /**
  48833. * the xr input to use with this pointer selection
  48834. */
  48835. xrInput: WebXRInput;
  48836. }
  48837. /**
  48838. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48839. */
  48840. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48841. private readonly _options;
  48842. private static _idCounter;
  48843. private _attachController;
  48844. private _controllers;
  48845. private _scene;
  48846. private _tmpVectorForPickCompare;
  48847. /**
  48848. * The module's name
  48849. */
  48850. static readonly Name: string;
  48851. /**
  48852. * The (Babylon) version of this module.
  48853. * This is an integer representing the implementation version.
  48854. * This number does not correspond to the WebXR specs version
  48855. */
  48856. static readonly Version: number;
  48857. /**
  48858. * Disable lighting on the laser pointer (so it will always be visible)
  48859. */
  48860. disablePointerLighting: boolean;
  48861. /**
  48862. * Disable lighting on the selection mesh (so it will always be visible)
  48863. */
  48864. disableSelectionMeshLighting: boolean;
  48865. /**
  48866. * Should the laser pointer be displayed
  48867. */
  48868. displayLaserPointer: boolean;
  48869. /**
  48870. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48871. */
  48872. displaySelectionMesh: boolean;
  48873. /**
  48874. * This color will be set to the laser pointer when selection is triggered
  48875. */
  48876. laserPointerPickedColor: Color3;
  48877. /**
  48878. * Default color of the laser pointer
  48879. */
  48880. laserPointerDefaultColor: Color3;
  48881. /**
  48882. * default color of the selection ring
  48883. */
  48884. selectionMeshDefaultColor: Color3;
  48885. /**
  48886. * This color will be applied to the selection ring when selection is triggered
  48887. */
  48888. selectionMeshPickedColor: Color3;
  48889. /**
  48890. * Optional filter to be used for ray selection. This predicate shares behavior with
  48891. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48892. */
  48893. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48894. /**
  48895. * constructs a new background remover module
  48896. * @param _xrSessionManager the session manager for this module
  48897. * @param _options read-only options to be used in this module
  48898. */
  48899. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48900. /**
  48901. * attach this feature
  48902. * Will usually be called by the features manager
  48903. *
  48904. * @returns true if successful.
  48905. */
  48906. attach(): boolean;
  48907. /**
  48908. * detach this feature.
  48909. * Will usually be called by the features manager
  48910. *
  48911. * @returns true if successful.
  48912. */
  48913. detach(): boolean;
  48914. /**
  48915. * Will get the mesh under a specific pointer.
  48916. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48917. * @param controllerId the controllerId to check
  48918. * @returns The mesh under pointer or null if no mesh is under the pointer
  48919. */
  48920. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48921. /**
  48922. * Get the xr controller that correlates to the pointer id in the pointer event
  48923. *
  48924. * @param id the pointer id to search for
  48925. * @returns the controller that correlates to this id or null if not found
  48926. */
  48927. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48928. protected _onXRFrame(_xrFrame: XRFrame): void;
  48929. private _attachGazeMode;
  48930. private _attachScreenRayMode;
  48931. private _attachTrackedPointerRayMode;
  48932. private _convertNormalToDirectionOfRay;
  48933. private _detachController;
  48934. private _generateNewMeshPair;
  48935. private _pickingMoved;
  48936. private _updatePointerDistance;
  48937. /** @hidden */
  48938. get lasterPointerDefaultColor(): Color3;
  48939. }
  48940. }
  48941. declare module BABYLON {
  48942. /**
  48943. * Button which can be used to enter a different mode of XR
  48944. */
  48945. export class WebXREnterExitUIButton {
  48946. /** button element */
  48947. element: HTMLElement;
  48948. /** XR initialization options for the button */
  48949. sessionMode: XRSessionMode;
  48950. /** Reference space type */
  48951. referenceSpaceType: XRReferenceSpaceType;
  48952. /**
  48953. * Creates a WebXREnterExitUIButton
  48954. * @param element button element
  48955. * @param sessionMode XR initialization session mode
  48956. * @param referenceSpaceType the type of reference space to be used
  48957. */
  48958. constructor(
  48959. /** button element */
  48960. element: HTMLElement,
  48961. /** XR initialization options for the button */
  48962. sessionMode: XRSessionMode,
  48963. /** Reference space type */
  48964. referenceSpaceType: XRReferenceSpaceType);
  48965. /**
  48966. * Extendable function which can be used to update the button's visuals when the state changes
  48967. * @param activeButton the current active button in the UI
  48968. */
  48969. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48970. }
  48971. /**
  48972. * Options to create the webXR UI
  48973. */
  48974. export class WebXREnterExitUIOptions {
  48975. /**
  48976. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48977. */
  48978. customButtons?: Array<WebXREnterExitUIButton>;
  48979. /**
  48980. * A reference space type to use when creating the default button.
  48981. * Default is local-floor
  48982. */
  48983. referenceSpaceType?: XRReferenceSpaceType;
  48984. /**
  48985. * Context to enter xr with
  48986. */
  48987. renderTarget?: Nullable<WebXRRenderTarget>;
  48988. /**
  48989. * A session mode to use when creating the default button.
  48990. * Default is immersive-vr
  48991. */
  48992. sessionMode?: XRSessionMode;
  48993. /**
  48994. * A list of optional features to init the session with
  48995. */
  48996. optionalFeatures?: string[];
  48997. /**
  48998. * A list of optional features to init the session with
  48999. */
  49000. requiredFeatures?: string[];
  49001. }
  49002. /**
  49003. * UI to allow the user to enter/exit XR mode
  49004. */
  49005. export class WebXREnterExitUI implements IDisposable {
  49006. private scene;
  49007. /** version of the options passed to this UI */
  49008. options: WebXREnterExitUIOptions;
  49009. private _activeButton;
  49010. private _buttons;
  49011. /**
  49012. * The HTML Div Element to which buttons are added.
  49013. */
  49014. readonly overlay: HTMLDivElement;
  49015. /**
  49016. * Fired every time the active button is changed.
  49017. *
  49018. * When xr is entered via a button that launches xr that button will be the callback parameter
  49019. *
  49020. * When exiting xr the callback parameter will be null)
  49021. */
  49022. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49023. /**
  49024. *
  49025. * @param scene babylon scene object to use
  49026. * @param options (read-only) version of the options passed to this UI
  49027. */
  49028. private constructor();
  49029. /**
  49030. * Creates UI to allow the user to enter/exit XR mode
  49031. * @param scene the scene to add the ui to
  49032. * @param helper the xr experience helper to enter/exit xr with
  49033. * @param options options to configure the UI
  49034. * @returns the created ui
  49035. */
  49036. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49037. /**
  49038. * Disposes of the XR UI component
  49039. */
  49040. dispose(): void;
  49041. private _updateButtons;
  49042. }
  49043. }
  49044. declare module BABYLON {
  49045. /**
  49046. * Class containing static functions to help procedurally build meshes
  49047. */
  49048. export class LinesBuilder {
  49049. /**
  49050. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49051. * * 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
  49052. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49053. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49054. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49055. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49056. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49057. * * 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
  49058. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49061. * @param name defines the name of the new line system
  49062. * @param options defines the options used to create the line system
  49063. * @param scene defines the hosting scene
  49064. * @returns a new line system mesh
  49065. */
  49066. static CreateLineSystem(name: string, options: {
  49067. lines: Vector3[][];
  49068. updatable?: boolean;
  49069. instance?: Nullable<LinesMesh>;
  49070. colors?: Nullable<Color4[][]>;
  49071. useVertexAlpha?: boolean;
  49072. }, scene: Nullable<Scene>): LinesMesh;
  49073. /**
  49074. * Creates a line mesh
  49075. * 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
  49076. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49077. * * The parameter `points` is an array successive Vector3
  49078. * * 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
  49079. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49080. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49081. * * When updating an instance, remember that only point positions can change, not the number of points
  49082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49084. * @param name defines the name of the new line system
  49085. * @param options defines the options used to create the line system
  49086. * @param scene defines the hosting scene
  49087. * @returns a new line mesh
  49088. */
  49089. static CreateLines(name: string, options: {
  49090. points: Vector3[];
  49091. updatable?: boolean;
  49092. instance?: Nullable<LinesMesh>;
  49093. colors?: Color4[];
  49094. useVertexAlpha?: boolean;
  49095. }, scene?: Nullable<Scene>): LinesMesh;
  49096. /**
  49097. * Creates a dashed line mesh
  49098. * * 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
  49099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49100. * * The parameter `points` is an array successive Vector3
  49101. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49102. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49103. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49104. * * 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
  49105. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49106. * * When updating an instance, remember that only point positions can change, not the number of points
  49107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49108. * @param name defines the name of the mesh
  49109. * @param options defines the options used to create the mesh
  49110. * @param scene defines the hosting scene
  49111. * @returns the dashed line mesh
  49112. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49113. */
  49114. static CreateDashedLines(name: string, options: {
  49115. points: Vector3[];
  49116. dashSize?: number;
  49117. gapSize?: number;
  49118. dashNb?: number;
  49119. updatable?: boolean;
  49120. instance?: LinesMesh;
  49121. useVertexAlpha?: boolean;
  49122. }, scene?: Nullable<Scene>): LinesMesh;
  49123. }
  49124. }
  49125. declare module BABYLON {
  49126. /**
  49127. * Construction options for a timer
  49128. */
  49129. export interface ITimerOptions<T> {
  49130. /**
  49131. * Time-to-end
  49132. */
  49133. timeout: number;
  49134. /**
  49135. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49136. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49137. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49138. */
  49139. contextObservable: Observable<T>;
  49140. /**
  49141. * Optional parameters when adding an observer to the observable
  49142. */
  49143. observableParameters?: {
  49144. mask?: number;
  49145. insertFirst?: boolean;
  49146. scope?: any;
  49147. };
  49148. /**
  49149. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49150. */
  49151. breakCondition?: (data?: ITimerData<T>) => boolean;
  49152. /**
  49153. * Will be triggered when the time condition has met
  49154. */
  49155. onEnded?: (data: ITimerData<any>) => void;
  49156. /**
  49157. * Will be triggered when the break condition has met (prematurely ended)
  49158. */
  49159. onAborted?: (data: ITimerData<any>) => void;
  49160. /**
  49161. * Optional function to execute on each tick (or count)
  49162. */
  49163. onTick?: (data: ITimerData<any>) => void;
  49164. }
  49165. /**
  49166. * An interface defining the data sent by the timer
  49167. */
  49168. export interface ITimerData<T> {
  49169. /**
  49170. * When did it start
  49171. */
  49172. startTime: number;
  49173. /**
  49174. * Time now
  49175. */
  49176. currentTime: number;
  49177. /**
  49178. * Time passed since started
  49179. */
  49180. deltaTime: number;
  49181. /**
  49182. * How much is completed, in [0.0...1.0].
  49183. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49184. */
  49185. completeRate: number;
  49186. /**
  49187. * What the registered observable sent in the last count
  49188. */
  49189. payload: T;
  49190. }
  49191. /**
  49192. * The current state of the timer
  49193. */
  49194. export enum TimerState {
  49195. /**
  49196. * Timer initialized, not yet started
  49197. */
  49198. INIT = 0,
  49199. /**
  49200. * Timer started and counting
  49201. */
  49202. STARTED = 1,
  49203. /**
  49204. * Timer ended (whether aborted or time reached)
  49205. */
  49206. ENDED = 2
  49207. }
  49208. /**
  49209. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49210. *
  49211. * @param options options with which to initialize this timer
  49212. */
  49213. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49214. /**
  49215. * An advanced implementation of a timer class
  49216. */
  49217. export class AdvancedTimer<T = any> implements IDisposable {
  49218. /**
  49219. * Will notify each time the timer calculates the remaining time
  49220. */
  49221. onEachCountObservable: Observable<ITimerData<T>>;
  49222. /**
  49223. * Will trigger when the timer was aborted due to the break condition
  49224. */
  49225. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49226. /**
  49227. * Will trigger when the timer ended successfully
  49228. */
  49229. onTimerEndedObservable: Observable<ITimerData<T>>;
  49230. /**
  49231. * Will trigger when the timer state has changed
  49232. */
  49233. onStateChangedObservable: Observable<TimerState>;
  49234. private _observer;
  49235. private _contextObservable;
  49236. private _observableParameters;
  49237. private _startTime;
  49238. private _timer;
  49239. private _state;
  49240. private _breakCondition;
  49241. private _timeToEnd;
  49242. private _breakOnNextTick;
  49243. /**
  49244. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49245. * @param options construction options for this advanced timer
  49246. */
  49247. constructor(options: ITimerOptions<T>);
  49248. /**
  49249. * set a breaking condition for this timer. Default is to never break during count
  49250. * @param predicate the new break condition. Returns true to break, false otherwise
  49251. */
  49252. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49253. /**
  49254. * Reset ALL associated observables in this advanced timer
  49255. */
  49256. clearObservables(): void;
  49257. /**
  49258. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49259. *
  49260. * @param timeToEnd how much time to measure until timer ended
  49261. */
  49262. start(timeToEnd?: number): void;
  49263. /**
  49264. * Will force a stop on the next tick.
  49265. */
  49266. stop(): void;
  49267. /**
  49268. * Dispose this timer, clearing all resources
  49269. */
  49270. dispose(): void;
  49271. private _setState;
  49272. private _tick;
  49273. private _stop;
  49274. }
  49275. }
  49276. declare module BABYLON {
  49277. /**
  49278. * The options container for the teleportation module
  49279. */
  49280. export interface IWebXRTeleportationOptions {
  49281. /**
  49282. * if provided, this scene will be used to render meshes.
  49283. */
  49284. customUtilityLayerScene?: Scene;
  49285. /**
  49286. * Values to configure the default target mesh
  49287. */
  49288. defaultTargetMeshOptions?: {
  49289. /**
  49290. * Fill color of the teleportation area
  49291. */
  49292. teleportationFillColor?: string;
  49293. /**
  49294. * Border color for the teleportation area
  49295. */
  49296. teleportationBorderColor?: string;
  49297. /**
  49298. * Disable the mesh's animation sequence
  49299. */
  49300. disableAnimation?: boolean;
  49301. /**
  49302. * Disable lighting on the material or the ring and arrow
  49303. */
  49304. disableLighting?: boolean;
  49305. /**
  49306. * Override the default material of the torus and arrow
  49307. */
  49308. torusArrowMaterial?: Material;
  49309. };
  49310. /**
  49311. * A list of meshes to use as floor meshes.
  49312. * Meshes can be added and removed after initializing the feature using the
  49313. * addFloorMesh and removeFloorMesh functions
  49314. * If empty, rotation will still work
  49315. */
  49316. floorMeshes?: AbstractMesh[];
  49317. /**
  49318. * use this rendering group id for the meshes (optional)
  49319. */
  49320. renderingGroupId?: number;
  49321. /**
  49322. * Should teleportation move only to snap points
  49323. */
  49324. snapPointsOnly?: boolean;
  49325. /**
  49326. * An array of points to which the teleportation will snap to.
  49327. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49328. */
  49329. snapPositions?: Vector3[];
  49330. /**
  49331. * How close should the teleportation ray be in order to snap to position.
  49332. * Default to 0.8 units (meters)
  49333. */
  49334. snapToPositionRadius?: number;
  49335. /**
  49336. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49337. * If you want to support rotation, make sure your mesh has a direction indicator.
  49338. *
  49339. * When left untouched, the default mesh will be initialized.
  49340. */
  49341. teleportationTargetMesh?: AbstractMesh;
  49342. /**
  49343. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49344. */
  49345. timeToTeleport?: number;
  49346. /**
  49347. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49348. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49349. */
  49350. useMainComponentOnly?: boolean;
  49351. /**
  49352. * Should meshes created here be added to a utility layer or the main scene
  49353. */
  49354. useUtilityLayer?: boolean;
  49355. /**
  49356. * Babylon XR Input class for controller
  49357. */
  49358. xrInput: WebXRInput;
  49359. }
  49360. /**
  49361. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49362. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49363. * the input of the attached controllers.
  49364. */
  49365. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49366. private _options;
  49367. private _controllers;
  49368. private _currentTeleportationControllerId;
  49369. private _floorMeshes;
  49370. private _quadraticBezierCurve;
  49371. private _selectionFeature;
  49372. private _snapToPositions;
  49373. private _snappedToPoint;
  49374. private _teleportationRingMaterial?;
  49375. private _tmpRay;
  49376. private _tmpVector;
  49377. /**
  49378. * The module's name
  49379. */
  49380. static readonly Name: string;
  49381. /**
  49382. * The (Babylon) version of this module.
  49383. * This is an integer representing the implementation version.
  49384. * This number does not correspond to the webxr specs version
  49385. */
  49386. static readonly Version: number;
  49387. /**
  49388. * Is movement backwards enabled
  49389. */
  49390. backwardsMovementEnabled: boolean;
  49391. /**
  49392. * Distance to travel when moving backwards
  49393. */
  49394. backwardsTeleportationDistance: number;
  49395. /**
  49396. * The distance from the user to the inspection point in the direction of the controller
  49397. * A higher number will allow the user to move further
  49398. * defaults to 5 (meters, in xr units)
  49399. */
  49400. parabolicCheckRadius: number;
  49401. /**
  49402. * Should the module support parabolic ray on top of direct ray
  49403. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49404. * Very helpful when moving between floors / different heights
  49405. */
  49406. parabolicRayEnabled: boolean;
  49407. /**
  49408. * How much rotation should be applied when rotating right and left
  49409. */
  49410. rotationAngle: number;
  49411. /**
  49412. * Is rotation enabled when moving forward?
  49413. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49414. */
  49415. rotationEnabled: boolean;
  49416. /**
  49417. * constructs a new anchor system
  49418. * @param _xrSessionManager an instance of WebXRSessionManager
  49419. * @param _options configuration object for this feature
  49420. */
  49421. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49422. /**
  49423. * Get the snapPointsOnly flag
  49424. */
  49425. get snapPointsOnly(): boolean;
  49426. /**
  49427. * Sets the snapPointsOnly flag
  49428. * @param snapToPoints should teleportation be exclusively to snap points
  49429. */
  49430. set snapPointsOnly(snapToPoints: boolean);
  49431. /**
  49432. * Add a new mesh to the floor meshes array
  49433. * @param mesh the mesh to use as floor mesh
  49434. */
  49435. addFloorMesh(mesh: AbstractMesh): void;
  49436. /**
  49437. * Add a new snap-to point to fix teleportation to this position
  49438. * @param newSnapPoint The new Snap-To point
  49439. */
  49440. addSnapPoint(newSnapPoint: Vector3): void;
  49441. attach(): boolean;
  49442. detach(): boolean;
  49443. dispose(): void;
  49444. /**
  49445. * Remove a mesh from the floor meshes array
  49446. * @param mesh the mesh to remove
  49447. */
  49448. removeFloorMesh(mesh: AbstractMesh): void;
  49449. /**
  49450. * Remove a mesh from the floor meshes array using its name
  49451. * @param name the mesh name to remove
  49452. */
  49453. removeFloorMeshByName(name: string): void;
  49454. /**
  49455. * 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
  49456. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49457. * @returns was the point found and removed or not
  49458. */
  49459. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49460. /**
  49461. * This function sets a selection feature that will be disabled when
  49462. * the forward ray is shown and will be reattached when hidden.
  49463. * This is used to remove the selection rays when moving.
  49464. * @param selectionFeature the feature to disable when forward movement is enabled
  49465. */
  49466. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49467. protected _onXRFrame(_xrFrame: XRFrame): void;
  49468. private _attachController;
  49469. private _createDefaultTargetMesh;
  49470. private _detachController;
  49471. private _findClosestSnapPointWithRadius;
  49472. private _setTargetMeshPosition;
  49473. private _setTargetMeshVisibility;
  49474. private _showParabolicPath;
  49475. private _teleportForward;
  49476. }
  49477. }
  49478. declare module BABYLON {
  49479. /**
  49480. * Options for the default xr helper
  49481. */
  49482. export class WebXRDefaultExperienceOptions {
  49483. /**
  49484. * Enable or disable default UI to enter XR
  49485. */
  49486. disableDefaultUI?: boolean;
  49487. /**
  49488. * Should teleportation not initialize. defaults to false.
  49489. */
  49490. disableTeleportation?: boolean;
  49491. /**
  49492. * Floor meshes that will be used for teleport
  49493. */
  49494. floorMeshes?: Array<AbstractMesh>;
  49495. /**
  49496. * If set to true, the first frame will not be used to reset position
  49497. * The first frame is mainly used when copying transformation from the old camera
  49498. * Mainly used in AR
  49499. */
  49500. ignoreNativeCameraTransformation?: boolean;
  49501. /**
  49502. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49503. */
  49504. inputOptions?: IWebXRInputOptions;
  49505. /**
  49506. * optional configuration for the output canvas
  49507. */
  49508. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49509. /**
  49510. * optional UI options. This can be used among other to change session mode and reference space type
  49511. */
  49512. uiOptions?: WebXREnterExitUIOptions;
  49513. /**
  49514. * When loading teleportation and pointer select, use stable versions instead of latest.
  49515. */
  49516. useStablePlugins?: boolean;
  49517. /**
  49518. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49519. */
  49520. renderingGroupId?: number;
  49521. /**
  49522. * A list of optional features to init the session with
  49523. * If set to true, all features we support will be added
  49524. */
  49525. optionalFeatures?: boolean | string[];
  49526. }
  49527. /**
  49528. * Default experience which provides a similar setup to the previous webVRExperience
  49529. */
  49530. export class WebXRDefaultExperience {
  49531. /**
  49532. * Base experience
  49533. */
  49534. baseExperience: WebXRExperienceHelper;
  49535. /**
  49536. * Enables ui for entering/exiting xr
  49537. */
  49538. enterExitUI: WebXREnterExitUI;
  49539. /**
  49540. * Input experience extension
  49541. */
  49542. input: WebXRInput;
  49543. /**
  49544. * Enables laser pointer and selection
  49545. */
  49546. pointerSelection: WebXRControllerPointerSelection;
  49547. /**
  49548. * Default target xr should render to
  49549. */
  49550. renderTarget: WebXRRenderTarget;
  49551. /**
  49552. * Enables teleportation
  49553. */
  49554. teleportation: WebXRMotionControllerTeleportation;
  49555. private constructor();
  49556. /**
  49557. * Creates the default xr experience
  49558. * @param scene scene
  49559. * @param options options for basic configuration
  49560. * @returns resulting WebXRDefaultExperience
  49561. */
  49562. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49563. /**
  49564. * DIsposes of the experience helper
  49565. */
  49566. dispose(): void;
  49567. }
  49568. }
  49569. declare module BABYLON {
  49570. /**
  49571. * Options to modify the vr teleportation behavior.
  49572. */
  49573. export interface VRTeleportationOptions {
  49574. /**
  49575. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49576. */
  49577. floorMeshName?: string;
  49578. /**
  49579. * A list of meshes to be used as the teleportation floor. (default: empty)
  49580. */
  49581. floorMeshes?: Mesh[];
  49582. /**
  49583. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49584. */
  49585. teleportationMode?: number;
  49586. /**
  49587. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49588. */
  49589. teleportationTime?: number;
  49590. /**
  49591. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49592. */
  49593. teleportationSpeed?: number;
  49594. /**
  49595. * The easing function used in the animation or null for Linear. (default CircleEase)
  49596. */
  49597. easingFunction?: EasingFunction;
  49598. }
  49599. /**
  49600. * Options to modify the vr experience helper's behavior.
  49601. */
  49602. export interface VRExperienceHelperOptions extends WebVROptions {
  49603. /**
  49604. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49605. */
  49606. createDeviceOrientationCamera?: boolean;
  49607. /**
  49608. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49609. */
  49610. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49611. /**
  49612. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49613. */
  49614. laserToggle?: boolean;
  49615. /**
  49616. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49617. */
  49618. floorMeshes?: Mesh[];
  49619. /**
  49620. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49621. */
  49622. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49623. /**
  49624. * Defines if WebXR should be used instead of WebVR (if available)
  49625. */
  49626. useXR?: boolean;
  49627. }
  49628. /**
  49629. * Event containing information after VR has been entered
  49630. */
  49631. export class OnAfterEnteringVRObservableEvent {
  49632. /**
  49633. * If entering vr was successful
  49634. */
  49635. success: boolean;
  49636. }
  49637. /**
  49638. * Helps to quickly add VR support to an existing scene.
  49639. * See https://doc.babylonjs.com/how_to/webvr_helper
  49640. */
  49641. export class VRExperienceHelper {
  49642. /** Options to modify the vr experience helper's behavior. */
  49643. webVROptions: VRExperienceHelperOptions;
  49644. private _scene;
  49645. private _position;
  49646. private _btnVR;
  49647. private _btnVRDisplayed;
  49648. private _webVRsupported;
  49649. private _webVRready;
  49650. private _webVRrequesting;
  49651. private _webVRpresenting;
  49652. private _hasEnteredVR;
  49653. private _fullscreenVRpresenting;
  49654. private _inputElement;
  49655. private _webVRCamera;
  49656. private _vrDeviceOrientationCamera;
  49657. private _deviceOrientationCamera;
  49658. private _existingCamera;
  49659. private _onKeyDown;
  49660. private _onVrDisplayPresentChange;
  49661. private _onVRDisplayChanged;
  49662. private _onVRRequestPresentStart;
  49663. private _onVRRequestPresentComplete;
  49664. /**
  49665. * 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)
  49666. */
  49667. enableGazeEvenWhenNoPointerLock: boolean;
  49668. /**
  49669. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49670. */
  49671. exitVROnDoubleTap: boolean;
  49672. /**
  49673. * Observable raised right before entering VR.
  49674. */
  49675. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49676. /**
  49677. * Observable raised when entering VR has completed.
  49678. */
  49679. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49680. /**
  49681. * Observable raised when exiting VR.
  49682. */
  49683. onExitingVRObservable: Observable<VRExperienceHelper>;
  49684. /**
  49685. * Observable raised when controller mesh is loaded.
  49686. */
  49687. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49688. /** Return this.onEnteringVRObservable
  49689. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49690. */
  49691. get onEnteringVR(): Observable<VRExperienceHelper>;
  49692. /** Return this.onExitingVRObservable
  49693. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49694. */
  49695. get onExitingVR(): Observable<VRExperienceHelper>;
  49696. /** Return this.onControllerMeshLoadedObservable
  49697. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49698. */
  49699. get onControllerMeshLoaded(): Observable<WebVRController>;
  49700. private _rayLength;
  49701. private _useCustomVRButton;
  49702. private _teleportationRequested;
  49703. private _teleportActive;
  49704. private _floorMeshName;
  49705. private _floorMeshesCollection;
  49706. private _teleportationMode;
  49707. private _teleportationTime;
  49708. private _teleportationSpeed;
  49709. private _teleportationEasing;
  49710. private _rotationAllowed;
  49711. private _teleportBackwardsVector;
  49712. private _teleportationTarget;
  49713. private _isDefaultTeleportationTarget;
  49714. private _postProcessMove;
  49715. private _teleportationFillColor;
  49716. private _teleportationBorderColor;
  49717. private _rotationAngle;
  49718. private _haloCenter;
  49719. private _cameraGazer;
  49720. private _padSensibilityUp;
  49721. private _padSensibilityDown;
  49722. private _leftController;
  49723. private _rightController;
  49724. private _gazeColor;
  49725. private _laserColor;
  49726. private _pickedLaserColor;
  49727. private _pickedGazeColor;
  49728. /**
  49729. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49730. */
  49731. onNewMeshSelected: Observable<AbstractMesh>;
  49732. /**
  49733. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49734. * This observable will provide the mesh and the controller used to select the mesh
  49735. */
  49736. onMeshSelectedWithController: Observable<{
  49737. mesh: AbstractMesh;
  49738. controller: WebVRController;
  49739. }>;
  49740. /**
  49741. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49742. */
  49743. onNewMeshPicked: Observable<PickingInfo>;
  49744. private _circleEase;
  49745. /**
  49746. * Observable raised before camera teleportation
  49747. */
  49748. onBeforeCameraTeleport: Observable<Vector3>;
  49749. /**
  49750. * Observable raised after camera teleportation
  49751. */
  49752. onAfterCameraTeleport: Observable<Vector3>;
  49753. /**
  49754. * Observable raised when current selected mesh gets unselected
  49755. */
  49756. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49757. private _raySelectionPredicate;
  49758. /**
  49759. * To be optionaly changed by user to define custom ray selection
  49760. */
  49761. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49762. /**
  49763. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49764. */
  49765. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49766. /**
  49767. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49768. */
  49769. teleportationEnabled: boolean;
  49770. private _defaultHeight;
  49771. private _teleportationInitialized;
  49772. private _interactionsEnabled;
  49773. private _interactionsRequested;
  49774. private _displayGaze;
  49775. private _displayLaserPointer;
  49776. /**
  49777. * The mesh used to display where the user is going to teleport.
  49778. */
  49779. get teleportationTarget(): Mesh;
  49780. /**
  49781. * Sets the mesh to be used to display where the user is going to teleport.
  49782. */
  49783. set teleportationTarget(value: Mesh);
  49784. /**
  49785. * 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
  49786. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49787. * See https://doc.babylonjs.com/resources/baking_transformations
  49788. */
  49789. get gazeTrackerMesh(): Mesh;
  49790. set gazeTrackerMesh(value: Mesh);
  49791. /**
  49792. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49793. */
  49794. updateGazeTrackerScale: boolean;
  49795. /**
  49796. * If the gaze trackers color should be updated when selecting meshes
  49797. */
  49798. updateGazeTrackerColor: boolean;
  49799. /**
  49800. * If the controller laser color should be updated when selecting meshes
  49801. */
  49802. updateControllerLaserColor: boolean;
  49803. /**
  49804. * The gaze tracking mesh corresponding to the left controller
  49805. */
  49806. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49807. /**
  49808. * The gaze tracking mesh corresponding to the right controller
  49809. */
  49810. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49811. /**
  49812. * If the ray of the gaze should be displayed.
  49813. */
  49814. get displayGaze(): boolean;
  49815. /**
  49816. * Sets if the ray of the gaze should be displayed.
  49817. */
  49818. set displayGaze(value: boolean);
  49819. /**
  49820. * If the ray of the LaserPointer should be displayed.
  49821. */
  49822. get displayLaserPointer(): boolean;
  49823. /**
  49824. * Sets if the ray of the LaserPointer should be displayed.
  49825. */
  49826. set displayLaserPointer(value: boolean);
  49827. /**
  49828. * The deviceOrientationCamera used as the camera when not in VR.
  49829. */
  49830. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49831. /**
  49832. * Based on the current WebVR support, returns the current VR camera used.
  49833. */
  49834. get currentVRCamera(): Nullable<Camera>;
  49835. /**
  49836. * The webVRCamera which is used when in VR.
  49837. */
  49838. get webVRCamera(): WebVRFreeCamera;
  49839. /**
  49840. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49841. */
  49842. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49843. /**
  49844. * The html button that is used to trigger entering into VR.
  49845. */
  49846. get vrButton(): Nullable<HTMLButtonElement>;
  49847. private get _teleportationRequestInitiated();
  49848. /**
  49849. * Defines whether or not Pointer lock should be requested when switching to
  49850. * full screen.
  49851. */
  49852. requestPointerLockOnFullScreen: boolean;
  49853. /**
  49854. * If asking to force XR, this will be populated with the default xr experience
  49855. */
  49856. xr: WebXRDefaultExperience;
  49857. /**
  49858. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49859. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49860. */
  49861. xrTestDone: boolean;
  49862. /**
  49863. * Instantiates a VRExperienceHelper.
  49864. * Helps to quickly add VR support to an existing scene.
  49865. * @param scene The scene the VRExperienceHelper belongs to.
  49866. * @param webVROptions Options to modify the vr experience helper's behavior.
  49867. */
  49868. constructor(scene: Scene,
  49869. /** Options to modify the vr experience helper's behavior. */
  49870. webVROptions?: VRExperienceHelperOptions);
  49871. private completeVRInit;
  49872. private _onDefaultMeshLoaded;
  49873. private _onResize;
  49874. private _onFullscreenChange;
  49875. /**
  49876. * Gets a value indicating if we are currently in VR mode.
  49877. */
  49878. get isInVRMode(): boolean;
  49879. private onVrDisplayPresentChange;
  49880. private onVRDisplayChanged;
  49881. private moveButtonToBottomRight;
  49882. private displayVRButton;
  49883. private updateButtonVisibility;
  49884. private _cachedAngularSensibility;
  49885. /**
  49886. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49887. * Otherwise, will use the fullscreen API.
  49888. */
  49889. enterVR(): void;
  49890. /**
  49891. * Attempt to exit VR, or fullscreen.
  49892. */
  49893. exitVR(): void;
  49894. /**
  49895. * The position of the vr experience helper.
  49896. */
  49897. get position(): Vector3;
  49898. /**
  49899. * Sets the position of the vr experience helper.
  49900. */
  49901. set position(value: Vector3);
  49902. /**
  49903. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49904. */
  49905. enableInteractions(): void;
  49906. private get _noControllerIsActive();
  49907. private beforeRender;
  49908. private _isTeleportationFloor;
  49909. /**
  49910. * Adds a floor mesh to be used for teleportation.
  49911. * @param floorMesh the mesh to be used for teleportation.
  49912. */
  49913. addFloorMesh(floorMesh: Mesh): void;
  49914. /**
  49915. * Removes a floor mesh from being used for teleportation.
  49916. * @param floorMesh the mesh to be removed.
  49917. */
  49918. removeFloorMesh(floorMesh: Mesh): void;
  49919. /**
  49920. * Enables interactions and teleportation using the VR controllers and gaze.
  49921. * @param vrTeleportationOptions options to modify teleportation behavior.
  49922. */
  49923. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49924. private _onNewGamepadConnected;
  49925. private _tryEnableInteractionOnController;
  49926. private _onNewGamepadDisconnected;
  49927. private _enableInteractionOnController;
  49928. private _checkTeleportWithRay;
  49929. private _checkRotate;
  49930. private _checkTeleportBackwards;
  49931. private _enableTeleportationOnController;
  49932. private _createTeleportationCircles;
  49933. private _displayTeleportationTarget;
  49934. private _hideTeleportationTarget;
  49935. private _rotateCamera;
  49936. private _moveTeleportationSelectorTo;
  49937. private _workingVector;
  49938. private _workingQuaternion;
  49939. private _workingMatrix;
  49940. /**
  49941. * Time Constant Teleportation Mode
  49942. */
  49943. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49944. /**
  49945. * Speed Constant Teleportation Mode
  49946. */
  49947. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49948. /**
  49949. * Teleports the users feet to the desired location
  49950. * @param location The location where the user's feet should be placed
  49951. */
  49952. teleportCamera(location: Vector3): void;
  49953. private _convertNormalToDirectionOfRay;
  49954. private _castRayAndSelectObject;
  49955. private _notifySelectedMeshUnselected;
  49956. /**
  49957. * Permanently set new colors for the laser pointer
  49958. * @param color the new laser color
  49959. * @param pickedColor the new laser color when picked mesh detected
  49960. */
  49961. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49962. /**
  49963. * Set lighting enabled / disabled on the laser pointer of both controllers
  49964. * @param enabled should the lighting be enabled on the laser pointer
  49965. */
  49966. setLaserLightingState(enabled?: boolean): void;
  49967. /**
  49968. * Permanently set new colors for the gaze pointer
  49969. * @param color the new gaze color
  49970. * @param pickedColor the new gaze color when picked mesh detected
  49971. */
  49972. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49973. /**
  49974. * Sets the color of the laser ray from the vr controllers.
  49975. * @param color new color for the ray.
  49976. */
  49977. changeLaserColor(color: Color3): void;
  49978. /**
  49979. * Sets the color of the ray from the vr headsets gaze.
  49980. * @param color new color for the ray.
  49981. */
  49982. changeGazeColor(color: Color3): void;
  49983. /**
  49984. * Exits VR and disposes of the vr experience helper
  49985. */
  49986. dispose(): void;
  49987. /**
  49988. * Gets the name of the VRExperienceHelper class
  49989. * @returns "VRExperienceHelper"
  49990. */
  49991. getClassName(): string;
  49992. }
  49993. }
  49994. declare module BABYLON {
  49995. /**
  49996. * Contains an array of blocks representing the octree
  49997. */
  49998. export interface IOctreeContainer<T> {
  49999. /**
  50000. * Blocks within the octree
  50001. */
  50002. blocks: Array<OctreeBlock<T>>;
  50003. }
  50004. /**
  50005. * Class used to store a cell in an octree
  50006. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50007. */
  50008. export class OctreeBlock<T> {
  50009. /**
  50010. * Gets the content of the current block
  50011. */
  50012. entries: T[];
  50013. /**
  50014. * Gets the list of block children
  50015. */
  50016. blocks: Array<OctreeBlock<T>>;
  50017. private _depth;
  50018. private _maxDepth;
  50019. private _capacity;
  50020. private _minPoint;
  50021. private _maxPoint;
  50022. private _boundingVectors;
  50023. private _creationFunc;
  50024. /**
  50025. * Creates a new block
  50026. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50027. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50028. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50029. * @param depth defines the current depth of this block in the octree
  50030. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50031. * @param creationFunc defines a callback to call when an element is added to the block
  50032. */
  50033. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50034. /**
  50035. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50036. */
  50037. get capacity(): number;
  50038. /**
  50039. * Gets the minimum vector (in world space) of the block's bounding box
  50040. */
  50041. get minPoint(): Vector3;
  50042. /**
  50043. * Gets the maximum vector (in world space) of the block's bounding box
  50044. */
  50045. get maxPoint(): Vector3;
  50046. /**
  50047. * Add a new element to this block
  50048. * @param entry defines the element to add
  50049. */
  50050. addEntry(entry: T): void;
  50051. /**
  50052. * Remove an element from this block
  50053. * @param entry defines the element to remove
  50054. */
  50055. removeEntry(entry: T): void;
  50056. /**
  50057. * Add an array of elements to this block
  50058. * @param entries defines the array of elements to add
  50059. */
  50060. addEntries(entries: T[]): void;
  50061. /**
  50062. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50063. * @param frustumPlanes defines the frustum planes to test
  50064. * @param selection defines the array to store current content if selection is positive
  50065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50066. */
  50067. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50068. /**
  50069. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50070. * @param sphereCenter defines the bounding sphere center
  50071. * @param sphereRadius defines the bounding sphere radius
  50072. * @param selection defines the array to store current content if selection is positive
  50073. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50074. */
  50075. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50076. /**
  50077. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50078. * @param ray defines the ray to test with
  50079. * @param selection defines the array to store current content if selection is positive
  50080. */
  50081. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50082. /**
  50083. * Subdivide the content into child blocks (this block will then be empty)
  50084. */
  50085. createInnerBlocks(): void;
  50086. /**
  50087. * @hidden
  50088. */
  50089. 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;
  50090. }
  50091. }
  50092. declare module BABYLON {
  50093. /**
  50094. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50096. */
  50097. export class Octree<T> {
  50098. /** 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.) */
  50099. maxDepth: number;
  50100. /**
  50101. * Blocks within the octree containing objects
  50102. */
  50103. blocks: Array<OctreeBlock<T>>;
  50104. /**
  50105. * Content stored in the octree
  50106. */
  50107. dynamicContent: T[];
  50108. private _maxBlockCapacity;
  50109. private _selectionContent;
  50110. private _creationFunc;
  50111. /**
  50112. * Creates a octree
  50113. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50114. * @param creationFunc function to be used to instatiate the octree
  50115. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50116. * @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.)
  50117. */
  50118. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50119. /** 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.) */
  50120. maxDepth?: number);
  50121. /**
  50122. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50123. * @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);
  50124. * @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);
  50125. * @param entries meshes to be added to the octree blocks
  50126. */
  50127. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50128. /**
  50129. * Adds a mesh to the octree
  50130. * @param entry Mesh to add to the octree
  50131. */
  50132. addMesh(entry: T): void;
  50133. /**
  50134. * Remove an element from the octree
  50135. * @param entry defines the element to remove
  50136. */
  50137. removeMesh(entry: T): void;
  50138. /**
  50139. * Selects an array of meshes within the frustum
  50140. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50141. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50142. * @returns array of meshes within the frustum
  50143. */
  50144. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50145. /**
  50146. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50147. * @param sphereCenter defines the bounding sphere center
  50148. * @param sphereRadius defines the bounding sphere radius
  50149. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50150. * @returns an array of objects that intersect the sphere
  50151. */
  50152. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50153. /**
  50154. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50155. * @param ray defines the ray to test with
  50156. * @returns array of intersected objects
  50157. */
  50158. intersectsRay(ray: Ray): SmartArray<T>;
  50159. /**
  50160. * Adds a mesh into the octree block if it intersects the block
  50161. */
  50162. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50163. /**
  50164. * Adds a submesh into the octree block if it intersects the block
  50165. */
  50166. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50167. }
  50168. }
  50169. declare module BABYLON {
  50170. interface Scene {
  50171. /**
  50172. * @hidden
  50173. * Backing Filed
  50174. */
  50175. _selectionOctree: Octree<AbstractMesh>;
  50176. /**
  50177. * Gets the octree used to boost mesh selection (picking)
  50178. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50179. */
  50180. selectionOctree: Octree<AbstractMesh>;
  50181. /**
  50182. * Creates or updates the octree used to boost selection (picking)
  50183. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50184. * @param maxCapacity defines the maximum capacity per leaf
  50185. * @param maxDepth defines the maximum depth of the octree
  50186. * @returns an octree of AbstractMesh
  50187. */
  50188. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50189. }
  50190. interface AbstractMesh {
  50191. /**
  50192. * @hidden
  50193. * Backing Field
  50194. */
  50195. _submeshesOctree: Octree<SubMesh>;
  50196. /**
  50197. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50198. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50199. * @param maxCapacity defines the maximum size of each block (64 by default)
  50200. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50201. * @returns the new octree
  50202. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50203. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50204. */
  50205. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50206. }
  50207. /**
  50208. * Defines the octree scene component responsible to manage any octrees
  50209. * in a given scene.
  50210. */
  50211. export class OctreeSceneComponent {
  50212. /**
  50213. * The component name help to identify the component in the list of scene components.
  50214. */
  50215. readonly name: string;
  50216. /**
  50217. * The scene the component belongs to.
  50218. */
  50219. scene: Scene;
  50220. /**
  50221. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50222. */
  50223. readonly checksIsEnabled: boolean;
  50224. /**
  50225. * Creates a new instance of the component for the given scene
  50226. * @param scene Defines the scene to register the component in
  50227. */
  50228. constructor(scene: Scene);
  50229. /**
  50230. * Registers the component in a given scene
  50231. */
  50232. register(): void;
  50233. /**
  50234. * Return the list of active meshes
  50235. * @returns the list of active meshes
  50236. */
  50237. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50238. /**
  50239. * Return the list of active sub meshes
  50240. * @param mesh The mesh to get the candidates sub meshes from
  50241. * @returns the list of active sub meshes
  50242. */
  50243. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50244. private _tempRay;
  50245. /**
  50246. * Return the list of sub meshes intersecting with a given local ray
  50247. * @param mesh defines the mesh to find the submesh for
  50248. * @param localRay defines the ray in local space
  50249. * @returns the list of intersecting sub meshes
  50250. */
  50251. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50252. /**
  50253. * Return the list of sub meshes colliding with a collider
  50254. * @param mesh defines the mesh to find the submesh for
  50255. * @param collider defines the collider to evaluate the collision against
  50256. * @returns the list of colliding sub meshes
  50257. */
  50258. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50259. /**
  50260. * Rebuilds the elements related to this component in case of
  50261. * context lost for instance.
  50262. */
  50263. rebuild(): void;
  50264. /**
  50265. * Disposes the component and the associated ressources.
  50266. */
  50267. dispose(): void;
  50268. }
  50269. }
  50270. declare module BABYLON {
  50271. /**
  50272. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50273. */
  50274. export class Gizmo implements IDisposable {
  50275. /** The utility layer the gizmo will be added to */
  50276. gizmoLayer: UtilityLayerRenderer;
  50277. /**
  50278. * The root mesh of the gizmo
  50279. */
  50280. _rootMesh: Mesh;
  50281. private _attachedMesh;
  50282. private _attachedNode;
  50283. /**
  50284. * Ratio for the scale of the gizmo (Default: 1)
  50285. */
  50286. protected _scaleRatio: number;
  50287. /**
  50288. * Ratio for the scale of the gizmo (Default: 1)
  50289. */
  50290. set scaleRatio(value: number);
  50291. get scaleRatio(): number;
  50292. /**
  50293. * If a custom mesh has been set (Default: false)
  50294. */
  50295. protected _customMeshSet: boolean;
  50296. /**
  50297. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50298. * * When set, interactions will be enabled
  50299. */
  50300. get attachedMesh(): Nullable<AbstractMesh>;
  50301. set attachedMesh(value: Nullable<AbstractMesh>);
  50302. /**
  50303. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50304. * * When set, interactions will be enabled
  50305. */
  50306. get attachedNode(): Nullable<Node>;
  50307. set attachedNode(value: Nullable<Node>);
  50308. /**
  50309. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50310. * @param mesh The mesh to replace the default mesh of the gizmo
  50311. */
  50312. setCustomMesh(mesh: Mesh): void;
  50313. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50314. /**
  50315. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50316. */
  50317. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50318. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50319. /**
  50320. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50321. */
  50322. updateGizmoPositionToMatchAttachedMesh: boolean;
  50323. /**
  50324. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50325. */
  50326. updateScale: boolean;
  50327. protected _interactionsEnabled: boolean;
  50328. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50329. private _beforeRenderObserver;
  50330. private _tempQuaternion;
  50331. private _tempVector;
  50332. private _tempVector2;
  50333. /**
  50334. * Creates a gizmo
  50335. * @param gizmoLayer The utility layer the gizmo will be added to
  50336. */
  50337. constructor(
  50338. /** The utility layer the gizmo will be added to */
  50339. gizmoLayer?: UtilityLayerRenderer);
  50340. /**
  50341. * Updates the gizmo to match the attached mesh's position/rotation
  50342. */
  50343. protected _update(): void;
  50344. /**
  50345. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50346. * @param value Node, TransformNode or mesh
  50347. */
  50348. protected _matrixChanged(): void;
  50349. /**
  50350. * Disposes of the gizmo
  50351. */
  50352. dispose(): void;
  50353. }
  50354. }
  50355. declare module BABYLON {
  50356. /**
  50357. * Single plane drag gizmo
  50358. */
  50359. export class PlaneDragGizmo extends Gizmo {
  50360. /**
  50361. * Drag behavior responsible for the gizmos dragging interactions
  50362. */
  50363. dragBehavior: PointerDragBehavior;
  50364. private _pointerObserver;
  50365. /**
  50366. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50367. */
  50368. snapDistance: number;
  50369. /**
  50370. * Event that fires each time the gizmo snaps to a new location.
  50371. * * snapDistance is the the change in distance
  50372. */
  50373. onSnapObservable: Observable<{
  50374. snapDistance: number;
  50375. }>;
  50376. private _plane;
  50377. private _coloredMaterial;
  50378. private _hoverMaterial;
  50379. private _isEnabled;
  50380. private _parent;
  50381. /** @hidden */
  50382. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50383. /** @hidden */
  50384. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50385. /**
  50386. * Creates a PlaneDragGizmo
  50387. * @param gizmoLayer The utility layer the gizmo will be added to
  50388. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50389. * @param color The color of the gizmo
  50390. */
  50391. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50392. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50393. /**
  50394. * If the gizmo is enabled
  50395. */
  50396. set isEnabled(value: boolean);
  50397. get isEnabled(): boolean;
  50398. /**
  50399. * Disposes of the gizmo
  50400. */
  50401. dispose(): void;
  50402. }
  50403. }
  50404. declare module BABYLON {
  50405. /**
  50406. * Gizmo that enables dragging a mesh along 3 axis
  50407. */
  50408. export class PositionGizmo extends Gizmo {
  50409. /**
  50410. * Internal gizmo used for interactions on the x axis
  50411. */
  50412. xGizmo: AxisDragGizmo;
  50413. /**
  50414. * Internal gizmo used for interactions on the y axis
  50415. */
  50416. yGizmo: AxisDragGizmo;
  50417. /**
  50418. * Internal gizmo used for interactions on the z axis
  50419. */
  50420. zGizmo: AxisDragGizmo;
  50421. /**
  50422. * Internal gizmo used for interactions on the yz plane
  50423. */
  50424. xPlaneGizmo: PlaneDragGizmo;
  50425. /**
  50426. * Internal gizmo used for interactions on the xz plane
  50427. */
  50428. yPlaneGizmo: PlaneDragGizmo;
  50429. /**
  50430. * Internal gizmo used for interactions on the xy plane
  50431. */
  50432. zPlaneGizmo: PlaneDragGizmo;
  50433. /**
  50434. * private variables
  50435. */
  50436. private _meshAttached;
  50437. private _nodeAttached;
  50438. private _snapDistance;
  50439. /** Fires an event when any of it's sub gizmos are dragged */
  50440. onDragStartObservable: Observable<unknown>;
  50441. /** Fires an event when any of it's sub gizmos are released from dragging */
  50442. onDragEndObservable: Observable<unknown>;
  50443. /**
  50444. * If set to true, planar drag is enabled
  50445. */
  50446. private _planarGizmoEnabled;
  50447. get attachedMesh(): Nullable<AbstractMesh>;
  50448. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50449. get attachedNode(): Nullable<Node>;
  50450. set attachedNode(node: Nullable<Node>);
  50451. /**
  50452. * Creates a PositionGizmo
  50453. * @param gizmoLayer The utility layer the gizmo will be added to
  50454. @param thickness display gizmo axis thickness
  50455. */
  50456. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50457. /**
  50458. * If the planar drag gizmo is enabled
  50459. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50460. */
  50461. set planarGizmoEnabled(value: boolean);
  50462. get planarGizmoEnabled(): boolean;
  50463. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50464. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50465. /**
  50466. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50467. */
  50468. set snapDistance(value: number);
  50469. get snapDistance(): number;
  50470. /**
  50471. * Ratio for the scale of the gizmo (Default: 1)
  50472. */
  50473. set scaleRatio(value: number);
  50474. get scaleRatio(): number;
  50475. /**
  50476. * Disposes of the gizmo
  50477. */
  50478. dispose(): void;
  50479. /**
  50480. * CustomMeshes are not supported by this gizmo
  50481. * @param mesh The mesh to replace the default mesh of the gizmo
  50482. */
  50483. setCustomMesh(mesh: Mesh): void;
  50484. }
  50485. }
  50486. declare module BABYLON {
  50487. /**
  50488. * Single axis drag gizmo
  50489. */
  50490. export class AxisDragGizmo extends Gizmo {
  50491. /**
  50492. * Drag behavior responsible for the gizmos dragging interactions
  50493. */
  50494. dragBehavior: PointerDragBehavior;
  50495. private _pointerObserver;
  50496. /**
  50497. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50498. */
  50499. snapDistance: number;
  50500. /**
  50501. * Event that fires each time the gizmo snaps to a new location.
  50502. * * snapDistance is the the change in distance
  50503. */
  50504. onSnapObservable: Observable<{
  50505. snapDistance: number;
  50506. }>;
  50507. private _isEnabled;
  50508. private _parent;
  50509. private _arrow;
  50510. private _coloredMaterial;
  50511. private _hoverMaterial;
  50512. /** @hidden */
  50513. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50514. /** @hidden */
  50515. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50516. /**
  50517. * Creates an AxisDragGizmo
  50518. * @param gizmoLayer The utility layer the gizmo will be added to
  50519. * @param dragAxis The axis which the gizmo will be able to drag on
  50520. * @param color The color of the gizmo
  50521. * @param thickness display gizmo axis thickness
  50522. */
  50523. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50524. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50525. /**
  50526. * If the gizmo is enabled
  50527. */
  50528. set isEnabled(value: boolean);
  50529. get isEnabled(): boolean;
  50530. /**
  50531. * Disposes of the gizmo
  50532. */
  50533. dispose(): void;
  50534. }
  50535. }
  50536. declare module BABYLON.Debug {
  50537. /**
  50538. * The Axes viewer will show 3 axes in a specific point in space
  50539. */
  50540. export class AxesViewer {
  50541. private _xAxis;
  50542. private _yAxis;
  50543. private _zAxis;
  50544. private _scaleLinesFactor;
  50545. private _instanced;
  50546. /**
  50547. * Gets the hosting scene
  50548. */
  50549. scene: Nullable<Scene>;
  50550. /**
  50551. * Gets or sets a number used to scale line length
  50552. */
  50553. scaleLines: number;
  50554. /** Gets the node hierarchy used to render x-axis */
  50555. get xAxis(): TransformNode;
  50556. /** Gets the node hierarchy used to render y-axis */
  50557. get yAxis(): TransformNode;
  50558. /** Gets the node hierarchy used to render z-axis */
  50559. get zAxis(): TransformNode;
  50560. /**
  50561. * Creates a new AxesViewer
  50562. * @param scene defines the hosting scene
  50563. * @param scaleLines defines a number used to scale line length (1 by default)
  50564. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50565. * @param xAxis defines the node hierarchy used to render the x-axis
  50566. * @param yAxis defines the node hierarchy used to render the y-axis
  50567. * @param zAxis defines the node hierarchy used to render the z-axis
  50568. */
  50569. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50570. /**
  50571. * Force the viewer to update
  50572. * @param position defines the position of the viewer
  50573. * @param xaxis defines the x axis of the viewer
  50574. * @param yaxis defines the y axis of the viewer
  50575. * @param zaxis defines the z axis of the viewer
  50576. */
  50577. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50578. /**
  50579. * Creates an instance of this axes viewer.
  50580. * @returns a new axes viewer with instanced meshes
  50581. */
  50582. createInstance(): AxesViewer;
  50583. /** Releases resources */
  50584. dispose(): void;
  50585. private static _SetRenderingGroupId;
  50586. }
  50587. }
  50588. declare module BABYLON.Debug {
  50589. /**
  50590. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50591. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50592. */
  50593. export class BoneAxesViewer extends AxesViewer {
  50594. /**
  50595. * Gets or sets the target mesh where to display the axes viewer
  50596. */
  50597. mesh: Nullable<Mesh>;
  50598. /**
  50599. * Gets or sets the target bone where to display the axes viewer
  50600. */
  50601. bone: Nullable<Bone>;
  50602. /** Gets current position */
  50603. pos: Vector3;
  50604. /** Gets direction of X axis */
  50605. xaxis: Vector3;
  50606. /** Gets direction of Y axis */
  50607. yaxis: Vector3;
  50608. /** Gets direction of Z axis */
  50609. zaxis: Vector3;
  50610. /**
  50611. * Creates a new BoneAxesViewer
  50612. * @param scene defines the hosting scene
  50613. * @param bone defines the target bone
  50614. * @param mesh defines the target mesh
  50615. * @param scaleLines defines a scaling factor for line length (1 by default)
  50616. */
  50617. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50618. /**
  50619. * Force the viewer to update
  50620. */
  50621. update(): void;
  50622. /** Releases resources */
  50623. dispose(): void;
  50624. }
  50625. }
  50626. declare module BABYLON {
  50627. /**
  50628. * Interface used to define scene explorer extensibility option
  50629. */
  50630. export interface IExplorerExtensibilityOption {
  50631. /**
  50632. * Define the option label
  50633. */
  50634. label: string;
  50635. /**
  50636. * Defines the action to execute on click
  50637. */
  50638. action: (entity: any) => void;
  50639. }
  50640. /**
  50641. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50642. */
  50643. export interface IExplorerExtensibilityGroup {
  50644. /**
  50645. * Defines a predicate to test if a given type mut be extended
  50646. */
  50647. predicate: (entity: any) => boolean;
  50648. /**
  50649. * Gets the list of options added to a type
  50650. */
  50651. entries: IExplorerExtensibilityOption[];
  50652. }
  50653. /**
  50654. * Interface used to define the options to use to create the Inspector
  50655. */
  50656. export interface IInspectorOptions {
  50657. /**
  50658. * Display in overlay mode (default: false)
  50659. */
  50660. overlay?: boolean;
  50661. /**
  50662. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50663. */
  50664. globalRoot?: HTMLElement;
  50665. /**
  50666. * Display the Scene explorer
  50667. */
  50668. showExplorer?: boolean;
  50669. /**
  50670. * Display the property inspector
  50671. */
  50672. showInspector?: boolean;
  50673. /**
  50674. * Display in embed mode (both panes on the right)
  50675. */
  50676. embedMode?: boolean;
  50677. /**
  50678. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50679. */
  50680. handleResize?: boolean;
  50681. /**
  50682. * Allow the panes to popup (default: true)
  50683. */
  50684. enablePopup?: boolean;
  50685. /**
  50686. * Allow the panes to be closed by users (default: true)
  50687. */
  50688. enableClose?: boolean;
  50689. /**
  50690. * Optional list of extensibility entries
  50691. */
  50692. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50693. /**
  50694. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50695. */
  50696. inspectorURL?: string;
  50697. /**
  50698. * Optional initial tab (default to DebugLayerTab.Properties)
  50699. */
  50700. initialTab?: DebugLayerTab;
  50701. }
  50702. interface Scene {
  50703. /**
  50704. * @hidden
  50705. * Backing field
  50706. */
  50707. _debugLayer: DebugLayer;
  50708. /**
  50709. * Gets the debug layer (aka Inspector) associated with the scene
  50710. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50711. */
  50712. debugLayer: DebugLayer;
  50713. }
  50714. /**
  50715. * Enum of inspector action tab
  50716. */
  50717. export enum DebugLayerTab {
  50718. /**
  50719. * Properties tag (default)
  50720. */
  50721. Properties = 0,
  50722. /**
  50723. * Debug tab
  50724. */
  50725. Debug = 1,
  50726. /**
  50727. * Statistics tab
  50728. */
  50729. Statistics = 2,
  50730. /**
  50731. * Tools tab
  50732. */
  50733. Tools = 3,
  50734. /**
  50735. * Settings tab
  50736. */
  50737. Settings = 4
  50738. }
  50739. /**
  50740. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50741. * what is happening in your scene
  50742. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50743. */
  50744. export class DebugLayer {
  50745. /**
  50746. * Define the url to get the inspector script from.
  50747. * By default it uses the babylonjs CDN.
  50748. * @ignoreNaming
  50749. */
  50750. static InspectorURL: string;
  50751. private _scene;
  50752. private BJSINSPECTOR;
  50753. private _onPropertyChangedObservable?;
  50754. /**
  50755. * Observable triggered when a property is changed through the inspector.
  50756. */
  50757. get onPropertyChangedObservable(): any;
  50758. /**
  50759. * Instantiates a new debug layer.
  50760. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50761. * what is happening in your scene
  50762. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50763. * @param scene Defines the scene to inspect
  50764. */
  50765. constructor(scene: Scene);
  50766. /** Creates the inspector window. */
  50767. private _createInspector;
  50768. /**
  50769. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50770. * @param entity defines the entity to select
  50771. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50772. */
  50773. select(entity: any, lineContainerTitles?: string | string[]): void;
  50774. /** Get the inspector from bundle or global */
  50775. private _getGlobalInspector;
  50776. /**
  50777. * Get if the inspector is visible or not.
  50778. * @returns true if visible otherwise, false
  50779. */
  50780. isVisible(): boolean;
  50781. /**
  50782. * Hide the inspector and close its window.
  50783. */
  50784. hide(): void;
  50785. /**
  50786. * Update the scene in the inspector
  50787. */
  50788. setAsActiveScene(): void;
  50789. /**
  50790. * Launch the debugLayer.
  50791. * @param config Define the configuration of the inspector
  50792. * @return a promise fulfilled when the debug layer is visible
  50793. */
  50794. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50795. }
  50796. }
  50797. declare module BABYLON {
  50798. /**
  50799. * Class containing static functions to help procedurally build meshes
  50800. */
  50801. export class BoxBuilder {
  50802. /**
  50803. * Creates a box mesh
  50804. * * The parameter `size` sets the size (float) of each box side (default 1)
  50805. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50806. * * 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)
  50807. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50809. * * 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
  50810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50811. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50812. * @param name defines the name of the mesh
  50813. * @param options defines the options used to create the mesh
  50814. * @param scene defines the hosting scene
  50815. * @returns the box mesh
  50816. */
  50817. static CreateBox(name: string, options: {
  50818. size?: number;
  50819. width?: number;
  50820. height?: number;
  50821. depth?: number;
  50822. faceUV?: Vector4[];
  50823. faceColors?: Color4[];
  50824. sideOrientation?: number;
  50825. frontUVs?: Vector4;
  50826. backUVs?: Vector4;
  50827. wrap?: boolean;
  50828. topBaseAt?: number;
  50829. bottomBaseAt?: number;
  50830. updatable?: boolean;
  50831. }, scene?: Nullable<Scene>): Mesh;
  50832. }
  50833. }
  50834. declare module BABYLON.Debug {
  50835. /**
  50836. * Used to show the physics impostor around the specific mesh
  50837. */
  50838. export class PhysicsViewer {
  50839. /** @hidden */
  50840. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50841. /** @hidden */
  50842. protected _meshes: Array<Nullable<AbstractMesh>>;
  50843. /** @hidden */
  50844. protected _scene: Nullable<Scene>;
  50845. /** @hidden */
  50846. protected _numMeshes: number;
  50847. /** @hidden */
  50848. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50849. private _renderFunction;
  50850. private _utilityLayer;
  50851. private _debugBoxMesh;
  50852. private _debugSphereMesh;
  50853. private _debugCylinderMesh;
  50854. private _debugMaterial;
  50855. private _debugMeshMeshes;
  50856. /**
  50857. * Creates a new PhysicsViewer
  50858. * @param scene defines the hosting scene
  50859. */
  50860. constructor(scene: Scene);
  50861. /** @hidden */
  50862. protected _updateDebugMeshes(): void;
  50863. /**
  50864. * Renders a specified physic impostor
  50865. * @param impostor defines the impostor to render
  50866. * @param targetMesh defines the mesh represented by the impostor
  50867. * @returns the new debug mesh used to render the impostor
  50868. */
  50869. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50870. /**
  50871. * Hides a specified physic impostor
  50872. * @param impostor defines the impostor to hide
  50873. */
  50874. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50875. private _getDebugMaterial;
  50876. private _getDebugBoxMesh;
  50877. private _getDebugSphereMesh;
  50878. private _getDebugCylinderMesh;
  50879. private _getDebugMeshMesh;
  50880. private _getDebugMesh;
  50881. /** Releases all resources */
  50882. dispose(): void;
  50883. }
  50884. }
  50885. declare module BABYLON {
  50886. /**
  50887. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50888. * in order to better appreciate the issue one might have.
  50889. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50890. */
  50891. export class RayHelper {
  50892. /**
  50893. * Defines the ray we are currently tryin to visualize.
  50894. */
  50895. ray: Nullable<Ray>;
  50896. private _renderPoints;
  50897. private _renderLine;
  50898. private _renderFunction;
  50899. private _scene;
  50900. private _onAfterRenderObserver;
  50901. private _onAfterStepObserver;
  50902. private _attachedToMesh;
  50903. private _meshSpaceDirection;
  50904. private _meshSpaceOrigin;
  50905. /**
  50906. * Helper function to create a colored helper in a scene in one line.
  50907. * @param ray Defines the ray we are currently tryin to visualize
  50908. * @param scene Defines the scene the ray is used in
  50909. * @param color Defines the color we want to see the ray in
  50910. * @returns The newly created ray helper.
  50911. */
  50912. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50913. /**
  50914. * Instantiate a new ray helper.
  50915. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50916. * in order to better appreciate the issue one might have.
  50917. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50918. * @param ray Defines the ray we are currently tryin to visualize
  50919. */
  50920. constructor(ray: Ray);
  50921. /**
  50922. * Shows the ray we are willing to debug.
  50923. * @param scene Defines the scene the ray needs to be rendered in
  50924. * @param color Defines the color the ray needs to be rendered in
  50925. */
  50926. show(scene: Scene, color?: Color3): void;
  50927. /**
  50928. * Hides the ray we are debugging.
  50929. */
  50930. hide(): void;
  50931. private _render;
  50932. /**
  50933. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50934. * @param mesh Defines the mesh we want the helper attached to
  50935. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50936. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50937. * @param length Defines the length of the ray
  50938. */
  50939. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50940. /**
  50941. * Detach the ray helper from the mesh it has previously been attached to.
  50942. */
  50943. detachFromMesh(): void;
  50944. private _updateToMesh;
  50945. /**
  50946. * Dispose the helper and release its associated resources.
  50947. */
  50948. dispose(): void;
  50949. }
  50950. }
  50951. declare module BABYLON {
  50952. /**
  50953. * Defines the options associated with the creation of a SkeletonViewer.
  50954. */
  50955. export interface ISkeletonViewerOptions {
  50956. /** Should the system pause animations before building the Viewer? */
  50957. pauseAnimations: boolean;
  50958. /** Should the system return the skeleton to rest before building? */
  50959. returnToRest: boolean;
  50960. /** public Display Mode of the Viewer */
  50961. displayMode: number;
  50962. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50963. displayOptions: ISkeletonViewerDisplayOptions;
  50964. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50965. computeBonesUsingShaders: boolean;
  50966. }
  50967. /**
  50968. * Defines how to display the various bone meshes for the viewer.
  50969. */
  50970. export interface ISkeletonViewerDisplayOptions {
  50971. /** How far down to start tapering the bone spurs */
  50972. midStep?: number;
  50973. /** How big is the midStep? */
  50974. midStepFactor?: number;
  50975. /** Base for the Sphere Size */
  50976. sphereBaseSize?: number;
  50977. /** The ratio of the sphere to the longest bone in units */
  50978. sphereScaleUnit?: number;
  50979. /** Ratio for the Sphere Size */
  50980. sphereFactor?: number;
  50981. }
  50982. }
  50983. declare module BABYLON {
  50984. /**
  50985. * Class containing static functions to help procedurally build meshes
  50986. */
  50987. export class RibbonBuilder {
  50988. /**
  50989. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50990. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50991. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50992. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50993. * * 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
  50994. * * 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
  50995. * * 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
  50996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50997. * * 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
  50998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50999. * * 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
  51000. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51001. * * 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
  51002. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51004. * @param name defines the name of the mesh
  51005. * @param options defines the options used to create the mesh
  51006. * @param scene defines the hosting scene
  51007. * @returns the ribbon mesh
  51008. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51009. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51010. */
  51011. static CreateRibbon(name: string, options: {
  51012. pathArray: Vector3[][];
  51013. closeArray?: boolean;
  51014. closePath?: boolean;
  51015. offset?: number;
  51016. updatable?: boolean;
  51017. sideOrientation?: number;
  51018. frontUVs?: Vector4;
  51019. backUVs?: Vector4;
  51020. instance?: Mesh;
  51021. invertUV?: boolean;
  51022. uvs?: Vector2[];
  51023. colors?: Color4[];
  51024. }, scene?: Nullable<Scene>): Mesh;
  51025. }
  51026. }
  51027. declare module BABYLON {
  51028. /**
  51029. * Class containing static functions to help procedurally build meshes
  51030. */
  51031. export class ShapeBuilder {
  51032. /**
  51033. * 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.
  51034. * * 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.
  51035. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51036. * * 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.
  51037. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51038. * * 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
  51039. * * 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
  51040. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51042. * * 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
  51043. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51045. * @param name defines the name of the mesh
  51046. * @param options defines the options used to create the mesh
  51047. * @param scene defines the hosting scene
  51048. * @returns the extruded shape mesh
  51049. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51051. */
  51052. static ExtrudeShape(name: string, options: {
  51053. shape: Vector3[];
  51054. path: Vector3[];
  51055. scale?: number;
  51056. rotation?: number;
  51057. cap?: number;
  51058. updatable?: boolean;
  51059. sideOrientation?: number;
  51060. frontUVs?: Vector4;
  51061. backUVs?: Vector4;
  51062. instance?: Mesh;
  51063. invertUV?: boolean;
  51064. }, scene?: Nullable<Scene>): Mesh;
  51065. /**
  51066. * Creates an custom extruded shape mesh.
  51067. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51068. * * 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.
  51069. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51070. * * 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
  51071. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51072. * * 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
  51073. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51074. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51075. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51076. * * 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
  51077. * * 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
  51078. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51080. * * 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
  51081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51083. * @param name defines the name of the mesh
  51084. * @param options defines the options used to create the mesh
  51085. * @param scene defines the hosting scene
  51086. * @returns the custom extruded shape mesh
  51087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51088. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51090. */
  51091. static ExtrudeShapeCustom(name: string, options: {
  51092. shape: Vector3[];
  51093. path: Vector3[];
  51094. scaleFunction?: any;
  51095. rotationFunction?: any;
  51096. ribbonCloseArray?: boolean;
  51097. ribbonClosePath?: boolean;
  51098. cap?: number;
  51099. updatable?: boolean;
  51100. sideOrientation?: number;
  51101. frontUVs?: Vector4;
  51102. backUVs?: Vector4;
  51103. instance?: Mesh;
  51104. invertUV?: boolean;
  51105. }, scene?: Nullable<Scene>): Mesh;
  51106. private static _ExtrudeShapeGeneric;
  51107. }
  51108. }
  51109. declare module BABYLON.Debug {
  51110. /**
  51111. * Class used to render a debug view of a given skeleton
  51112. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51113. */
  51114. export class SkeletonViewer {
  51115. /** defines the skeleton to render */
  51116. skeleton: Skeleton;
  51117. /** defines the mesh attached to the skeleton */
  51118. mesh: AbstractMesh;
  51119. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51120. autoUpdateBonesMatrices: boolean;
  51121. /** defines the rendering group id to use with the viewer */
  51122. renderingGroupId: number;
  51123. /** is the options for the viewer */
  51124. options: Partial<ISkeletonViewerOptions>;
  51125. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51126. static readonly DISPLAY_LINES: number;
  51127. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51128. static readonly DISPLAY_SPHERES: number;
  51129. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51130. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51131. /** If SkeletonViewer scene scope. */
  51132. private _scene;
  51133. /** Gets or sets the color used to render the skeleton */
  51134. color: Color3;
  51135. /** Array of the points of the skeleton fo the line view. */
  51136. private _debugLines;
  51137. /** The SkeletonViewers Mesh. */
  51138. private _debugMesh;
  51139. /** If SkeletonViewer is enabled. */
  51140. private _isEnabled;
  51141. /** If SkeletonViewer is ready. */
  51142. private _ready;
  51143. /** SkeletonViewer render observable. */
  51144. private _obs;
  51145. /** The Utility Layer to render the gizmos in. */
  51146. private _utilityLayer;
  51147. private _boneIndices;
  51148. /** Gets the Scene. */
  51149. get scene(): Scene;
  51150. /** Gets the utilityLayer. */
  51151. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51152. /** Checks Ready Status. */
  51153. get isReady(): Boolean;
  51154. /** Sets Ready Status. */
  51155. set ready(value: boolean);
  51156. /** Gets the debugMesh */
  51157. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51158. /** Sets the debugMesh */
  51159. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51160. /** Gets the material */
  51161. get material(): StandardMaterial;
  51162. /** Sets the material */
  51163. set material(value: StandardMaterial);
  51164. /** Gets the material */
  51165. get displayMode(): number;
  51166. /** Sets the material */
  51167. set displayMode(value: number);
  51168. /**
  51169. * Creates a new SkeletonViewer
  51170. * @param skeleton defines the skeleton to render
  51171. * @param mesh defines the mesh attached to the skeleton
  51172. * @param scene defines the hosting scene
  51173. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51174. * @param renderingGroupId defines the rendering group id to use with the viewer
  51175. * @param options All of the extra constructor options for the SkeletonViewer
  51176. */
  51177. constructor(
  51178. /** defines the skeleton to render */
  51179. skeleton: Skeleton,
  51180. /** defines the mesh attached to the skeleton */
  51181. mesh: AbstractMesh,
  51182. /** The Scene scope*/
  51183. scene: Scene,
  51184. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51185. autoUpdateBonesMatrices?: boolean,
  51186. /** defines the rendering group id to use with the viewer */
  51187. renderingGroupId?: number,
  51188. /** is the options for the viewer */
  51189. options?: Partial<ISkeletonViewerOptions>);
  51190. /** The Dynamic bindings for the update functions */
  51191. private _bindObs;
  51192. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51193. update(): void;
  51194. /** Gets or sets a boolean indicating if the viewer is enabled */
  51195. set isEnabled(value: boolean);
  51196. get isEnabled(): boolean;
  51197. private _getBonePosition;
  51198. private _getLinesForBonesWithLength;
  51199. private _getLinesForBonesNoLength;
  51200. /** function to revert the mesh and scene back to the initial state. */
  51201. private _revert;
  51202. /** function to build and bind sphere joint points and spur bone representations. */
  51203. private _buildSpheresAndSpurs;
  51204. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51205. private _displayLinesUpdate;
  51206. /** Changes the displayMode of the skeleton viewer
  51207. * @param mode The displayMode numerical value
  51208. */
  51209. changeDisplayMode(mode: number): void;
  51210. /** Changes the displayMode of the skeleton viewer
  51211. * @param option String of the option name
  51212. * @param value The numerical option value
  51213. */
  51214. changeDisplayOptions(option: string, value: number): void;
  51215. /** Release associated resources */
  51216. dispose(): void;
  51217. }
  51218. }
  51219. declare module BABYLON {
  51220. /**
  51221. * Enum for Device Types
  51222. */
  51223. export enum DeviceType {
  51224. /** Generic */
  51225. Generic = 0,
  51226. /** Keyboard */
  51227. Keyboard = 1,
  51228. /** Mouse */
  51229. Mouse = 2,
  51230. /** Touch Pointers */
  51231. Touch = 3,
  51232. /** PS4 Dual Shock */
  51233. DualShock = 4,
  51234. /** Xbox */
  51235. Xbox = 5,
  51236. /** Switch Controller */
  51237. Switch = 6
  51238. }
  51239. /**
  51240. * Enum for All Pointers (Touch/Mouse)
  51241. */
  51242. export enum PointerInput {
  51243. /** Horizontal Axis */
  51244. Horizontal = 0,
  51245. /** Vertical Axis */
  51246. Vertical = 1,
  51247. /** Left Click or Touch */
  51248. LeftClick = 2,
  51249. /** Middle Click */
  51250. MiddleClick = 3,
  51251. /** Right Click */
  51252. RightClick = 4,
  51253. /** Browser Back */
  51254. BrowserBack = 5,
  51255. /** Browser Forward */
  51256. BrowserForward = 6
  51257. }
  51258. /**
  51259. * Enum for Dual Shock Gamepad
  51260. */
  51261. export enum DualShockInput {
  51262. /** Cross */
  51263. Cross = 0,
  51264. /** Circle */
  51265. Circle = 1,
  51266. /** Square */
  51267. Square = 2,
  51268. /** Triangle */
  51269. Triangle = 3,
  51270. /** L1 */
  51271. L1 = 4,
  51272. /** R1 */
  51273. R1 = 5,
  51274. /** L2 */
  51275. L2 = 6,
  51276. /** R2 */
  51277. R2 = 7,
  51278. /** Share */
  51279. Share = 8,
  51280. /** Options */
  51281. Options = 9,
  51282. /** L3 */
  51283. L3 = 10,
  51284. /** R3 */
  51285. R3 = 11,
  51286. /** DPadUp */
  51287. DPadUp = 12,
  51288. /** DPadDown */
  51289. DPadDown = 13,
  51290. /** DPadLeft */
  51291. DPadLeft = 14,
  51292. /** DRight */
  51293. DPadRight = 15,
  51294. /** Home */
  51295. Home = 16,
  51296. /** TouchPad */
  51297. TouchPad = 17,
  51298. /** LStickXAxis */
  51299. LStickXAxis = 18,
  51300. /** LStickYAxis */
  51301. LStickYAxis = 19,
  51302. /** RStickXAxis */
  51303. RStickXAxis = 20,
  51304. /** RStickYAxis */
  51305. RStickYAxis = 21
  51306. }
  51307. /**
  51308. * Enum for Xbox Gamepad
  51309. */
  51310. export enum XboxInput {
  51311. /** A */
  51312. A = 0,
  51313. /** B */
  51314. B = 1,
  51315. /** X */
  51316. X = 2,
  51317. /** Y */
  51318. Y = 3,
  51319. /** LB */
  51320. LB = 4,
  51321. /** RB */
  51322. RB = 5,
  51323. /** LT */
  51324. LT = 6,
  51325. /** RT */
  51326. RT = 7,
  51327. /** Back */
  51328. Back = 8,
  51329. /** Start */
  51330. Start = 9,
  51331. /** LS */
  51332. LS = 10,
  51333. /** RS */
  51334. RS = 11,
  51335. /** DPadUp */
  51336. DPadUp = 12,
  51337. /** DPadDown */
  51338. DPadDown = 13,
  51339. /** DPadLeft */
  51340. DPadLeft = 14,
  51341. /** DRight */
  51342. DPadRight = 15,
  51343. /** Home */
  51344. Home = 16,
  51345. /** LStickXAxis */
  51346. LStickXAxis = 17,
  51347. /** LStickYAxis */
  51348. LStickYAxis = 18,
  51349. /** RStickXAxis */
  51350. RStickXAxis = 19,
  51351. /** RStickYAxis */
  51352. RStickYAxis = 20
  51353. }
  51354. /**
  51355. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51356. */
  51357. export enum SwitchInput {
  51358. /** B */
  51359. B = 0,
  51360. /** A */
  51361. A = 1,
  51362. /** Y */
  51363. Y = 2,
  51364. /** X */
  51365. X = 3,
  51366. /** L */
  51367. L = 4,
  51368. /** R */
  51369. R = 5,
  51370. /** ZL */
  51371. ZL = 6,
  51372. /** ZR */
  51373. ZR = 7,
  51374. /** Minus */
  51375. Minus = 8,
  51376. /** Plus */
  51377. Plus = 9,
  51378. /** LS */
  51379. LS = 10,
  51380. /** RS */
  51381. RS = 11,
  51382. /** DPadUp */
  51383. DPadUp = 12,
  51384. /** DPadDown */
  51385. DPadDown = 13,
  51386. /** DPadLeft */
  51387. DPadLeft = 14,
  51388. /** DRight */
  51389. DPadRight = 15,
  51390. /** Home */
  51391. Home = 16,
  51392. /** Capture */
  51393. Capture = 17,
  51394. /** LStickXAxis */
  51395. LStickXAxis = 18,
  51396. /** LStickYAxis */
  51397. LStickYAxis = 19,
  51398. /** RStickXAxis */
  51399. RStickXAxis = 20,
  51400. /** RStickYAxis */
  51401. RStickYAxis = 21
  51402. }
  51403. }
  51404. declare module BABYLON {
  51405. /**
  51406. * This class will take all inputs from Keyboard, Pointer, and
  51407. * any Gamepads and provide a polling system that all devices
  51408. * will use. This class assumes that there will only be one
  51409. * pointer device and one keyboard.
  51410. */
  51411. export class DeviceInputSystem implements IDisposable {
  51412. /**
  51413. * Callback to be triggered when a device is connected
  51414. */
  51415. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51416. /**
  51417. * Callback to be triggered when a device is disconnected
  51418. */
  51419. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51420. /**
  51421. * Callback to be triggered when event driven input is updated
  51422. */
  51423. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51424. private _inputs;
  51425. private _gamepads;
  51426. private _keyboardActive;
  51427. private _pointerActive;
  51428. private _elementToAttachTo;
  51429. private _keyboardDownEvent;
  51430. private _keyboardUpEvent;
  51431. private _pointerMoveEvent;
  51432. private _pointerDownEvent;
  51433. private _pointerUpEvent;
  51434. private _gamepadConnectedEvent;
  51435. private _gamepadDisconnectedEvent;
  51436. private static _MAX_KEYCODES;
  51437. private static _MAX_POINTER_INPUTS;
  51438. private constructor();
  51439. /**
  51440. * Creates a new DeviceInputSystem instance
  51441. * @param engine Engine to pull input element from
  51442. * @returns The new instance
  51443. */
  51444. static Create(engine: Engine): DeviceInputSystem;
  51445. /**
  51446. * Checks for current device input value, given an id and input index
  51447. * @param deviceName Id of connected device
  51448. * @param inputIndex Index of device input
  51449. * @returns Current value of input
  51450. */
  51451. /**
  51452. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51453. * @param deviceType Enum specifiying device type
  51454. * @param deviceSlot "Slot" or index that device is referenced in
  51455. * @param inputIndex Id of input to be checked
  51456. * @returns Current value of input
  51457. */
  51458. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51459. /**
  51460. * Dispose of all the eventlisteners
  51461. */
  51462. dispose(): void;
  51463. /**
  51464. * Add device and inputs to device array
  51465. * @param deviceType Enum specifiying device type
  51466. * @param deviceSlot "Slot" or index that device is referenced in
  51467. * @param numberOfInputs Number of input entries to create for given device
  51468. */
  51469. private _registerDevice;
  51470. /**
  51471. * Given a specific device name, remove that device from the device map
  51472. * @param deviceType Enum specifiying device type
  51473. * @param deviceSlot "Slot" or index that device is referenced in
  51474. */
  51475. private _unregisterDevice;
  51476. /**
  51477. * Handle all actions that come from keyboard interaction
  51478. */
  51479. private _handleKeyActions;
  51480. /**
  51481. * Handle all actions that come from pointer interaction
  51482. */
  51483. private _handlePointerActions;
  51484. /**
  51485. * Handle all actions that come from gamepad interaction
  51486. */
  51487. private _handleGamepadActions;
  51488. /**
  51489. * Update all non-event based devices with each frame
  51490. * @param deviceType Enum specifiying device type
  51491. * @param deviceSlot "Slot" or index that device is referenced in
  51492. * @param inputIndex Id of input to be checked
  51493. */
  51494. private _updateDevice;
  51495. /**
  51496. * Gets DeviceType from the device name
  51497. * @param deviceName Name of Device from DeviceInputSystem
  51498. * @returns DeviceType enum value
  51499. */
  51500. private _getGamepadDeviceType;
  51501. }
  51502. }
  51503. declare module BABYLON {
  51504. /**
  51505. * Type to handle enforcement of inputs
  51506. */
  51507. 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;
  51508. }
  51509. declare module BABYLON {
  51510. /**
  51511. * Class that handles all input for a specific device
  51512. */
  51513. export class DeviceSource<T extends DeviceType> {
  51514. /** Type of device */
  51515. readonly deviceType: DeviceType;
  51516. /** "Slot" or index that device is referenced in */
  51517. readonly deviceSlot: number;
  51518. /**
  51519. * Observable to handle device input changes per device
  51520. */
  51521. readonly onInputChangedObservable: Observable<{
  51522. inputIndex: DeviceInput<T>;
  51523. previousState: Nullable<number>;
  51524. currentState: Nullable<number>;
  51525. }>;
  51526. private readonly _deviceInputSystem;
  51527. /**
  51528. * Default Constructor
  51529. * @param deviceInputSystem Reference to DeviceInputSystem
  51530. * @param deviceType Type of device
  51531. * @param deviceSlot "Slot" or index that device is referenced in
  51532. */
  51533. constructor(deviceInputSystem: DeviceInputSystem,
  51534. /** Type of device */
  51535. deviceType: DeviceType,
  51536. /** "Slot" or index that device is referenced in */
  51537. deviceSlot?: number);
  51538. /**
  51539. * Get input for specific input
  51540. * @param inputIndex index of specific input on device
  51541. * @returns Input value from DeviceInputSystem
  51542. */
  51543. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51544. }
  51545. /**
  51546. * Class to keep track of devices
  51547. */
  51548. export class DeviceSourceManager implements IDisposable {
  51549. /**
  51550. * Observable to be triggered when before a device is connected
  51551. */
  51552. readonly onBeforeDeviceConnectedObservable: Observable<{
  51553. deviceType: DeviceType;
  51554. deviceSlot: number;
  51555. }>;
  51556. /**
  51557. * Observable to be triggered when before a device is disconnected
  51558. */
  51559. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51560. deviceType: DeviceType;
  51561. deviceSlot: number;
  51562. }>;
  51563. /**
  51564. * Observable to be triggered when after a device is connected
  51565. */
  51566. readonly onAfterDeviceConnectedObservable: Observable<{
  51567. deviceType: DeviceType;
  51568. deviceSlot: number;
  51569. }>;
  51570. /**
  51571. * Observable to be triggered when after a device is disconnected
  51572. */
  51573. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51574. deviceType: DeviceType;
  51575. deviceSlot: number;
  51576. }>;
  51577. private readonly _devices;
  51578. private readonly _firstDevice;
  51579. private readonly _deviceInputSystem;
  51580. /**
  51581. * Default Constructor
  51582. * @param engine engine to pull input element from
  51583. */
  51584. constructor(engine: Engine);
  51585. /**
  51586. * Gets a DeviceSource, given a type and slot
  51587. * @param deviceType Enum specifying device type
  51588. * @param deviceSlot "Slot" or index that device is referenced in
  51589. * @returns DeviceSource object
  51590. */
  51591. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51592. /**
  51593. * Gets an array of DeviceSource objects for a given device type
  51594. * @param deviceType Enum specifying device type
  51595. * @returns Array of DeviceSource objects
  51596. */
  51597. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51598. /**
  51599. * Dispose of DeviceInputSystem and other parts
  51600. */
  51601. dispose(): void;
  51602. /**
  51603. * Function to add device name to device list
  51604. * @param deviceType Enum specifying device type
  51605. * @param deviceSlot "Slot" or index that device is referenced in
  51606. */
  51607. private _addDevice;
  51608. /**
  51609. * Function to remove device name to device list
  51610. * @param deviceType Enum specifying device type
  51611. * @param deviceSlot "Slot" or index that device is referenced in
  51612. */
  51613. private _removeDevice;
  51614. /**
  51615. * Updates array storing first connected device of each type
  51616. * @param type Type of Device
  51617. */
  51618. private _updateFirstDevices;
  51619. }
  51620. }
  51621. declare module BABYLON {
  51622. /**
  51623. * Options to create the null engine
  51624. */
  51625. export class NullEngineOptions {
  51626. /**
  51627. * Render width (Default: 512)
  51628. */
  51629. renderWidth: number;
  51630. /**
  51631. * Render height (Default: 256)
  51632. */
  51633. renderHeight: number;
  51634. /**
  51635. * Texture size (Default: 512)
  51636. */
  51637. textureSize: number;
  51638. /**
  51639. * If delta time between frames should be constant
  51640. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51641. */
  51642. deterministicLockstep: boolean;
  51643. /**
  51644. * Maximum about of steps between frames (Default: 4)
  51645. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51646. */
  51647. lockstepMaxSteps: number;
  51648. /**
  51649. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51650. */
  51651. useHighPrecisionMatrix?: boolean;
  51652. }
  51653. /**
  51654. * The null engine class provides support for headless version of babylon.js.
  51655. * This can be used in server side scenario or for testing purposes
  51656. */
  51657. export class NullEngine extends Engine {
  51658. private _options;
  51659. /**
  51660. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51661. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51662. * @returns true if engine is in deterministic lock step mode
  51663. */
  51664. isDeterministicLockStep(): boolean;
  51665. /**
  51666. * Gets the max steps when engine is running in deterministic lock step
  51667. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51668. * @returns the max steps
  51669. */
  51670. getLockstepMaxSteps(): number;
  51671. /**
  51672. * Gets the current hardware scaling level.
  51673. * By default the hardware scaling level is computed from the window device ratio.
  51674. * 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.
  51675. * @returns a number indicating the current hardware scaling level
  51676. */
  51677. getHardwareScalingLevel(): number;
  51678. constructor(options?: NullEngineOptions);
  51679. /**
  51680. * Creates a vertex buffer
  51681. * @param vertices the data for the vertex buffer
  51682. * @returns the new WebGL static buffer
  51683. */
  51684. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51685. /**
  51686. * Creates a new index buffer
  51687. * @param indices defines the content of the index buffer
  51688. * @param updatable defines if the index buffer must be updatable
  51689. * @returns a new webGL buffer
  51690. */
  51691. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51692. /**
  51693. * Clear the current render buffer or the current render target (if any is set up)
  51694. * @param color defines the color to use
  51695. * @param backBuffer defines if the back buffer must be cleared
  51696. * @param depth defines if the depth buffer must be cleared
  51697. * @param stencil defines if the stencil buffer must be cleared
  51698. */
  51699. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51700. /**
  51701. * Gets the current render width
  51702. * @param useScreen defines if screen size must be used (or the current render target if any)
  51703. * @returns a number defining the current render width
  51704. */
  51705. getRenderWidth(useScreen?: boolean): number;
  51706. /**
  51707. * Gets the current render height
  51708. * @param useScreen defines if screen size must be used (or the current render target if any)
  51709. * @returns a number defining the current render height
  51710. */
  51711. getRenderHeight(useScreen?: boolean): number;
  51712. /**
  51713. * Set the WebGL's viewport
  51714. * @param viewport defines the viewport element to be used
  51715. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51716. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51717. */
  51718. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51719. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51720. /**
  51721. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51722. * @param pipelineContext defines the pipeline context to use
  51723. * @param uniformsNames defines the list of uniform names
  51724. * @returns an array of webGL uniform locations
  51725. */
  51726. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51727. /**
  51728. * Gets the lsit of active attributes for a given webGL program
  51729. * @param pipelineContext defines the pipeline context to use
  51730. * @param attributesNames defines the list of attribute names to get
  51731. * @returns an array of indices indicating the offset of each attribute
  51732. */
  51733. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51734. /**
  51735. * Binds an effect to the webGL context
  51736. * @param effect defines the effect to bind
  51737. */
  51738. bindSamplers(effect: Effect): void;
  51739. /**
  51740. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51741. * @param effect defines the effect to activate
  51742. */
  51743. enableEffect(effect: Effect): void;
  51744. /**
  51745. * Set various states to the webGL context
  51746. * @param culling defines backface culling state
  51747. * @param zOffset defines the value to apply to zOffset (0 by default)
  51748. * @param force defines if states must be applied even if cache is up to date
  51749. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51750. */
  51751. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51752. /**
  51753. * Set the value of an uniform to an array of int32
  51754. * @param uniform defines the webGL uniform location where to store the value
  51755. * @param array defines the array of int32 to store
  51756. */
  51757. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51758. /**
  51759. * Set the value of an uniform to an array of int32 (stored as vec2)
  51760. * @param uniform defines the webGL uniform location where to store the value
  51761. * @param array defines the array of int32 to store
  51762. */
  51763. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51764. /**
  51765. * Set the value of an uniform to an array of int32 (stored as vec3)
  51766. * @param uniform defines the webGL uniform location where to store the value
  51767. * @param array defines the array of int32 to store
  51768. */
  51769. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51770. /**
  51771. * Set the value of an uniform to an array of int32 (stored as vec4)
  51772. * @param uniform defines the webGL uniform location where to store the value
  51773. * @param array defines the array of int32 to store
  51774. */
  51775. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51776. /**
  51777. * Set the value of an uniform to an array of float32
  51778. * @param uniform defines the webGL uniform location where to store the value
  51779. * @param array defines the array of float32 to store
  51780. */
  51781. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51782. /**
  51783. * Set the value of an uniform to an array of float32 (stored as vec2)
  51784. * @param uniform defines the webGL uniform location where to store the value
  51785. * @param array defines the array of float32 to store
  51786. */
  51787. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51788. /**
  51789. * Set the value of an uniform to an array of float32 (stored as vec3)
  51790. * @param uniform defines the webGL uniform location where to store the value
  51791. * @param array defines the array of float32 to store
  51792. */
  51793. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51794. /**
  51795. * Set the value of an uniform to an array of float32 (stored as vec4)
  51796. * @param uniform defines the webGL uniform location where to store the value
  51797. * @param array defines the array of float32 to store
  51798. */
  51799. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51800. /**
  51801. * Set the value of an uniform to an array of number
  51802. * @param uniform defines the webGL uniform location where to store the value
  51803. * @param array defines the array of number to store
  51804. */
  51805. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51806. /**
  51807. * Set the value of an uniform to an array of number (stored as vec2)
  51808. * @param uniform defines the webGL uniform location where to store the value
  51809. * @param array defines the array of number to store
  51810. */
  51811. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51812. /**
  51813. * Set the value of an uniform to an array of number (stored as vec3)
  51814. * @param uniform defines the webGL uniform location where to store the value
  51815. * @param array defines the array of number to store
  51816. */
  51817. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51818. /**
  51819. * Set the value of an uniform to an array of number (stored as vec4)
  51820. * @param uniform defines the webGL uniform location where to store the value
  51821. * @param array defines the array of number to store
  51822. */
  51823. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51824. /**
  51825. * Set the value of an uniform to an array of float32 (stored as matrices)
  51826. * @param uniform defines the webGL uniform location where to store the value
  51827. * @param matrices defines the array of float32 to store
  51828. */
  51829. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51830. /**
  51831. * Set the value of an uniform to a matrix (3x3)
  51832. * @param uniform defines the webGL uniform location where to store the value
  51833. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51834. */
  51835. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51836. /**
  51837. * Set the value of an uniform to a matrix (2x2)
  51838. * @param uniform defines the webGL uniform location where to store the value
  51839. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51840. */
  51841. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51842. /**
  51843. * Set the value of an uniform to a number (float)
  51844. * @param uniform defines the webGL uniform location where to store the value
  51845. * @param value defines the float number to store
  51846. */
  51847. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51848. /**
  51849. * Set the value of an uniform to a vec2
  51850. * @param uniform defines the webGL uniform location where to store the value
  51851. * @param x defines the 1st component of the value
  51852. * @param y defines the 2nd component of the value
  51853. */
  51854. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51855. /**
  51856. * Set the value of an uniform to a vec3
  51857. * @param uniform defines the webGL uniform location where to store the value
  51858. * @param x defines the 1st component of the value
  51859. * @param y defines the 2nd component of the value
  51860. * @param z defines the 3rd component of the value
  51861. */
  51862. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51863. /**
  51864. * Set the value of an uniform to a boolean
  51865. * @param uniform defines the webGL uniform location where to store the value
  51866. * @param bool defines the boolean to store
  51867. */
  51868. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51869. /**
  51870. * Set the value of an uniform to a vec4
  51871. * @param uniform defines the webGL uniform location where to store the value
  51872. * @param x defines the 1st component of the value
  51873. * @param y defines the 2nd component of the value
  51874. * @param z defines the 3rd component of the value
  51875. * @param w defines the 4th component of the value
  51876. */
  51877. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51878. /**
  51879. * Sets the current alpha mode
  51880. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51881. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51882. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51883. */
  51884. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51885. /**
  51886. * Bind webGl buffers directly to the webGL context
  51887. * @param vertexBuffers defines the vertex buffer to bind
  51888. * @param indexBuffer defines the index buffer to bind
  51889. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51890. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51891. * @param effect defines the effect associated with the vertex buffer
  51892. */
  51893. bindBuffers(vertexBuffers: {
  51894. [key: string]: VertexBuffer;
  51895. }, indexBuffer: DataBuffer, effect: Effect): void;
  51896. /**
  51897. * Force the entire cache to be cleared
  51898. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51899. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51900. */
  51901. wipeCaches(bruteForce?: boolean): void;
  51902. /**
  51903. * Send a draw order
  51904. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51905. * @param indexStart defines the starting index
  51906. * @param indexCount defines the number of index to draw
  51907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51908. */
  51909. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51910. /**
  51911. * Draw a list of indexed primitives
  51912. * @param fillMode defines the primitive to use
  51913. * @param indexStart defines the starting index
  51914. * @param indexCount defines the number of index to draw
  51915. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51916. */
  51917. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51918. /**
  51919. * Draw a list of unindexed primitives
  51920. * @param fillMode defines the primitive to use
  51921. * @param verticesStart defines the index of first vertex to draw
  51922. * @param verticesCount defines the count of vertices to draw
  51923. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51924. */
  51925. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51926. /** @hidden */
  51927. _createTexture(): WebGLTexture;
  51928. /** @hidden */
  51929. _releaseTexture(texture: InternalTexture): void;
  51930. /**
  51931. * Usually called from Texture.ts.
  51932. * Passed information to create a WebGLTexture
  51933. * @param urlArg defines a value which contains one of the following:
  51934. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51935. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51936. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51937. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51938. * @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)
  51939. * @param scene needed for loading to the correct scene
  51940. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51941. * @param onLoad optional callback to be called upon successful completion
  51942. * @param onError optional callback to be called upon failure
  51943. * @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
  51944. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51945. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51946. * @param forcedExtension defines the extension to use to pick the right loader
  51947. * @param mimeType defines an optional mime type
  51948. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51949. */
  51950. 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;
  51951. /**
  51952. * Creates a new render target texture
  51953. * @param size defines the size of the texture
  51954. * @param options defines the options used to create the texture
  51955. * @returns a new render target texture stored in an InternalTexture
  51956. */
  51957. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51958. /**
  51959. * Update the sampling mode of a given texture
  51960. * @param samplingMode defines the required sampling mode
  51961. * @param texture defines the texture to update
  51962. */
  51963. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51964. /**
  51965. * Binds the frame buffer to the specified texture.
  51966. * @param texture The texture to render to or null for the default canvas
  51967. * @param faceIndex The face of the texture to render to in case of cube texture
  51968. * @param requiredWidth The width of the target to render to
  51969. * @param requiredHeight The height of the target to render to
  51970. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51971. * @param lodLevel defines le lod level to bind to the frame buffer
  51972. */
  51973. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51974. /**
  51975. * Unbind the current render target texture from the webGL context
  51976. * @param texture defines the render target texture to unbind
  51977. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51978. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51979. */
  51980. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51981. /**
  51982. * Creates a dynamic vertex buffer
  51983. * @param vertices the data for the dynamic vertex buffer
  51984. * @returns the new WebGL dynamic buffer
  51985. */
  51986. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51987. /**
  51988. * Update the content of a dynamic texture
  51989. * @param texture defines the texture to update
  51990. * @param canvas defines the canvas containing the source
  51991. * @param invertY defines if data must be stored with Y axis inverted
  51992. * @param premulAlpha defines if alpha is stored as premultiplied
  51993. * @param format defines the format of the data
  51994. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51995. */
  51996. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51997. /**
  51998. * Gets a boolean indicating if all created effects are ready
  51999. * @returns true if all effects are ready
  52000. */
  52001. areAllEffectsReady(): boolean;
  52002. /**
  52003. * @hidden
  52004. * Get the current error code of the webGL context
  52005. * @returns the error code
  52006. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52007. */
  52008. getError(): number;
  52009. /** @hidden */
  52010. _getUnpackAlignement(): number;
  52011. /** @hidden */
  52012. _unpackFlipY(value: boolean): void;
  52013. /**
  52014. * Update a dynamic index buffer
  52015. * @param indexBuffer defines the target index buffer
  52016. * @param indices defines the data to update
  52017. * @param offset defines the offset in the target index buffer where update should start
  52018. */
  52019. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52020. /**
  52021. * Updates a dynamic vertex buffer.
  52022. * @param vertexBuffer the vertex buffer to update
  52023. * @param vertices the data used to update the vertex buffer
  52024. * @param byteOffset the byte offset of the data (optional)
  52025. * @param byteLength the byte length of the data (optional)
  52026. */
  52027. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52028. /** @hidden */
  52029. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52030. /** @hidden */
  52031. _bindTexture(channel: number, texture: InternalTexture): void;
  52032. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52033. /**
  52034. * 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
  52035. */
  52036. releaseEffects(): void;
  52037. displayLoadingUI(): void;
  52038. hideLoadingUI(): void;
  52039. /** @hidden */
  52040. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52041. /** @hidden */
  52042. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52043. /** @hidden */
  52044. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52045. /** @hidden */
  52046. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52047. }
  52048. }
  52049. declare module BABYLON {
  52050. /**
  52051. * @hidden
  52052. **/
  52053. export class _TimeToken {
  52054. _startTimeQuery: Nullable<WebGLQuery>;
  52055. _endTimeQuery: Nullable<WebGLQuery>;
  52056. _timeElapsedQuery: Nullable<WebGLQuery>;
  52057. _timeElapsedQueryEnded: boolean;
  52058. }
  52059. }
  52060. declare module BABYLON {
  52061. /** @hidden */
  52062. export class _OcclusionDataStorage {
  52063. /** @hidden */
  52064. occlusionInternalRetryCounter: number;
  52065. /** @hidden */
  52066. isOcclusionQueryInProgress: boolean;
  52067. /** @hidden */
  52068. isOccluded: boolean;
  52069. /** @hidden */
  52070. occlusionRetryCount: number;
  52071. /** @hidden */
  52072. occlusionType: number;
  52073. /** @hidden */
  52074. occlusionQueryAlgorithmType: number;
  52075. }
  52076. interface Engine {
  52077. /**
  52078. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52079. * @return the new query
  52080. */
  52081. createQuery(): WebGLQuery;
  52082. /**
  52083. * Delete and release a webGL query
  52084. * @param query defines the query to delete
  52085. * @return the current engine
  52086. */
  52087. deleteQuery(query: WebGLQuery): Engine;
  52088. /**
  52089. * Check if a given query has resolved and got its value
  52090. * @param query defines the query to check
  52091. * @returns true if the query got its value
  52092. */
  52093. isQueryResultAvailable(query: WebGLQuery): boolean;
  52094. /**
  52095. * Gets the value of a given query
  52096. * @param query defines the query to check
  52097. * @returns the value of the query
  52098. */
  52099. getQueryResult(query: WebGLQuery): number;
  52100. /**
  52101. * Initiates an occlusion query
  52102. * @param algorithmType defines the algorithm to use
  52103. * @param query defines the query to use
  52104. * @returns the current engine
  52105. * @see https://doc.babylonjs.com/features/occlusionquery
  52106. */
  52107. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52108. /**
  52109. * Ends an occlusion query
  52110. * @see https://doc.babylonjs.com/features/occlusionquery
  52111. * @param algorithmType defines the algorithm to use
  52112. * @returns the current engine
  52113. */
  52114. endOcclusionQuery(algorithmType: number): Engine;
  52115. /**
  52116. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52117. * Please note that only one query can be issued at a time
  52118. * @returns a time token used to track the time span
  52119. */
  52120. startTimeQuery(): Nullable<_TimeToken>;
  52121. /**
  52122. * Ends a time query
  52123. * @param token defines the token used to measure the time span
  52124. * @returns the time spent (in ns)
  52125. */
  52126. endTimeQuery(token: _TimeToken): int;
  52127. /** @hidden */
  52128. _currentNonTimestampToken: Nullable<_TimeToken>;
  52129. /** @hidden */
  52130. _createTimeQuery(): WebGLQuery;
  52131. /** @hidden */
  52132. _deleteTimeQuery(query: WebGLQuery): void;
  52133. /** @hidden */
  52134. _getGlAlgorithmType(algorithmType: number): number;
  52135. /** @hidden */
  52136. _getTimeQueryResult(query: WebGLQuery): any;
  52137. /** @hidden */
  52138. _getTimeQueryAvailability(query: WebGLQuery): any;
  52139. }
  52140. interface AbstractMesh {
  52141. /**
  52142. * Backing filed
  52143. * @hidden
  52144. */
  52145. __occlusionDataStorage: _OcclusionDataStorage;
  52146. /**
  52147. * Access property
  52148. * @hidden
  52149. */
  52150. _occlusionDataStorage: _OcclusionDataStorage;
  52151. /**
  52152. * 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.
  52153. * The default value is -1 which means don't break the query and wait till the result
  52154. * @see https://doc.babylonjs.com/features/occlusionquery
  52155. */
  52156. occlusionRetryCount: number;
  52157. /**
  52158. * 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:
  52159. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52160. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52161. * * 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.
  52162. * @see https://doc.babylonjs.com/features/occlusionquery
  52163. */
  52164. occlusionType: number;
  52165. /**
  52166. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52167. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52168. * * 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.
  52169. * @see https://doc.babylonjs.com/features/occlusionquery
  52170. */
  52171. occlusionQueryAlgorithmType: number;
  52172. /**
  52173. * 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
  52174. * @see https://doc.babylonjs.com/features/occlusionquery
  52175. */
  52176. isOccluded: boolean;
  52177. /**
  52178. * Flag to check the progress status of the query
  52179. * @see https://doc.babylonjs.com/features/occlusionquery
  52180. */
  52181. isOcclusionQueryInProgress: boolean;
  52182. }
  52183. }
  52184. declare module BABYLON {
  52185. /** @hidden */
  52186. export var _forceTransformFeedbackToBundle: boolean;
  52187. interface Engine {
  52188. /**
  52189. * Creates a webGL transform feedback object
  52190. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52191. * @returns the webGL transform feedback object
  52192. */
  52193. createTransformFeedback(): WebGLTransformFeedback;
  52194. /**
  52195. * Delete a webGL transform feedback object
  52196. * @param value defines the webGL transform feedback object to delete
  52197. */
  52198. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52199. /**
  52200. * Bind a webGL transform feedback object to the webgl context
  52201. * @param value defines the webGL transform feedback object to bind
  52202. */
  52203. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52204. /**
  52205. * Begins a transform feedback operation
  52206. * @param usePoints defines if points or triangles must be used
  52207. */
  52208. beginTransformFeedback(usePoints: boolean): void;
  52209. /**
  52210. * Ends a transform feedback operation
  52211. */
  52212. endTransformFeedback(): void;
  52213. /**
  52214. * Specify the varyings to use with transform feedback
  52215. * @param program defines the associated webGL program
  52216. * @param value defines the list of strings representing the varying names
  52217. */
  52218. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52219. /**
  52220. * Bind a webGL buffer for a transform feedback operation
  52221. * @param value defines the webGL buffer to bind
  52222. */
  52223. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52224. }
  52225. }
  52226. declare module BABYLON {
  52227. /**
  52228. * Class used to define an additional view for the engine
  52229. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52230. */
  52231. export class EngineView {
  52232. /** Defines the canvas where to render the view */
  52233. target: HTMLCanvasElement;
  52234. /** Defines an optional camera used to render the view (will use active camera else) */
  52235. camera?: Camera;
  52236. }
  52237. interface Engine {
  52238. /**
  52239. * Gets or sets the HTML element to use for attaching events
  52240. */
  52241. inputElement: Nullable<HTMLElement>;
  52242. /**
  52243. * Gets the current engine view
  52244. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52245. */
  52246. activeView: Nullable<EngineView>;
  52247. /** Gets or sets the list of views */
  52248. views: EngineView[];
  52249. /**
  52250. * Register a new child canvas
  52251. * @param canvas defines the canvas to register
  52252. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52253. * @returns the associated view
  52254. */
  52255. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52256. /**
  52257. * Remove a registered child canvas
  52258. * @param canvas defines the canvas to remove
  52259. * @returns the current engine
  52260. */
  52261. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52262. }
  52263. }
  52264. declare module BABYLON {
  52265. interface Engine {
  52266. /** @hidden */
  52267. _excludedCompressedTextures: string[];
  52268. /** @hidden */
  52269. _textureFormatInUse: string;
  52270. /**
  52271. * Gets the list of texture formats supported
  52272. */
  52273. readonly texturesSupported: Array<string>;
  52274. /**
  52275. * Gets the texture format in use
  52276. */
  52277. readonly textureFormatInUse: Nullable<string>;
  52278. /**
  52279. * Set the compressed texture extensions or file names to skip.
  52280. *
  52281. * @param skippedFiles defines the list of those texture files you want to skip
  52282. * Example: [".dds", ".env", "myfile.png"]
  52283. */
  52284. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52285. /**
  52286. * Set the compressed texture format to use, based on the formats you have, and the formats
  52287. * supported by the hardware / browser.
  52288. *
  52289. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52290. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52291. * to API arguments needed to compressed textures. This puts the burden on the container
  52292. * generator to house the arcane code for determining these for current & future formats.
  52293. *
  52294. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52295. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52296. *
  52297. * Note: The result of this call is not taken into account when a texture is base64.
  52298. *
  52299. * @param formatsAvailable defines the list of those format families you have created
  52300. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52301. *
  52302. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52303. * @returns The extension selected.
  52304. */
  52305. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52306. }
  52307. }
  52308. declare module BABYLON {
  52309. /**
  52310. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52311. */
  52312. export interface CubeMapInfo {
  52313. /**
  52314. * The pixel array for the front face.
  52315. * This is stored in format, left to right, up to down format.
  52316. */
  52317. front: Nullable<ArrayBufferView>;
  52318. /**
  52319. * The pixel array for the back face.
  52320. * This is stored in format, left to right, up to down format.
  52321. */
  52322. back: Nullable<ArrayBufferView>;
  52323. /**
  52324. * The pixel array for the left face.
  52325. * This is stored in format, left to right, up to down format.
  52326. */
  52327. left: Nullable<ArrayBufferView>;
  52328. /**
  52329. * The pixel array for the right face.
  52330. * This is stored in format, left to right, up to down format.
  52331. */
  52332. right: Nullable<ArrayBufferView>;
  52333. /**
  52334. * The pixel array for the up face.
  52335. * This is stored in format, left to right, up to down format.
  52336. */
  52337. up: Nullable<ArrayBufferView>;
  52338. /**
  52339. * The pixel array for the down face.
  52340. * This is stored in format, left to right, up to down format.
  52341. */
  52342. down: Nullable<ArrayBufferView>;
  52343. /**
  52344. * The size of the cubemap stored.
  52345. *
  52346. * Each faces will be size * size pixels.
  52347. */
  52348. size: number;
  52349. /**
  52350. * The format of the texture.
  52351. *
  52352. * RGBA, RGB.
  52353. */
  52354. format: number;
  52355. /**
  52356. * The type of the texture data.
  52357. *
  52358. * UNSIGNED_INT, FLOAT.
  52359. */
  52360. type: number;
  52361. /**
  52362. * Specifies whether the texture is in gamma space.
  52363. */
  52364. gammaSpace: boolean;
  52365. }
  52366. /**
  52367. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52368. */
  52369. export class PanoramaToCubeMapTools {
  52370. private static FACE_LEFT;
  52371. private static FACE_RIGHT;
  52372. private static FACE_FRONT;
  52373. private static FACE_BACK;
  52374. private static FACE_DOWN;
  52375. private static FACE_UP;
  52376. /**
  52377. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52378. *
  52379. * @param float32Array The source data.
  52380. * @param inputWidth The width of the input panorama.
  52381. * @param inputHeight The height of the input panorama.
  52382. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52383. * @return The cubemap data
  52384. */
  52385. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52386. private static CreateCubemapTexture;
  52387. private static CalcProjectionSpherical;
  52388. }
  52389. }
  52390. declare module BABYLON {
  52391. /**
  52392. * Helper class dealing with the extraction of spherical polynomial dataArray
  52393. * from a cube map.
  52394. */
  52395. export class CubeMapToSphericalPolynomialTools {
  52396. private static FileFaces;
  52397. /**
  52398. * Converts a texture to the according Spherical Polynomial data.
  52399. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52400. *
  52401. * @param texture The texture to extract the information from.
  52402. * @return The Spherical Polynomial data.
  52403. */
  52404. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52405. /**
  52406. * Converts a cubemap to the according Spherical Polynomial data.
  52407. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52408. *
  52409. * @param cubeInfo The Cube map to extract the information from.
  52410. * @return The Spherical Polynomial data.
  52411. */
  52412. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52413. }
  52414. }
  52415. declare module BABYLON {
  52416. interface BaseTexture {
  52417. /**
  52418. * Get the polynomial representation of the texture data.
  52419. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52420. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52421. */
  52422. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52423. }
  52424. }
  52425. declare module BABYLON {
  52426. /** @hidden */
  52427. export var rgbdEncodePixelShader: {
  52428. name: string;
  52429. shader: string;
  52430. };
  52431. }
  52432. declare module BABYLON {
  52433. /** @hidden */
  52434. export var rgbdDecodePixelShader: {
  52435. name: string;
  52436. shader: string;
  52437. };
  52438. }
  52439. declare module BABYLON {
  52440. /**
  52441. * Raw texture data and descriptor sufficient for WebGL texture upload
  52442. */
  52443. export interface EnvironmentTextureInfo {
  52444. /**
  52445. * Version of the environment map
  52446. */
  52447. version: number;
  52448. /**
  52449. * Width of image
  52450. */
  52451. width: number;
  52452. /**
  52453. * Irradiance information stored in the file.
  52454. */
  52455. irradiance: any;
  52456. /**
  52457. * Specular information stored in the file.
  52458. */
  52459. specular: any;
  52460. }
  52461. /**
  52462. * Defines One Image in the file. It requires only the position in the file
  52463. * as well as the length.
  52464. */
  52465. interface BufferImageData {
  52466. /**
  52467. * Length of the image data.
  52468. */
  52469. length: number;
  52470. /**
  52471. * Position of the data from the null terminator delimiting the end of the JSON.
  52472. */
  52473. position: number;
  52474. }
  52475. /**
  52476. * Defines the specular data enclosed in the file.
  52477. * This corresponds to the version 1 of the data.
  52478. */
  52479. export interface EnvironmentTextureSpecularInfoV1 {
  52480. /**
  52481. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52482. */
  52483. specularDataPosition?: number;
  52484. /**
  52485. * This contains all the images data needed to reconstruct the cubemap.
  52486. */
  52487. mipmaps: Array<BufferImageData>;
  52488. /**
  52489. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52490. */
  52491. lodGenerationScale: number;
  52492. }
  52493. /**
  52494. * Sets of helpers addressing the serialization and deserialization of environment texture
  52495. * stored in a BabylonJS env file.
  52496. * Those files are usually stored as .env files.
  52497. */
  52498. export class EnvironmentTextureTools {
  52499. /**
  52500. * Magic number identifying the env file.
  52501. */
  52502. private static _MagicBytes;
  52503. /**
  52504. * Gets the environment info from an env file.
  52505. * @param data The array buffer containing the .env bytes.
  52506. * @returns the environment file info (the json header) if successfully parsed.
  52507. */
  52508. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52509. /**
  52510. * Creates an environment texture from a loaded cube texture.
  52511. * @param texture defines the cube texture to convert in env file
  52512. * @return a promise containing the environment data if succesfull.
  52513. */
  52514. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52515. /**
  52516. * Creates a JSON representation of the spherical data.
  52517. * @param texture defines the texture containing the polynomials
  52518. * @return the JSON representation of the spherical info
  52519. */
  52520. private static _CreateEnvTextureIrradiance;
  52521. /**
  52522. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52523. * @param data the image data
  52524. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52525. * @return the views described by info providing access to the underlying buffer
  52526. */
  52527. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52528. /**
  52529. * Uploads the texture info contained in the env file to the GPU.
  52530. * @param texture defines the internal texture to upload to
  52531. * @param data defines the data to load
  52532. * @param info defines the texture info retrieved through the GetEnvInfo method
  52533. * @returns a promise
  52534. */
  52535. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52536. private static _OnImageReadyAsync;
  52537. /**
  52538. * Uploads the levels of image data to the GPU.
  52539. * @param texture defines the internal texture to upload to
  52540. * @param imageData defines the array buffer views of image data [mipmap][face]
  52541. * @returns a promise
  52542. */
  52543. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52544. /**
  52545. * Uploads spherical polynomials information to the texture.
  52546. * @param texture defines the texture we are trying to upload the information to
  52547. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52548. */
  52549. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52550. /** @hidden */
  52551. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52552. }
  52553. }
  52554. declare module BABYLON {
  52555. /**
  52556. * Class used to inline functions in shader code
  52557. */
  52558. export class ShaderCodeInliner {
  52559. private static readonly _RegexpFindFunctionNameAndType;
  52560. private _sourceCode;
  52561. private _functionDescr;
  52562. private _numMaxIterations;
  52563. /** Gets or sets the token used to mark the functions to inline */
  52564. inlineToken: string;
  52565. /** Gets or sets the debug mode */
  52566. debug: boolean;
  52567. /** Gets the code after the inlining process */
  52568. get code(): string;
  52569. /**
  52570. * Initializes the inliner
  52571. * @param sourceCode shader code source to inline
  52572. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52573. */
  52574. constructor(sourceCode: string, numMaxIterations?: number);
  52575. /**
  52576. * Start the processing of the shader code
  52577. */
  52578. processCode(): void;
  52579. private _collectFunctions;
  52580. private _processInlining;
  52581. private _extractBetweenMarkers;
  52582. private _skipWhitespaces;
  52583. private _removeComments;
  52584. private _replaceFunctionCallsByCode;
  52585. private _findBackward;
  52586. private _escapeRegExp;
  52587. private _replaceNames;
  52588. }
  52589. }
  52590. declare module BABYLON {
  52591. /**
  52592. * Container for accessors for natively-stored mesh data buffers.
  52593. */
  52594. class NativeDataBuffer extends DataBuffer {
  52595. /**
  52596. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52597. */
  52598. nativeIndexBuffer?: any;
  52599. /**
  52600. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52601. */
  52602. nativeVertexBuffer?: any;
  52603. }
  52604. /** @hidden */
  52605. class NativeTexture extends InternalTexture {
  52606. getInternalTexture(): InternalTexture;
  52607. getViewCount(): number;
  52608. }
  52609. /** @hidden */
  52610. export class NativeEngine extends Engine {
  52611. private readonly _native;
  52612. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52613. private readonly INVALID_HANDLE;
  52614. private _boundBuffersVertexArray;
  52615. getHardwareScalingLevel(): number;
  52616. constructor();
  52617. dispose(): void;
  52618. /**
  52619. * Can be used to override the current requestAnimationFrame requester.
  52620. * @hidden
  52621. */
  52622. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52623. /**
  52624. * Override default engine behavior.
  52625. * @param color
  52626. * @param backBuffer
  52627. * @param depth
  52628. * @param stencil
  52629. */
  52630. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52631. /**
  52632. * Gets host document
  52633. * @returns the host document object
  52634. */
  52635. getHostDocument(): Nullable<Document>;
  52636. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52637. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52638. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52639. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52640. [key: string]: VertexBuffer;
  52641. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52642. bindBuffers(vertexBuffers: {
  52643. [key: string]: VertexBuffer;
  52644. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52645. recordVertexArrayObject(vertexBuffers: {
  52646. [key: string]: VertexBuffer;
  52647. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52648. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52649. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52650. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52651. /**
  52652. * Draw a list of indexed primitives
  52653. * @param fillMode defines the primitive to use
  52654. * @param indexStart defines the starting index
  52655. * @param indexCount defines the number of index to draw
  52656. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52657. */
  52658. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52659. /**
  52660. * Draw a list of unindexed primitives
  52661. * @param fillMode defines the primitive to use
  52662. * @param verticesStart defines the index of first vertex to draw
  52663. * @param verticesCount defines the count of vertices to draw
  52664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52665. */
  52666. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52667. createPipelineContext(): IPipelineContext;
  52668. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52669. /** @hidden */
  52670. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52671. /** @hidden */
  52672. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52673. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52674. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52675. protected _setProgram(program: WebGLProgram): void;
  52676. _releaseEffect(effect: Effect): void;
  52677. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52678. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52679. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52680. bindSamplers(effect: Effect): void;
  52681. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52682. getRenderWidth(useScreen?: boolean): number;
  52683. getRenderHeight(useScreen?: boolean): number;
  52684. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52685. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52686. /**
  52687. * Set the z offset to apply to current rendering
  52688. * @param value defines the offset to apply
  52689. */
  52690. setZOffset(value: number): void;
  52691. /**
  52692. * Gets the current value of the zOffset
  52693. * @returns the current zOffset state
  52694. */
  52695. getZOffset(): number;
  52696. /**
  52697. * Enable or disable depth buffering
  52698. * @param enable defines the state to set
  52699. */
  52700. setDepthBuffer(enable: boolean): void;
  52701. /**
  52702. * Gets a boolean indicating if depth writing is enabled
  52703. * @returns the current depth writing state
  52704. */
  52705. getDepthWrite(): boolean;
  52706. /**
  52707. * Enable or disable depth writing
  52708. * @param enable defines the state to set
  52709. */
  52710. setDepthWrite(enable: boolean): void;
  52711. /**
  52712. * Enable or disable color writing
  52713. * @param enable defines the state to set
  52714. */
  52715. setColorWrite(enable: boolean): void;
  52716. /**
  52717. * Gets a boolean indicating if color writing is enabled
  52718. * @returns the current color writing state
  52719. */
  52720. getColorWrite(): boolean;
  52721. /**
  52722. * Sets alpha constants used by some alpha blending modes
  52723. * @param r defines the red component
  52724. * @param g defines the green component
  52725. * @param b defines the blue component
  52726. * @param a defines the alpha component
  52727. */
  52728. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52729. /**
  52730. * Sets the current alpha mode
  52731. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52732. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52733. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52734. */
  52735. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52736. /**
  52737. * Gets the current alpha mode
  52738. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52739. * @returns the current alpha mode
  52740. */
  52741. getAlphaMode(): number;
  52742. setInt(uniform: WebGLUniformLocation, int: number): void;
  52743. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52744. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52745. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52746. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52747. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52748. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52749. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52750. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52751. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52752. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52753. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52754. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52755. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52756. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52757. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52758. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52759. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52760. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52761. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52762. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52763. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52764. wipeCaches(bruteForce?: boolean): void;
  52765. _createTexture(): WebGLTexture;
  52766. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52767. /**
  52768. * Usually called from Texture.ts.
  52769. * Passed information to create a WebGLTexture
  52770. * @param url defines a value which contains one of the following:
  52771. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52772. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52773. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52774. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52775. * @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)
  52776. * @param scene needed for loading to the correct scene
  52777. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52778. * @param onLoad optional callback to be called upon successful completion
  52779. * @param onError optional callback to be called upon failure
  52780. * @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
  52781. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52782. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52783. * @param forcedExtension defines the extension to use to pick the right loader
  52784. * @param mimeType defines an optional mime type
  52785. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52786. */
  52787. 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;
  52788. /**
  52789. * Creates a cube texture
  52790. * @param rootUrl defines the url where the files to load is located
  52791. * @param scene defines the current scene
  52792. * @param files defines the list of files to load (1 per face)
  52793. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52794. * @param onLoad defines an optional callback raised when the texture is loaded
  52795. * @param onError defines an optional callback raised if there is an issue to load the texture
  52796. * @param format defines the format of the data
  52797. * @param forcedExtension defines the extension to use to pick the right loader
  52798. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52799. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52800. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52801. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52802. * @returns the cube texture as an InternalTexture
  52803. */
  52804. 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;
  52805. private _getSamplingFilter;
  52806. private static _GetNativeTextureFormat;
  52807. createRenderTargetTexture(size: number | {
  52808. width: number;
  52809. height: number;
  52810. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52811. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52812. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52813. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52814. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52815. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52816. /**
  52817. * Updates a dynamic vertex buffer.
  52818. * @param vertexBuffer the vertex buffer to update
  52819. * @param data the data used to update the vertex buffer
  52820. * @param byteOffset the byte offset of the data (optional)
  52821. * @param byteLength the byte length of the data (optional)
  52822. */
  52823. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52824. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52825. private _updateAnisotropicLevel;
  52826. private _getAddressMode;
  52827. /** @hidden */
  52828. _bindTexture(channel: number, texture: InternalTexture): void;
  52829. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52830. releaseEffects(): void;
  52831. /** @hidden */
  52832. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52833. /** @hidden */
  52834. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52835. /** @hidden */
  52836. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52837. /** @hidden */
  52838. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52839. }
  52840. }
  52841. declare module BABYLON {
  52842. /**
  52843. * Gather the list of clipboard event types as constants.
  52844. */
  52845. export class ClipboardEventTypes {
  52846. /**
  52847. * The clipboard event is fired when a copy command is active (pressed).
  52848. */
  52849. static readonly COPY: number;
  52850. /**
  52851. * The clipboard event is fired when a cut command is active (pressed).
  52852. */
  52853. static readonly CUT: number;
  52854. /**
  52855. * The clipboard event is fired when a paste command is active (pressed).
  52856. */
  52857. static readonly PASTE: number;
  52858. }
  52859. /**
  52860. * This class is used to store clipboard related info for the onClipboardObservable event.
  52861. */
  52862. export class ClipboardInfo {
  52863. /**
  52864. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52865. */
  52866. type: number;
  52867. /**
  52868. * Defines the related dom event
  52869. */
  52870. event: ClipboardEvent;
  52871. /**
  52872. *Creates an instance of ClipboardInfo.
  52873. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52874. * @param event Defines the related dom event
  52875. */
  52876. constructor(
  52877. /**
  52878. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52879. */
  52880. type: number,
  52881. /**
  52882. * Defines the related dom event
  52883. */
  52884. event: ClipboardEvent);
  52885. /**
  52886. * Get the clipboard event's type from the keycode.
  52887. * @param keyCode Defines the keyCode for the current keyboard event.
  52888. * @return {number}
  52889. */
  52890. static GetTypeFromCharacter(keyCode: number): number;
  52891. }
  52892. }
  52893. declare module BABYLON {
  52894. /**
  52895. * Google Daydream controller
  52896. */
  52897. export class DaydreamController extends WebVRController {
  52898. /**
  52899. * Base Url for the controller model.
  52900. */
  52901. static MODEL_BASE_URL: string;
  52902. /**
  52903. * File name for the controller model.
  52904. */
  52905. static MODEL_FILENAME: string;
  52906. /**
  52907. * Gamepad Id prefix used to identify Daydream Controller.
  52908. */
  52909. static readonly GAMEPAD_ID_PREFIX: string;
  52910. /**
  52911. * Creates a new DaydreamController from a gamepad
  52912. * @param vrGamepad the gamepad that the controller should be created from
  52913. */
  52914. constructor(vrGamepad: any);
  52915. /**
  52916. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52917. * @param scene scene in which to add meshes
  52918. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52919. */
  52920. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52921. /**
  52922. * Called once for each button that changed state since the last frame
  52923. * @param buttonIdx Which button index changed
  52924. * @param state New state of the button
  52925. * @param changes Which properties on the state changed since last frame
  52926. */
  52927. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52928. }
  52929. }
  52930. declare module BABYLON {
  52931. /**
  52932. * Gear VR Controller
  52933. */
  52934. export class GearVRController extends WebVRController {
  52935. /**
  52936. * Base Url for the controller model.
  52937. */
  52938. static MODEL_BASE_URL: string;
  52939. /**
  52940. * File name for the controller model.
  52941. */
  52942. static MODEL_FILENAME: string;
  52943. /**
  52944. * Gamepad Id prefix used to identify this controller.
  52945. */
  52946. static readonly GAMEPAD_ID_PREFIX: string;
  52947. private readonly _buttonIndexToObservableNameMap;
  52948. /**
  52949. * Creates a new GearVRController from a gamepad
  52950. * @param vrGamepad the gamepad that the controller should be created from
  52951. */
  52952. constructor(vrGamepad: any);
  52953. /**
  52954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52955. * @param scene scene in which to add meshes
  52956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52957. */
  52958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52959. /**
  52960. * Called once for each button that changed state since the last frame
  52961. * @param buttonIdx Which button index changed
  52962. * @param state New state of the button
  52963. * @param changes Which properties on the state changed since last frame
  52964. */
  52965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52966. }
  52967. }
  52968. declare module BABYLON {
  52969. /**
  52970. * Generic Controller
  52971. */
  52972. export class GenericController extends WebVRController {
  52973. /**
  52974. * Base Url for the controller model.
  52975. */
  52976. static readonly MODEL_BASE_URL: string;
  52977. /**
  52978. * File name for the controller model.
  52979. */
  52980. static readonly MODEL_FILENAME: string;
  52981. /**
  52982. * Creates a new GenericController from a gamepad
  52983. * @param vrGamepad the gamepad that the controller should be created from
  52984. */
  52985. constructor(vrGamepad: any);
  52986. /**
  52987. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52988. * @param scene scene in which to add meshes
  52989. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52990. */
  52991. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52992. /**
  52993. * Called once for each button that changed state since the last frame
  52994. * @param buttonIdx Which button index changed
  52995. * @param state New state of the button
  52996. * @param changes Which properties on the state changed since last frame
  52997. */
  52998. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52999. }
  53000. }
  53001. declare module BABYLON {
  53002. /**
  53003. * Oculus Touch Controller
  53004. */
  53005. export class OculusTouchController extends WebVRController {
  53006. /**
  53007. * Base Url for the controller model.
  53008. */
  53009. static MODEL_BASE_URL: string;
  53010. /**
  53011. * File name for the left controller model.
  53012. */
  53013. static MODEL_LEFT_FILENAME: string;
  53014. /**
  53015. * File name for the right controller model.
  53016. */
  53017. static MODEL_RIGHT_FILENAME: string;
  53018. /**
  53019. * Base Url for the Quest controller model.
  53020. */
  53021. static QUEST_MODEL_BASE_URL: string;
  53022. /**
  53023. * @hidden
  53024. * If the controllers are running on a device that needs the updated Quest controller models
  53025. */
  53026. static _IsQuest: boolean;
  53027. /**
  53028. * Fired when the secondary trigger on this controller is modified
  53029. */
  53030. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53031. /**
  53032. * Fired when the thumb rest on this controller is modified
  53033. */
  53034. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53035. /**
  53036. * Creates a new OculusTouchController from a gamepad
  53037. * @param vrGamepad the gamepad that the controller should be created from
  53038. */
  53039. constructor(vrGamepad: any);
  53040. /**
  53041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53042. * @param scene scene in which to add meshes
  53043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53044. */
  53045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53046. /**
  53047. * Fired when the A button on this controller is modified
  53048. */
  53049. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53050. /**
  53051. * Fired when the B button on this controller is modified
  53052. */
  53053. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53054. /**
  53055. * Fired when the X button on this controller is modified
  53056. */
  53057. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53058. /**
  53059. * Fired when the Y button on this controller is modified
  53060. */
  53061. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53062. /**
  53063. * Called once for each button that changed state since the last frame
  53064. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53065. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53066. * 2) secondary trigger (same)
  53067. * 3) A (right) X (left), touch, pressed = value
  53068. * 4) B / Y
  53069. * 5) thumb rest
  53070. * @param buttonIdx Which button index changed
  53071. * @param state New state of the button
  53072. * @param changes Which properties on the state changed since last frame
  53073. */
  53074. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53075. }
  53076. }
  53077. declare module BABYLON {
  53078. /**
  53079. * Vive Controller
  53080. */
  53081. export class ViveController extends WebVRController {
  53082. /**
  53083. * Base Url for the controller model.
  53084. */
  53085. static MODEL_BASE_URL: string;
  53086. /**
  53087. * File name for the controller model.
  53088. */
  53089. static MODEL_FILENAME: string;
  53090. /**
  53091. * Creates a new ViveController from a gamepad
  53092. * @param vrGamepad the gamepad that the controller should be created from
  53093. */
  53094. constructor(vrGamepad: any);
  53095. /**
  53096. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53097. * @param scene scene in which to add meshes
  53098. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53099. */
  53100. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53101. /**
  53102. * Fired when the left button on this controller is modified
  53103. */
  53104. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53105. /**
  53106. * Fired when the right button on this controller is modified
  53107. */
  53108. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53109. /**
  53110. * Fired when the menu button on this controller is modified
  53111. */
  53112. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53113. /**
  53114. * Called once for each button that changed state since the last frame
  53115. * Vive mapping:
  53116. * 0: touchpad
  53117. * 1: trigger
  53118. * 2: left AND right buttons
  53119. * 3: menu button
  53120. * @param buttonIdx Which button index changed
  53121. * @param state New state of the button
  53122. * @param changes Which properties on the state changed since last frame
  53123. */
  53124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53125. }
  53126. }
  53127. declare module BABYLON {
  53128. /**
  53129. * Defines the WindowsMotionController object that the state of the windows motion controller
  53130. */
  53131. export class WindowsMotionController extends WebVRController {
  53132. /**
  53133. * The base url used to load the left and right controller models
  53134. */
  53135. static MODEL_BASE_URL: string;
  53136. /**
  53137. * The name of the left controller model file
  53138. */
  53139. static MODEL_LEFT_FILENAME: string;
  53140. /**
  53141. * The name of the right controller model file
  53142. */
  53143. static MODEL_RIGHT_FILENAME: string;
  53144. /**
  53145. * The controller name prefix for this controller type
  53146. */
  53147. static readonly GAMEPAD_ID_PREFIX: string;
  53148. /**
  53149. * The controller id pattern for this controller type
  53150. */
  53151. private static readonly GAMEPAD_ID_PATTERN;
  53152. private _loadedMeshInfo;
  53153. protected readonly _mapping: {
  53154. buttons: string[];
  53155. buttonMeshNames: {
  53156. trigger: string;
  53157. menu: string;
  53158. grip: string;
  53159. thumbstick: string;
  53160. trackpad: string;
  53161. };
  53162. buttonObservableNames: {
  53163. trigger: string;
  53164. menu: string;
  53165. grip: string;
  53166. thumbstick: string;
  53167. trackpad: string;
  53168. };
  53169. axisMeshNames: string[];
  53170. pointingPoseMeshName: string;
  53171. };
  53172. /**
  53173. * Fired when the trackpad on this controller is clicked
  53174. */
  53175. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53176. /**
  53177. * Fired when the trackpad on this controller is modified
  53178. */
  53179. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53180. /**
  53181. * The current x and y values of this controller's trackpad
  53182. */
  53183. trackpad: StickValues;
  53184. /**
  53185. * Creates a new WindowsMotionController from a gamepad
  53186. * @param vrGamepad the gamepad that the controller should be created from
  53187. */
  53188. constructor(vrGamepad: any);
  53189. /**
  53190. * Fired when the trigger on this controller is modified
  53191. */
  53192. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53193. /**
  53194. * Fired when the menu button on this controller is modified
  53195. */
  53196. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53197. /**
  53198. * Fired when the grip button on this controller is modified
  53199. */
  53200. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53201. /**
  53202. * Fired when the thumbstick button on this controller is modified
  53203. */
  53204. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53205. /**
  53206. * Fired when the touchpad button on this controller is modified
  53207. */
  53208. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53209. /**
  53210. * Fired when the touchpad values on this controller are modified
  53211. */
  53212. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53213. protected _updateTrackpad(): void;
  53214. /**
  53215. * Called once per frame by the engine.
  53216. */
  53217. update(): void;
  53218. /**
  53219. * Called once for each button that changed state since the last frame
  53220. * @param buttonIdx Which button index changed
  53221. * @param state New state of the button
  53222. * @param changes Which properties on the state changed since last frame
  53223. */
  53224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53225. /**
  53226. * Moves the buttons on the controller mesh based on their current state
  53227. * @param buttonName the name of the button to move
  53228. * @param buttonValue the value of the button which determines the buttons new position
  53229. */
  53230. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53231. /**
  53232. * Moves the axis on the controller mesh based on its current state
  53233. * @param axis the index of the axis
  53234. * @param axisValue the value of the axis which determines the meshes new position
  53235. * @hidden
  53236. */
  53237. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53238. /**
  53239. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53240. * @param scene scene in which to add meshes
  53241. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53242. */
  53243. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53244. /**
  53245. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53246. * can be transformed by button presses and axes values, based on this._mapping.
  53247. *
  53248. * @param scene scene in which the meshes exist
  53249. * @param meshes list of meshes that make up the controller model to process
  53250. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53251. */
  53252. private processModel;
  53253. private createMeshInfo;
  53254. /**
  53255. * Gets the ray of the controller in the direction the controller is pointing
  53256. * @param length the length the resulting ray should be
  53257. * @returns a ray in the direction the controller is pointing
  53258. */
  53259. getForwardRay(length?: number): Ray;
  53260. /**
  53261. * Disposes of the controller
  53262. */
  53263. dispose(): void;
  53264. }
  53265. /**
  53266. * This class represents a new windows motion controller in XR.
  53267. */
  53268. export class XRWindowsMotionController extends WindowsMotionController {
  53269. /**
  53270. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53271. */
  53272. protected readonly _mapping: {
  53273. buttons: string[];
  53274. buttonMeshNames: {
  53275. trigger: string;
  53276. menu: string;
  53277. grip: string;
  53278. thumbstick: string;
  53279. trackpad: string;
  53280. };
  53281. buttonObservableNames: {
  53282. trigger: string;
  53283. menu: string;
  53284. grip: string;
  53285. thumbstick: string;
  53286. trackpad: string;
  53287. };
  53288. axisMeshNames: string[];
  53289. pointingPoseMeshName: string;
  53290. };
  53291. /**
  53292. * Construct a new XR-Based windows motion controller
  53293. *
  53294. * @param gamepadInfo the gamepad object from the browser
  53295. */
  53296. constructor(gamepadInfo: any);
  53297. /**
  53298. * holds the thumbstick values (X,Y)
  53299. */
  53300. thumbstickValues: StickValues;
  53301. /**
  53302. * Fired when the thumbstick on this controller is clicked
  53303. */
  53304. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53305. /**
  53306. * Fired when the thumbstick on this controller is modified
  53307. */
  53308. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53309. /**
  53310. * Fired when the touchpad button on this controller is modified
  53311. */
  53312. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53313. /**
  53314. * Fired when the touchpad values on this controller are modified
  53315. */
  53316. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53317. /**
  53318. * Fired when the thumbstick button on this controller is modified
  53319. * here to prevent breaking changes
  53320. */
  53321. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53322. /**
  53323. * updating the thumbstick(!) and not the trackpad.
  53324. * This is named this way due to the difference between WebVR and XR and to avoid
  53325. * changing the parent class.
  53326. */
  53327. protected _updateTrackpad(): void;
  53328. /**
  53329. * Disposes the class with joy
  53330. */
  53331. dispose(): void;
  53332. }
  53333. }
  53334. declare module BABYLON {
  53335. /**
  53336. * Class containing static functions to help procedurally build meshes
  53337. */
  53338. export class PolyhedronBuilder {
  53339. /**
  53340. * Creates a polyhedron mesh
  53341. * * 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
  53342. * * The parameter `size` (positive float, default 1) sets the polygon size
  53343. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53344. * * 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`
  53345. * * 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
  53346. * * 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)`)
  53347. * * 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
  53348. * * 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
  53349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53350. * * 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
  53351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53352. * @param name defines the name of the mesh
  53353. * @param options defines the options used to create the mesh
  53354. * @param scene defines the hosting scene
  53355. * @returns the polyhedron mesh
  53356. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53357. */
  53358. static CreatePolyhedron(name: string, options: {
  53359. type?: number;
  53360. size?: number;
  53361. sizeX?: number;
  53362. sizeY?: number;
  53363. sizeZ?: number;
  53364. custom?: any;
  53365. faceUV?: Vector4[];
  53366. faceColors?: Color4[];
  53367. flat?: boolean;
  53368. updatable?: boolean;
  53369. sideOrientation?: number;
  53370. frontUVs?: Vector4;
  53371. backUVs?: Vector4;
  53372. }, scene?: Nullable<Scene>): Mesh;
  53373. }
  53374. }
  53375. declare module BABYLON {
  53376. /**
  53377. * Gizmo that enables scaling a mesh along 3 axis
  53378. */
  53379. export class ScaleGizmo extends Gizmo {
  53380. /**
  53381. * Internal gizmo used for interactions on the x axis
  53382. */
  53383. xGizmo: AxisScaleGizmo;
  53384. /**
  53385. * Internal gizmo used for interactions on the y axis
  53386. */
  53387. yGizmo: AxisScaleGizmo;
  53388. /**
  53389. * Internal gizmo used for interactions on the z axis
  53390. */
  53391. zGizmo: AxisScaleGizmo;
  53392. /**
  53393. * Internal gizmo used to scale all axis equally
  53394. */
  53395. uniformScaleGizmo: AxisScaleGizmo;
  53396. private _meshAttached;
  53397. private _nodeAttached;
  53398. private _snapDistance;
  53399. private _uniformScalingMesh;
  53400. private _octahedron;
  53401. private _sensitivity;
  53402. /** Fires an event when any of it's sub gizmos are dragged */
  53403. onDragStartObservable: Observable<unknown>;
  53404. /** Fires an event when any of it's sub gizmos are released from dragging */
  53405. onDragEndObservable: Observable<unknown>;
  53406. get attachedMesh(): Nullable<AbstractMesh>;
  53407. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53408. get attachedNode(): Nullable<Node>;
  53409. set attachedNode(node: Nullable<Node>);
  53410. /**
  53411. * Creates a ScaleGizmo
  53412. * @param gizmoLayer The utility layer the gizmo will be added to
  53413. * @param thickness display gizmo axis thickness
  53414. */
  53415. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53416. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53417. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53418. /**
  53419. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53420. */
  53421. set snapDistance(value: number);
  53422. get snapDistance(): number;
  53423. /**
  53424. * Ratio for the scale of the gizmo (Default: 1)
  53425. */
  53426. set scaleRatio(value: number);
  53427. get scaleRatio(): number;
  53428. /**
  53429. * Sensitivity factor for dragging (Default: 1)
  53430. */
  53431. set sensitivity(value: number);
  53432. get sensitivity(): number;
  53433. /**
  53434. * Disposes of the gizmo
  53435. */
  53436. dispose(): void;
  53437. }
  53438. }
  53439. declare module BABYLON {
  53440. /**
  53441. * Single axis scale gizmo
  53442. */
  53443. export class AxisScaleGizmo extends Gizmo {
  53444. /**
  53445. * Drag behavior responsible for the gizmos dragging interactions
  53446. */
  53447. dragBehavior: PointerDragBehavior;
  53448. private _pointerObserver;
  53449. /**
  53450. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53451. */
  53452. snapDistance: number;
  53453. /**
  53454. * Event that fires each time the gizmo snaps to a new location.
  53455. * * snapDistance is the the change in distance
  53456. */
  53457. onSnapObservable: Observable<{
  53458. snapDistance: number;
  53459. }>;
  53460. /**
  53461. * If the scaling operation should be done on all axis (default: false)
  53462. */
  53463. uniformScaling: boolean;
  53464. /**
  53465. * Custom sensitivity value for the drag strength
  53466. */
  53467. sensitivity: number;
  53468. private _isEnabled;
  53469. private _parent;
  53470. private _arrow;
  53471. private _coloredMaterial;
  53472. private _hoverMaterial;
  53473. /**
  53474. * Creates an AxisScaleGizmo
  53475. * @param gizmoLayer The utility layer the gizmo will be added to
  53476. * @param dragAxis The axis which the gizmo will be able to scale on
  53477. * @param color The color of the gizmo
  53478. * @param thickness display gizmo axis thickness
  53479. */
  53480. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53481. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53482. /**
  53483. * If the gizmo is enabled
  53484. */
  53485. set isEnabled(value: boolean);
  53486. get isEnabled(): boolean;
  53487. /**
  53488. * Disposes of the gizmo
  53489. */
  53490. dispose(): void;
  53491. /**
  53492. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53493. * @param mesh The mesh to replace the default mesh of the gizmo
  53494. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53495. */
  53496. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53497. }
  53498. }
  53499. declare module BABYLON {
  53500. /**
  53501. * Bounding box gizmo
  53502. */
  53503. export class BoundingBoxGizmo extends Gizmo {
  53504. private _lineBoundingBox;
  53505. private _rotateSpheresParent;
  53506. private _scaleBoxesParent;
  53507. private _boundingDimensions;
  53508. private _renderObserver;
  53509. private _pointerObserver;
  53510. private _scaleDragSpeed;
  53511. private _tmpQuaternion;
  53512. private _tmpVector;
  53513. private _tmpRotationMatrix;
  53514. /**
  53515. * 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)
  53516. */
  53517. ignoreChildren: boolean;
  53518. /**
  53519. * 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)
  53520. */
  53521. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53522. /**
  53523. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53524. */
  53525. rotationSphereSize: number;
  53526. /**
  53527. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53528. */
  53529. scaleBoxSize: number;
  53530. /**
  53531. * 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)
  53532. */
  53533. fixedDragMeshScreenSize: boolean;
  53534. /**
  53535. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53536. */
  53537. fixedDragMeshScreenSizeDistanceFactor: number;
  53538. /**
  53539. * Fired when a rotation sphere or scale box is dragged
  53540. */
  53541. onDragStartObservable: Observable<{}>;
  53542. /**
  53543. * Fired when a scale box is dragged
  53544. */
  53545. onScaleBoxDragObservable: Observable<{}>;
  53546. /**
  53547. * Fired when a scale box drag is ended
  53548. */
  53549. onScaleBoxDragEndObservable: Observable<{}>;
  53550. /**
  53551. * Fired when a rotation sphere is dragged
  53552. */
  53553. onRotationSphereDragObservable: Observable<{}>;
  53554. /**
  53555. * Fired when a rotation sphere drag is ended
  53556. */
  53557. onRotationSphereDragEndObservable: Observable<{}>;
  53558. /**
  53559. * 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)
  53560. */
  53561. scalePivot: Nullable<Vector3>;
  53562. /**
  53563. * Mesh used as a pivot to rotate the attached node
  53564. */
  53565. private _anchorMesh;
  53566. private _existingMeshScale;
  53567. private _dragMesh;
  53568. private pointerDragBehavior;
  53569. private coloredMaterial;
  53570. private hoverColoredMaterial;
  53571. /**
  53572. * Sets the color of the bounding box gizmo
  53573. * @param color the color to set
  53574. */
  53575. setColor(color: Color3): void;
  53576. /**
  53577. * Creates an BoundingBoxGizmo
  53578. * @param gizmoLayer The utility layer the gizmo will be added to
  53579. * @param color The color of the gizmo
  53580. */
  53581. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53582. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53583. private _selectNode;
  53584. /**
  53585. * Updates the bounding box information for the Gizmo
  53586. */
  53587. updateBoundingBox(): void;
  53588. private _updateRotationSpheres;
  53589. private _updateScaleBoxes;
  53590. /**
  53591. * Enables rotation on the specified axis and disables rotation on the others
  53592. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53593. */
  53594. setEnabledRotationAxis(axis: string): void;
  53595. /**
  53596. * Enables/disables scaling
  53597. * @param enable if scaling should be enabled
  53598. * @param homogeneousScaling defines if scaling should only be homogeneous
  53599. */
  53600. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53601. private _updateDummy;
  53602. /**
  53603. * Enables a pointer drag behavior on the bounding box of the gizmo
  53604. */
  53605. enableDragBehavior(): void;
  53606. /**
  53607. * Disposes of the gizmo
  53608. */
  53609. dispose(): void;
  53610. /**
  53611. * 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)
  53612. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53613. * @returns the bounding box mesh with the passed in mesh as a child
  53614. */
  53615. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53616. /**
  53617. * CustomMeshes are not supported by this gizmo
  53618. * @param mesh The mesh to replace the default mesh of the gizmo
  53619. */
  53620. setCustomMesh(mesh: Mesh): void;
  53621. }
  53622. }
  53623. declare module BABYLON {
  53624. /**
  53625. * Single plane rotation gizmo
  53626. */
  53627. export class PlaneRotationGizmo extends Gizmo {
  53628. /**
  53629. * Drag behavior responsible for the gizmos dragging interactions
  53630. */
  53631. dragBehavior: PointerDragBehavior;
  53632. private _pointerObserver;
  53633. /**
  53634. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53635. */
  53636. snapDistance: number;
  53637. /**
  53638. * Event that fires each time the gizmo snaps to a new location.
  53639. * * snapDistance is the the change in distance
  53640. */
  53641. onSnapObservable: Observable<{
  53642. snapDistance: number;
  53643. }>;
  53644. private _isEnabled;
  53645. private _parent;
  53646. /**
  53647. * Creates a PlaneRotationGizmo
  53648. * @param gizmoLayer The utility layer the gizmo will be added to
  53649. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53650. * @param color The color of the gizmo
  53651. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53652. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53653. * @param thickness display gizmo axis thickness
  53654. */
  53655. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53656. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53657. /**
  53658. * If the gizmo is enabled
  53659. */
  53660. set isEnabled(value: boolean);
  53661. get isEnabled(): boolean;
  53662. /**
  53663. * Disposes of the gizmo
  53664. */
  53665. dispose(): void;
  53666. }
  53667. }
  53668. declare module BABYLON {
  53669. /**
  53670. * Gizmo that enables rotating a mesh along 3 axis
  53671. */
  53672. export class RotationGizmo extends Gizmo {
  53673. /**
  53674. * Internal gizmo used for interactions on the x axis
  53675. */
  53676. xGizmo: PlaneRotationGizmo;
  53677. /**
  53678. * Internal gizmo used for interactions on the y axis
  53679. */
  53680. yGizmo: PlaneRotationGizmo;
  53681. /**
  53682. * Internal gizmo used for interactions on the z axis
  53683. */
  53684. zGizmo: PlaneRotationGizmo;
  53685. /** Fires an event when any of it's sub gizmos are dragged */
  53686. onDragStartObservable: Observable<unknown>;
  53687. /** Fires an event when any of it's sub gizmos are released from dragging */
  53688. onDragEndObservable: Observable<unknown>;
  53689. private _meshAttached;
  53690. private _nodeAttached;
  53691. get attachedMesh(): Nullable<AbstractMesh>;
  53692. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53693. get attachedNode(): Nullable<Node>;
  53694. set attachedNode(node: Nullable<Node>);
  53695. /**
  53696. * Creates a RotationGizmo
  53697. * @param gizmoLayer The utility layer the gizmo will be added to
  53698. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53699. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53700. * @param thickness display gizmo axis thickness
  53701. */
  53702. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53703. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53704. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53705. /**
  53706. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53707. */
  53708. set snapDistance(value: number);
  53709. get snapDistance(): number;
  53710. /**
  53711. * Ratio for the scale of the gizmo (Default: 1)
  53712. */
  53713. set scaleRatio(value: number);
  53714. get scaleRatio(): number;
  53715. /**
  53716. * Disposes of the gizmo
  53717. */
  53718. dispose(): void;
  53719. /**
  53720. * CustomMeshes are not supported by this gizmo
  53721. * @param mesh The mesh to replace the default mesh of the gizmo
  53722. */
  53723. setCustomMesh(mesh: Mesh): void;
  53724. }
  53725. }
  53726. declare module BABYLON {
  53727. /**
  53728. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53729. */
  53730. export class GizmoManager implements IDisposable {
  53731. private scene;
  53732. /**
  53733. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53734. */
  53735. gizmos: {
  53736. positionGizmo: Nullable<PositionGizmo>;
  53737. rotationGizmo: Nullable<RotationGizmo>;
  53738. scaleGizmo: Nullable<ScaleGizmo>;
  53739. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53740. };
  53741. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53742. clearGizmoOnEmptyPointerEvent: boolean;
  53743. /** Fires an event when the manager is attached to a mesh */
  53744. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53745. /** Fires an event when the manager is attached to a node */
  53746. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53747. private _gizmosEnabled;
  53748. private _pointerObserver;
  53749. private _attachedMesh;
  53750. private _attachedNode;
  53751. private _boundingBoxColor;
  53752. private _defaultUtilityLayer;
  53753. private _defaultKeepDepthUtilityLayer;
  53754. private _thickness;
  53755. /**
  53756. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53757. */
  53758. boundingBoxDragBehavior: SixDofDragBehavior;
  53759. /**
  53760. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53761. */
  53762. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53763. /**
  53764. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53765. */
  53766. attachableNodes: Nullable<Array<Node>>;
  53767. /**
  53768. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53769. */
  53770. usePointerToAttachGizmos: boolean;
  53771. /**
  53772. * Utility layer that the bounding box gizmo belongs to
  53773. */
  53774. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53775. /**
  53776. * Utility layer that all gizmos besides bounding box belong to
  53777. */
  53778. get utilityLayer(): UtilityLayerRenderer;
  53779. /**
  53780. * Instatiates a gizmo manager
  53781. * @param scene the scene to overlay the gizmos on top of
  53782. * @param thickness display gizmo axis thickness
  53783. */
  53784. constructor(scene: Scene, thickness?: number);
  53785. /**
  53786. * Attaches a set of gizmos to the specified mesh
  53787. * @param mesh The mesh the gizmo's should be attached to
  53788. */
  53789. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53790. /**
  53791. * Attaches a set of gizmos to the specified node
  53792. * @param node The node the gizmo's should be attached to
  53793. */
  53794. attachToNode(node: Nullable<Node>): void;
  53795. /**
  53796. * If the position gizmo is enabled
  53797. */
  53798. set positionGizmoEnabled(value: boolean);
  53799. get positionGizmoEnabled(): boolean;
  53800. /**
  53801. * If the rotation gizmo is enabled
  53802. */
  53803. set rotationGizmoEnabled(value: boolean);
  53804. get rotationGizmoEnabled(): boolean;
  53805. /**
  53806. * If the scale gizmo is enabled
  53807. */
  53808. set scaleGizmoEnabled(value: boolean);
  53809. get scaleGizmoEnabled(): boolean;
  53810. /**
  53811. * If the boundingBox gizmo is enabled
  53812. */
  53813. set boundingBoxGizmoEnabled(value: boolean);
  53814. get boundingBoxGizmoEnabled(): boolean;
  53815. /**
  53816. * Disposes of the gizmo manager
  53817. */
  53818. dispose(): void;
  53819. }
  53820. }
  53821. declare module BABYLON {
  53822. /**
  53823. * A directional light is defined by a direction (what a surprise!).
  53824. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53825. * 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.
  53826. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53827. */
  53828. export class DirectionalLight extends ShadowLight {
  53829. private _shadowFrustumSize;
  53830. /**
  53831. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53832. */
  53833. get shadowFrustumSize(): number;
  53834. /**
  53835. * Specifies a fix frustum size for the shadow generation.
  53836. */
  53837. set shadowFrustumSize(value: number);
  53838. private _shadowOrthoScale;
  53839. /**
  53840. * Gets the shadow projection scale against the optimal computed one.
  53841. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53842. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53843. */
  53844. get shadowOrthoScale(): number;
  53845. /**
  53846. * Sets the shadow projection scale against the optimal computed one.
  53847. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53848. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53849. */
  53850. set shadowOrthoScale(value: number);
  53851. /**
  53852. * Automatically compute the projection matrix to best fit (including all the casters)
  53853. * on each frame.
  53854. */
  53855. autoUpdateExtends: boolean;
  53856. /**
  53857. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53858. * on each frame. autoUpdateExtends must be set to true for this to work
  53859. */
  53860. autoCalcShadowZBounds: boolean;
  53861. private _orthoLeft;
  53862. private _orthoRight;
  53863. private _orthoTop;
  53864. private _orthoBottom;
  53865. /**
  53866. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53867. * The directional light is emitted from everywhere in the given direction.
  53868. * It can cast shadows.
  53869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53870. * @param name The friendly name of the light
  53871. * @param direction The direction of the light
  53872. * @param scene The scene the light belongs to
  53873. */
  53874. constructor(name: string, direction: Vector3, scene: Scene);
  53875. /**
  53876. * Returns the string "DirectionalLight".
  53877. * @return The class name
  53878. */
  53879. getClassName(): string;
  53880. /**
  53881. * Returns the integer 1.
  53882. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53883. */
  53884. getTypeID(): number;
  53885. /**
  53886. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53887. * Returns the DirectionalLight Shadow projection matrix.
  53888. */
  53889. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53890. /**
  53891. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53892. * Returns the DirectionalLight Shadow projection matrix.
  53893. */
  53894. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53895. /**
  53896. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53897. * Returns the DirectionalLight Shadow projection matrix.
  53898. */
  53899. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53900. protected _buildUniformLayout(): void;
  53901. /**
  53902. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53903. * @param effect The effect to update
  53904. * @param lightIndex The index of the light in the effect to update
  53905. * @returns The directional light
  53906. */
  53907. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53908. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53909. /**
  53910. * Gets the minZ used for shadow according to both the scene and the light.
  53911. *
  53912. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53913. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53914. * @param activeCamera The camera we are returning the min for
  53915. * @returns the depth min z
  53916. */
  53917. getDepthMinZ(activeCamera: Camera): number;
  53918. /**
  53919. * Gets the maxZ used for shadow according to both the scene and the light.
  53920. *
  53921. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53922. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53923. * @param activeCamera The camera we are returning the max for
  53924. * @returns the depth max z
  53925. */
  53926. getDepthMaxZ(activeCamera: Camera): number;
  53927. /**
  53928. * Prepares the list of defines specific to the light type.
  53929. * @param defines the list of defines
  53930. * @param lightIndex defines the index of the light for the effect
  53931. */
  53932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /**
  53937. * Class containing static functions to help procedurally build meshes
  53938. */
  53939. export class HemisphereBuilder {
  53940. /**
  53941. * Creates a hemisphere mesh
  53942. * @param name defines the name of the mesh
  53943. * @param options defines the options used to create the mesh
  53944. * @param scene defines the hosting scene
  53945. * @returns the hemisphere mesh
  53946. */
  53947. static CreateHemisphere(name: string, options: {
  53948. segments?: number;
  53949. diameter?: number;
  53950. sideOrientation?: number;
  53951. }, scene: any): Mesh;
  53952. }
  53953. }
  53954. declare module BABYLON {
  53955. /**
  53956. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53957. * These values define a cone of light starting from the position, emitting toward the direction.
  53958. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53959. * and the exponent defines the speed of the decay of the light with distance (reach).
  53960. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53961. */
  53962. export class SpotLight extends ShadowLight {
  53963. private _angle;
  53964. private _innerAngle;
  53965. private _cosHalfAngle;
  53966. private _lightAngleScale;
  53967. private _lightAngleOffset;
  53968. /**
  53969. * Gets the cone angle of the spot light in Radians.
  53970. */
  53971. get angle(): number;
  53972. /**
  53973. * Sets the cone angle of the spot light in Radians.
  53974. */
  53975. set angle(value: number);
  53976. /**
  53977. * Only used in gltf falloff mode, this defines the angle where
  53978. * the directional falloff will start before cutting at angle which could be seen
  53979. * as outer angle.
  53980. */
  53981. get innerAngle(): number;
  53982. /**
  53983. * Only used in gltf falloff mode, this defines the angle where
  53984. * the directional falloff will start before cutting at angle which could be seen
  53985. * as outer angle.
  53986. */
  53987. set innerAngle(value: number);
  53988. private _shadowAngleScale;
  53989. /**
  53990. * Allows scaling the angle of the light for shadow generation only.
  53991. */
  53992. get shadowAngleScale(): number;
  53993. /**
  53994. * Allows scaling the angle of the light for shadow generation only.
  53995. */
  53996. set shadowAngleScale(value: number);
  53997. /**
  53998. * The light decay speed with the distance from the emission spot.
  53999. */
  54000. exponent: number;
  54001. private _projectionTextureMatrix;
  54002. /**
  54003. * Allows reading the projecton texture
  54004. */
  54005. get projectionTextureMatrix(): Matrix;
  54006. protected _projectionTextureLightNear: number;
  54007. /**
  54008. * Gets the near clip of the Spotlight for texture projection.
  54009. */
  54010. get projectionTextureLightNear(): number;
  54011. /**
  54012. * Sets the near clip of the Spotlight for texture projection.
  54013. */
  54014. set projectionTextureLightNear(value: number);
  54015. protected _projectionTextureLightFar: number;
  54016. /**
  54017. * Gets the far clip of the Spotlight for texture projection.
  54018. */
  54019. get projectionTextureLightFar(): number;
  54020. /**
  54021. * Sets the far clip of the Spotlight for texture projection.
  54022. */
  54023. set projectionTextureLightFar(value: number);
  54024. protected _projectionTextureUpDirection: Vector3;
  54025. /**
  54026. * Gets the Up vector of the Spotlight for texture projection.
  54027. */
  54028. get projectionTextureUpDirection(): Vector3;
  54029. /**
  54030. * Sets the Up vector of the Spotlight for texture projection.
  54031. */
  54032. set projectionTextureUpDirection(value: Vector3);
  54033. private _projectionTexture;
  54034. /**
  54035. * Gets the projection texture of the light.
  54036. */
  54037. get projectionTexture(): Nullable<BaseTexture>;
  54038. /**
  54039. * Sets the projection texture of the light.
  54040. */
  54041. set projectionTexture(value: Nullable<BaseTexture>);
  54042. private _projectionTextureViewLightDirty;
  54043. private _projectionTextureProjectionLightDirty;
  54044. private _projectionTextureDirty;
  54045. private _projectionTextureViewTargetVector;
  54046. private _projectionTextureViewLightMatrix;
  54047. private _projectionTextureProjectionLightMatrix;
  54048. private _projectionTextureScalingMatrix;
  54049. /**
  54050. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54051. * It can cast shadows.
  54052. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54053. * @param name The light friendly name
  54054. * @param position The position of the spot light in the scene
  54055. * @param direction The direction of the light in the scene
  54056. * @param angle The cone angle of the light in Radians
  54057. * @param exponent The light decay speed with the distance from the emission spot
  54058. * @param scene The scene the lights belongs to
  54059. */
  54060. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54061. /**
  54062. * Returns the string "SpotLight".
  54063. * @returns the class name
  54064. */
  54065. getClassName(): string;
  54066. /**
  54067. * Returns the integer 2.
  54068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54069. */
  54070. getTypeID(): number;
  54071. /**
  54072. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54073. */
  54074. protected _setDirection(value: Vector3): void;
  54075. /**
  54076. * Overrides the position setter to recompute the projection texture view light Matrix.
  54077. */
  54078. protected _setPosition(value: Vector3): void;
  54079. /**
  54080. * 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.
  54081. * Returns the SpotLight.
  54082. */
  54083. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54084. protected _computeProjectionTextureViewLightMatrix(): void;
  54085. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54086. /**
  54087. * Main function for light texture projection matrix computing.
  54088. */
  54089. protected _computeProjectionTextureMatrix(): void;
  54090. protected _buildUniformLayout(): void;
  54091. private _computeAngleValues;
  54092. /**
  54093. * Sets the passed Effect "effect" with the Light textures.
  54094. * @param effect The effect to update
  54095. * @param lightIndex The index of the light in the effect to update
  54096. * @returns The light
  54097. */
  54098. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54099. /**
  54100. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54101. * @param effect The effect to update
  54102. * @param lightIndex The index of the light in the effect to update
  54103. * @returns The spot light
  54104. */
  54105. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54106. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54107. /**
  54108. * Disposes the light and the associated resources.
  54109. */
  54110. dispose(): void;
  54111. /**
  54112. * Prepares the list of defines specific to the light type.
  54113. * @param defines the list of defines
  54114. * @param lightIndex defines the index of the light for the effect
  54115. */
  54116. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54117. }
  54118. }
  54119. declare module BABYLON {
  54120. /**
  54121. * Gizmo that enables viewing a light
  54122. */
  54123. export class LightGizmo extends Gizmo {
  54124. private _lightMesh;
  54125. private _material;
  54126. private _cachedPosition;
  54127. private _cachedForward;
  54128. private _attachedMeshParent;
  54129. /**
  54130. * Creates a LightGizmo
  54131. * @param gizmoLayer The utility layer the gizmo will be added to
  54132. */
  54133. constructor(gizmoLayer?: UtilityLayerRenderer);
  54134. private _light;
  54135. /**
  54136. * The light that the gizmo is attached to
  54137. */
  54138. set light(light: Nullable<Light>);
  54139. get light(): Nullable<Light>;
  54140. /**
  54141. * Gets the material used to render the light gizmo
  54142. */
  54143. get material(): StandardMaterial;
  54144. /**
  54145. * @hidden
  54146. * Updates the gizmo to match the attached mesh's position/rotation
  54147. */
  54148. protected _update(): void;
  54149. private static _Scale;
  54150. /**
  54151. * Creates the lines for a light mesh
  54152. */
  54153. private static _CreateLightLines;
  54154. /**
  54155. * Disposes of the light gizmo
  54156. */
  54157. dispose(): void;
  54158. private static _CreateHemisphericLightMesh;
  54159. private static _CreatePointLightMesh;
  54160. private static _CreateSpotLightMesh;
  54161. private static _CreateDirectionalLightMesh;
  54162. }
  54163. }
  54164. declare module BABYLON {
  54165. /**
  54166. * Gizmo that enables viewing a camera
  54167. */
  54168. export class CameraGizmo extends Gizmo {
  54169. private _cameraMesh;
  54170. private _cameraLinesMesh;
  54171. private _material;
  54172. /**
  54173. * Creates a CameraGizmo
  54174. * @param gizmoLayer The utility layer the gizmo will be added to
  54175. */
  54176. constructor(gizmoLayer?: UtilityLayerRenderer);
  54177. private _camera;
  54178. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54179. get displayFrustum(): boolean;
  54180. set displayFrustum(value: boolean);
  54181. /**
  54182. * The camera that the gizmo is attached to
  54183. */
  54184. set camera(camera: Nullable<Camera>);
  54185. get camera(): Nullable<Camera>;
  54186. /**
  54187. * Gets the material used to render the camera gizmo
  54188. */
  54189. get material(): StandardMaterial;
  54190. /**
  54191. * @hidden
  54192. * Updates the gizmo to match the attached mesh's position/rotation
  54193. */
  54194. protected _update(): void;
  54195. private static _Scale;
  54196. private _invProjection;
  54197. /**
  54198. * Disposes of the camera gizmo
  54199. */
  54200. dispose(): void;
  54201. private static _CreateCameraMesh;
  54202. private static _CreateCameraFrustum;
  54203. }
  54204. }
  54205. declare module BABYLON {
  54206. /** @hidden */
  54207. export var backgroundFragmentDeclaration: {
  54208. name: string;
  54209. shader: string;
  54210. };
  54211. }
  54212. declare module BABYLON {
  54213. /** @hidden */
  54214. export var backgroundUboDeclaration: {
  54215. name: string;
  54216. shader: string;
  54217. };
  54218. }
  54219. declare module BABYLON {
  54220. /** @hidden */
  54221. export var backgroundPixelShader: {
  54222. name: string;
  54223. shader: string;
  54224. };
  54225. }
  54226. declare module BABYLON {
  54227. /** @hidden */
  54228. export var backgroundVertexDeclaration: {
  54229. name: string;
  54230. shader: string;
  54231. };
  54232. }
  54233. declare module BABYLON {
  54234. /** @hidden */
  54235. export var backgroundVertexShader: {
  54236. name: string;
  54237. shader: string;
  54238. };
  54239. }
  54240. declare module BABYLON {
  54241. /**
  54242. * Background material used to create an efficient environement around your scene.
  54243. */
  54244. export class BackgroundMaterial extends PushMaterial {
  54245. /**
  54246. * Standard reflectance value at parallel view angle.
  54247. */
  54248. static StandardReflectance0: number;
  54249. /**
  54250. * Standard reflectance value at grazing angle.
  54251. */
  54252. static StandardReflectance90: number;
  54253. protected _primaryColor: Color3;
  54254. /**
  54255. * Key light Color (multiply against the environement texture)
  54256. */
  54257. primaryColor: Color3;
  54258. protected __perceptualColor: Nullable<Color3>;
  54259. /**
  54260. * Experimental Internal Use Only.
  54261. *
  54262. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54263. * This acts as a helper to set the primary color to a more "human friendly" value.
  54264. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54265. * output color as close as possible from the chosen value.
  54266. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54267. * part of lighting setup.)
  54268. */
  54269. get _perceptualColor(): Nullable<Color3>;
  54270. set _perceptualColor(value: Nullable<Color3>);
  54271. protected _primaryColorShadowLevel: float;
  54272. /**
  54273. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54274. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54275. */
  54276. get primaryColorShadowLevel(): float;
  54277. set primaryColorShadowLevel(value: float);
  54278. protected _primaryColorHighlightLevel: float;
  54279. /**
  54280. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54281. * The primary color is used at the level chosen to define what the white area would look.
  54282. */
  54283. get primaryColorHighlightLevel(): float;
  54284. set primaryColorHighlightLevel(value: float);
  54285. protected _reflectionTexture: Nullable<BaseTexture>;
  54286. /**
  54287. * Reflection Texture used in the material.
  54288. * Should be author in a specific way for the best result (refer to the documentation).
  54289. */
  54290. reflectionTexture: Nullable<BaseTexture>;
  54291. protected _reflectionBlur: float;
  54292. /**
  54293. * Reflection Texture level of blur.
  54294. *
  54295. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54296. * texture twice.
  54297. */
  54298. reflectionBlur: float;
  54299. protected _diffuseTexture: Nullable<BaseTexture>;
  54300. /**
  54301. * Diffuse Texture used in the material.
  54302. * Should be author in a specific way for the best result (refer to the documentation).
  54303. */
  54304. diffuseTexture: Nullable<BaseTexture>;
  54305. protected _shadowLights: Nullable<IShadowLight[]>;
  54306. /**
  54307. * Specify the list of lights casting shadow on the material.
  54308. * All scene shadow lights will be included if null.
  54309. */
  54310. shadowLights: Nullable<IShadowLight[]>;
  54311. protected _shadowLevel: float;
  54312. /**
  54313. * Helps adjusting the shadow to a softer level if required.
  54314. * 0 means black shadows and 1 means no shadows.
  54315. */
  54316. shadowLevel: float;
  54317. protected _sceneCenter: Vector3;
  54318. /**
  54319. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54320. * It is usually zero but might be interesting to modify according to your setup.
  54321. */
  54322. sceneCenter: Vector3;
  54323. protected _opacityFresnel: boolean;
  54324. /**
  54325. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54326. * This helps ensuring a nice transition when the camera goes under the ground.
  54327. */
  54328. opacityFresnel: boolean;
  54329. protected _reflectionFresnel: boolean;
  54330. /**
  54331. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54332. * This helps adding a mirror texture on the ground.
  54333. */
  54334. reflectionFresnel: boolean;
  54335. protected _reflectionFalloffDistance: number;
  54336. /**
  54337. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54338. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54339. */
  54340. reflectionFalloffDistance: number;
  54341. protected _reflectionAmount: number;
  54342. /**
  54343. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54344. */
  54345. reflectionAmount: number;
  54346. protected _reflectionReflectance0: number;
  54347. /**
  54348. * This specifies the weight of the reflection at grazing angle.
  54349. */
  54350. reflectionReflectance0: number;
  54351. protected _reflectionReflectance90: number;
  54352. /**
  54353. * This specifies the weight of the reflection at a perpendicular point of view.
  54354. */
  54355. reflectionReflectance90: number;
  54356. /**
  54357. * Sets the reflection reflectance fresnel values according to the default standard
  54358. * empirically know to work well :-)
  54359. */
  54360. set reflectionStandardFresnelWeight(value: number);
  54361. protected _useRGBColor: boolean;
  54362. /**
  54363. * Helps to directly use the maps channels instead of their level.
  54364. */
  54365. useRGBColor: boolean;
  54366. protected _enableNoise: boolean;
  54367. /**
  54368. * This helps reducing the banding effect that could occur on the background.
  54369. */
  54370. enableNoise: boolean;
  54371. /**
  54372. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54373. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54374. * Recommended to be keep at 1.0 except for special cases.
  54375. */
  54376. get fovMultiplier(): number;
  54377. set fovMultiplier(value: number);
  54378. private _fovMultiplier;
  54379. /**
  54380. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54381. */
  54382. useEquirectangularFOV: boolean;
  54383. private _maxSimultaneousLights;
  54384. /**
  54385. * Number of Simultaneous lights allowed on the material.
  54386. */
  54387. maxSimultaneousLights: int;
  54388. private _shadowOnly;
  54389. /**
  54390. * Make the material only render shadows
  54391. */
  54392. shadowOnly: boolean;
  54393. /**
  54394. * Default configuration related to image processing available in the Background Material.
  54395. */
  54396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54397. /**
  54398. * Keep track of the image processing observer to allow dispose and replace.
  54399. */
  54400. private _imageProcessingObserver;
  54401. /**
  54402. * Attaches a new image processing configuration to the PBR Material.
  54403. * @param configuration (if null the scene configuration will be use)
  54404. */
  54405. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54406. /**
  54407. * Gets the image processing configuration used either in this material.
  54408. */
  54409. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54410. /**
  54411. * Sets the Default image processing configuration used either in the this material.
  54412. *
  54413. * If sets to null, the scene one is in use.
  54414. */
  54415. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54416. /**
  54417. * Gets wether the color curves effect is enabled.
  54418. */
  54419. get cameraColorCurvesEnabled(): boolean;
  54420. /**
  54421. * Sets wether the color curves effect is enabled.
  54422. */
  54423. set cameraColorCurvesEnabled(value: boolean);
  54424. /**
  54425. * Gets wether the color grading effect is enabled.
  54426. */
  54427. get cameraColorGradingEnabled(): boolean;
  54428. /**
  54429. * Gets wether the color grading effect is enabled.
  54430. */
  54431. set cameraColorGradingEnabled(value: boolean);
  54432. /**
  54433. * Gets wether tonemapping is enabled or not.
  54434. */
  54435. get cameraToneMappingEnabled(): boolean;
  54436. /**
  54437. * Sets wether tonemapping is enabled or not
  54438. */
  54439. set cameraToneMappingEnabled(value: boolean);
  54440. /**
  54441. * The camera exposure used on this material.
  54442. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54443. * This corresponds to a photographic exposure.
  54444. */
  54445. get cameraExposure(): float;
  54446. /**
  54447. * The camera exposure used on this material.
  54448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54449. * This corresponds to a photographic exposure.
  54450. */
  54451. set cameraExposure(value: float);
  54452. /**
  54453. * Gets The camera contrast used on this material.
  54454. */
  54455. get cameraContrast(): float;
  54456. /**
  54457. * Sets The camera contrast used on this material.
  54458. */
  54459. set cameraContrast(value: float);
  54460. /**
  54461. * Gets the Color Grading 2D Lookup Texture.
  54462. */
  54463. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54464. /**
  54465. * Sets the Color Grading 2D Lookup Texture.
  54466. */
  54467. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54468. /**
  54469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54471. * 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;
  54472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54473. */
  54474. get cameraColorCurves(): Nullable<ColorCurves>;
  54475. /**
  54476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54478. * 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;
  54479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54480. */
  54481. set cameraColorCurves(value: Nullable<ColorCurves>);
  54482. /**
  54483. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54484. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54485. */
  54486. switchToBGR: boolean;
  54487. private _renderTargets;
  54488. private _reflectionControls;
  54489. private _white;
  54490. private _primaryShadowColor;
  54491. private _primaryHighlightColor;
  54492. /**
  54493. * Instantiates a Background Material in the given scene
  54494. * @param name The friendly name of the material
  54495. * @param scene The scene to add the material to
  54496. */
  54497. constructor(name: string, scene: Scene);
  54498. /**
  54499. * Gets a boolean indicating that current material needs to register RTT
  54500. */
  54501. get hasRenderTargetTextures(): boolean;
  54502. /**
  54503. * The entire material has been created in order to prevent overdraw.
  54504. * @returns false
  54505. */
  54506. needAlphaTesting(): boolean;
  54507. /**
  54508. * The entire material has been created in order to prevent overdraw.
  54509. * @returns true if blending is enable
  54510. */
  54511. needAlphaBlending(): boolean;
  54512. /**
  54513. * Checks wether the material is ready to be rendered for a given mesh.
  54514. * @param mesh The mesh to render
  54515. * @param subMesh The submesh to check against
  54516. * @param useInstances Specify wether or not the material is used with instances
  54517. * @returns true if all the dependencies are ready (Textures, Effects...)
  54518. */
  54519. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54520. /**
  54521. * Compute the primary color according to the chosen perceptual color.
  54522. */
  54523. private _computePrimaryColorFromPerceptualColor;
  54524. /**
  54525. * Compute the highlights and shadow colors according to their chosen levels.
  54526. */
  54527. private _computePrimaryColors;
  54528. /**
  54529. * Build the uniform buffer used in the material.
  54530. */
  54531. buildUniformLayout(): void;
  54532. /**
  54533. * Unbind the material.
  54534. */
  54535. unbind(): void;
  54536. /**
  54537. * Bind only the world matrix to the material.
  54538. * @param world The world matrix to bind.
  54539. */
  54540. bindOnlyWorldMatrix(world: Matrix): void;
  54541. /**
  54542. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54543. * @param world The world matrix to bind.
  54544. * @param subMesh The submesh to bind for.
  54545. */
  54546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54547. /**
  54548. * Checks to see if a texture is used in the material.
  54549. * @param texture - Base texture to use.
  54550. * @returns - Boolean specifying if a texture is used in the material.
  54551. */
  54552. hasTexture(texture: BaseTexture): boolean;
  54553. /**
  54554. * Dispose the material.
  54555. * @param forceDisposeEffect Force disposal of the associated effect.
  54556. * @param forceDisposeTextures Force disposal of the associated textures.
  54557. */
  54558. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54559. /**
  54560. * Clones the material.
  54561. * @param name The cloned name.
  54562. * @returns The cloned material.
  54563. */
  54564. clone(name: string): BackgroundMaterial;
  54565. /**
  54566. * Serializes the current material to its JSON representation.
  54567. * @returns The JSON representation.
  54568. */
  54569. serialize(): any;
  54570. /**
  54571. * Gets the class name of the material
  54572. * @returns "BackgroundMaterial"
  54573. */
  54574. getClassName(): string;
  54575. /**
  54576. * Parse a JSON input to create back a background material.
  54577. * @param source The JSON data to parse
  54578. * @param scene The scene to create the parsed material in
  54579. * @param rootUrl The root url of the assets the material depends upon
  54580. * @returns the instantiated BackgroundMaterial.
  54581. */
  54582. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54583. }
  54584. }
  54585. declare module BABYLON {
  54586. /**
  54587. * Represents the different options available during the creation of
  54588. * a Environment helper.
  54589. *
  54590. * This can control the default ground, skybox and image processing setup of your scene.
  54591. */
  54592. export interface IEnvironmentHelperOptions {
  54593. /**
  54594. * Specifies whether or not to create a ground.
  54595. * True by default.
  54596. */
  54597. createGround: boolean;
  54598. /**
  54599. * Specifies the ground size.
  54600. * 15 by default.
  54601. */
  54602. groundSize: number;
  54603. /**
  54604. * The texture used on the ground for the main color.
  54605. * Comes from the BabylonJS CDN by default.
  54606. *
  54607. * Remarks: Can be either a texture or a url.
  54608. */
  54609. groundTexture: string | BaseTexture;
  54610. /**
  54611. * The color mixed in the ground texture by default.
  54612. * BabylonJS clearColor by default.
  54613. */
  54614. groundColor: Color3;
  54615. /**
  54616. * Specifies the ground opacity.
  54617. * 1 by default.
  54618. */
  54619. groundOpacity: number;
  54620. /**
  54621. * Enables the ground to receive shadows.
  54622. * True by default.
  54623. */
  54624. enableGroundShadow: boolean;
  54625. /**
  54626. * Helps preventing the shadow to be fully black on the ground.
  54627. * 0.5 by default.
  54628. */
  54629. groundShadowLevel: number;
  54630. /**
  54631. * Creates a mirror texture attach to the ground.
  54632. * false by default.
  54633. */
  54634. enableGroundMirror: boolean;
  54635. /**
  54636. * Specifies the ground mirror size ratio.
  54637. * 0.3 by default as the default kernel is 64.
  54638. */
  54639. groundMirrorSizeRatio: number;
  54640. /**
  54641. * Specifies the ground mirror blur kernel size.
  54642. * 64 by default.
  54643. */
  54644. groundMirrorBlurKernel: number;
  54645. /**
  54646. * Specifies the ground mirror visibility amount.
  54647. * 1 by default
  54648. */
  54649. groundMirrorAmount: number;
  54650. /**
  54651. * Specifies the ground mirror reflectance weight.
  54652. * This uses the standard weight of the background material to setup the fresnel effect
  54653. * of the mirror.
  54654. * 1 by default.
  54655. */
  54656. groundMirrorFresnelWeight: number;
  54657. /**
  54658. * Specifies the ground mirror Falloff distance.
  54659. * This can helps reducing the size of the reflection.
  54660. * 0 by Default.
  54661. */
  54662. groundMirrorFallOffDistance: number;
  54663. /**
  54664. * Specifies the ground mirror texture type.
  54665. * Unsigned Int by Default.
  54666. */
  54667. groundMirrorTextureType: number;
  54668. /**
  54669. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54670. * the shown objects.
  54671. */
  54672. groundYBias: number;
  54673. /**
  54674. * Specifies whether or not to create a skybox.
  54675. * True by default.
  54676. */
  54677. createSkybox: boolean;
  54678. /**
  54679. * Specifies the skybox size.
  54680. * 20 by default.
  54681. */
  54682. skyboxSize: number;
  54683. /**
  54684. * The texture used on the skybox for the main color.
  54685. * Comes from the BabylonJS CDN by default.
  54686. *
  54687. * Remarks: Can be either a texture or a url.
  54688. */
  54689. skyboxTexture: string | BaseTexture;
  54690. /**
  54691. * The color mixed in the skybox texture by default.
  54692. * BabylonJS clearColor by default.
  54693. */
  54694. skyboxColor: Color3;
  54695. /**
  54696. * The background rotation around the Y axis of the scene.
  54697. * This helps aligning the key lights of your scene with the background.
  54698. * 0 by default.
  54699. */
  54700. backgroundYRotation: number;
  54701. /**
  54702. * Compute automatically the size of the elements to best fit with the scene.
  54703. */
  54704. sizeAuto: boolean;
  54705. /**
  54706. * Default position of the rootMesh if autoSize is not true.
  54707. */
  54708. rootPosition: Vector3;
  54709. /**
  54710. * Sets up the image processing in the scene.
  54711. * true by default.
  54712. */
  54713. setupImageProcessing: boolean;
  54714. /**
  54715. * The texture used as your environment texture in the scene.
  54716. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54717. *
  54718. * Remarks: Can be either a texture or a url.
  54719. */
  54720. environmentTexture: string | BaseTexture;
  54721. /**
  54722. * The value of the exposure to apply to the scene.
  54723. * 0.6 by default if setupImageProcessing is true.
  54724. */
  54725. cameraExposure: number;
  54726. /**
  54727. * The value of the contrast to apply to the scene.
  54728. * 1.6 by default if setupImageProcessing is true.
  54729. */
  54730. cameraContrast: number;
  54731. /**
  54732. * Specifies whether or not tonemapping should be enabled in the scene.
  54733. * true by default if setupImageProcessing is true.
  54734. */
  54735. toneMappingEnabled: boolean;
  54736. }
  54737. /**
  54738. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54739. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54740. * It also helps with the default setup of your imageProcessing configuration.
  54741. */
  54742. export class EnvironmentHelper {
  54743. /**
  54744. * Default ground texture URL.
  54745. */
  54746. private static _groundTextureCDNUrl;
  54747. /**
  54748. * Default skybox texture URL.
  54749. */
  54750. private static _skyboxTextureCDNUrl;
  54751. /**
  54752. * Default environment texture URL.
  54753. */
  54754. private static _environmentTextureCDNUrl;
  54755. /**
  54756. * Creates the default options for the helper.
  54757. */
  54758. private static _getDefaultOptions;
  54759. private _rootMesh;
  54760. /**
  54761. * Gets the root mesh created by the helper.
  54762. */
  54763. get rootMesh(): Mesh;
  54764. private _skybox;
  54765. /**
  54766. * Gets the skybox created by the helper.
  54767. */
  54768. get skybox(): Nullable<Mesh>;
  54769. private _skyboxTexture;
  54770. /**
  54771. * Gets the skybox texture created by the helper.
  54772. */
  54773. get skyboxTexture(): Nullable<BaseTexture>;
  54774. private _skyboxMaterial;
  54775. /**
  54776. * Gets the skybox material created by the helper.
  54777. */
  54778. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54779. private _ground;
  54780. /**
  54781. * Gets the ground mesh created by the helper.
  54782. */
  54783. get ground(): Nullable<Mesh>;
  54784. private _groundTexture;
  54785. /**
  54786. * Gets the ground texture created by the helper.
  54787. */
  54788. get groundTexture(): Nullable<BaseTexture>;
  54789. private _groundMirror;
  54790. /**
  54791. * Gets the ground mirror created by the helper.
  54792. */
  54793. get groundMirror(): Nullable<MirrorTexture>;
  54794. /**
  54795. * Gets the ground mirror render list to helps pushing the meshes
  54796. * you wish in the ground reflection.
  54797. */
  54798. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54799. private _groundMaterial;
  54800. /**
  54801. * Gets the ground material created by the helper.
  54802. */
  54803. get groundMaterial(): Nullable<BackgroundMaterial>;
  54804. /**
  54805. * Stores the creation options.
  54806. */
  54807. private readonly _scene;
  54808. private _options;
  54809. /**
  54810. * This observable will be notified with any error during the creation of the environment,
  54811. * mainly texture creation errors.
  54812. */
  54813. onErrorObservable: Observable<{
  54814. message?: string;
  54815. exception?: any;
  54816. }>;
  54817. /**
  54818. * constructor
  54819. * @param options Defines the options we want to customize the helper
  54820. * @param scene The scene to add the material to
  54821. */
  54822. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54823. /**
  54824. * Updates the background according to the new options
  54825. * @param options
  54826. */
  54827. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54828. /**
  54829. * Sets the primary color of all the available elements.
  54830. * @param color the main color to affect to the ground and the background
  54831. */
  54832. setMainColor(color: Color3): void;
  54833. /**
  54834. * Setup the image processing according to the specified options.
  54835. */
  54836. private _setupImageProcessing;
  54837. /**
  54838. * Setup the environment texture according to the specified options.
  54839. */
  54840. private _setupEnvironmentTexture;
  54841. /**
  54842. * Setup the background according to the specified options.
  54843. */
  54844. private _setupBackground;
  54845. /**
  54846. * Get the scene sizes according to the setup.
  54847. */
  54848. private _getSceneSize;
  54849. /**
  54850. * Setup the ground according to the specified options.
  54851. */
  54852. private _setupGround;
  54853. /**
  54854. * Setup the ground material according to the specified options.
  54855. */
  54856. private _setupGroundMaterial;
  54857. /**
  54858. * Setup the ground diffuse texture according to the specified options.
  54859. */
  54860. private _setupGroundDiffuseTexture;
  54861. /**
  54862. * Setup the ground mirror texture according to the specified options.
  54863. */
  54864. private _setupGroundMirrorTexture;
  54865. /**
  54866. * Setup the ground to receive the mirror texture.
  54867. */
  54868. private _setupMirrorInGroundMaterial;
  54869. /**
  54870. * Setup the skybox according to the specified options.
  54871. */
  54872. private _setupSkybox;
  54873. /**
  54874. * Setup the skybox material according to the specified options.
  54875. */
  54876. private _setupSkyboxMaterial;
  54877. /**
  54878. * Setup the skybox reflection texture according to the specified options.
  54879. */
  54880. private _setupSkyboxReflectionTexture;
  54881. private _errorHandler;
  54882. /**
  54883. * Dispose all the elements created by the Helper.
  54884. */
  54885. dispose(): void;
  54886. }
  54887. }
  54888. declare module BABYLON {
  54889. /**
  54890. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  54891. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  54892. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54893. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54894. */
  54895. export abstract class TextureDome<T extends Texture> extends TransformNode {
  54896. protected onError: Nullable<(message?: string, exception?: any) => void>;
  54897. /**
  54898. * Define the source as a Monoscopic panoramic 360/180.
  54899. */
  54900. static readonly MODE_MONOSCOPIC: number;
  54901. /**
  54902. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  54903. */
  54904. static readonly MODE_TOPBOTTOM: number;
  54905. /**
  54906. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  54907. */
  54908. static readonly MODE_SIDEBYSIDE: number;
  54909. private _halfDome;
  54910. protected _useDirectMapping: boolean;
  54911. /**
  54912. * The texture being displayed on the sphere
  54913. */
  54914. protected _texture: T;
  54915. /**
  54916. * Gets the texture being displayed on the sphere
  54917. */
  54918. get texture(): T;
  54919. /**
  54920. * Sets the texture being displayed on the sphere
  54921. */
  54922. set texture(newTexture: T);
  54923. /**
  54924. * The skybox material
  54925. */
  54926. protected _material: BackgroundMaterial;
  54927. /**
  54928. * The surface used for the dome
  54929. */
  54930. protected _mesh: Mesh;
  54931. /**
  54932. * Gets the mesh used for the dome.
  54933. */
  54934. get mesh(): Mesh;
  54935. /**
  54936. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  54937. */
  54938. private _halfDomeMask;
  54939. /**
  54940. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54941. * Also see the options.resolution property.
  54942. */
  54943. get fovMultiplier(): number;
  54944. set fovMultiplier(value: number);
  54945. protected _textureMode: number;
  54946. /**
  54947. * Gets or set the current texture mode for the texture. It can be:
  54948. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54949. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54950. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54951. */
  54952. get textureMode(): number;
  54953. /**
  54954. * Sets the current texture mode for the texture. It can be:
  54955. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54956. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54957. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54958. */
  54959. set textureMode(value: number);
  54960. /**
  54961. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  54962. */
  54963. get halfDome(): boolean;
  54964. /**
  54965. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54966. */
  54967. set halfDome(enabled: boolean);
  54968. /**
  54969. * Oberserver used in Stereoscopic VR Mode.
  54970. */
  54971. private _onBeforeCameraRenderObserver;
  54972. /**
  54973. * Observable raised when an error occured while loading the 360 image
  54974. */
  54975. onLoadErrorObservable: Observable<string>;
  54976. /**
  54977. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  54978. * @param name Element's name, child elements will append suffixes for their own names.
  54979. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  54980. * @param options An object containing optional or exposed sub element properties
  54981. */
  54982. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  54983. resolution?: number;
  54984. clickToPlay?: boolean;
  54985. autoPlay?: boolean;
  54986. loop?: boolean;
  54987. size?: number;
  54988. poster?: string;
  54989. faceForward?: boolean;
  54990. useDirectMapping?: boolean;
  54991. halfDomeMode?: boolean;
  54992. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54993. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  54994. protected _changeTextureMode(value: number): void;
  54995. /**
  54996. * Releases resources associated with this node.
  54997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54999. */
  55000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55001. }
  55002. }
  55003. declare module BABYLON {
  55004. /**
  55005. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55006. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55007. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55008. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55009. */
  55010. export class PhotoDome extends TextureDome<Texture> {
  55011. /**
  55012. * Define the image as a Monoscopic panoramic 360 image.
  55013. */
  55014. static readonly MODE_MONOSCOPIC: number;
  55015. /**
  55016. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55017. */
  55018. static readonly MODE_TOPBOTTOM: number;
  55019. /**
  55020. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55021. */
  55022. static readonly MODE_SIDEBYSIDE: number;
  55023. /**
  55024. * Gets or sets the texture being displayed on the sphere
  55025. */
  55026. get photoTexture(): Texture;
  55027. /**
  55028. * sets the texture being displayed on the sphere
  55029. */
  55030. set photoTexture(value: Texture);
  55031. /**
  55032. * Gets the current video mode for the video. It can be:
  55033. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55034. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55035. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55036. */
  55037. get imageMode(): number;
  55038. /**
  55039. * Sets the current video mode for the video. It can be:
  55040. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55041. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55042. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55043. */
  55044. set imageMode(value: number);
  55045. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55046. }
  55047. }
  55048. declare module BABYLON {
  55049. /**
  55050. * Class used to host RGBD texture specific utilities
  55051. */
  55052. export class RGBDTextureTools {
  55053. /**
  55054. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55055. * @param texture the texture to expand.
  55056. */
  55057. static ExpandRGBDTexture(texture: Texture): void;
  55058. }
  55059. }
  55060. declare module BABYLON {
  55061. /**
  55062. * Class used to host texture specific utilities
  55063. */
  55064. export class BRDFTextureTools {
  55065. /**
  55066. * Prevents texture cache collision
  55067. */
  55068. private static _instanceNumber;
  55069. /**
  55070. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55071. * @param scene defines the hosting scene
  55072. * @returns the environment BRDF texture
  55073. */
  55074. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55075. private static _environmentBRDFBase64Texture;
  55076. }
  55077. }
  55078. declare module BABYLON {
  55079. /**
  55080. * @hidden
  55081. */
  55082. export interface IMaterialClearCoatDefines {
  55083. CLEARCOAT: boolean;
  55084. CLEARCOAT_DEFAULTIOR: boolean;
  55085. CLEARCOAT_TEXTURE: boolean;
  55086. CLEARCOAT_TEXTUREDIRECTUV: number;
  55087. CLEARCOAT_BUMP: boolean;
  55088. CLEARCOAT_BUMPDIRECTUV: number;
  55089. CLEARCOAT_TINT: boolean;
  55090. CLEARCOAT_TINT_TEXTURE: boolean;
  55091. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55092. /** @hidden */
  55093. _areTexturesDirty: boolean;
  55094. }
  55095. /**
  55096. * Define the code related to the clear coat parameters of the pbr material.
  55097. */
  55098. export class PBRClearCoatConfiguration {
  55099. /**
  55100. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55101. * The default fits with a polyurethane material.
  55102. */
  55103. private static readonly _DefaultIndexOfRefraction;
  55104. private _isEnabled;
  55105. /**
  55106. * Defines if the clear coat is enabled in the material.
  55107. */
  55108. isEnabled: boolean;
  55109. /**
  55110. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55111. */
  55112. intensity: number;
  55113. /**
  55114. * Defines the clear coat layer roughness.
  55115. */
  55116. roughness: number;
  55117. private _indexOfRefraction;
  55118. /**
  55119. * Defines the index of refraction of the clear coat.
  55120. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55121. * The default fits with a polyurethane material.
  55122. * Changing the default value is more performance intensive.
  55123. */
  55124. indexOfRefraction: number;
  55125. private _texture;
  55126. /**
  55127. * Stores the clear coat values in a texture.
  55128. */
  55129. texture: Nullable<BaseTexture>;
  55130. private _bumpTexture;
  55131. /**
  55132. * Define the clear coat specific bump texture.
  55133. */
  55134. bumpTexture: Nullable<BaseTexture>;
  55135. private _isTintEnabled;
  55136. /**
  55137. * Defines if the clear coat tint is enabled in the material.
  55138. */
  55139. isTintEnabled: boolean;
  55140. /**
  55141. * Defines the clear coat tint of the material.
  55142. * This is only use if tint is enabled
  55143. */
  55144. tintColor: Color3;
  55145. /**
  55146. * Defines the distance at which the tint color should be found in the
  55147. * clear coat media.
  55148. * This is only use if tint is enabled
  55149. */
  55150. tintColorAtDistance: number;
  55151. /**
  55152. * Defines the clear coat layer thickness.
  55153. * This is only use if tint is enabled
  55154. */
  55155. tintThickness: number;
  55156. private _tintTexture;
  55157. /**
  55158. * Stores the clear tint values in a texture.
  55159. * rgb is tint
  55160. * a is a thickness factor
  55161. */
  55162. tintTexture: Nullable<BaseTexture>;
  55163. /** @hidden */
  55164. private _internalMarkAllSubMeshesAsTexturesDirty;
  55165. /** @hidden */
  55166. _markAllSubMeshesAsTexturesDirty(): void;
  55167. /**
  55168. * Instantiate a new istance of clear coat configuration.
  55169. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55170. */
  55171. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55172. /**
  55173. * Gets wehter the submesh is ready to be used or not.
  55174. * @param defines the list of "defines" to update.
  55175. * @param scene defines the scene the material belongs to.
  55176. * @param engine defines the engine the material belongs to.
  55177. * @param disableBumpMap defines wether the material disables bump or not.
  55178. * @returns - boolean indicating that the submesh is ready or not.
  55179. */
  55180. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55181. /**
  55182. * Checks to see if a texture is used in the material.
  55183. * @param defines the list of "defines" to update.
  55184. * @param scene defines the scene to the material belongs to.
  55185. */
  55186. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55187. /**
  55188. * Binds the material data.
  55189. * @param uniformBuffer defines the Uniform buffer to fill in.
  55190. * @param scene defines the scene the material belongs to.
  55191. * @param engine defines the engine the material belongs to.
  55192. * @param disableBumpMap defines wether the material disables bump or not.
  55193. * @param isFrozen defines wether the material is frozen or not.
  55194. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55195. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55196. */
  55197. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55198. /**
  55199. * Checks to see if a texture is used in the material.
  55200. * @param texture - Base texture to use.
  55201. * @returns - Boolean specifying if a texture is used in the material.
  55202. */
  55203. hasTexture(texture: BaseTexture): boolean;
  55204. /**
  55205. * Returns an array of the actively used textures.
  55206. * @param activeTextures Array of BaseTextures
  55207. */
  55208. getActiveTextures(activeTextures: BaseTexture[]): void;
  55209. /**
  55210. * Returns the animatable textures.
  55211. * @param animatables Array of animatable textures.
  55212. */
  55213. getAnimatables(animatables: IAnimatable[]): void;
  55214. /**
  55215. * Disposes the resources of the material.
  55216. * @param forceDisposeTextures - Forces the disposal of all textures.
  55217. */
  55218. dispose(forceDisposeTextures?: boolean): void;
  55219. /**
  55220. * Get the current class name of the texture useful for serialization or dynamic coding.
  55221. * @returns "PBRClearCoatConfiguration"
  55222. */
  55223. getClassName(): string;
  55224. /**
  55225. * Add fallbacks to the effect fallbacks list.
  55226. * @param defines defines the Base texture to use.
  55227. * @param fallbacks defines the current fallback list.
  55228. * @param currentRank defines the current fallback rank.
  55229. * @returns the new fallback rank.
  55230. */
  55231. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55232. /**
  55233. * Add the required uniforms to the current list.
  55234. * @param uniforms defines the current uniform list.
  55235. */
  55236. static AddUniforms(uniforms: string[]): void;
  55237. /**
  55238. * Add the required samplers to the current list.
  55239. * @param samplers defines the current sampler list.
  55240. */
  55241. static AddSamplers(samplers: string[]): void;
  55242. /**
  55243. * Add the required uniforms to the current buffer.
  55244. * @param uniformBuffer defines the current uniform buffer.
  55245. */
  55246. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55247. /**
  55248. * Makes a duplicate of the current configuration into another one.
  55249. * @param clearCoatConfiguration define the config where to copy the info
  55250. */
  55251. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55252. /**
  55253. * Serializes this clear coat configuration.
  55254. * @returns - An object with the serialized config.
  55255. */
  55256. serialize(): any;
  55257. /**
  55258. * Parses a anisotropy Configuration from a serialized object.
  55259. * @param source - Serialized object.
  55260. * @param scene Defines the scene we are parsing for
  55261. * @param rootUrl Defines the rootUrl to load from
  55262. */
  55263. parse(source: any, scene: Scene, rootUrl: string): void;
  55264. }
  55265. }
  55266. declare module BABYLON {
  55267. /**
  55268. * @hidden
  55269. */
  55270. export interface IMaterialAnisotropicDefines {
  55271. ANISOTROPIC: boolean;
  55272. ANISOTROPIC_TEXTURE: boolean;
  55273. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55274. MAINUV1: boolean;
  55275. _areTexturesDirty: boolean;
  55276. _needUVs: boolean;
  55277. }
  55278. /**
  55279. * Define the code related to the anisotropic parameters of the pbr material.
  55280. */
  55281. export class PBRAnisotropicConfiguration {
  55282. private _isEnabled;
  55283. /**
  55284. * Defines if the anisotropy is enabled in the material.
  55285. */
  55286. isEnabled: boolean;
  55287. /**
  55288. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55289. */
  55290. intensity: number;
  55291. /**
  55292. * Defines if the effect is along the tangents, bitangents or in between.
  55293. * By default, the effect is "strectching" the highlights along the tangents.
  55294. */
  55295. direction: Vector2;
  55296. private _texture;
  55297. /**
  55298. * Stores the anisotropy values in a texture.
  55299. * rg is direction (like normal from -1 to 1)
  55300. * b is a intensity
  55301. */
  55302. texture: Nullable<BaseTexture>;
  55303. /** @hidden */
  55304. private _internalMarkAllSubMeshesAsTexturesDirty;
  55305. /** @hidden */
  55306. _markAllSubMeshesAsTexturesDirty(): void;
  55307. /**
  55308. * Instantiate a new istance of anisotropy configuration.
  55309. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55310. */
  55311. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55312. /**
  55313. * Specifies that the submesh is ready to be used.
  55314. * @param defines the list of "defines" to update.
  55315. * @param scene defines the scene the material belongs to.
  55316. * @returns - boolean indicating that the submesh is ready or not.
  55317. */
  55318. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55319. /**
  55320. * Checks to see if a texture is used in the material.
  55321. * @param defines the list of "defines" to update.
  55322. * @param mesh the mesh we are preparing the defines for.
  55323. * @param scene defines the scene the material belongs to.
  55324. */
  55325. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55326. /**
  55327. * Binds the material data.
  55328. * @param uniformBuffer defines the Uniform buffer to fill in.
  55329. * @param scene defines the scene the material belongs to.
  55330. * @param isFrozen defines wether the material is frozen or not.
  55331. */
  55332. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55333. /**
  55334. * Checks to see if a texture is used in the material.
  55335. * @param texture - Base texture to use.
  55336. * @returns - Boolean specifying if a texture is used in the material.
  55337. */
  55338. hasTexture(texture: BaseTexture): boolean;
  55339. /**
  55340. * Returns an array of the actively used textures.
  55341. * @param activeTextures Array of BaseTextures
  55342. */
  55343. getActiveTextures(activeTextures: BaseTexture[]): void;
  55344. /**
  55345. * Returns the animatable textures.
  55346. * @param animatables Array of animatable textures.
  55347. */
  55348. getAnimatables(animatables: IAnimatable[]): void;
  55349. /**
  55350. * Disposes the resources of the material.
  55351. * @param forceDisposeTextures - Forces the disposal of all textures.
  55352. */
  55353. dispose(forceDisposeTextures?: boolean): void;
  55354. /**
  55355. * Get the current class name of the texture useful for serialization or dynamic coding.
  55356. * @returns "PBRAnisotropicConfiguration"
  55357. */
  55358. getClassName(): string;
  55359. /**
  55360. * Add fallbacks to the effect fallbacks list.
  55361. * @param defines defines the Base texture to use.
  55362. * @param fallbacks defines the current fallback list.
  55363. * @param currentRank defines the current fallback rank.
  55364. * @returns the new fallback rank.
  55365. */
  55366. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55367. /**
  55368. * Add the required uniforms to the current list.
  55369. * @param uniforms defines the current uniform list.
  55370. */
  55371. static AddUniforms(uniforms: string[]): void;
  55372. /**
  55373. * Add the required uniforms to the current buffer.
  55374. * @param uniformBuffer defines the current uniform buffer.
  55375. */
  55376. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55377. /**
  55378. * Add the required samplers to the current list.
  55379. * @param samplers defines the current sampler list.
  55380. */
  55381. static AddSamplers(samplers: string[]): void;
  55382. /**
  55383. * Makes a duplicate of the current configuration into another one.
  55384. * @param anisotropicConfiguration define the config where to copy the info
  55385. */
  55386. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55387. /**
  55388. * Serializes this anisotropy configuration.
  55389. * @returns - An object with the serialized config.
  55390. */
  55391. serialize(): any;
  55392. /**
  55393. * Parses a anisotropy Configuration from a serialized object.
  55394. * @param source - Serialized object.
  55395. * @param scene Defines the scene we are parsing for
  55396. * @param rootUrl Defines the rootUrl to load from
  55397. */
  55398. parse(source: any, scene: Scene, rootUrl: string): void;
  55399. }
  55400. }
  55401. declare module BABYLON {
  55402. /**
  55403. * @hidden
  55404. */
  55405. export interface IMaterialBRDFDefines {
  55406. BRDF_V_HEIGHT_CORRELATED: boolean;
  55407. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55408. SPHERICAL_HARMONICS: boolean;
  55409. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55410. /** @hidden */
  55411. _areMiscDirty: boolean;
  55412. }
  55413. /**
  55414. * Define the code related to the BRDF parameters of the pbr material.
  55415. */
  55416. export class PBRBRDFConfiguration {
  55417. /**
  55418. * Default value used for the energy conservation.
  55419. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55420. */
  55421. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55422. /**
  55423. * Default value used for the Smith Visibility Height Correlated mode.
  55424. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55425. */
  55426. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55427. /**
  55428. * Default value used for the IBL diffuse part.
  55429. * This can help switching back to the polynomials mode globally which is a tiny bit
  55430. * less GPU intensive at the drawback of a lower quality.
  55431. */
  55432. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55433. /**
  55434. * Default value used for activating energy conservation for the specular workflow.
  55435. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55436. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55437. */
  55438. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55439. private _useEnergyConservation;
  55440. /**
  55441. * Defines if the material uses energy conservation.
  55442. */
  55443. useEnergyConservation: boolean;
  55444. private _useSmithVisibilityHeightCorrelated;
  55445. /**
  55446. * LEGACY Mode set to false
  55447. * Defines if the material uses height smith correlated visibility term.
  55448. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55449. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55450. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55451. * Not relying on height correlated will also disable energy conservation.
  55452. */
  55453. useSmithVisibilityHeightCorrelated: boolean;
  55454. private _useSphericalHarmonics;
  55455. /**
  55456. * LEGACY Mode set to false
  55457. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55458. * diffuse part of the IBL.
  55459. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55460. * to the ground truth.
  55461. */
  55462. useSphericalHarmonics: boolean;
  55463. private _useSpecularGlossinessInputEnergyConservation;
  55464. /**
  55465. * Defines if the material uses energy conservation, when the specular workflow is active.
  55466. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55467. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55468. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55469. */
  55470. useSpecularGlossinessInputEnergyConservation: boolean;
  55471. /** @hidden */
  55472. private _internalMarkAllSubMeshesAsMiscDirty;
  55473. /** @hidden */
  55474. _markAllSubMeshesAsMiscDirty(): void;
  55475. /**
  55476. * Instantiate a new istance of clear coat configuration.
  55477. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55478. */
  55479. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55480. /**
  55481. * Checks to see if a texture is used in the material.
  55482. * @param defines the list of "defines" to update.
  55483. */
  55484. prepareDefines(defines: IMaterialBRDFDefines): void;
  55485. /**
  55486. * Get the current class name of the texture useful for serialization or dynamic coding.
  55487. * @returns "PBRClearCoatConfiguration"
  55488. */
  55489. getClassName(): string;
  55490. /**
  55491. * Makes a duplicate of the current configuration into another one.
  55492. * @param brdfConfiguration define the config where to copy the info
  55493. */
  55494. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55495. /**
  55496. * Serializes this BRDF configuration.
  55497. * @returns - An object with the serialized config.
  55498. */
  55499. serialize(): any;
  55500. /**
  55501. * Parses a anisotropy Configuration from a serialized object.
  55502. * @param source - Serialized object.
  55503. * @param scene Defines the scene we are parsing for
  55504. * @param rootUrl Defines the rootUrl to load from
  55505. */
  55506. parse(source: any, scene: Scene, rootUrl: string): void;
  55507. }
  55508. }
  55509. declare module BABYLON {
  55510. /**
  55511. * @hidden
  55512. */
  55513. export interface IMaterialSheenDefines {
  55514. SHEEN: boolean;
  55515. SHEEN_TEXTURE: boolean;
  55516. SHEEN_TEXTUREDIRECTUV: number;
  55517. SHEEN_LINKWITHALBEDO: boolean;
  55518. SHEEN_ROUGHNESS: boolean;
  55519. SHEEN_ALBEDOSCALING: boolean;
  55520. /** @hidden */
  55521. _areTexturesDirty: boolean;
  55522. }
  55523. /**
  55524. * Define the code related to the Sheen parameters of the pbr material.
  55525. */
  55526. export class PBRSheenConfiguration {
  55527. private _isEnabled;
  55528. /**
  55529. * Defines if the material uses sheen.
  55530. */
  55531. isEnabled: boolean;
  55532. private _linkSheenWithAlbedo;
  55533. /**
  55534. * Defines if the sheen is linked to the sheen color.
  55535. */
  55536. linkSheenWithAlbedo: boolean;
  55537. /**
  55538. * Defines the sheen intensity.
  55539. */
  55540. intensity: number;
  55541. /**
  55542. * Defines the sheen color.
  55543. */
  55544. color: Color3;
  55545. private _texture;
  55546. /**
  55547. * Stores the sheen tint values in a texture.
  55548. * rgb is tint
  55549. * a is a intensity or roughness if roughness has been defined
  55550. */
  55551. texture: Nullable<BaseTexture>;
  55552. private _roughness;
  55553. /**
  55554. * Defines the sheen roughness.
  55555. * It is not taken into account if linkSheenWithAlbedo is true.
  55556. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55557. */
  55558. roughness: Nullable<number>;
  55559. private _albedoScaling;
  55560. /**
  55561. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55562. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55563. * making it easier to setup and tweak the effect
  55564. */
  55565. albedoScaling: boolean;
  55566. /** @hidden */
  55567. private _internalMarkAllSubMeshesAsTexturesDirty;
  55568. /** @hidden */
  55569. _markAllSubMeshesAsTexturesDirty(): void;
  55570. /**
  55571. * Instantiate a new istance of clear coat configuration.
  55572. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55573. */
  55574. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55575. /**
  55576. * Specifies that the submesh is ready to be used.
  55577. * @param defines the list of "defines" to update.
  55578. * @param scene defines the scene the material belongs to.
  55579. * @returns - boolean indicating that the submesh is ready or not.
  55580. */
  55581. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55582. /**
  55583. * Checks to see if a texture is used in the material.
  55584. * @param defines the list of "defines" to update.
  55585. * @param scene defines the scene the material belongs to.
  55586. */
  55587. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55588. /**
  55589. * Binds the material data.
  55590. * @param uniformBuffer defines the Uniform buffer to fill in.
  55591. * @param scene defines the scene the material belongs to.
  55592. * @param isFrozen defines wether the material is frozen or not.
  55593. */
  55594. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55595. /**
  55596. * Checks to see if a texture is used in the material.
  55597. * @param texture - Base texture to use.
  55598. * @returns - Boolean specifying if a texture is used in the material.
  55599. */
  55600. hasTexture(texture: BaseTexture): boolean;
  55601. /**
  55602. * Returns an array of the actively used textures.
  55603. * @param activeTextures Array of BaseTextures
  55604. */
  55605. getActiveTextures(activeTextures: BaseTexture[]): void;
  55606. /**
  55607. * Returns the animatable textures.
  55608. * @param animatables Array of animatable textures.
  55609. */
  55610. getAnimatables(animatables: IAnimatable[]): void;
  55611. /**
  55612. * Disposes the resources of the material.
  55613. * @param forceDisposeTextures - Forces the disposal of all textures.
  55614. */
  55615. dispose(forceDisposeTextures?: boolean): void;
  55616. /**
  55617. * Get the current class name of the texture useful for serialization or dynamic coding.
  55618. * @returns "PBRSheenConfiguration"
  55619. */
  55620. getClassName(): string;
  55621. /**
  55622. * Add fallbacks to the effect fallbacks list.
  55623. * @param defines defines the Base texture to use.
  55624. * @param fallbacks defines the current fallback list.
  55625. * @param currentRank defines the current fallback rank.
  55626. * @returns the new fallback rank.
  55627. */
  55628. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55629. /**
  55630. * Add the required uniforms to the current list.
  55631. * @param uniforms defines the current uniform list.
  55632. */
  55633. static AddUniforms(uniforms: string[]): void;
  55634. /**
  55635. * Add the required uniforms to the current buffer.
  55636. * @param uniformBuffer defines the current uniform buffer.
  55637. */
  55638. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55639. /**
  55640. * Add the required samplers to the current list.
  55641. * @param samplers defines the current sampler list.
  55642. */
  55643. static AddSamplers(samplers: string[]): void;
  55644. /**
  55645. * Makes a duplicate of the current configuration into another one.
  55646. * @param sheenConfiguration define the config where to copy the info
  55647. */
  55648. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55649. /**
  55650. * Serializes this BRDF configuration.
  55651. * @returns - An object with the serialized config.
  55652. */
  55653. serialize(): any;
  55654. /**
  55655. * Parses a anisotropy Configuration from a serialized object.
  55656. * @param source - Serialized object.
  55657. * @param scene Defines the scene we are parsing for
  55658. * @param rootUrl Defines the rootUrl to load from
  55659. */
  55660. parse(source: any, scene: Scene, rootUrl: string): void;
  55661. }
  55662. }
  55663. declare module BABYLON {
  55664. /**
  55665. * @hidden
  55666. */
  55667. export interface IMaterialSubSurfaceDefines {
  55668. SUBSURFACE: boolean;
  55669. SS_REFRACTION: boolean;
  55670. SS_TRANSLUCENCY: boolean;
  55671. SS_SCATTERING: boolean;
  55672. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55673. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55674. SS_REFRACTIONMAP_3D: boolean;
  55675. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55676. SS_LODINREFRACTIONALPHA: boolean;
  55677. SS_GAMMAREFRACTION: boolean;
  55678. SS_RGBDREFRACTION: boolean;
  55679. SS_LINEARSPECULARREFRACTION: boolean;
  55680. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55681. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55682. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55683. /** @hidden */
  55684. _areTexturesDirty: boolean;
  55685. }
  55686. /**
  55687. * Define the code related to the sub surface parameters of the pbr material.
  55688. */
  55689. export class PBRSubSurfaceConfiguration {
  55690. private _isRefractionEnabled;
  55691. /**
  55692. * Defines if the refraction is enabled in the material.
  55693. */
  55694. isRefractionEnabled: boolean;
  55695. private _isTranslucencyEnabled;
  55696. /**
  55697. * Defines if the translucency is enabled in the material.
  55698. */
  55699. isTranslucencyEnabled: boolean;
  55700. private _isScatteringEnabled;
  55701. /**
  55702. * Defines if the sub surface scattering is enabled in the material.
  55703. */
  55704. isScatteringEnabled: boolean;
  55705. private _scatteringDiffusionProfileIndex;
  55706. /**
  55707. * Diffusion profile for subsurface scattering.
  55708. * Useful for better scattering in the skins or foliages.
  55709. */
  55710. get scatteringDiffusionProfile(): Nullable<Color3>;
  55711. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55712. /**
  55713. * Defines the refraction intensity of the material.
  55714. * The refraction when enabled replaces the Diffuse part of the material.
  55715. * The intensity helps transitionning between diffuse and refraction.
  55716. */
  55717. refractionIntensity: number;
  55718. /**
  55719. * Defines the translucency intensity of the material.
  55720. * When translucency has been enabled, this defines how much of the "translucency"
  55721. * is addded to the diffuse part of the material.
  55722. */
  55723. translucencyIntensity: number;
  55724. /**
  55725. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55726. */
  55727. useAlbedoToTintRefraction: boolean;
  55728. private _thicknessTexture;
  55729. /**
  55730. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55731. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55732. * 0 would mean minimumThickness
  55733. * 1 would mean maximumThickness
  55734. * The other channels might be use as a mask to vary the different effects intensity.
  55735. */
  55736. thicknessTexture: Nullable<BaseTexture>;
  55737. private _refractionTexture;
  55738. /**
  55739. * Defines the texture to use for refraction.
  55740. */
  55741. refractionTexture: Nullable<BaseTexture>;
  55742. private _indexOfRefraction;
  55743. /**
  55744. * Index of refraction of the material base layer.
  55745. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55746. *
  55747. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55748. *
  55749. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55750. */
  55751. indexOfRefraction: number;
  55752. private _volumeIndexOfRefraction;
  55753. /**
  55754. * Index of refraction of the material's volume.
  55755. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55756. *
  55757. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55758. * the volume will use the same IOR as the surface.
  55759. */
  55760. get volumeIndexOfRefraction(): number;
  55761. set volumeIndexOfRefraction(value: number);
  55762. private _invertRefractionY;
  55763. /**
  55764. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55765. */
  55766. invertRefractionY: boolean;
  55767. private _linkRefractionWithTransparency;
  55768. /**
  55769. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55770. * Materials half opaque for instance using refraction could benefit from this control.
  55771. */
  55772. linkRefractionWithTransparency: boolean;
  55773. /**
  55774. * Defines the minimum thickness stored in the thickness map.
  55775. * If no thickness map is defined, this value will be used to simulate thickness.
  55776. */
  55777. minimumThickness: number;
  55778. /**
  55779. * Defines the maximum thickness stored in the thickness map.
  55780. */
  55781. maximumThickness: number;
  55782. /**
  55783. * Defines the volume tint of the material.
  55784. * This is used for both translucency and scattering.
  55785. */
  55786. tintColor: Color3;
  55787. /**
  55788. * Defines the distance at which the tint color should be found in the media.
  55789. * This is used for refraction only.
  55790. */
  55791. tintColorAtDistance: number;
  55792. /**
  55793. * Defines how far each channel transmit through the media.
  55794. * It is defined as a color to simplify it selection.
  55795. */
  55796. diffusionDistance: Color3;
  55797. private _useMaskFromThicknessTexture;
  55798. /**
  55799. * Stores the intensity of the different subsurface effects in the thickness texture.
  55800. * * the green channel is the translucency intensity.
  55801. * * the blue channel is the scattering intensity.
  55802. * * the alpha channel is the refraction intensity.
  55803. */
  55804. useMaskFromThicknessTexture: boolean;
  55805. private _scene;
  55806. /** @hidden */
  55807. private _internalMarkAllSubMeshesAsTexturesDirty;
  55808. private _internalMarkScenePrePassDirty;
  55809. /** @hidden */
  55810. _markAllSubMeshesAsTexturesDirty(): void;
  55811. /** @hidden */
  55812. _markScenePrePassDirty(): void;
  55813. /**
  55814. * Instantiate a new istance of sub surface configuration.
  55815. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55816. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55817. * @param scene The scene
  55818. */
  55819. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55820. /**
  55821. * Gets wehter the submesh is ready to be used or not.
  55822. * @param defines the list of "defines" to update.
  55823. * @param scene defines the scene the material belongs to.
  55824. * @returns - boolean indicating that the submesh is ready or not.
  55825. */
  55826. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55827. /**
  55828. * Checks to see if a texture is used in the material.
  55829. * @param defines the list of "defines" to update.
  55830. * @param scene defines the scene to the material belongs to.
  55831. */
  55832. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55833. /**
  55834. * Binds the material data.
  55835. * @param uniformBuffer defines the Uniform buffer to fill in.
  55836. * @param scene defines the scene the material belongs to.
  55837. * @param engine defines the engine the material belongs to.
  55838. * @param isFrozen defines whether the material is frozen or not.
  55839. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55840. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55841. */
  55842. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55843. /**
  55844. * Unbinds the material from the mesh.
  55845. * @param activeEffect defines the effect that should be unbound from.
  55846. * @returns true if unbound, otherwise false
  55847. */
  55848. unbind(activeEffect: Effect): boolean;
  55849. /**
  55850. * Returns the texture used for refraction or null if none is used.
  55851. * @param scene defines the scene the material belongs to.
  55852. * @returns - Refraction texture if present. If no refraction texture and refraction
  55853. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55854. */
  55855. private _getRefractionTexture;
  55856. /**
  55857. * Returns true if alpha blending should be disabled.
  55858. */
  55859. get disableAlphaBlending(): boolean;
  55860. /**
  55861. * Fills the list of render target textures.
  55862. * @param renderTargets the list of render targets to update
  55863. */
  55864. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55865. /**
  55866. * Checks to see if a texture is used in the material.
  55867. * @param texture - Base texture to use.
  55868. * @returns - Boolean specifying if a texture is used in the material.
  55869. */
  55870. hasTexture(texture: BaseTexture): boolean;
  55871. /**
  55872. * Gets a boolean indicating that current material needs to register RTT
  55873. * @returns true if this uses a render target otherwise false.
  55874. */
  55875. hasRenderTargetTextures(): boolean;
  55876. /**
  55877. * Returns an array of the actively used textures.
  55878. * @param activeTextures Array of BaseTextures
  55879. */
  55880. getActiveTextures(activeTextures: BaseTexture[]): void;
  55881. /**
  55882. * Returns the animatable textures.
  55883. * @param animatables Array of animatable textures.
  55884. */
  55885. getAnimatables(animatables: IAnimatable[]): void;
  55886. /**
  55887. * Disposes the resources of the material.
  55888. * @param forceDisposeTextures - Forces the disposal of all textures.
  55889. */
  55890. dispose(forceDisposeTextures?: boolean): void;
  55891. /**
  55892. * Get the current class name of the texture useful for serialization or dynamic coding.
  55893. * @returns "PBRSubSurfaceConfiguration"
  55894. */
  55895. getClassName(): string;
  55896. /**
  55897. * Add fallbacks to the effect fallbacks list.
  55898. * @param defines defines the Base texture to use.
  55899. * @param fallbacks defines the current fallback list.
  55900. * @param currentRank defines the current fallback rank.
  55901. * @returns the new fallback rank.
  55902. */
  55903. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55904. /**
  55905. * Add the required uniforms to the current list.
  55906. * @param uniforms defines the current uniform list.
  55907. */
  55908. static AddUniforms(uniforms: string[]): void;
  55909. /**
  55910. * Add the required samplers to the current list.
  55911. * @param samplers defines the current sampler list.
  55912. */
  55913. static AddSamplers(samplers: string[]): void;
  55914. /**
  55915. * Add the required uniforms to the current buffer.
  55916. * @param uniformBuffer defines the current uniform buffer.
  55917. */
  55918. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55919. /**
  55920. * Makes a duplicate of the current configuration into another one.
  55921. * @param configuration define the config where to copy the info
  55922. */
  55923. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55924. /**
  55925. * Serializes this Sub Surface configuration.
  55926. * @returns - An object with the serialized config.
  55927. */
  55928. serialize(): any;
  55929. /**
  55930. * Parses a anisotropy Configuration from a serialized object.
  55931. * @param source - Serialized object.
  55932. * @param scene Defines the scene we are parsing for
  55933. * @param rootUrl Defines the rootUrl to load from
  55934. */
  55935. parse(source: any, scene: Scene, rootUrl: string): void;
  55936. }
  55937. }
  55938. declare module BABYLON {
  55939. /** @hidden */
  55940. export var pbrFragmentDeclaration: {
  55941. name: string;
  55942. shader: string;
  55943. };
  55944. }
  55945. declare module BABYLON {
  55946. /** @hidden */
  55947. export var pbrUboDeclaration: {
  55948. name: string;
  55949. shader: string;
  55950. };
  55951. }
  55952. declare module BABYLON {
  55953. /** @hidden */
  55954. export var pbrFragmentExtraDeclaration: {
  55955. name: string;
  55956. shader: string;
  55957. };
  55958. }
  55959. declare module BABYLON {
  55960. /** @hidden */
  55961. export var pbrFragmentSamplersDeclaration: {
  55962. name: string;
  55963. shader: string;
  55964. };
  55965. }
  55966. declare module BABYLON {
  55967. /** @hidden */
  55968. export var importanceSampling: {
  55969. name: string;
  55970. shader: string;
  55971. };
  55972. }
  55973. declare module BABYLON {
  55974. /** @hidden */
  55975. export var pbrHelperFunctions: {
  55976. name: string;
  55977. shader: string;
  55978. };
  55979. }
  55980. declare module BABYLON {
  55981. /** @hidden */
  55982. export var harmonicsFunctions: {
  55983. name: string;
  55984. shader: string;
  55985. };
  55986. }
  55987. declare module BABYLON {
  55988. /** @hidden */
  55989. export var pbrDirectLightingSetupFunctions: {
  55990. name: string;
  55991. shader: string;
  55992. };
  55993. }
  55994. declare module BABYLON {
  55995. /** @hidden */
  55996. export var pbrDirectLightingFalloffFunctions: {
  55997. name: string;
  55998. shader: string;
  55999. };
  56000. }
  56001. declare module BABYLON {
  56002. /** @hidden */
  56003. export var pbrBRDFFunctions: {
  56004. name: string;
  56005. shader: string;
  56006. };
  56007. }
  56008. declare module BABYLON {
  56009. /** @hidden */
  56010. export var hdrFilteringFunctions: {
  56011. name: string;
  56012. shader: string;
  56013. };
  56014. }
  56015. declare module BABYLON {
  56016. /** @hidden */
  56017. export var pbrDirectLightingFunctions: {
  56018. name: string;
  56019. shader: string;
  56020. };
  56021. }
  56022. declare module BABYLON {
  56023. /** @hidden */
  56024. export var pbrIBLFunctions: {
  56025. name: string;
  56026. shader: string;
  56027. };
  56028. }
  56029. declare module BABYLON {
  56030. /** @hidden */
  56031. export var pbrBlockAlbedoOpacity: {
  56032. name: string;
  56033. shader: string;
  56034. };
  56035. }
  56036. declare module BABYLON {
  56037. /** @hidden */
  56038. export var pbrBlockReflectivity: {
  56039. name: string;
  56040. shader: string;
  56041. };
  56042. }
  56043. declare module BABYLON {
  56044. /** @hidden */
  56045. export var pbrBlockAmbientOcclusion: {
  56046. name: string;
  56047. shader: string;
  56048. };
  56049. }
  56050. declare module BABYLON {
  56051. /** @hidden */
  56052. export var pbrBlockAlphaFresnel: {
  56053. name: string;
  56054. shader: string;
  56055. };
  56056. }
  56057. declare module BABYLON {
  56058. /** @hidden */
  56059. export var pbrBlockAnisotropic: {
  56060. name: string;
  56061. shader: string;
  56062. };
  56063. }
  56064. declare module BABYLON {
  56065. /** @hidden */
  56066. export var pbrBlockReflection: {
  56067. name: string;
  56068. shader: string;
  56069. };
  56070. }
  56071. declare module BABYLON {
  56072. /** @hidden */
  56073. export var pbrBlockSheen: {
  56074. name: string;
  56075. shader: string;
  56076. };
  56077. }
  56078. declare module BABYLON {
  56079. /** @hidden */
  56080. export var pbrBlockClearcoat: {
  56081. name: string;
  56082. shader: string;
  56083. };
  56084. }
  56085. declare module BABYLON {
  56086. /** @hidden */
  56087. export var pbrBlockSubSurface: {
  56088. name: string;
  56089. shader: string;
  56090. };
  56091. }
  56092. declare module BABYLON {
  56093. /** @hidden */
  56094. export var pbrBlockNormalGeometric: {
  56095. name: string;
  56096. shader: string;
  56097. };
  56098. }
  56099. declare module BABYLON {
  56100. /** @hidden */
  56101. export var pbrBlockNormalFinal: {
  56102. name: string;
  56103. shader: string;
  56104. };
  56105. }
  56106. declare module BABYLON {
  56107. /** @hidden */
  56108. export var pbrBlockLightmapInit: {
  56109. name: string;
  56110. shader: string;
  56111. };
  56112. }
  56113. declare module BABYLON {
  56114. /** @hidden */
  56115. export var pbrBlockGeometryInfo: {
  56116. name: string;
  56117. shader: string;
  56118. };
  56119. }
  56120. declare module BABYLON {
  56121. /** @hidden */
  56122. export var pbrBlockReflectance0: {
  56123. name: string;
  56124. shader: string;
  56125. };
  56126. }
  56127. declare module BABYLON {
  56128. /** @hidden */
  56129. export var pbrBlockReflectance: {
  56130. name: string;
  56131. shader: string;
  56132. };
  56133. }
  56134. declare module BABYLON {
  56135. /** @hidden */
  56136. export var pbrBlockDirectLighting: {
  56137. name: string;
  56138. shader: string;
  56139. };
  56140. }
  56141. declare module BABYLON {
  56142. /** @hidden */
  56143. export var pbrBlockFinalLitComponents: {
  56144. name: string;
  56145. shader: string;
  56146. };
  56147. }
  56148. declare module BABYLON {
  56149. /** @hidden */
  56150. export var pbrBlockFinalUnlitComponents: {
  56151. name: string;
  56152. shader: string;
  56153. };
  56154. }
  56155. declare module BABYLON {
  56156. /** @hidden */
  56157. export var pbrBlockFinalColorComposition: {
  56158. name: string;
  56159. shader: string;
  56160. };
  56161. }
  56162. declare module BABYLON {
  56163. /** @hidden */
  56164. export var pbrBlockImageProcessing: {
  56165. name: string;
  56166. shader: string;
  56167. };
  56168. }
  56169. declare module BABYLON {
  56170. /** @hidden */
  56171. export var pbrDebug: {
  56172. name: string;
  56173. shader: string;
  56174. };
  56175. }
  56176. declare module BABYLON {
  56177. /** @hidden */
  56178. export var pbrPixelShader: {
  56179. name: string;
  56180. shader: string;
  56181. };
  56182. }
  56183. declare module BABYLON {
  56184. /** @hidden */
  56185. export var pbrVertexDeclaration: {
  56186. name: string;
  56187. shader: string;
  56188. };
  56189. }
  56190. declare module BABYLON {
  56191. /** @hidden */
  56192. export var pbrVertexShader: {
  56193. name: string;
  56194. shader: string;
  56195. };
  56196. }
  56197. declare module BABYLON {
  56198. /**
  56199. * Manages the defines for the PBR Material.
  56200. * @hidden
  56201. */
  56202. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56203. PBR: boolean;
  56204. NUM_SAMPLES: string;
  56205. REALTIME_FILTERING: boolean;
  56206. MAINUV1: boolean;
  56207. MAINUV2: boolean;
  56208. UV1: boolean;
  56209. UV2: boolean;
  56210. ALBEDO: boolean;
  56211. GAMMAALBEDO: boolean;
  56212. ALBEDODIRECTUV: number;
  56213. VERTEXCOLOR: boolean;
  56214. DETAIL: boolean;
  56215. DETAILDIRECTUV: number;
  56216. DETAIL_NORMALBLENDMETHOD: number;
  56217. AMBIENT: boolean;
  56218. AMBIENTDIRECTUV: number;
  56219. AMBIENTINGRAYSCALE: boolean;
  56220. OPACITY: boolean;
  56221. VERTEXALPHA: boolean;
  56222. OPACITYDIRECTUV: number;
  56223. OPACITYRGB: boolean;
  56224. ALPHATEST: boolean;
  56225. DEPTHPREPASS: boolean;
  56226. ALPHABLEND: boolean;
  56227. ALPHAFROMALBEDO: boolean;
  56228. ALPHATESTVALUE: string;
  56229. SPECULAROVERALPHA: boolean;
  56230. RADIANCEOVERALPHA: boolean;
  56231. ALPHAFRESNEL: boolean;
  56232. LINEARALPHAFRESNEL: boolean;
  56233. PREMULTIPLYALPHA: boolean;
  56234. EMISSIVE: boolean;
  56235. EMISSIVEDIRECTUV: number;
  56236. REFLECTIVITY: boolean;
  56237. REFLECTIVITYDIRECTUV: number;
  56238. SPECULARTERM: boolean;
  56239. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56240. MICROSURFACEAUTOMATIC: boolean;
  56241. LODBASEDMICROSFURACE: boolean;
  56242. MICROSURFACEMAP: boolean;
  56243. MICROSURFACEMAPDIRECTUV: number;
  56244. METALLICWORKFLOW: boolean;
  56245. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56246. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56247. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56248. AOSTOREINMETALMAPRED: boolean;
  56249. METALLIC_REFLECTANCE: boolean;
  56250. METALLIC_REFLECTANCEDIRECTUV: number;
  56251. ENVIRONMENTBRDF: boolean;
  56252. ENVIRONMENTBRDF_RGBD: boolean;
  56253. NORMAL: boolean;
  56254. TANGENT: boolean;
  56255. BUMP: boolean;
  56256. BUMPDIRECTUV: number;
  56257. OBJECTSPACE_NORMALMAP: boolean;
  56258. PARALLAX: boolean;
  56259. PARALLAXOCCLUSION: boolean;
  56260. NORMALXYSCALE: boolean;
  56261. LIGHTMAP: boolean;
  56262. LIGHTMAPDIRECTUV: number;
  56263. USELIGHTMAPASSHADOWMAP: boolean;
  56264. GAMMALIGHTMAP: boolean;
  56265. RGBDLIGHTMAP: boolean;
  56266. REFLECTION: boolean;
  56267. REFLECTIONMAP_3D: boolean;
  56268. REFLECTIONMAP_SPHERICAL: boolean;
  56269. REFLECTIONMAP_PLANAR: boolean;
  56270. REFLECTIONMAP_CUBIC: boolean;
  56271. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56272. REFLECTIONMAP_PROJECTION: boolean;
  56273. REFLECTIONMAP_SKYBOX: boolean;
  56274. REFLECTIONMAP_EXPLICIT: boolean;
  56275. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56276. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56277. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56278. INVERTCUBICMAP: boolean;
  56279. USESPHERICALFROMREFLECTIONMAP: boolean;
  56280. USEIRRADIANCEMAP: boolean;
  56281. SPHERICAL_HARMONICS: boolean;
  56282. USESPHERICALINVERTEX: boolean;
  56283. REFLECTIONMAP_OPPOSITEZ: boolean;
  56284. LODINREFLECTIONALPHA: boolean;
  56285. GAMMAREFLECTION: boolean;
  56286. RGBDREFLECTION: boolean;
  56287. LINEARSPECULARREFLECTION: boolean;
  56288. RADIANCEOCCLUSION: boolean;
  56289. HORIZONOCCLUSION: boolean;
  56290. INSTANCES: boolean;
  56291. THIN_INSTANCES: boolean;
  56292. PREPASS: boolean;
  56293. SCENE_MRT_COUNT: number;
  56294. NUM_BONE_INFLUENCERS: number;
  56295. BonesPerMesh: number;
  56296. BONETEXTURE: boolean;
  56297. NONUNIFORMSCALING: boolean;
  56298. MORPHTARGETS: boolean;
  56299. MORPHTARGETS_NORMAL: boolean;
  56300. MORPHTARGETS_TANGENT: boolean;
  56301. MORPHTARGETS_UV: boolean;
  56302. NUM_MORPH_INFLUENCERS: number;
  56303. IMAGEPROCESSING: boolean;
  56304. VIGNETTE: boolean;
  56305. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56306. VIGNETTEBLENDMODEOPAQUE: boolean;
  56307. TONEMAPPING: boolean;
  56308. TONEMAPPING_ACES: boolean;
  56309. CONTRAST: boolean;
  56310. COLORCURVES: boolean;
  56311. COLORGRADING: boolean;
  56312. COLORGRADING3D: boolean;
  56313. SAMPLER3DGREENDEPTH: boolean;
  56314. SAMPLER3DBGRMAP: boolean;
  56315. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56316. EXPOSURE: boolean;
  56317. MULTIVIEW: boolean;
  56318. USEPHYSICALLIGHTFALLOFF: boolean;
  56319. USEGLTFLIGHTFALLOFF: boolean;
  56320. TWOSIDEDLIGHTING: boolean;
  56321. SHADOWFLOAT: boolean;
  56322. CLIPPLANE: boolean;
  56323. CLIPPLANE2: boolean;
  56324. CLIPPLANE3: boolean;
  56325. CLIPPLANE4: boolean;
  56326. CLIPPLANE5: boolean;
  56327. CLIPPLANE6: boolean;
  56328. POINTSIZE: boolean;
  56329. FOG: boolean;
  56330. LOGARITHMICDEPTH: boolean;
  56331. FORCENORMALFORWARD: boolean;
  56332. SPECULARAA: boolean;
  56333. CLEARCOAT: boolean;
  56334. CLEARCOAT_DEFAULTIOR: boolean;
  56335. CLEARCOAT_TEXTURE: boolean;
  56336. CLEARCOAT_TEXTUREDIRECTUV: number;
  56337. CLEARCOAT_BUMP: boolean;
  56338. CLEARCOAT_BUMPDIRECTUV: number;
  56339. CLEARCOAT_TINT: boolean;
  56340. CLEARCOAT_TINT_TEXTURE: boolean;
  56341. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56342. ANISOTROPIC: boolean;
  56343. ANISOTROPIC_TEXTURE: boolean;
  56344. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56345. BRDF_V_HEIGHT_CORRELATED: boolean;
  56346. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56347. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56348. SHEEN: boolean;
  56349. SHEEN_TEXTURE: boolean;
  56350. SHEEN_TEXTUREDIRECTUV: number;
  56351. SHEEN_LINKWITHALBEDO: boolean;
  56352. SHEEN_ROUGHNESS: boolean;
  56353. SHEEN_ALBEDOSCALING: boolean;
  56354. SUBSURFACE: boolean;
  56355. SS_REFRACTION: boolean;
  56356. SS_TRANSLUCENCY: boolean;
  56357. SS_SCATTERING: boolean;
  56358. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56359. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56360. SS_REFRACTIONMAP_3D: boolean;
  56361. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56362. SS_LODINREFRACTIONALPHA: boolean;
  56363. SS_GAMMAREFRACTION: boolean;
  56364. SS_RGBDREFRACTION: boolean;
  56365. SS_LINEARSPECULARREFRACTION: boolean;
  56366. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56367. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56368. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56369. UNLIT: boolean;
  56370. DEBUGMODE: number;
  56371. /**
  56372. * Initializes the PBR Material defines.
  56373. */
  56374. constructor();
  56375. /**
  56376. * Resets the PBR Material defines.
  56377. */
  56378. reset(): void;
  56379. }
  56380. /**
  56381. * The Physically based material base class of BJS.
  56382. *
  56383. * This offers the main features of a standard PBR material.
  56384. * For more information, please refer to the documentation :
  56385. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56386. */
  56387. export abstract class PBRBaseMaterial extends PushMaterial {
  56388. /**
  56389. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56390. */
  56391. static readonly PBRMATERIAL_OPAQUE: number;
  56392. /**
  56393. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56394. */
  56395. static readonly PBRMATERIAL_ALPHATEST: number;
  56396. /**
  56397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56398. */
  56399. static readonly PBRMATERIAL_ALPHABLEND: number;
  56400. /**
  56401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56402. * They are also discarded below the alpha cutoff threshold to improve performances.
  56403. */
  56404. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56405. /**
  56406. * Defines the default value of how much AO map is occluding the analytical lights
  56407. * (point spot...).
  56408. */
  56409. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56410. /**
  56411. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56412. */
  56413. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56414. /**
  56415. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56416. * to enhance interoperability with other engines.
  56417. */
  56418. static readonly LIGHTFALLOFF_GLTF: number;
  56419. /**
  56420. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56421. * to enhance interoperability with other materials.
  56422. */
  56423. static readonly LIGHTFALLOFF_STANDARD: number;
  56424. /**
  56425. * Intensity of the direct lights e.g. the four lights available in your scene.
  56426. * This impacts both the direct diffuse and specular highlights.
  56427. */
  56428. protected _directIntensity: number;
  56429. /**
  56430. * Intensity of the emissive part of the material.
  56431. * This helps controlling the emissive effect without modifying the emissive color.
  56432. */
  56433. protected _emissiveIntensity: number;
  56434. /**
  56435. * Intensity of the environment e.g. how much the environment will light the object
  56436. * either through harmonics for rough material or through the refelction for shiny ones.
  56437. */
  56438. protected _environmentIntensity: number;
  56439. /**
  56440. * This is a special control allowing the reduction of the specular highlights coming from the
  56441. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56442. */
  56443. protected _specularIntensity: number;
  56444. /**
  56445. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56446. */
  56447. private _lightingInfos;
  56448. /**
  56449. * Debug Control allowing disabling the bump map on this material.
  56450. */
  56451. protected _disableBumpMap: boolean;
  56452. /**
  56453. * AKA Diffuse Texture in standard nomenclature.
  56454. */
  56455. protected _albedoTexture: Nullable<BaseTexture>;
  56456. /**
  56457. * AKA Occlusion Texture in other nomenclature.
  56458. */
  56459. protected _ambientTexture: Nullable<BaseTexture>;
  56460. /**
  56461. * AKA Occlusion Texture Intensity in other nomenclature.
  56462. */
  56463. protected _ambientTextureStrength: number;
  56464. /**
  56465. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56466. * 1 means it completely occludes it
  56467. * 0 mean it has no impact
  56468. */
  56469. protected _ambientTextureImpactOnAnalyticalLights: number;
  56470. /**
  56471. * Stores the alpha values in a texture.
  56472. */
  56473. protected _opacityTexture: Nullable<BaseTexture>;
  56474. /**
  56475. * Stores the reflection values in a texture.
  56476. */
  56477. protected _reflectionTexture: Nullable<BaseTexture>;
  56478. /**
  56479. * Stores the emissive values in a texture.
  56480. */
  56481. protected _emissiveTexture: Nullable<BaseTexture>;
  56482. /**
  56483. * AKA Specular texture in other nomenclature.
  56484. */
  56485. protected _reflectivityTexture: Nullable<BaseTexture>;
  56486. /**
  56487. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56488. */
  56489. protected _metallicTexture: Nullable<BaseTexture>;
  56490. /**
  56491. * Specifies the metallic scalar of the metallic/roughness workflow.
  56492. * Can also be used to scale the metalness values of the metallic texture.
  56493. */
  56494. protected _metallic: Nullable<number>;
  56495. /**
  56496. * Specifies the roughness scalar of the metallic/roughness workflow.
  56497. * Can also be used to scale the roughness values of the metallic texture.
  56498. */
  56499. protected _roughness: Nullable<number>;
  56500. /**
  56501. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56502. * By default the indexOfrefraction is used to compute F0;
  56503. *
  56504. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56505. *
  56506. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56507. * F90 = metallicReflectanceColor;
  56508. */
  56509. protected _metallicF0Factor: number;
  56510. /**
  56511. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56512. * By default the F90 is always 1;
  56513. *
  56514. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56515. *
  56516. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56517. * F90 = metallicReflectanceColor;
  56518. */
  56519. protected _metallicReflectanceColor: Color3;
  56520. /**
  56521. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56522. * This is multiply against the scalar values defined in the material.
  56523. */
  56524. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56525. /**
  56526. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56527. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56528. */
  56529. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56530. /**
  56531. * Stores surface normal data used to displace a mesh in a texture.
  56532. */
  56533. protected _bumpTexture: Nullable<BaseTexture>;
  56534. /**
  56535. * Stores the pre-calculated light information of a mesh in a texture.
  56536. */
  56537. protected _lightmapTexture: Nullable<BaseTexture>;
  56538. /**
  56539. * The color of a material in ambient lighting.
  56540. */
  56541. protected _ambientColor: Color3;
  56542. /**
  56543. * AKA Diffuse Color in other nomenclature.
  56544. */
  56545. protected _albedoColor: Color3;
  56546. /**
  56547. * AKA Specular Color in other nomenclature.
  56548. */
  56549. protected _reflectivityColor: Color3;
  56550. /**
  56551. * The color applied when light is reflected from a material.
  56552. */
  56553. protected _reflectionColor: Color3;
  56554. /**
  56555. * The color applied when light is emitted from a material.
  56556. */
  56557. protected _emissiveColor: Color3;
  56558. /**
  56559. * AKA Glossiness in other nomenclature.
  56560. */
  56561. protected _microSurface: number;
  56562. /**
  56563. * Specifies that the material will use the light map as a show map.
  56564. */
  56565. protected _useLightmapAsShadowmap: boolean;
  56566. /**
  56567. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56568. * makes the reflect vector face the model (under horizon).
  56569. */
  56570. protected _useHorizonOcclusion: boolean;
  56571. /**
  56572. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56573. * too much the area relying on ambient texture to define their ambient occlusion.
  56574. */
  56575. protected _useRadianceOcclusion: boolean;
  56576. /**
  56577. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56578. */
  56579. protected _useAlphaFromAlbedoTexture: boolean;
  56580. /**
  56581. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56582. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56583. */
  56584. protected _useSpecularOverAlpha: boolean;
  56585. /**
  56586. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56587. */
  56588. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56589. /**
  56590. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56591. */
  56592. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56593. /**
  56594. * Specifies if the metallic texture contains the roughness information in its green channel.
  56595. */
  56596. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56597. /**
  56598. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56599. */
  56600. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56601. /**
  56602. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56603. */
  56604. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56605. /**
  56606. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56607. */
  56608. protected _useAmbientInGrayScale: boolean;
  56609. /**
  56610. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56611. * The material will try to infer what glossiness each pixel should be.
  56612. */
  56613. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56614. /**
  56615. * Defines the falloff type used in this material.
  56616. * It by default is Physical.
  56617. */
  56618. protected _lightFalloff: number;
  56619. /**
  56620. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56621. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56622. */
  56623. protected _useRadianceOverAlpha: boolean;
  56624. /**
  56625. * Allows using an object space normal map (instead of tangent space).
  56626. */
  56627. protected _useObjectSpaceNormalMap: boolean;
  56628. /**
  56629. * Allows using the bump map in parallax mode.
  56630. */
  56631. protected _useParallax: boolean;
  56632. /**
  56633. * Allows using the bump map in parallax occlusion mode.
  56634. */
  56635. protected _useParallaxOcclusion: boolean;
  56636. /**
  56637. * Controls the scale bias of the parallax mode.
  56638. */
  56639. protected _parallaxScaleBias: number;
  56640. /**
  56641. * If sets to true, disables all the lights affecting the material.
  56642. */
  56643. protected _disableLighting: boolean;
  56644. /**
  56645. * Number of Simultaneous lights allowed on the material.
  56646. */
  56647. protected _maxSimultaneousLights: number;
  56648. /**
  56649. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56650. */
  56651. protected _invertNormalMapX: boolean;
  56652. /**
  56653. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56654. */
  56655. protected _invertNormalMapY: boolean;
  56656. /**
  56657. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56658. */
  56659. protected _twoSidedLighting: boolean;
  56660. /**
  56661. * Defines the alpha limits in alpha test mode.
  56662. */
  56663. protected _alphaCutOff: number;
  56664. /**
  56665. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56666. */
  56667. protected _forceAlphaTest: boolean;
  56668. /**
  56669. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56670. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56671. */
  56672. protected _useAlphaFresnel: boolean;
  56673. /**
  56674. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56675. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56676. */
  56677. protected _useLinearAlphaFresnel: boolean;
  56678. /**
  56679. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56680. * from cos thetav and roughness:
  56681. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56682. */
  56683. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56684. /**
  56685. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56686. */
  56687. protected _forceIrradianceInFragment: boolean;
  56688. private _realTimeFiltering;
  56689. /**
  56690. * Enables realtime filtering on the texture.
  56691. */
  56692. get realTimeFiltering(): boolean;
  56693. set realTimeFiltering(b: boolean);
  56694. private _realTimeFilteringQuality;
  56695. /**
  56696. * Quality switch for realtime filtering
  56697. */
  56698. get realTimeFilteringQuality(): number;
  56699. set realTimeFilteringQuality(n: number);
  56700. /**
  56701. * Can this material render to several textures at once
  56702. */
  56703. get canRenderToMRT(): boolean;
  56704. /**
  56705. * Force normal to face away from face.
  56706. */
  56707. protected _forceNormalForward: boolean;
  56708. /**
  56709. * Enables specular anti aliasing in the PBR shader.
  56710. * It will both interacts on the Geometry for analytical and IBL lighting.
  56711. * It also prefilter the roughness map based on the bump values.
  56712. */
  56713. protected _enableSpecularAntiAliasing: boolean;
  56714. /**
  56715. * Default configuration related to image processing available in the PBR Material.
  56716. */
  56717. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56718. /**
  56719. * Keep track of the image processing observer to allow dispose and replace.
  56720. */
  56721. private _imageProcessingObserver;
  56722. /**
  56723. * Attaches a new image processing configuration to the PBR Material.
  56724. * @param configuration
  56725. */
  56726. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56727. /**
  56728. * Stores the available render targets.
  56729. */
  56730. private _renderTargets;
  56731. /**
  56732. * Sets the global ambient color for the material used in lighting calculations.
  56733. */
  56734. private _globalAmbientColor;
  56735. /**
  56736. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56737. */
  56738. private _useLogarithmicDepth;
  56739. /**
  56740. * If set to true, no lighting calculations will be applied.
  56741. */
  56742. private _unlit;
  56743. private _debugMode;
  56744. /**
  56745. * @hidden
  56746. * This is reserved for the inspector.
  56747. * Defines the material debug mode.
  56748. * It helps seeing only some components of the material while troubleshooting.
  56749. */
  56750. debugMode: number;
  56751. /**
  56752. * @hidden
  56753. * This is reserved for the inspector.
  56754. * Specify from where on screen the debug mode should start.
  56755. * The value goes from -1 (full screen) to 1 (not visible)
  56756. * It helps with side by side comparison against the final render
  56757. * This defaults to -1
  56758. */
  56759. private debugLimit;
  56760. /**
  56761. * @hidden
  56762. * This is reserved for the inspector.
  56763. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56764. * You can use the factor to better multiply the final value.
  56765. */
  56766. private debugFactor;
  56767. /**
  56768. * Defines the clear coat layer parameters for the material.
  56769. */
  56770. readonly clearCoat: PBRClearCoatConfiguration;
  56771. /**
  56772. * Defines the anisotropic parameters for the material.
  56773. */
  56774. readonly anisotropy: PBRAnisotropicConfiguration;
  56775. /**
  56776. * Defines the BRDF parameters for the material.
  56777. */
  56778. readonly brdf: PBRBRDFConfiguration;
  56779. /**
  56780. * Defines the Sheen parameters for the material.
  56781. */
  56782. readonly sheen: PBRSheenConfiguration;
  56783. /**
  56784. * Defines the SubSurface parameters for the material.
  56785. */
  56786. readonly subSurface: PBRSubSurfaceConfiguration;
  56787. /**
  56788. * Defines the detail map parameters for the material.
  56789. */
  56790. readonly detailMap: DetailMapConfiguration;
  56791. protected _rebuildInParallel: boolean;
  56792. /**
  56793. * Instantiates a new PBRMaterial instance.
  56794. *
  56795. * @param name The material name
  56796. * @param scene The scene the material will be use in.
  56797. */
  56798. constructor(name: string, scene: Scene);
  56799. /**
  56800. * Gets a boolean indicating that current material needs to register RTT
  56801. */
  56802. get hasRenderTargetTextures(): boolean;
  56803. /**
  56804. * Gets the name of the material class.
  56805. */
  56806. getClassName(): string;
  56807. /**
  56808. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56809. */
  56810. get useLogarithmicDepth(): boolean;
  56811. /**
  56812. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56813. */
  56814. set useLogarithmicDepth(value: boolean);
  56815. /**
  56816. * Returns true if alpha blending should be disabled.
  56817. */
  56818. protected get _disableAlphaBlending(): boolean;
  56819. /**
  56820. * Specifies whether or not this material should be rendered in alpha blend mode.
  56821. */
  56822. needAlphaBlending(): boolean;
  56823. /**
  56824. * Specifies whether or not this material should be rendered in alpha test mode.
  56825. */
  56826. needAlphaTesting(): boolean;
  56827. /**
  56828. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56829. */
  56830. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56831. /**
  56832. * Gets the texture used for the alpha test.
  56833. */
  56834. getAlphaTestTexture(): Nullable<BaseTexture>;
  56835. /**
  56836. * Specifies that the submesh is ready to be used.
  56837. * @param mesh - BJS mesh.
  56838. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56839. * @param useInstances - Specifies that instances should be used.
  56840. * @returns - boolean indicating that the submesh is ready or not.
  56841. */
  56842. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56843. /**
  56844. * Specifies if the material uses metallic roughness workflow.
  56845. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56846. */
  56847. isMetallicWorkflow(): boolean;
  56848. private _prepareEffect;
  56849. private _prepareDefines;
  56850. /**
  56851. * Force shader compilation
  56852. */
  56853. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56854. /**
  56855. * Initializes the uniform buffer layout for the shader.
  56856. */
  56857. buildUniformLayout(): void;
  56858. /**
  56859. * Unbinds the material from the mesh
  56860. */
  56861. unbind(): void;
  56862. /**
  56863. * Binds the submesh data.
  56864. * @param world - The world matrix.
  56865. * @param mesh - The BJS mesh.
  56866. * @param subMesh - A submesh of the BJS mesh.
  56867. */
  56868. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56869. /**
  56870. * Returns the animatable textures.
  56871. * @returns - Array of animatable textures.
  56872. */
  56873. getAnimatables(): IAnimatable[];
  56874. /**
  56875. * Returns the texture used for reflections.
  56876. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56877. */
  56878. private _getReflectionTexture;
  56879. /**
  56880. * Returns an array of the actively used textures.
  56881. * @returns - Array of BaseTextures
  56882. */
  56883. getActiveTextures(): BaseTexture[];
  56884. /**
  56885. * Checks to see if a texture is used in the material.
  56886. * @param texture - Base texture to use.
  56887. * @returns - Boolean specifying if a texture is used in the material.
  56888. */
  56889. hasTexture(texture: BaseTexture): boolean;
  56890. /**
  56891. * Sets the required values to the prepass renderer.
  56892. * @param prePassRenderer defines the prepass renderer to setup
  56893. */
  56894. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56895. /**
  56896. * Disposes the resources of the material.
  56897. * @param forceDisposeEffect - Forces the disposal of effects.
  56898. * @param forceDisposeTextures - Forces the disposal of all textures.
  56899. */
  56900. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56901. }
  56902. }
  56903. declare module BABYLON {
  56904. /**
  56905. * The Physically based material of BJS.
  56906. *
  56907. * This offers the main features of a standard PBR material.
  56908. * For more information, please refer to the documentation :
  56909. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56910. */
  56911. export class PBRMaterial extends PBRBaseMaterial {
  56912. /**
  56913. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56914. */
  56915. static readonly PBRMATERIAL_OPAQUE: number;
  56916. /**
  56917. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56918. */
  56919. static readonly PBRMATERIAL_ALPHATEST: number;
  56920. /**
  56921. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56922. */
  56923. static readonly PBRMATERIAL_ALPHABLEND: number;
  56924. /**
  56925. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56926. * They are also discarded below the alpha cutoff threshold to improve performances.
  56927. */
  56928. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56929. /**
  56930. * Defines the default value of how much AO map is occluding the analytical lights
  56931. * (point spot...).
  56932. */
  56933. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56934. /**
  56935. * Intensity of the direct lights e.g. the four lights available in your scene.
  56936. * This impacts both the direct diffuse and specular highlights.
  56937. */
  56938. directIntensity: number;
  56939. /**
  56940. * Intensity of the emissive part of the material.
  56941. * This helps controlling the emissive effect without modifying the emissive color.
  56942. */
  56943. emissiveIntensity: number;
  56944. /**
  56945. * Intensity of the environment e.g. how much the environment will light the object
  56946. * either through harmonics for rough material or through the refelction for shiny ones.
  56947. */
  56948. environmentIntensity: number;
  56949. /**
  56950. * This is a special control allowing the reduction of the specular highlights coming from the
  56951. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56952. */
  56953. specularIntensity: number;
  56954. /**
  56955. * Debug Control allowing disabling the bump map on this material.
  56956. */
  56957. disableBumpMap: boolean;
  56958. /**
  56959. * AKA Diffuse Texture in standard nomenclature.
  56960. */
  56961. albedoTexture: BaseTexture;
  56962. /**
  56963. * AKA Occlusion Texture in other nomenclature.
  56964. */
  56965. ambientTexture: BaseTexture;
  56966. /**
  56967. * AKA Occlusion Texture Intensity in other nomenclature.
  56968. */
  56969. ambientTextureStrength: number;
  56970. /**
  56971. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56972. * 1 means it completely occludes it
  56973. * 0 mean it has no impact
  56974. */
  56975. ambientTextureImpactOnAnalyticalLights: number;
  56976. /**
  56977. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56978. */
  56979. opacityTexture: BaseTexture;
  56980. /**
  56981. * Stores the reflection values in a texture.
  56982. */
  56983. reflectionTexture: Nullable<BaseTexture>;
  56984. /**
  56985. * Stores the emissive values in a texture.
  56986. */
  56987. emissiveTexture: BaseTexture;
  56988. /**
  56989. * AKA Specular texture in other nomenclature.
  56990. */
  56991. reflectivityTexture: BaseTexture;
  56992. /**
  56993. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56994. */
  56995. metallicTexture: BaseTexture;
  56996. /**
  56997. * Specifies the metallic scalar of the metallic/roughness workflow.
  56998. * Can also be used to scale the metalness values of the metallic texture.
  56999. */
  57000. metallic: Nullable<number>;
  57001. /**
  57002. * Specifies the roughness scalar of the metallic/roughness workflow.
  57003. * Can also be used to scale the roughness values of the metallic texture.
  57004. */
  57005. roughness: Nullable<number>;
  57006. /**
  57007. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57008. * By default the indexOfrefraction is used to compute F0;
  57009. *
  57010. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57011. *
  57012. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57013. * F90 = metallicReflectanceColor;
  57014. */
  57015. metallicF0Factor: number;
  57016. /**
  57017. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57018. * By default the F90 is always 1;
  57019. *
  57020. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57021. *
  57022. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57023. * F90 = metallicReflectanceColor;
  57024. */
  57025. metallicReflectanceColor: Color3;
  57026. /**
  57027. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57028. * This is multiply against the scalar values defined in the material.
  57029. */
  57030. metallicReflectanceTexture: Nullable<BaseTexture>;
  57031. /**
  57032. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57033. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57034. */
  57035. microSurfaceTexture: BaseTexture;
  57036. /**
  57037. * Stores surface normal data used to displace a mesh in a texture.
  57038. */
  57039. bumpTexture: BaseTexture;
  57040. /**
  57041. * Stores the pre-calculated light information of a mesh in a texture.
  57042. */
  57043. lightmapTexture: BaseTexture;
  57044. /**
  57045. * Stores the refracted light information in a texture.
  57046. */
  57047. get refractionTexture(): Nullable<BaseTexture>;
  57048. set refractionTexture(value: Nullable<BaseTexture>);
  57049. /**
  57050. * The color of a material in ambient lighting.
  57051. */
  57052. ambientColor: Color3;
  57053. /**
  57054. * AKA Diffuse Color in other nomenclature.
  57055. */
  57056. albedoColor: Color3;
  57057. /**
  57058. * AKA Specular Color in other nomenclature.
  57059. */
  57060. reflectivityColor: Color3;
  57061. /**
  57062. * The color reflected from the material.
  57063. */
  57064. reflectionColor: Color3;
  57065. /**
  57066. * The color emitted from the material.
  57067. */
  57068. emissiveColor: Color3;
  57069. /**
  57070. * AKA Glossiness in other nomenclature.
  57071. */
  57072. microSurface: number;
  57073. /**
  57074. * Index of refraction of the material base layer.
  57075. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57076. *
  57077. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57078. *
  57079. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57080. */
  57081. get indexOfRefraction(): number;
  57082. set indexOfRefraction(value: number);
  57083. /**
  57084. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57085. */
  57086. get invertRefractionY(): boolean;
  57087. set invertRefractionY(value: boolean);
  57088. /**
  57089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57090. * Materials half opaque for instance using refraction could benefit from this control.
  57091. */
  57092. get linkRefractionWithTransparency(): boolean;
  57093. set linkRefractionWithTransparency(value: boolean);
  57094. /**
  57095. * If true, the light map contains occlusion information instead of lighting info.
  57096. */
  57097. useLightmapAsShadowmap: boolean;
  57098. /**
  57099. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57100. */
  57101. useAlphaFromAlbedoTexture: boolean;
  57102. /**
  57103. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57104. */
  57105. forceAlphaTest: boolean;
  57106. /**
  57107. * Defines the alpha limits in alpha test mode.
  57108. */
  57109. alphaCutOff: number;
  57110. /**
  57111. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57112. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57113. */
  57114. useSpecularOverAlpha: boolean;
  57115. /**
  57116. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57117. */
  57118. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57119. /**
  57120. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57121. */
  57122. useRoughnessFromMetallicTextureAlpha: boolean;
  57123. /**
  57124. * Specifies if the metallic texture contains the roughness information in its green channel.
  57125. */
  57126. useRoughnessFromMetallicTextureGreen: boolean;
  57127. /**
  57128. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57129. */
  57130. useMetallnessFromMetallicTextureBlue: boolean;
  57131. /**
  57132. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57133. */
  57134. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57135. /**
  57136. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57137. */
  57138. useAmbientInGrayScale: boolean;
  57139. /**
  57140. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57141. * The material will try to infer what glossiness each pixel should be.
  57142. */
  57143. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57144. /**
  57145. * BJS is using an harcoded light falloff based on a manually sets up range.
  57146. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57147. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57148. */
  57149. get usePhysicalLightFalloff(): boolean;
  57150. /**
  57151. * BJS is using an harcoded light falloff based on a manually sets up range.
  57152. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57153. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57154. */
  57155. set usePhysicalLightFalloff(value: boolean);
  57156. /**
  57157. * In order to support the falloff compatibility with gltf, a special mode has been added
  57158. * to reproduce the gltf light falloff.
  57159. */
  57160. get useGLTFLightFalloff(): boolean;
  57161. /**
  57162. * In order to support the falloff compatibility with gltf, a special mode has been added
  57163. * to reproduce the gltf light falloff.
  57164. */
  57165. set useGLTFLightFalloff(value: boolean);
  57166. /**
  57167. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57168. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57169. */
  57170. useRadianceOverAlpha: boolean;
  57171. /**
  57172. * Allows using an object space normal map (instead of tangent space).
  57173. */
  57174. useObjectSpaceNormalMap: boolean;
  57175. /**
  57176. * Allows using the bump map in parallax mode.
  57177. */
  57178. useParallax: boolean;
  57179. /**
  57180. * Allows using the bump map in parallax occlusion mode.
  57181. */
  57182. useParallaxOcclusion: boolean;
  57183. /**
  57184. * Controls the scale bias of the parallax mode.
  57185. */
  57186. parallaxScaleBias: number;
  57187. /**
  57188. * If sets to true, disables all the lights affecting the material.
  57189. */
  57190. disableLighting: boolean;
  57191. /**
  57192. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57193. */
  57194. forceIrradianceInFragment: boolean;
  57195. /**
  57196. * Number of Simultaneous lights allowed on the material.
  57197. */
  57198. maxSimultaneousLights: number;
  57199. /**
  57200. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57201. */
  57202. invertNormalMapX: boolean;
  57203. /**
  57204. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57205. */
  57206. invertNormalMapY: boolean;
  57207. /**
  57208. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57209. */
  57210. twoSidedLighting: boolean;
  57211. /**
  57212. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57213. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57214. */
  57215. useAlphaFresnel: boolean;
  57216. /**
  57217. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57218. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57219. */
  57220. useLinearAlphaFresnel: boolean;
  57221. /**
  57222. * Let user defines the brdf lookup texture used for IBL.
  57223. * A default 8bit version is embedded but you could point at :
  57224. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57225. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57226. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57227. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57228. */
  57229. environmentBRDFTexture: Nullable<BaseTexture>;
  57230. /**
  57231. * Force normal to face away from face.
  57232. */
  57233. forceNormalForward: boolean;
  57234. /**
  57235. * Enables specular anti aliasing in the PBR shader.
  57236. * It will both interacts on the Geometry for analytical and IBL lighting.
  57237. * It also prefilter the roughness map based on the bump values.
  57238. */
  57239. enableSpecularAntiAliasing: boolean;
  57240. /**
  57241. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57242. * makes the reflect vector face the model (under horizon).
  57243. */
  57244. useHorizonOcclusion: boolean;
  57245. /**
  57246. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57247. * too much the area relying on ambient texture to define their ambient occlusion.
  57248. */
  57249. useRadianceOcclusion: boolean;
  57250. /**
  57251. * If set to true, no lighting calculations will be applied.
  57252. */
  57253. unlit: boolean;
  57254. /**
  57255. * Gets the image processing configuration used either in this material.
  57256. */
  57257. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57258. /**
  57259. * Sets the Default image processing configuration used either in the this material.
  57260. *
  57261. * If sets to null, the scene one is in use.
  57262. */
  57263. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57264. /**
  57265. * Gets wether the color curves effect is enabled.
  57266. */
  57267. get cameraColorCurvesEnabled(): boolean;
  57268. /**
  57269. * Sets wether the color curves effect is enabled.
  57270. */
  57271. set cameraColorCurvesEnabled(value: boolean);
  57272. /**
  57273. * Gets wether the color grading effect is enabled.
  57274. */
  57275. get cameraColorGradingEnabled(): boolean;
  57276. /**
  57277. * Gets wether the color grading effect is enabled.
  57278. */
  57279. set cameraColorGradingEnabled(value: boolean);
  57280. /**
  57281. * Gets wether tonemapping is enabled or not.
  57282. */
  57283. get cameraToneMappingEnabled(): boolean;
  57284. /**
  57285. * Sets wether tonemapping is enabled or not
  57286. */
  57287. set cameraToneMappingEnabled(value: boolean);
  57288. /**
  57289. * The camera exposure used on this material.
  57290. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57291. * This corresponds to a photographic exposure.
  57292. */
  57293. get cameraExposure(): number;
  57294. /**
  57295. * The camera exposure used on this material.
  57296. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57297. * This corresponds to a photographic exposure.
  57298. */
  57299. set cameraExposure(value: number);
  57300. /**
  57301. * Gets The camera contrast used on this material.
  57302. */
  57303. get cameraContrast(): number;
  57304. /**
  57305. * Sets The camera contrast used on this material.
  57306. */
  57307. set cameraContrast(value: number);
  57308. /**
  57309. * Gets the Color Grading 2D Lookup Texture.
  57310. */
  57311. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57312. /**
  57313. * Sets the Color Grading 2D Lookup Texture.
  57314. */
  57315. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57316. /**
  57317. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57318. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57319. * 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;
  57320. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57321. */
  57322. get cameraColorCurves(): Nullable<ColorCurves>;
  57323. /**
  57324. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57325. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57326. * 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;
  57327. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57328. */
  57329. set cameraColorCurves(value: Nullable<ColorCurves>);
  57330. /**
  57331. * Instantiates a new PBRMaterial instance.
  57332. *
  57333. * @param name The material name
  57334. * @param scene The scene the material will be use in.
  57335. */
  57336. constructor(name: string, scene: Scene);
  57337. /**
  57338. * Returns the name of this material class.
  57339. */
  57340. getClassName(): string;
  57341. /**
  57342. * Makes a duplicate of the current material.
  57343. * @param name - name to use for the new material.
  57344. */
  57345. clone(name: string): PBRMaterial;
  57346. /**
  57347. * Serializes this PBR Material.
  57348. * @returns - An object with the serialized material.
  57349. */
  57350. serialize(): any;
  57351. /**
  57352. * Parses a PBR Material from a serialized object.
  57353. * @param source - Serialized object.
  57354. * @param scene - BJS scene instance.
  57355. * @param rootUrl - url for the scene object
  57356. * @returns - PBRMaterial
  57357. */
  57358. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57359. }
  57360. }
  57361. declare module BABYLON {
  57362. /**
  57363. * Direct draw surface info
  57364. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57365. */
  57366. export interface DDSInfo {
  57367. /**
  57368. * Width of the texture
  57369. */
  57370. width: number;
  57371. /**
  57372. * Width of the texture
  57373. */
  57374. height: number;
  57375. /**
  57376. * Number of Mipmaps for the texture
  57377. * @see https://en.wikipedia.org/wiki/Mipmap
  57378. */
  57379. mipmapCount: number;
  57380. /**
  57381. * If the textures format is a known fourCC format
  57382. * @see https://www.fourcc.org/
  57383. */
  57384. isFourCC: boolean;
  57385. /**
  57386. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57387. */
  57388. isRGB: boolean;
  57389. /**
  57390. * If the texture is a lumincance format
  57391. */
  57392. isLuminance: boolean;
  57393. /**
  57394. * If this is a cube texture
  57395. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57396. */
  57397. isCube: boolean;
  57398. /**
  57399. * If the texture is a compressed format eg. FOURCC_DXT1
  57400. */
  57401. isCompressed: boolean;
  57402. /**
  57403. * The dxgiFormat of the texture
  57404. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57405. */
  57406. dxgiFormat: number;
  57407. /**
  57408. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57409. */
  57410. textureType: number;
  57411. /**
  57412. * Sphericle polynomial created for the dds texture
  57413. */
  57414. sphericalPolynomial?: SphericalPolynomial;
  57415. }
  57416. /**
  57417. * Class used to provide DDS decompression tools
  57418. */
  57419. export class DDSTools {
  57420. /**
  57421. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57422. */
  57423. static StoreLODInAlphaChannel: boolean;
  57424. /**
  57425. * Gets DDS information from an array buffer
  57426. * @param data defines the array buffer view to read data from
  57427. * @returns the DDS information
  57428. */
  57429. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57430. private static _FloatView;
  57431. private static _Int32View;
  57432. private static _ToHalfFloat;
  57433. private static _FromHalfFloat;
  57434. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57435. private static _GetHalfFloatRGBAArrayBuffer;
  57436. private static _GetFloatRGBAArrayBuffer;
  57437. private static _GetFloatAsUIntRGBAArrayBuffer;
  57438. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57439. private static _GetRGBAArrayBuffer;
  57440. private static _ExtractLongWordOrder;
  57441. private static _GetRGBArrayBuffer;
  57442. private static _GetLuminanceArrayBuffer;
  57443. /**
  57444. * Uploads DDS Levels to a Babylon Texture
  57445. * @hidden
  57446. */
  57447. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57448. }
  57449. interface ThinEngine {
  57450. /**
  57451. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57452. * @param rootUrl defines the url where the file to load is located
  57453. * @param scene defines the current scene
  57454. * @param lodScale defines scale to apply to the mip map selection
  57455. * @param lodOffset defines offset to apply to the mip map selection
  57456. * @param onLoad defines an optional callback raised when the texture is loaded
  57457. * @param onError defines an optional callback raised if there is an issue to load the texture
  57458. * @param format defines the format of the data
  57459. * @param forcedExtension defines the extension to use to pick the right loader
  57460. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57461. * @returns the cube texture as an InternalTexture
  57462. */
  57463. 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;
  57464. }
  57465. }
  57466. declare module BABYLON {
  57467. /**
  57468. * Implementation of the DDS Texture Loader.
  57469. * @hidden
  57470. */
  57471. export class _DDSTextureLoader implements IInternalTextureLoader {
  57472. /**
  57473. * Defines wether the loader supports cascade loading the different faces.
  57474. */
  57475. readonly supportCascades: boolean;
  57476. /**
  57477. * This returns if the loader support the current file information.
  57478. * @param extension defines the file extension of the file being loaded
  57479. * @returns true if the loader can load the specified file
  57480. */
  57481. canLoad(extension: string): boolean;
  57482. /**
  57483. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57484. * @param data contains the texture data
  57485. * @param texture defines the BabylonJS internal texture
  57486. * @param createPolynomials will be true if polynomials have been requested
  57487. * @param onLoad defines the callback to trigger once the texture is ready
  57488. * @param onError defines the callback to trigger in case of error
  57489. */
  57490. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57491. /**
  57492. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57493. * @param data contains the texture data
  57494. * @param texture defines the BabylonJS internal texture
  57495. * @param callback defines the method to call once ready to upload
  57496. */
  57497. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57498. }
  57499. }
  57500. declare module BABYLON {
  57501. /**
  57502. * Implementation of the ENV Texture Loader.
  57503. * @hidden
  57504. */
  57505. export class _ENVTextureLoader implements IInternalTextureLoader {
  57506. /**
  57507. * Defines wether the loader supports cascade loading the different faces.
  57508. */
  57509. readonly supportCascades: boolean;
  57510. /**
  57511. * This returns if the loader support the current file information.
  57512. * @param extension defines the file extension of the file being loaded
  57513. * @returns true if the loader can load the specified file
  57514. */
  57515. canLoad(extension: string): boolean;
  57516. /**
  57517. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57518. * @param data contains the texture data
  57519. * @param texture defines the BabylonJS internal texture
  57520. * @param createPolynomials will be true if polynomials have been requested
  57521. * @param onLoad defines the callback to trigger once the texture is ready
  57522. * @param onError defines the callback to trigger in case of error
  57523. */
  57524. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57525. /**
  57526. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57527. * @param data contains the texture data
  57528. * @param texture defines the BabylonJS internal texture
  57529. * @param callback defines the method to call once ready to upload
  57530. */
  57531. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57532. }
  57533. }
  57534. declare module BABYLON {
  57535. /**
  57536. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57537. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57538. */
  57539. export class KhronosTextureContainer {
  57540. /** contents of the KTX container file */
  57541. data: ArrayBufferView;
  57542. private static HEADER_LEN;
  57543. private static COMPRESSED_2D;
  57544. private static COMPRESSED_3D;
  57545. private static TEX_2D;
  57546. private static TEX_3D;
  57547. /**
  57548. * Gets the openGL type
  57549. */
  57550. glType: number;
  57551. /**
  57552. * Gets the openGL type size
  57553. */
  57554. glTypeSize: number;
  57555. /**
  57556. * Gets the openGL format
  57557. */
  57558. glFormat: number;
  57559. /**
  57560. * Gets the openGL internal format
  57561. */
  57562. glInternalFormat: number;
  57563. /**
  57564. * Gets the base internal format
  57565. */
  57566. glBaseInternalFormat: number;
  57567. /**
  57568. * Gets image width in pixel
  57569. */
  57570. pixelWidth: number;
  57571. /**
  57572. * Gets image height in pixel
  57573. */
  57574. pixelHeight: number;
  57575. /**
  57576. * Gets image depth in pixels
  57577. */
  57578. pixelDepth: number;
  57579. /**
  57580. * Gets the number of array elements
  57581. */
  57582. numberOfArrayElements: number;
  57583. /**
  57584. * Gets the number of faces
  57585. */
  57586. numberOfFaces: number;
  57587. /**
  57588. * Gets the number of mipmap levels
  57589. */
  57590. numberOfMipmapLevels: number;
  57591. /**
  57592. * Gets the bytes of key value data
  57593. */
  57594. bytesOfKeyValueData: number;
  57595. /**
  57596. * Gets the load type
  57597. */
  57598. loadType: number;
  57599. /**
  57600. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57601. */
  57602. isInvalid: boolean;
  57603. /**
  57604. * Creates a new KhronosTextureContainer
  57605. * @param data contents of the KTX container file
  57606. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57607. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57608. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57609. */
  57610. constructor(
  57611. /** contents of the KTX container file */
  57612. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57613. /**
  57614. * Uploads KTX content to a Babylon Texture.
  57615. * It is assumed that the texture has already been created & is currently bound
  57616. * @hidden
  57617. */
  57618. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57619. private _upload2DCompressedLevels;
  57620. /**
  57621. * Checks if the given data starts with a KTX file identifier.
  57622. * @param data the data to check
  57623. * @returns true if the data is a KTX file or false otherwise
  57624. */
  57625. static IsValid(data: ArrayBufferView): boolean;
  57626. }
  57627. }
  57628. declare module BABYLON {
  57629. /**
  57630. * Class for loading KTX2 files
  57631. * !!! Experimental Extension Subject to Changes !!!
  57632. * @hidden
  57633. */
  57634. export class KhronosTextureContainer2 {
  57635. private static _ModulePromise;
  57636. private static _TranscodeFormat;
  57637. constructor(engine: ThinEngine);
  57638. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57639. private _determineTranscodeFormat;
  57640. /**
  57641. * Checks if the given data starts with a KTX2 file identifier.
  57642. * @param data the data to check
  57643. * @returns true if the data is a KTX2 file or false otherwise
  57644. */
  57645. static IsValid(data: ArrayBufferView): boolean;
  57646. }
  57647. }
  57648. declare module BABYLON {
  57649. /**
  57650. * Implementation of the KTX Texture Loader.
  57651. * @hidden
  57652. */
  57653. export class _KTXTextureLoader implements IInternalTextureLoader {
  57654. /**
  57655. * Defines wether the loader supports cascade loading the different faces.
  57656. */
  57657. readonly supportCascades: boolean;
  57658. /**
  57659. * This returns if the loader support the current file information.
  57660. * @param extension defines the file extension of the file being loaded
  57661. * @param mimeType defines the optional mime type of the file being loaded
  57662. * @returns true if the loader can load the specified file
  57663. */
  57664. canLoad(extension: string, mimeType?: string): boolean;
  57665. /**
  57666. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57667. * @param data contains the texture data
  57668. * @param texture defines the BabylonJS internal texture
  57669. * @param createPolynomials will be true if polynomials have been requested
  57670. * @param onLoad defines the callback to trigger once the texture is ready
  57671. * @param onError defines the callback to trigger in case of error
  57672. */
  57673. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57674. /**
  57675. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57676. * @param data contains the texture data
  57677. * @param texture defines the BabylonJS internal texture
  57678. * @param callback defines the method to call once ready to upload
  57679. */
  57680. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57681. }
  57682. }
  57683. declare module BABYLON {
  57684. /** @hidden */
  57685. export var _forceSceneHelpersToBundle: boolean;
  57686. interface Scene {
  57687. /**
  57688. * Creates a default light for the scene.
  57689. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57690. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57691. */
  57692. createDefaultLight(replace?: boolean): void;
  57693. /**
  57694. * Creates a default camera for the scene.
  57695. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57696. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57697. * @param replace has default false, when true replaces the active camera in the scene
  57698. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57699. */
  57700. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57701. /**
  57702. * Creates a default camera and a default light.
  57703. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57704. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57705. * @param replace has the default false, when true replaces the active camera/light in the scene
  57706. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57707. */
  57708. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57709. /**
  57710. * Creates a new sky box
  57711. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57712. * @param environmentTexture defines the texture to use as environment texture
  57713. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57714. * @param scale defines the overall scale of the skybox
  57715. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57716. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57717. * @returns a new mesh holding the sky box
  57718. */
  57719. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57720. /**
  57721. * Creates a new environment
  57722. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57723. * @param options defines the options you can use to configure the environment
  57724. * @returns the new EnvironmentHelper
  57725. */
  57726. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57727. /**
  57728. * Creates a new VREXperienceHelper
  57729. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57730. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57731. * @returns a new VREXperienceHelper
  57732. */
  57733. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57734. /**
  57735. * Creates a new WebXRDefaultExperience
  57736. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57737. * @param options experience options
  57738. * @returns a promise for a new WebXRDefaultExperience
  57739. */
  57740. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57741. }
  57742. }
  57743. declare module BABYLON {
  57744. /**
  57745. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57746. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57747. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57748. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57749. */
  57750. export class VideoDome extends TextureDome<VideoTexture> {
  57751. /**
  57752. * Define the video source as a Monoscopic panoramic 360 video.
  57753. */
  57754. static readonly MODE_MONOSCOPIC: number;
  57755. /**
  57756. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57757. */
  57758. static readonly MODE_TOPBOTTOM: number;
  57759. /**
  57760. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57761. */
  57762. static readonly MODE_SIDEBYSIDE: number;
  57763. /**
  57764. * Get the video texture associated with this video dome
  57765. */
  57766. get videoTexture(): VideoTexture;
  57767. /**
  57768. * Get the video mode of this dome
  57769. */
  57770. get videoMode(): number;
  57771. /**
  57772. * Set the video mode of this dome.
  57773. * @see textureMode
  57774. */
  57775. set videoMode(value: number);
  57776. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  57777. }
  57778. }
  57779. declare module BABYLON {
  57780. /**
  57781. * This class can be used to get instrumentation data from a Babylon engine
  57782. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57783. */
  57784. export class EngineInstrumentation implements IDisposable {
  57785. /**
  57786. * Define the instrumented engine.
  57787. */
  57788. engine: Engine;
  57789. private _captureGPUFrameTime;
  57790. private _gpuFrameTimeToken;
  57791. private _gpuFrameTime;
  57792. private _captureShaderCompilationTime;
  57793. private _shaderCompilationTime;
  57794. private _onBeginFrameObserver;
  57795. private _onEndFrameObserver;
  57796. private _onBeforeShaderCompilationObserver;
  57797. private _onAfterShaderCompilationObserver;
  57798. /**
  57799. * Gets the perf counter used for GPU frame time
  57800. */
  57801. get gpuFrameTimeCounter(): PerfCounter;
  57802. /**
  57803. * Gets the GPU frame time capture status
  57804. */
  57805. get captureGPUFrameTime(): boolean;
  57806. /**
  57807. * Enable or disable the GPU frame time capture
  57808. */
  57809. set captureGPUFrameTime(value: boolean);
  57810. /**
  57811. * Gets the perf counter used for shader compilation time
  57812. */
  57813. get shaderCompilationTimeCounter(): PerfCounter;
  57814. /**
  57815. * Gets the shader compilation time capture status
  57816. */
  57817. get captureShaderCompilationTime(): boolean;
  57818. /**
  57819. * Enable or disable the shader compilation time capture
  57820. */
  57821. set captureShaderCompilationTime(value: boolean);
  57822. /**
  57823. * Instantiates a new engine instrumentation.
  57824. * This class can be used to get instrumentation data from a Babylon engine
  57825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57826. * @param engine Defines the engine to instrument
  57827. */
  57828. constructor(
  57829. /**
  57830. * Define the instrumented engine.
  57831. */
  57832. engine: Engine);
  57833. /**
  57834. * Dispose and release associated resources.
  57835. */
  57836. dispose(): void;
  57837. }
  57838. }
  57839. declare module BABYLON {
  57840. /**
  57841. * This class can be used to get instrumentation data from a Babylon engine
  57842. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57843. */
  57844. export class SceneInstrumentation implements IDisposable {
  57845. /**
  57846. * Defines the scene to instrument
  57847. */
  57848. scene: Scene;
  57849. private _captureActiveMeshesEvaluationTime;
  57850. private _activeMeshesEvaluationTime;
  57851. private _captureRenderTargetsRenderTime;
  57852. private _renderTargetsRenderTime;
  57853. private _captureFrameTime;
  57854. private _frameTime;
  57855. private _captureRenderTime;
  57856. private _renderTime;
  57857. private _captureInterFrameTime;
  57858. private _interFrameTime;
  57859. private _captureParticlesRenderTime;
  57860. private _particlesRenderTime;
  57861. private _captureSpritesRenderTime;
  57862. private _spritesRenderTime;
  57863. private _capturePhysicsTime;
  57864. private _physicsTime;
  57865. private _captureAnimationsTime;
  57866. private _animationsTime;
  57867. private _captureCameraRenderTime;
  57868. private _cameraRenderTime;
  57869. private _onBeforeActiveMeshesEvaluationObserver;
  57870. private _onAfterActiveMeshesEvaluationObserver;
  57871. private _onBeforeRenderTargetsRenderObserver;
  57872. private _onAfterRenderTargetsRenderObserver;
  57873. private _onAfterRenderObserver;
  57874. private _onBeforeDrawPhaseObserver;
  57875. private _onAfterDrawPhaseObserver;
  57876. private _onBeforeAnimationsObserver;
  57877. private _onBeforeParticlesRenderingObserver;
  57878. private _onAfterParticlesRenderingObserver;
  57879. private _onBeforeSpritesRenderingObserver;
  57880. private _onAfterSpritesRenderingObserver;
  57881. private _onBeforePhysicsObserver;
  57882. private _onAfterPhysicsObserver;
  57883. private _onAfterAnimationsObserver;
  57884. private _onBeforeCameraRenderObserver;
  57885. private _onAfterCameraRenderObserver;
  57886. /**
  57887. * Gets the perf counter used for active meshes evaluation time
  57888. */
  57889. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57890. /**
  57891. * Gets the active meshes evaluation time capture status
  57892. */
  57893. get captureActiveMeshesEvaluationTime(): boolean;
  57894. /**
  57895. * Enable or disable the active meshes evaluation time capture
  57896. */
  57897. set captureActiveMeshesEvaluationTime(value: boolean);
  57898. /**
  57899. * Gets the perf counter used for render targets render time
  57900. */
  57901. get renderTargetsRenderTimeCounter(): PerfCounter;
  57902. /**
  57903. * Gets the render targets render time capture status
  57904. */
  57905. get captureRenderTargetsRenderTime(): boolean;
  57906. /**
  57907. * Enable or disable the render targets render time capture
  57908. */
  57909. set captureRenderTargetsRenderTime(value: boolean);
  57910. /**
  57911. * Gets the perf counter used for particles render time
  57912. */
  57913. get particlesRenderTimeCounter(): PerfCounter;
  57914. /**
  57915. * Gets the particles render time capture status
  57916. */
  57917. get captureParticlesRenderTime(): boolean;
  57918. /**
  57919. * Enable or disable the particles render time capture
  57920. */
  57921. set captureParticlesRenderTime(value: boolean);
  57922. /**
  57923. * Gets the perf counter used for sprites render time
  57924. */
  57925. get spritesRenderTimeCounter(): PerfCounter;
  57926. /**
  57927. * Gets the sprites render time capture status
  57928. */
  57929. get captureSpritesRenderTime(): boolean;
  57930. /**
  57931. * Enable or disable the sprites render time capture
  57932. */
  57933. set captureSpritesRenderTime(value: boolean);
  57934. /**
  57935. * Gets the perf counter used for physics time
  57936. */
  57937. get physicsTimeCounter(): PerfCounter;
  57938. /**
  57939. * Gets the physics time capture status
  57940. */
  57941. get capturePhysicsTime(): boolean;
  57942. /**
  57943. * Enable or disable the physics time capture
  57944. */
  57945. set capturePhysicsTime(value: boolean);
  57946. /**
  57947. * Gets the perf counter used for animations time
  57948. */
  57949. get animationsTimeCounter(): PerfCounter;
  57950. /**
  57951. * Gets the animations time capture status
  57952. */
  57953. get captureAnimationsTime(): boolean;
  57954. /**
  57955. * Enable or disable the animations time capture
  57956. */
  57957. set captureAnimationsTime(value: boolean);
  57958. /**
  57959. * Gets the perf counter used for frame time capture
  57960. */
  57961. get frameTimeCounter(): PerfCounter;
  57962. /**
  57963. * Gets the frame time capture status
  57964. */
  57965. get captureFrameTime(): boolean;
  57966. /**
  57967. * Enable or disable the frame time capture
  57968. */
  57969. set captureFrameTime(value: boolean);
  57970. /**
  57971. * Gets the perf counter used for inter-frames time capture
  57972. */
  57973. get interFrameTimeCounter(): PerfCounter;
  57974. /**
  57975. * Gets the inter-frames time capture status
  57976. */
  57977. get captureInterFrameTime(): boolean;
  57978. /**
  57979. * Enable or disable the inter-frames time capture
  57980. */
  57981. set captureInterFrameTime(value: boolean);
  57982. /**
  57983. * Gets the perf counter used for render time capture
  57984. */
  57985. get renderTimeCounter(): PerfCounter;
  57986. /**
  57987. * Gets the render time capture status
  57988. */
  57989. get captureRenderTime(): boolean;
  57990. /**
  57991. * Enable or disable the render time capture
  57992. */
  57993. set captureRenderTime(value: boolean);
  57994. /**
  57995. * Gets the perf counter used for camera render time capture
  57996. */
  57997. get cameraRenderTimeCounter(): PerfCounter;
  57998. /**
  57999. * Gets the camera render time capture status
  58000. */
  58001. get captureCameraRenderTime(): boolean;
  58002. /**
  58003. * Enable or disable the camera render time capture
  58004. */
  58005. set captureCameraRenderTime(value: boolean);
  58006. /**
  58007. * Gets the perf counter used for draw calls
  58008. */
  58009. get drawCallsCounter(): PerfCounter;
  58010. /**
  58011. * Instantiates a new scene instrumentation.
  58012. * This class can be used to get instrumentation data from a Babylon engine
  58013. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58014. * @param scene Defines the scene to instrument
  58015. */
  58016. constructor(
  58017. /**
  58018. * Defines the scene to instrument
  58019. */
  58020. scene: Scene);
  58021. /**
  58022. * Dispose and release associated resources.
  58023. */
  58024. dispose(): void;
  58025. }
  58026. }
  58027. declare module BABYLON {
  58028. /** @hidden */
  58029. export var glowMapGenerationPixelShader: {
  58030. name: string;
  58031. shader: string;
  58032. };
  58033. }
  58034. declare module BABYLON {
  58035. /** @hidden */
  58036. export var glowMapGenerationVertexShader: {
  58037. name: string;
  58038. shader: string;
  58039. };
  58040. }
  58041. declare module BABYLON {
  58042. /**
  58043. * Effect layer options. This helps customizing the behaviour
  58044. * of the effect layer.
  58045. */
  58046. export interface IEffectLayerOptions {
  58047. /**
  58048. * Multiplication factor apply to the canvas size to compute the render target size
  58049. * used to generated the objects (the smaller the faster).
  58050. */
  58051. mainTextureRatio: number;
  58052. /**
  58053. * Enforces a fixed size texture to ensure effect stability across devices.
  58054. */
  58055. mainTextureFixedSize?: number;
  58056. /**
  58057. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58058. */
  58059. alphaBlendingMode: number;
  58060. /**
  58061. * The camera attached to the layer.
  58062. */
  58063. camera: Nullable<Camera>;
  58064. /**
  58065. * The rendering group to draw the layer in.
  58066. */
  58067. renderingGroupId: number;
  58068. }
  58069. /**
  58070. * The effect layer Helps adding post process effect blended with the main pass.
  58071. *
  58072. * This can be for instance use to generate glow or higlight effects on the scene.
  58073. *
  58074. * The effect layer class can not be used directly and is intented to inherited from to be
  58075. * customized per effects.
  58076. */
  58077. export abstract class EffectLayer {
  58078. private _vertexBuffers;
  58079. private _indexBuffer;
  58080. private _cachedDefines;
  58081. private _effectLayerMapGenerationEffect;
  58082. private _effectLayerOptions;
  58083. private _mergeEffect;
  58084. protected _scene: Scene;
  58085. protected _engine: Engine;
  58086. protected _maxSize: number;
  58087. protected _mainTextureDesiredSize: ISize;
  58088. protected _mainTexture: RenderTargetTexture;
  58089. protected _shouldRender: boolean;
  58090. protected _postProcesses: PostProcess[];
  58091. protected _textures: BaseTexture[];
  58092. protected _emissiveTextureAndColor: {
  58093. texture: Nullable<BaseTexture>;
  58094. color: Color4;
  58095. };
  58096. /**
  58097. * The name of the layer
  58098. */
  58099. name: string;
  58100. /**
  58101. * The clear color of the texture used to generate the glow map.
  58102. */
  58103. neutralColor: Color4;
  58104. /**
  58105. * Specifies whether the highlight layer is enabled or not.
  58106. */
  58107. isEnabled: boolean;
  58108. /**
  58109. * Gets the camera attached to the layer.
  58110. */
  58111. get camera(): Nullable<Camera>;
  58112. /**
  58113. * Gets the rendering group id the layer should render in.
  58114. */
  58115. get renderingGroupId(): number;
  58116. set renderingGroupId(renderingGroupId: number);
  58117. /**
  58118. * An event triggered when the effect layer has been disposed.
  58119. */
  58120. onDisposeObservable: Observable<EffectLayer>;
  58121. /**
  58122. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58123. */
  58124. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58125. /**
  58126. * An event triggered when the generated texture is being merged in the scene.
  58127. */
  58128. onBeforeComposeObservable: Observable<EffectLayer>;
  58129. /**
  58130. * An event triggered when the mesh is rendered into the effect render target.
  58131. */
  58132. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58133. /**
  58134. * An event triggered after the mesh has been rendered into the effect render target.
  58135. */
  58136. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58137. /**
  58138. * An event triggered when the generated texture has been merged in the scene.
  58139. */
  58140. onAfterComposeObservable: Observable<EffectLayer>;
  58141. /**
  58142. * An event triggered when the efffect layer changes its size.
  58143. */
  58144. onSizeChangedObservable: Observable<EffectLayer>;
  58145. /** @hidden */
  58146. static _SceneComponentInitialization: (scene: Scene) => void;
  58147. /**
  58148. * Instantiates a new effect Layer and references it in the scene.
  58149. * @param name The name of the layer
  58150. * @param scene The scene to use the layer in
  58151. */
  58152. constructor(
  58153. /** The Friendly of the effect in the scene */
  58154. name: string, scene: Scene);
  58155. /**
  58156. * Get the effect name of the layer.
  58157. * @return The effect name
  58158. */
  58159. abstract getEffectName(): string;
  58160. /**
  58161. * Checks for the readiness of the element composing the layer.
  58162. * @param subMesh the mesh to check for
  58163. * @param useInstances specify whether or not to use instances to render the mesh
  58164. * @return true if ready otherwise, false
  58165. */
  58166. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58167. /**
  58168. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58169. * @returns true if the effect requires stencil during the main canvas render pass.
  58170. */
  58171. abstract needStencil(): boolean;
  58172. /**
  58173. * Create the merge effect. This is the shader use to blit the information back
  58174. * to the main canvas at the end of the scene rendering.
  58175. * @returns The effect containing the shader used to merge the effect on the main canvas
  58176. */
  58177. protected abstract _createMergeEffect(): Effect;
  58178. /**
  58179. * Creates the render target textures and post processes used in the effect layer.
  58180. */
  58181. protected abstract _createTextureAndPostProcesses(): void;
  58182. /**
  58183. * Implementation specific of rendering the generating effect on the main canvas.
  58184. * @param effect The effect used to render through
  58185. */
  58186. protected abstract _internalRender(effect: Effect): void;
  58187. /**
  58188. * Sets the required values for both the emissive texture and and the main color.
  58189. */
  58190. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58191. /**
  58192. * Free any resources and references associated to a mesh.
  58193. * Internal use
  58194. * @param mesh The mesh to free.
  58195. */
  58196. abstract _disposeMesh(mesh: Mesh): void;
  58197. /**
  58198. * Serializes this layer (Glow or Highlight for example)
  58199. * @returns a serialized layer object
  58200. */
  58201. abstract serialize?(): any;
  58202. /**
  58203. * Initializes the effect layer with the required options.
  58204. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58205. */
  58206. protected _init(options: Partial<IEffectLayerOptions>): void;
  58207. /**
  58208. * Generates the index buffer of the full screen quad blending to the main canvas.
  58209. */
  58210. private _generateIndexBuffer;
  58211. /**
  58212. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58213. */
  58214. private _generateVertexBuffer;
  58215. /**
  58216. * Sets the main texture desired size which is the closest power of two
  58217. * of the engine canvas size.
  58218. */
  58219. private _setMainTextureSize;
  58220. /**
  58221. * Creates the main texture for the effect layer.
  58222. */
  58223. protected _createMainTexture(): void;
  58224. /**
  58225. * Adds specific effects defines.
  58226. * @param defines The defines to add specifics to.
  58227. */
  58228. protected _addCustomEffectDefines(defines: string[]): void;
  58229. /**
  58230. * Checks for the readiness of the element composing the layer.
  58231. * @param subMesh the mesh to check for
  58232. * @param useInstances specify whether or not to use instances to render the mesh
  58233. * @param emissiveTexture the associated emissive texture used to generate the glow
  58234. * @return true if ready otherwise, false
  58235. */
  58236. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58237. /**
  58238. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58239. */
  58240. render(): void;
  58241. /**
  58242. * Determine if a given mesh will be used in the current effect.
  58243. * @param mesh mesh to test
  58244. * @returns true if the mesh will be used
  58245. */
  58246. hasMesh(mesh: AbstractMesh): boolean;
  58247. /**
  58248. * Returns true if the layer contains information to display, otherwise false.
  58249. * @returns true if the glow layer should be rendered
  58250. */
  58251. shouldRender(): boolean;
  58252. /**
  58253. * Returns true if the mesh should render, otherwise false.
  58254. * @param mesh The mesh to render
  58255. * @returns true if it should render otherwise false
  58256. */
  58257. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58258. /**
  58259. * Returns true if the mesh can be rendered, otherwise false.
  58260. * @param mesh The mesh to render
  58261. * @param material The material used on the mesh
  58262. * @returns true if it can be rendered otherwise false
  58263. */
  58264. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58265. /**
  58266. * Returns true if the mesh should render, otherwise false.
  58267. * @param mesh The mesh to render
  58268. * @returns true if it should render otherwise false
  58269. */
  58270. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58271. /**
  58272. * Renders the submesh passed in parameter to the generation map.
  58273. */
  58274. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58275. /**
  58276. * Defines whether the current material of the mesh should be use to render the effect.
  58277. * @param mesh defines the current mesh to render
  58278. */
  58279. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58280. /**
  58281. * Rebuild the required buffers.
  58282. * @hidden Internal use only.
  58283. */
  58284. _rebuild(): void;
  58285. /**
  58286. * Dispose only the render target textures and post process.
  58287. */
  58288. private _disposeTextureAndPostProcesses;
  58289. /**
  58290. * Dispose the highlight layer and free resources.
  58291. */
  58292. dispose(): void;
  58293. /**
  58294. * Gets the class name of the effect layer
  58295. * @returns the string with the class name of the effect layer
  58296. */
  58297. getClassName(): string;
  58298. /**
  58299. * Creates an effect layer from parsed effect layer data
  58300. * @param parsedEffectLayer defines effect layer data
  58301. * @param scene defines the current scene
  58302. * @param rootUrl defines the root URL containing the effect layer information
  58303. * @returns a parsed effect Layer
  58304. */
  58305. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58306. }
  58307. }
  58308. declare module BABYLON {
  58309. interface AbstractScene {
  58310. /**
  58311. * The list of effect layers (highlights/glow) added to the scene
  58312. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58313. * @see https://doc.babylonjs.com/how_to/glow_layer
  58314. */
  58315. effectLayers: Array<EffectLayer>;
  58316. /**
  58317. * Removes the given effect layer from this scene.
  58318. * @param toRemove defines the effect layer to remove
  58319. * @returns the index of the removed effect layer
  58320. */
  58321. removeEffectLayer(toRemove: EffectLayer): number;
  58322. /**
  58323. * Adds the given effect layer to this scene
  58324. * @param newEffectLayer defines the effect layer to add
  58325. */
  58326. addEffectLayer(newEffectLayer: EffectLayer): void;
  58327. }
  58328. /**
  58329. * Defines the layer scene component responsible to manage any effect layers
  58330. * in a given scene.
  58331. */
  58332. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58333. /**
  58334. * The component name helpfull to identify the component in the list of scene components.
  58335. */
  58336. readonly name: string;
  58337. /**
  58338. * The scene the component belongs to.
  58339. */
  58340. scene: Scene;
  58341. private _engine;
  58342. private _renderEffects;
  58343. private _needStencil;
  58344. private _previousStencilState;
  58345. /**
  58346. * Creates a new instance of the component for the given scene
  58347. * @param scene Defines the scene to register the component in
  58348. */
  58349. constructor(scene: Scene);
  58350. /**
  58351. * Registers the component in a given scene
  58352. */
  58353. register(): void;
  58354. /**
  58355. * Rebuilds the elements related to this component in case of
  58356. * context lost for instance.
  58357. */
  58358. rebuild(): void;
  58359. /**
  58360. * Serializes the component data to the specified json object
  58361. * @param serializationObject The object to serialize to
  58362. */
  58363. serialize(serializationObject: any): void;
  58364. /**
  58365. * Adds all the elements from the container to the scene
  58366. * @param container the container holding the elements
  58367. */
  58368. addFromContainer(container: AbstractScene): void;
  58369. /**
  58370. * Removes all the elements in the container from the scene
  58371. * @param container contains the elements to remove
  58372. * @param dispose if the removed element should be disposed (default: false)
  58373. */
  58374. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58375. /**
  58376. * Disposes the component and the associated ressources.
  58377. */
  58378. dispose(): void;
  58379. private _isReadyForMesh;
  58380. private _renderMainTexture;
  58381. private _setStencil;
  58382. private _setStencilBack;
  58383. private _draw;
  58384. private _drawCamera;
  58385. private _drawRenderingGroup;
  58386. }
  58387. }
  58388. declare module BABYLON {
  58389. /** @hidden */
  58390. export var glowMapMergePixelShader: {
  58391. name: string;
  58392. shader: string;
  58393. };
  58394. }
  58395. declare module BABYLON {
  58396. /** @hidden */
  58397. export var glowMapMergeVertexShader: {
  58398. name: string;
  58399. shader: string;
  58400. };
  58401. }
  58402. declare module BABYLON {
  58403. interface AbstractScene {
  58404. /**
  58405. * Return a the first highlight layer of the scene with a given name.
  58406. * @param name The name of the highlight layer to look for.
  58407. * @return The highlight layer if found otherwise null.
  58408. */
  58409. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58410. }
  58411. /**
  58412. * Glow layer options. This helps customizing the behaviour
  58413. * of the glow layer.
  58414. */
  58415. export interface IGlowLayerOptions {
  58416. /**
  58417. * Multiplication factor apply to the canvas size to compute the render target size
  58418. * used to generated the glowing objects (the smaller the faster).
  58419. */
  58420. mainTextureRatio: number;
  58421. /**
  58422. * Enforces a fixed size texture to ensure resize independant blur.
  58423. */
  58424. mainTextureFixedSize?: number;
  58425. /**
  58426. * How big is the kernel of the blur texture.
  58427. */
  58428. blurKernelSize: number;
  58429. /**
  58430. * The camera attached to the layer.
  58431. */
  58432. camera: Nullable<Camera>;
  58433. /**
  58434. * Enable MSAA by chosing the number of samples.
  58435. */
  58436. mainTextureSamples?: number;
  58437. /**
  58438. * The rendering group to draw the layer in.
  58439. */
  58440. renderingGroupId: number;
  58441. }
  58442. /**
  58443. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58444. *
  58445. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58446. *
  58447. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58448. */
  58449. export class GlowLayer extends EffectLayer {
  58450. /**
  58451. * Effect Name of the layer.
  58452. */
  58453. static readonly EffectName: string;
  58454. /**
  58455. * The default blur kernel size used for the glow.
  58456. */
  58457. static DefaultBlurKernelSize: number;
  58458. /**
  58459. * The default texture size ratio used for the glow.
  58460. */
  58461. static DefaultTextureRatio: number;
  58462. /**
  58463. * Sets the kernel size of the blur.
  58464. */
  58465. set blurKernelSize(value: number);
  58466. /**
  58467. * Gets the kernel size of the blur.
  58468. */
  58469. get blurKernelSize(): number;
  58470. /**
  58471. * Sets the glow intensity.
  58472. */
  58473. set intensity(value: number);
  58474. /**
  58475. * Gets the glow intensity.
  58476. */
  58477. get intensity(): number;
  58478. private _options;
  58479. private _intensity;
  58480. private _horizontalBlurPostprocess1;
  58481. private _verticalBlurPostprocess1;
  58482. private _horizontalBlurPostprocess2;
  58483. private _verticalBlurPostprocess2;
  58484. private _blurTexture1;
  58485. private _blurTexture2;
  58486. private _postProcesses1;
  58487. private _postProcesses2;
  58488. private _includedOnlyMeshes;
  58489. private _excludedMeshes;
  58490. private _meshesUsingTheirOwnMaterials;
  58491. /**
  58492. * Callback used to let the user override the color selection on a per mesh basis
  58493. */
  58494. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58495. /**
  58496. * Callback used to let the user override the texture selection on a per mesh basis
  58497. */
  58498. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58499. /**
  58500. * Instantiates a new glow Layer and references it to the scene.
  58501. * @param name The name of the layer
  58502. * @param scene The scene to use the layer in
  58503. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58504. */
  58505. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58506. /**
  58507. * Get the effect name of the layer.
  58508. * @return The effect name
  58509. */
  58510. getEffectName(): string;
  58511. /**
  58512. * Create the merge effect. This is the shader use to blit the information back
  58513. * to the main canvas at the end of the scene rendering.
  58514. */
  58515. protected _createMergeEffect(): Effect;
  58516. /**
  58517. * Creates the render target textures and post processes used in the glow layer.
  58518. */
  58519. protected _createTextureAndPostProcesses(): void;
  58520. /**
  58521. * Checks for the readiness of the element composing the layer.
  58522. * @param subMesh the mesh to check for
  58523. * @param useInstances specify wether or not to use instances to render the mesh
  58524. * @param emissiveTexture the associated emissive texture used to generate the glow
  58525. * @return true if ready otherwise, false
  58526. */
  58527. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58528. /**
  58529. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58530. */
  58531. needStencil(): boolean;
  58532. /**
  58533. * Returns true if the mesh can be rendered, otherwise false.
  58534. * @param mesh The mesh to render
  58535. * @param material The material used on the mesh
  58536. * @returns true if it can be rendered otherwise false
  58537. */
  58538. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58539. /**
  58540. * Implementation specific of rendering the generating effect on the main canvas.
  58541. * @param effect The effect used to render through
  58542. */
  58543. protected _internalRender(effect: Effect): void;
  58544. /**
  58545. * Sets the required values for both the emissive texture and and the main color.
  58546. */
  58547. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58548. /**
  58549. * Returns true if the mesh should render, otherwise false.
  58550. * @param mesh The mesh to render
  58551. * @returns true if it should render otherwise false
  58552. */
  58553. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58554. /**
  58555. * Adds specific effects defines.
  58556. * @param defines The defines to add specifics to.
  58557. */
  58558. protected _addCustomEffectDefines(defines: string[]): void;
  58559. /**
  58560. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58561. * @param mesh The mesh to exclude from the glow layer
  58562. */
  58563. addExcludedMesh(mesh: Mesh): void;
  58564. /**
  58565. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58566. * @param mesh The mesh to remove
  58567. */
  58568. removeExcludedMesh(mesh: Mesh): void;
  58569. /**
  58570. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58571. * @param mesh The mesh to include in the glow layer
  58572. */
  58573. addIncludedOnlyMesh(mesh: Mesh): void;
  58574. /**
  58575. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58576. * @param mesh The mesh to remove
  58577. */
  58578. removeIncludedOnlyMesh(mesh: Mesh): void;
  58579. /**
  58580. * Determine if a given mesh will be used in the glow layer
  58581. * @param mesh The mesh to test
  58582. * @returns true if the mesh will be highlighted by the current glow layer
  58583. */
  58584. hasMesh(mesh: AbstractMesh): boolean;
  58585. /**
  58586. * Defines whether the current material of the mesh should be use to render the effect.
  58587. * @param mesh defines the current mesh to render
  58588. */
  58589. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58590. /**
  58591. * Add a mesh to be rendered through its own material and not with emissive only.
  58592. * @param mesh The mesh for which we need to use its material
  58593. */
  58594. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58595. /**
  58596. * Remove a mesh from being rendered through its own material and not with emissive only.
  58597. * @param mesh The mesh for which we need to not use its material
  58598. */
  58599. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58600. /**
  58601. * Free any resources and references associated to a mesh.
  58602. * Internal use
  58603. * @param mesh The mesh to free.
  58604. * @hidden
  58605. */
  58606. _disposeMesh(mesh: Mesh): void;
  58607. /**
  58608. * Gets the class name of the effect layer
  58609. * @returns the string with the class name of the effect layer
  58610. */
  58611. getClassName(): string;
  58612. /**
  58613. * Serializes this glow layer
  58614. * @returns a serialized glow layer object
  58615. */
  58616. serialize(): any;
  58617. /**
  58618. * Creates a Glow Layer from parsed glow layer data
  58619. * @param parsedGlowLayer defines glow layer data
  58620. * @param scene defines the current scene
  58621. * @param rootUrl defines the root URL containing the glow layer information
  58622. * @returns a parsed Glow Layer
  58623. */
  58624. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58625. }
  58626. }
  58627. declare module BABYLON {
  58628. /** @hidden */
  58629. export var glowBlurPostProcessPixelShader: {
  58630. name: string;
  58631. shader: string;
  58632. };
  58633. }
  58634. declare module BABYLON {
  58635. interface AbstractScene {
  58636. /**
  58637. * Return a the first highlight layer of the scene with a given name.
  58638. * @param name The name of the highlight layer to look for.
  58639. * @return The highlight layer if found otherwise null.
  58640. */
  58641. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58642. }
  58643. /**
  58644. * Highlight layer options. This helps customizing the behaviour
  58645. * of the highlight layer.
  58646. */
  58647. export interface IHighlightLayerOptions {
  58648. /**
  58649. * Multiplication factor apply to the canvas size to compute the render target size
  58650. * used to generated the glowing objects (the smaller the faster).
  58651. */
  58652. mainTextureRatio: number;
  58653. /**
  58654. * Enforces a fixed size texture to ensure resize independant blur.
  58655. */
  58656. mainTextureFixedSize?: number;
  58657. /**
  58658. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58659. * of the picture to blur (the smaller the faster).
  58660. */
  58661. blurTextureSizeRatio: number;
  58662. /**
  58663. * How big in texel of the blur texture is the vertical blur.
  58664. */
  58665. blurVerticalSize: number;
  58666. /**
  58667. * How big in texel of the blur texture is the horizontal blur.
  58668. */
  58669. blurHorizontalSize: number;
  58670. /**
  58671. * Alpha blending mode used to apply the blur. Default is combine.
  58672. */
  58673. alphaBlendingMode: number;
  58674. /**
  58675. * The camera attached to the layer.
  58676. */
  58677. camera: Nullable<Camera>;
  58678. /**
  58679. * Should we display highlight as a solid stroke?
  58680. */
  58681. isStroke?: boolean;
  58682. /**
  58683. * The rendering group to draw the layer in.
  58684. */
  58685. renderingGroupId: number;
  58686. }
  58687. /**
  58688. * The highlight layer Helps adding a glow effect around a mesh.
  58689. *
  58690. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58691. * glowy meshes to your scene.
  58692. *
  58693. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58694. */
  58695. export class HighlightLayer extends EffectLayer {
  58696. name: string;
  58697. /**
  58698. * Effect Name of the highlight layer.
  58699. */
  58700. static readonly EffectName: string;
  58701. /**
  58702. * The neutral color used during the preparation of the glow effect.
  58703. * This is black by default as the blend operation is a blend operation.
  58704. */
  58705. static NeutralColor: Color4;
  58706. /**
  58707. * Stencil value used for glowing meshes.
  58708. */
  58709. static GlowingMeshStencilReference: number;
  58710. /**
  58711. * Stencil value used for the other meshes in the scene.
  58712. */
  58713. static NormalMeshStencilReference: number;
  58714. /**
  58715. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58716. */
  58717. innerGlow: boolean;
  58718. /**
  58719. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58720. */
  58721. outerGlow: boolean;
  58722. /**
  58723. * Specifies the horizontal size of the blur.
  58724. */
  58725. set blurHorizontalSize(value: number);
  58726. /**
  58727. * Specifies the vertical size of the blur.
  58728. */
  58729. set blurVerticalSize(value: number);
  58730. /**
  58731. * Gets the horizontal size of the blur.
  58732. */
  58733. get blurHorizontalSize(): number;
  58734. /**
  58735. * Gets the vertical size of the blur.
  58736. */
  58737. get blurVerticalSize(): number;
  58738. /**
  58739. * An event triggered when the highlight layer is being blurred.
  58740. */
  58741. onBeforeBlurObservable: Observable<HighlightLayer>;
  58742. /**
  58743. * An event triggered when the highlight layer has been blurred.
  58744. */
  58745. onAfterBlurObservable: Observable<HighlightLayer>;
  58746. private _instanceGlowingMeshStencilReference;
  58747. private _options;
  58748. private _downSamplePostprocess;
  58749. private _horizontalBlurPostprocess;
  58750. private _verticalBlurPostprocess;
  58751. private _blurTexture;
  58752. private _meshes;
  58753. private _excludedMeshes;
  58754. /**
  58755. * Instantiates a new highlight Layer and references it to the scene..
  58756. * @param name The name of the layer
  58757. * @param scene The scene to use the layer in
  58758. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58759. */
  58760. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58761. /**
  58762. * Get the effect name of the layer.
  58763. * @return The effect name
  58764. */
  58765. getEffectName(): string;
  58766. /**
  58767. * Create the merge effect. This is the shader use to blit the information back
  58768. * to the main canvas at the end of the scene rendering.
  58769. */
  58770. protected _createMergeEffect(): Effect;
  58771. /**
  58772. * Creates the render target textures and post processes used in the highlight layer.
  58773. */
  58774. protected _createTextureAndPostProcesses(): void;
  58775. /**
  58776. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58777. */
  58778. needStencil(): boolean;
  58779. /**
  58780. * Checks for the readiness of the element composing the layer.
  58781. * @param subMesh the mesh to check for
  58782. * @param useInstances specify wether or not to use instances to render the mesh
  58783. * @param emissiveTexture the associated emissive texture used to generate the glow
  58784. * @return true if ready otherwise, false
  58785. */
  58786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58787. /**
  58788. * Implementation specific of rendering the generating effect on the main canvas.
  58789. * @param effect The effect used to render through
  58790. */
  58791. protected _internalRender(effect: Effect): void;
  58792. /**
  58793. * Returns true if the layer contains information to display, otherwise false.
  58794. */
  58795. shouldRender(): boolean;
  58796. /**
  58797. * Returns true if the mesh should render, otherwise false.
  58798. * @param mesh The mesh to render
  58799. * @returns true if it should render otherwise false
  58800. */
  58801. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58802. /**
  58803. * Returns true if the mesh can be rendered, otherwise false.
  58804. * @param mesh The mesh to render
  58805. * @param material The material used on the mesh
  58806. * @returns true if it can be rendered otherwise false
  58807. */
  58808. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58809. /**
  58810. * Adds specific effects defines.
  58811. * @param defines The defines to add specifics to.
  58812. */
  58813. protected _addCustomEffectDefines(defines: string[]): void;
  58814. /**
  58815. * Sets the required values for both the emissive texture and and the main color.
  58816. */
  58817. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58818. /**
  58819. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58820. * @param mesh The mesh to exclude from the highlight layer
  58821. */
  58822. addExcludedMesh(mesh: Mesh): void;
  58823. /**
  58824. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58825. * @param mesh The mesh to highlight
  58826. */
  58827. removeExcludedMesh(mesh: Mesh): void;
  58828. /**
  58829. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58830. * @param mesh mesh to test
  58831. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58832. */
  58833. hasMesh(mesh: AbstractMesh): boolean;
  58834. /**
  58835. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58836. * @param mesh The mesh to highlight
  58837. * @param color The color of the highlight
  58838. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58839. */
  58840. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58841. /**
  58842. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58843. * @param mesh The mesh to highlight
  58844. */
  58845. removeMesh(mesh: Mesh): void;
  58846. /**
  58847. * Remove all the meshes currently referenced in the highlight layer
  58848. */
  58849. removeAllMeshes(): void;
  58850. /**
  58851. * Force the stencil to the normal expected value for none glowing parts
  58852. */
  58853. private _defaultStencilReference;
  58854. /**
  58855. * Free any resources and references associated to a mesh.
  58856. * Internal use
  58857. * @param mesh The mesh to free.
  58858. * @hidden
  58859. */
  58860. _disposeMesh(mesh: Mesh): void;
  58861. /**
  58862. * Dispose the highlight layer and free resources.
  58863. */
  58864. dispose(): void;
  58865. /**
  58866. * Gets the class name of the effect layer
  58867. * @returns the string with the class name of the effect layer
  58868. */
  58869. getClassName(): string;
  58870. /**
  58871. * Serializes this Highlight layer
  58872. * @returns a serialized Highlight layer object
  58873. */
  58874. serialize(): any;
  58875. /**
  58876. * Creates a Highlight layer from parsed Highlight layer data
  58877. * @param parsedHightlightLayer defines the Highlight layer data
  58878. * @param scene defines the current scene
  58879. * @param rootUrl defines the root URL containing the Highlight layer information
  58880. * @returns a parsed Highlight layer
  58881. */
  58882. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58883. }
  58884. }
  58885. declare module BABYLON {
  58886. interface AbstractScene {
  58887. /**
  58888. * The list of layers (background and foreground) of the scene
  58889. */
  58890. layers: Array<Layer>;
  58891. }
  58892. /**
  58893. * Defines the layer scene component responsible to manage any layers
  58894. * in a given scene.
  58895. */
  58896. export class LayerSceneComponent implements ISceneComponent {
  58897. /**
  58898. * The component name helpfull to identify the component in the list of scene components.
  58899. */
  58900. readonly name: string;
  58901. /**
  58902. * The scene the component belongs to.
  58903. */
  58904. scene: Scene;
  58905. private _engine;
  58906. /**
  58907. * Creates a new instance of the component for the given scene
  58908. * @param scene Defines the scene to register the component in
  58909. */
  58910. constructor(scene: Scene);
  58911. /**
  58912. * Registers the component in a given scene
  58913. */
  58914. register(): void;
  58915. /**
  58916. * Rebuilds the elements related to this component in case of
  58917. * context lost for instance.
  58918. */
  58919. rebuild(): void;
  58920. /**
  58921. * Disposes the component and the associated ressources.
  58922. */
  58923. dispose(): void;
  58924. private _draw;
  58925. private _drawCameraPredicate;
  58926. private _drawCameraBackground;
  58927. private _drawCameraForeground;
  58928. private _drawRenderTargetPredicate;
  58929. private _drawRenderTargetBackground;
  58930. private _drawRenderTargetForeground;
  58931. /**
  58932. * Adds all the elements from the container to the scene
  58933. * @param container the container holding the elements
  58934. */
  58935. addFromContainer(container: AbstractScene): void;
  58936. /**
  58937. * Removes all the elements in the container from the scene
  58938. * @param container contains the elements to remove
  58939. * @param dispose if the removed element should be disposed (default: false)
  58940. */
  58941. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58942. }
  58943. }
  58944. declare module BABYLON {
  58945. /** @hidden */
  58946. export var layerPixelShader: {
  58947. name: string;
  58948. shader: string;
  58949. };
  58950. }
  58951. declare module BABYLON {
  58952. /** @hidden */
  58953. export var layerVertexShader: {
  58954. name: string;
  58955. shader: string;
  58956. };
  58957. }
  58958. declare module BABYLON {
  58959. /**
  58960. * This represents a full screen 2d layer.
  58961. * This can be useful to display a picture in the background of your scene for instance.
  58962. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58963. */
  58964. export class Layer {
  58965. /**
  58966. * Define the name of the layer.
  58967. */
  58968. name: string;
  58969. /**
  58970. * Define the texture the layer should display.
  58971. */
  58972. texture: Nullable<Texture>;
  58973. /**
  58974. * Is the layer in background or foreground.
  58975. */
  58976. isBackground: boolean;
  58977. /**
  58978. * Define the color of the layer (instead of texture).
  58979. */
  58980. color: Color4;
  58981. /**
  58982. * Define the scale of the layer in order to zoom in out of the texture.
  58983. */
  58984. scale: Vector2;
  58985. /**
  58986. * Define an offset for the layer in order to shift the texture.
  58987. */
  58988. offset: Vector2;
  58989. /**
  58990. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58991. */
  58992. alphaBlendingMode: number;
  58993. /**
  58994. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58995. * Alpha test will not mix with the background color in case of transparency.
  58996. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58997. */
  58998. alphaTest: boolean;
  58999. /**
  59000. * Define a mask to restrict the layer to only some of the scene cameras.
  59001. */
  59002. layerMask: number;
  59003. /**
  59004. * Define the list of render target the layer is visible into.
  59005. */
  59006. renderTargetTextures: RenderTargetTexture[];
  59007. /**
  59008. * Define if the layer is only used in renderTarget or if it also
  59009. * renders in the main frame buffer of the canvas.
  59010. */
  59011. renderOnlyInRenderTargetTextures: boolean;
  59012. private _scene;
  59013. private _vertexBuffers;
  59014. private _indexBuffer;
  59015. private _effect;
  59016. private _previousDefines;
  59017. /**
  59018. * An event triggered when the layer is disposed.
  59019. */
  59020. onDisposeObservable: Observable<Layer>;
  59021. private _onDisposeObserver;
  59022. /**
  59023. * Back compatibility with callback before the onDisposeObservable existed.
  59024. * The set callback will be triggered when the layer has been disposed.
  59025. */
  59026. set onDispose(callback: () => void);
  59027. /**
  59028. * An event triggered before rendering the scene
  59029. */
  59030. onBeforeRenderObservable: Observable<Layer>;
  59031. private _onBeforeRenderObserver;
  59032. /**
  59033. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59034. * The set callback will be triggered just before rendering the layer.
  59035. */
  59036. set onBeforeRender(callback: () => void);
  59037. /**
  59038. * An event triggered after rendering the scene
  59039. */
  59040. onAfterRenderObservable: Observable<Layer>;
  59041. private _onAfterRenderObserver;
  59042. /**
  59043. * Back compatibility with callback before the onAfterRenderObservable existed.
  59044. * The set callback will be triggered just after rendering the layer.
  59045. */
  59046. set onAfterRender(callback: () => void);
  59047. /**
  59048. * Instantiates a new layer.
  59049. * This represents a full screen 2d layer.
  59050. * This can be useful to display a picture in the background of your scene for instance.
  59051. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59052. * @param name Define the name of the layer in the scene
  59053. * @param imgUrl Define the url of the texture to display in the layer
  59054. * @param scene Define the scene the layer belongs to
  59055. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59056. * @param color Defines a color for the layer
  59057. */
  59058. constructor(
  59059. /**
  59060. * Define the name of the layer.
  59061. */
  59062. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59063. private _createIndexBuffer;
  59064. /** @hidden */
  59065. _rebuild(): void;
  59066. /**
  59067. * Renders the layer in the scene.
  59068. */
  59069. render(): void;
  59070. /**
  59071. * Disposes and releases the associated ressources.
  59072. */
  59073. dispose(): void;
  59074. }
  59075. }
  59076. declare module BABYLON {
  59077. /** @hidden */
  59078. export var lensFlarePixelShader: {
  59079. name: string;
  59080. shader: string;
  59081. };
  59082. }
  59083. declare module BABYLON {
  59084. /** @hidden */
  59085. export var lensFlareVertexShader: {
  59086. name: string;
  59087. shader: string;
  59088. };
  59089. }
  59090. declare module BABYLON {
  59091. /**
  59092. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59093. * It is usually composed of several `lensFlare`.
  59094. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59095. */
  59096. export class LensFlareSystem {
  59097. /**
  59098. * Define the name of the lens flare system
  59099. */
  59100. name: string;
  59101. /**
  59102. * List of lens flares used in this system.
  59103. */
  59104. lensFlares: LensFlare[];
  59105. /**
  59106. * Define a limit from the border the lens flare can be visible.
  59107. */
  59108. borderLimit: number;
  59109. /**
  59110. * Define a viewport border we do not want to see the lens flare in.
  59111. */
  59112. viewportBorder: number;
  59113. /**
  59114. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59115. */
  59116. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59117. /**
  59118. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59119. */
  59120. layerMask: number;
  59121. /**
  59122. * Define the id of the lens flare system in the scene.
  59123. * (equal to name by default)
  59124. */
  59125. id: string;
  59126. private _scene;
  59127. private _emitter;
  59128. private _vertexBuffers;
  59129. private _indexBuffer;
  59130. private _effect;
  59131. private _positionX;
  59132. private _positionY;
  59133. private _isEnabled;
  59134. /** @hidden */
  59135. static _SceneComponentInitialization: (scene: Scene) => void;
  59136. /**
  59137. * Instantiates a lens flare system.
  59138. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59139. * It is usually composed of several `lensFlare`.
  59140. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59141. * @param name Define the name of the lens flare system in the scene
  59142. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59143. * @param scene Define the scene the lens flare system belongs to
  59144. */
  59145. constructor(
  59146. /**
  59147. * Define the name of the lens flare system
  59148. */
  59149. name: string, emitter: any, scene: Scene);
  59150. /**
  59151. * Define if the lens flare system is enabled.
  59152. */
  59153. get isEnabled(): boolean;
  59154. set isEnabled(value: boolean);
  59155. /**
  59156. * Get the scene the effects belongs to.
  59157. * @returns the scene holding the lens flare system
  59158. */
  59159. getScene(): Scene;
  59160. /**
  59161. * Get the emitter of the lens flare system.
  59162. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59163. * @returns the emitter of the lens flare system
  59164. */
  59165. getEmitter(): any;
  59166. /**
  59167. * Set the emitter of the lens flare system.
  59168. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59169. * @param newEmitter Define the new emitter of the system
  59170. */
  59171. setEmitter(newEmitter: any): void;
  59172. /**
  59173. * Get the lens flare system emitter position.
  59174. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59175. * @returns the position
  59176. */
  59177. getEmitterPosition(): Vector3;
  59178. /**
  59179. * @hidden
  59180. */
  59181. computeEffectivePosition(globalViewport: Viewport): boolean;
  59182. /** @hidden */
  59183. _isVisible(): boolean;
  59184. /**
  59185. * @hidden
  59186. */
  59187. render(): boolean;
  59188. /**
  59189. * Dispose and release the lens flare with its associated resources.
  59190. */
  59191. dispose(): void;
  59192. /**
  59193. * Parse a lens flare system from a JSON repressentation
  59194. * @param parsedLensFlareSystem Define the JSON to parse
  59195. * @param scene Define the scene the parsed system should be instantiated in
  59196. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59197. * @returns the parsed system
  59198. */
  59199. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59200. /**
  59201. * Serialize the current Lens Flare System into a JSON representation.
  59202. * @returns the serialized JSON
  59203. */
  59204. serialize(): any;
  59205. }
  59206. }
  59207. declare module BABYLON {
  59208. /**
  59209. * This represents one of the lens effect in a `lensFlareSystem`.
  59210. * It controls one of the indiviual texture used in the effect.
  59211. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59212. */
  59213. export class LensFlare {
  59214. /**
  59215. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59216. */
  59217. size: number;
  59218. /**
  59219. * 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.
  59220. */
  59221. position: number;
  59222. /**
  59223. * Define the lens color.
  59224. */
  59225. color: Color3;
  59226. /**
  59227. * Define the lens texture.
  59228. */
  59229. texture: Nullable<Texture>;
  59230. /**
  59231. * Define the alpha mode to render this particular lens.
  59232. */
  59233. alphaMode: number;
  59234. private _system;
  59235. /**
  59236. * Creates a new Lens Flare.
  59237. * This represents one of the lens effect in a `lensFlareSystem`.
  59238. * It controls one of the indiviual texture used in the effect.
  59239. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59240. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59241. * @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.
  59242. * @param color Define the lens color
  59243. * @param imgUrl Define the lens texture url
  59244. * @param system Define the `lensFlareSystem` this flare is part of
  59245. * @returns The newly created Lens Flare
  59246. */
  59247. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59248. /**
  59249. * Instantiates a new Lens Flare.
  59250. * This represents one of the lens effect in a `lensFlareSystem`.
  59251. * It controls one of the indiviual texture used in the effect.
  59252. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59253. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59254. * @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.
  59255. * @param color Define the lens color
  59256. * @param imgUrl Define the lens texture url
  59257. * @param system Define the `lensFlareSystem` this flare is part of
  59258. */
  59259. constructor(
  59260. /**
  59261. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59262. */
  59263. size: number,
  59264. /**
  59265. * 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.
  59266. */
  59267. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59268. /**
  59269. * Dispose and release the lens flare with its associated resources.
  59270. */
  59271. dispose(): void;
  59272. }
  59273. }
  59274. declare module BABYLON {
  59275. interface AbstractScene {
  59276. /**
  59277. * The list of lens flare system added to the scene
  59278. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59279. */
  59280. lensFlareSystems: Array<LensFlareSystem>;
  59281. /**
  59282. * Removes the given lens flare system from this scene.
  59283. * @param toRemove The lens flare system to remove
  59284. * @returns The index of the removed lens flare system
  59285. */
  59286. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59287. /**
  59288. * Adds the given lens flare system to this scene
  59289. * @param newLensFlareSystem The lens flare system to add
  59290. */
  59291. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59292. /**
  59293. * Gets a lens flare system using its name
  59294. * @param name defines the name to look for
  59295. * @returns the lens flare system or null if not found
  59296. */
  59297. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59298. /**
  59299. * Gets a lens flare system using its id
  59300. * @param id defines the id to look for
  59301. * @returns the lens flare system or null if not found
  59302. */
  59303. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59304. }
  59305. /**
  59306. * Defines the lens flare scene component responsible to manage any lens flares
  59307. * in a given scene.
  59308. */
  59309. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59310. /**
  59311. * The component name helpfull to identify the component in the list of scene components.
  59312. */
  59313. readonly name: string;
  59314. /**
  59315. * The scene the component belongs to.
  59316. */
  59317. scene: Scene;
  59318. /**
  59319. * Creates a new instance of the component for the given scene
  59320. * @param scene Defines the scene to register the component in
  59321. */
  59322. constructor(scene: Scene);
  59323. /**
  59324. * Registers the component in a given scene
  59325. */
  59326. register(): void;
  59327. /**
  59328. * Rebuilds the elements related to this component in case of
  59329. * context lost for instance.
  59330. */
  59331. rebuild(): void;
  59332. /**
  59333. * Adds all the elements from the container to the scene
  59334. * @param container the container holding the elements
  59335. */
  59336. addFromContainer(container: AbstractScene): void;
  59337. /**
  59338. * Removes all the elements in the container from the scene
  59339. * @param container contains the elements to remove
  59340. * @param dispose if the removed element should be disposed (default: false)
  59341. */
  59342. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59343. /**
  59344. * Serializes the component data to the specified json object
  59345. * @param serializationObject The object to serialize to
  59346. */
  59347. serialize(serializationObject: any): void;
  59348. /**
  59349. * Disposes the component and the associated ressources.
  59350. */
  59351. dispose(): void;
  59352. private _draw;
  59353. }
  59354. }
  59355. declare module BABYLON {
  59356. /** @hidden */
  59357. export var depthPixelShader: {
  59358. name: string;
  59359. shader: string;
  59360. };
  59361. }
  59362. declare module BABYLON {
  59363. /** @hidden */
  59364. export var depthVertexShader: {
  59365. name: string;
  59366. shader: string;
  59367. };
  59368. }
  59369. declare module BABYLON {
  59370. /**
  59371. * This represents a depth renderer in Babylon.
  59372. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59373. */
  59374. export class DepthRenderer {
  59375. private _scene;
  59376. private _depthMap;
  59377. private _effect;
  59378. private readonly _storeNonLinearDepth;
  59379. private readonly _clearColor;
  59380. /** Get if the depth renderer is using packed depth or not */
  59381. readonly isPacked: boolean;
  59382. private _cachedDefines;
  59383. private _camera;
  59384. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59385. enabled: boolean;
  59386. /**
  59387. * Specifiess that the depth renderer will only be used within
  59388. * the camera it is created for.
  59389. * This can help forcing its rendering during the camera processing.
  59390. */
  59391. useOnlyInActiveCamera: boolean;
  59392. /** @hidden */
  59393. static _SceneComponentInitialization: (scene: Scene) => void;
  59394. /**
  59395. * Instantiates a depth renderer
  59396. * @param scene The scene the renderer belongs to
  59397. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59398. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59399. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59400. */
  59401. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59402. /**
  59403. * Creates the depth rendering effect and checks if the effect is ready.
  59404. * @param subMesh The submesh to be used to render the depth map of
  59405. * @param useInstances If multiple world instances should be used
  59406. * @returns if the depth renderer is ready to render the depth map
  59407. */
  59408. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59409. /**
  59410. * Gets the texture which the depth map will be written to.
  59411. * @returns The depth map texture
  59412. */
  59413. getDepthMap(): RenderTargetTexture;
  59414. /**
  59415. * Disposes of the depth renderer.
  59416. */
  59417. dispose(): void;
  59418. }
  59419. }
  59420. declare module BABYLON {
  59421. /** @hidden */
  59422. export var minmaxReduxPixelShader: {
  59423. name: string;
  59424. shader: string;
  59425. };
  59426. }
  59427. declare module BABYLON {
  59428. /**
  59429. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59430. * and maximum values from all values of the texture.
  59431. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59432. * The source values are read from the red channel of the texture.
  59433. */
  59434. export class MinMaxReducer {
  59435. /**
  59436. * Observable triggered when the computation has been performed
  59437. */
  59438. onAfterReductionPerformed: Observable<{
  59439. min: number;
  59440. max: number;
  59441. }>;
  59442. protected _camera: Camera;
  59443. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59444. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59445. protected _postProcessManager: PostProcessManager;
  59446. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59447. protected _forceFullscreenViewport: boolean;
  59448. /**
  59449. * Creates a min/max reducer
  59450. * @param camera The camera to use for the post processes
  59451. */
  59452. constructor(camera: Camera);
  59453. /**
  59454. * Gets the texture used to read the values from.
  59455. */
  59456. get sourceTexture(): Nullable<RenderTargetTexture>;
  59457. /**
  59458. * Sets the source texture to read the values from.
  59459. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59460. * because in such textures '1' value must not be taken into account to compute the maximum
  59461. * as this value is used to clear the texture.
  59462. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59463. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59464. * @param depthRedux Indicates if the texture is a depth texture or not
  59465. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59466. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59467. */
  59468. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59469. /**
  59470. * Defines the refresh rate of the computation.
  59471. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59472. */
  59473. get refreshRate(): number;
  59474. set refreshRate(value: number);
  59475. protected _activated: boolean;
  59476. /**
  59477. * Gets the activation status of the reducer
  59478. */
  59479. get activated(): boolean;
  59480. /**
  59481. * Activates the reduction computation.
  59482. * When activated, the observers registered in onAfterReductionPerformed are
  59483. * called after the compuation is performed
  59484. */
  59485. activate(): void;
  59486. /**
  59487. * Deactivates the reduction computation.
  59488. */
  59489. deactivate(): void;
  59490. /**
  59491. * Disposes the min/max reducer
  59492. * @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.
  59493. */
  59494. dispose(disposeAll?: boolean): void;
  59495. }
  59496. }
  59497. declare module BABYLON {
  59498. /**
  59499. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59500. */
  59501. export class DepthReducer extends MinMaxReducer {
  59502. private _depthRenderer;
  59503. private _depthRendererId;
  59504. /**
  59505. * Gets the depth renderer used for the computation.
  59506. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59507. */
  59508. get depthRenderer(): Nullable<DepthRenderer>;
  59509. /**
  59510. * Creates a depth reducer
  59511. * @param camera The camera used to render the depth texture
  59512. */
  59513. constructor(camera: Camera);
  59514. /**
  59515. * Sets the depth renderer to use to generate the depth map
  59516. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59517. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59518. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59519. */
  59520. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59521. /** @hidden */
  59522. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59523. /**
  59524. * Activates the reduction computation.
  59525. * When activated, the observers registered in onAfterReductionPerformed are
  59526. * called after the compuation is performed
  59527. */
  59528. activate(): void;
  59529. /**
  59530. * Deactivates the reduction computation.
  59531. */
  59532. deactivate(): void;
  59533. /**
  59534. * Disposes the depth reducer
  59535. * @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.
  59536. */
  59537. dispose(disposeAll?: boolean): void;
  59538. }
  59539. }
  59540. declare module BABYLON {
  59541. /**
  59542. * A CSM implementation allowing casting shadows on large scenes.
  59543. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59544. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59545. */
  59546. export class CascadedShadowGenerator extends ShadowGenerator {
  59547. private static readonly frustumCornersNDCSpace;
  59548. /**
  59549. * Name of the CSM class
  59550. */
  59551. static CLASSNAME: string;
  59552. /**
  59553. * Defines the default number of cascades used by the CSM.
  59554. */
  59555. static readonly DEFAULT_CASCADES_COUNT: number;
  59556. /**
  59557. * Defines the minimum number of cascades used by the CSM.
  59558. */
  59559. static readonly MIN_CASCADES_COUNT: number;
  59560. /**
  59561. * Defines the maximum number of cascades used by the CSM.
  59562. */
  59563. static readonly MAX_CASCADES_COUNT: number;
  59564. protected _validateFilter(filter: number): number;
  59565. /**
  59566. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59567. */
  59568. penumbraDarkness: number;
  59569. private _numCascades;
  59570. /**
  59571. * Gets or set the number of cascades used by the CSM.
  59572. */
  59573. get numCascades(): number;
  59574. set numCascades(value: number);
  59575. /**
  59576. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59577. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59578. */
  59579. stabilizeCascades: boolean;
  59580. private _freezeShadowCastersBoundingInfo;
  59581. private _freezeShadowCastersBoundingInfoObservable;
  59582. /**
  59583. * Enables or disables the shadow casters bounding info computation.
  59584. * If your shadow casters don't move, you can disable this feature.
  59585. * If it is enabled, the bounding box computation is done every frame.
  59586. */
  59587. get freezeShadowCastersBoundingInfo(): boolean;
  59588. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59589. private _scbiMin;
  59590. private _scbiMax;
  59591. protected _computeShadowCastersBoundingInfo(): void;
  59592. protected _shadowCastersBoundingInfo: BoundingInfo;
  59593. /**
  59594. * Gets or sets the shadow casters bounding info.
  59595. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59596. * so that the system won't overwrite the bounds you provide
  59597. */
  59598. get shadowCastersBoundingInfo(): BoundingInfo;
  59599. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59600. protected _breaksAreDirty: boolean;
  59601. protected _minDistance: number;
  59602. protected _maxDistance: number;
  59603. /**
  59604. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59605. *
  59606. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59607. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59608. * @param min minimal distance for the breaks (default to 0.)
  59609. * @param max maximal distance for the breaks (default to 1.)
  59610. */
  59611. setMinMaxDistance(min: number, max: number): void;
  59612. /** Gets the minimal distance used in the cascade break computation */
  59613. get minDistance(): number;
  59614. /** Gets the maximal distance used in the cascade break computation */
  59615. get maxDistance(): number;
  59616. /**
  59617. * Gets the class name of that object
  59618. * @returns "CascadedShadowGenerator"
  59619. */
  59620. getClassName(): string;
  59621. private _cascadeMinExtents;
  59622. private _cascadeMaxExtents;
  59623. /**
  59624. * Gets a cascade minimum extents
  59625. * @param cascadeIndex index of the cascade
  59626. * @returns the minimum cascade extents
  59627. */
  59628. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59629. /**
  59630. * Gets a cascade maximum extents
  59631. * @param cascadeIndex index of the cascade
  59632. * @returns the maximum cascade extents
  59633. */
  59634. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59635. private _cascades;
  59636. private _currentLayer;
  59637. private _viewSpaceFrustumsZ;
  59638. private _viewMatrices;
  59639. private _projectionMatrices;
  59640. private _transformMatrices;
  59641. private _transformMatricesAsArray;
  59642. private _frustumLengths;
  59643. private _lightSizeUVCorrection;
  59644. private _depthCorrection;
  59645. private _frustumCornersWorldSpace;
  59646. private _frustumCenter;
  59647. private _shadowCameraPos;
  59648. private _shadowMaxZ;
  59649. /**
  59650. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59651. * It defaults to camera.maxZ
  59652. */
  59653. get shadowMaxZ(): number;
  59654. /**
  59655. * Sets the shadow max z distance.
  59656. */
  59657. set shadowMaxZ(value: number);
  59658. protected _debug: boolean;
  59659. /**
  59660. * Gets or sets the debug flag.
  59661. * When enabled, the cascades are materialized by different colors on the screen.
  59662. */
  59663. get debug(): boolean;
  59664. set debug(dbg: boolean);
  59665. private _depthClamp;
  59666. /**
  59667. * Gets or sets the depth clamping value.
  59668. *
  59669. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59670. * to account for the shadow casters far away.
  59671. *
  59672. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59673. */
  59674. get depthClamp(): boolean;
  59675. set depthClamp(value: boolean);
  59676. private _cascadeBlendPercentage;
  59677. /**
  59678. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59679. * It defaults to 0.1 (10% blending).
  59680. */
  59681. get cascadeBlendPercentage(): number;
  59682. set cascadeBlendPercentage(value: number);
  59683. private _lambda;
  59684. /**
  59685. * Gets or set the lambda parameter.
  59686. * This parameter is used to split the camera frustum and create the cascades.
  59687. * 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.
  59688. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59689. */
  59690. get lambda(): number;
  59691. set lambda(value: number);
  59692. /**
  59693. * Gets the view matrix corresponding to a given cascade
  59694. * @param cascadeNum cascade to retrieve the view matrix from
  59695. * @returns the cascade view matrix
  59696. */
  59697. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59698. /**
  59699. * Gets the projection matrix corresponding to a given cascade
  59700. * @param cascadeNum cascade to retrieve the projection matrix from
  59701. * @returns the cascade projection matrix
  59702. */
  59703. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59704. /**
  59705. * Gets the transformation matrix corresponding to a given cascade
  59706. * @param cascadeNum cascade to retrieve the transformation matrix from
  59707. * @returns the cascade transformation matrix
  59708. */
  59709. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59710. private _depthRenderer;
  59711. /**
  59712. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59713. *
  59714. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59715. *
  59716. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59717. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59718. * @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
  59719. */
  59720. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59721. private _depthReducer;
  59722. private _autoCalcDepthBounds;
  59723. /**
  59724. * Gets or sets the autoCalcDepthBounds property.
  59725. *
  59726. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59727. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59728. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59729. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59730. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59731. */
  59732. get autoCalcDepthBounds(): boolean;
  59733. set autoCalcDepthBounds(value: boolean);
  59734. /**
  59735. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59736. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59737. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59738. * for setting the refresh rate on the renderer yourself!
  59739. */
  59740. get autoCalcDepthBoundsRefreshRate(): number;
  59741. set autoCalcDepthBoundsRefreshRate(value: number);
  59742. /**
  59743. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59744. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59745. * you change the camera near/far planes!
  59746. */
  59747. splitFrustum(): void;
  59748. private _splitFrustum;
  59749. private _computeMatrices;
  59750. private _computeFrustumInWorldSpace;
  59751. private _computeCascadeFrustum;
  59752. /**
  59753. * Support test.
  59754. */
  59755. static get IsSupported(): boolean;
  59756. /** @hidden */
  59757. static _SceneComponentInitialization: (scene: Scene) => void;
  59758. /**
  59759. * Creates a Cascaded Shadow Generator object.
  59760. * A ShadowGenerator is the required tool to use the shadows.
  59761. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59762. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59763. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59764. * @param light The directional light object generating the shadows.
  59765. * @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.
  59766. */
  59767. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59768. protected _initializeGenerator(): void;
  59769. protected _createTargetRenderTexture(): void;
  59770. protected _initializeShadowMap(): void;
  59771. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59772. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59773. /**
  59774. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59775. * @param defines Defines of the material we want to update
  59776. * @param lightIndex Index of the light in the enabled light list of the material
  59777. */
  59778. prepareDefines(defines: any, lightIndex: number): void;
  59779. /**
  59780. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59781. * defined in the generator but impacting the effect).
  59782. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59783. * @param effect The effect we are binfing the information for
  59784. */
  59785. bindShadowLight(lightIndex: string, effect: Effect): void;
  59786. /**
  59787. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59788. * (eq to view projection * shadow projection matrices)
  59789. * @returns The transform matrix used to create the shadow map
  59790. */
  59791. getTransformMatrix(): Matrix;
  59792. /**
  59793. * Disposes the ShadowGenerator.
  59794. * Returns nothing.
  59795. */
  59796. dispose(): void;
  59797. /**
  59798. * Serializes the shadow generator setup to a json object.
  59799. * @returns The serialized JSON object
  59800. */
  59801. serialize(): any;
  59802. /**
  59803. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59804. * @param parsedShadowGenerator The JSON object to parse
  59805. * @param scene The scene to create the shadow map for
  59806. * @returns The parsed shadow generator
  59807. */
  59808. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59809. }
  59810. }
  59811. declare module BABYLON {
  59812. /**
  59813. * Defines the shadow generator component responsible to manage any shadow generators
  59814. * in a given scene.
  59815. */
  59816. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59817. /**
  59818. * The component name helpfull to identify the component in the list of scene components.
  59819. */
  59820. readonly name: string;
  59821. /**
  59822. * The scene the component belongs to.
  59823. */
  59824. scene: Scene;
  59825. /**
  59826. * Creates a new instance of the component for the given scene
  59827. * @param scene Defines the scene to register the component in
  59828. */
  59829. constructor(scene: Scene);
  59830. /**
  59831. * Registers the component in a given scene
  59832. */
  59833. register(): void;
  59834. /**
  59835. * Rebuilds the elements related to this component in case of
  59836. * context lost for instance.
  59837. */
  59838. rebuild(): void;
  59839. /**
  59840. * Serializes the component data to the specified json object
  59841. * @param serializationObject The object to serialize to
  59842. */
  59843. serialize(serializationObject: any): void;
  59844. /**
  59845. * Adds all the elements from the container to the scene
  59846. * @param container the container holding the elements
  59847. */
  59848. addFromContainer(container: AbstractScene): void;
  59849. /**
  59850. * Removes all the elements in the container from the scene
  59851. * @param container contains the elements to remove
  59852. * @param dispose if the removed element should be disposed (default: false)
  59853. */
  59854. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59855. /**
  59856. * Rebuilds the elements related to this component in case of
  59857. * context lost for instance.
  59858. */
  59859. dispose(): void;
  59860. private _gatherRenderTargets;
  59861. }
  59862. }
  59863. declare module BABYLON {
  59864. /**
  59865. * A point light is a light defined by an unique point in world space.
  59866. * The light is emitted in every direction from this point.
  59867. * A good example of a point light is a standard light bulb.
  59868. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59869. */
  59870. export class PointLight extends ShadowLight {
  59871. private _shadowAngle;
  59872. /**
  59873. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59874. * This specifies what angle the shadow will use to be created.
  59875. *
  59876. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59877. */
  59878. get shadowAngle(): number;
  59879. /**
  59880. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59881. * This specifies what angle the shadow will use to be created.
  59882. *
  59883. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59884. */
  59885. set shadowAngle(value: number);
  59886. /**
  59887. * Gets the direction if it has been set.
  59888. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59889. */
  59890. get direction(): Vector3;
  59891. /**
  59892. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59893. */
  59894. set direction(value: Vector3);
  59895. /**
  59896. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59897. * A PointLight emits the light in every direction.
  59898. * It can cast shadows.
  59899. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59900. * ```javascript
  59901. * var pointLight = new PointLight("pl", camera.position, scene);
  59902. * ```
  59903. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59904. * @param name The light friendly name
  59905. * @param position The position of the point light in the scene
  59906. * @param scene The scene the lights belongs to
  59907. */
  59908. constructor(name: string, position: Vector3, scene: Scene);
  59909. /**
  59910. * Returns the string "PointLight"
  59911. * @returns the class name
  59912. */
  59913. getClassName(): string;
  59914. /**
  59915. * Returns the integer 0.
  59916. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59917. */
  59918. getTypeID(): number;
  59919. /**
  59920. * Specifies wether or not the shadowmap should be a cube texture.
  59921. * @returns true if the shadowmap needs to be a cube texture.
  59922. */
  59923. needCube(): boolean;
  59924. /**
  59925. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59926. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59927. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59928. */
  59929. getShadowDirection(faceIndex?: number): Vector3;
  59930. /**
  59931. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59932. * - fov = PI / 2
  59933. * - aspect ratio : 1.0
  59934. * - z-near and far equal to the active camera minZ and maxZ.
  59935. * Returns the PointLight.
  59936. */
  59937. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59938. protected _buildUniformLayout(): void;
  59939. /**
  59940. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59941. * @param effect The effect to update
  59942. * @param lightIndex The index of the light in the effect to update
  59943. * @returns The point light
  59944. */
  59945. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59946. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59947. /**
  59948. * Prepares the list of defines specific to the light type.
  59949. * @param defines the list of defines
  59950. * @param lightIndex defines the index of the light for the effect
  59951. */
  59952. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59953. }
  59954. }
  59955. declare module BABYLON {
  59956. /**
  59957. * Header information of HDR texture files.
  59958. */
  59959. export interface HDRInfo {
  59960. /**
  59961. * The height of the texture in pixels.
  59962. */
  59963. height: number;
  59964. /**
  59965. * The width of the texture in pixels.
  59966. */
  59967. width: number;
  59968. /**
  59969. * The index of the beginning of the data in the binary file.
  59970. */
  59971. dataPosition: number;
  59972. }
  59973. /**
  59974. * This groups tools to convert HDR texture to native colors array.
  59975. */
  59976. export class HDRTools {
  59977. private static Ldexp;
  59978. private static Rgbe2float;
  59979. private static readStringLine;
  59980. /**
  59981. * Reads header information from an RGBE texture stored in a native array.
  59982. * More information on this format are available here:
  59983. * https://en.wikipedia.org/wiki/RGBE_image_format
  59984. *
  59985. * @param uint8array The binary file stored in native array.
  59986. * @return The header information.
  59987. */
  59988. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59989. /**
  59990. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59991. * This RGBE texture needs to store the information as a panorama.
  59992. *
  59993. * More information on this format are available here:
  59994. * https://en.wikipedia.org/wiki/RGBE_image_format
  59995. *
  59996. * @param buffer The binary file stored in an array buffer.
  59997. * @param size The expected size of the extracted cubemap.
  59998. * @return The Cube Map information.
  59999. */
  60000. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60001. /**
  60002. * Returns the pixels data extracted from an RGBE texture.
  60003. * This pixels will be stored left to right up to down in the R G B order in one array.
  60004. *
  60005. * More information on this format are available here:
  60006. * https://en.wikipedia.org/wiki/RGBE_image_format
  60007. *
  60008. * @param uint8array The binary file stored in an array buffer.
  60009. * @param hdrInfo The header information of the file.
  60010. * @return The pixels data in RGB right to left up to down order.
  60011. */
  60012. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60013. private static RGBE_ReadPixels_RLE;
  60014. private static RGBE_ReadPixels_NOT_RLE;
  60015. }
  60016. }
  60017. declare module BABYLON {
  60018. /**
  60019. * Effect Render Options
  60020. */
  60021. export interface IEffectRendererOptions {
  60022. /**
  60023. * Defines the vertices positions.
  60024. */
  60025. positions?: number[];
  60026. /**
  60027. * Defines the indices.
  60028. */
  60029. indices?: number[];
  60030. }
  60031. /**
  60032. * Helper class to render one or more effects.
  60033. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60034. */
  60035. export class EffectRenderer {
  60036. private engine;
  60037. private static _DefaultOptions;
  60038. private _vertexBuffers;
  60039. private _indexBuffer;
  60040. private _fullscreenViewport;
  60041. /**
  60042. * Creates an effect renderer
  60043. * @param engine the engine to use for rendering
  60044. * @param options defines the options of the effect renderer
  60045. */
  60046. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60047. /**
  60048. * Sets the current viewport in normalized coordinates 0-1
  60049. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60050. */
  60051. setViewport(viewport?: Viewport): void;
  60052. /**
  60053. * Binds the embedded attributes buffer to the effect.
  60054. * @param effect Defines the effect to bind the attributes for
  60055. */
  60056. bindBuffers(effect: Effect): void;
  60057. /**
  60058. * Sets the current effect wrapper to use during draw.
  60059. * The effect needs to be ready before calling this api.
  60060. * This also sets the default full screen position attribute.
  60061. * @param effectWrapper Defines the effect to draw with
  60062. */
  60063. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60064. /**
  60065. * Restores engine states
  60066. */
  60067. restoreStates(): void;
  60068. /**
  60069. * Draws a full screen quad.
  60070. */
  60071. draw(): void;
  60072. private isRenderTargetTexture;
  60073. /**
  60074. * renders one or more effects to a specified texture
  60075. * @param effectWrapper the effect to renderer
  60076. * @param outputTexture texture to draw to, if null it will render to the screen.
  60077. */
  60078. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60079. /**
  60080. * Disposes of the effect renderer
  60081. */
  60082. dispose(): void;
  60083. }
  60084. /**
  60085. * Options to create an EffectWrapper
  60086. */
  60087. interface EffectWrapperCreationOptions {
  60088. /**
  60089. * Engine to use to create the effect
  60090. */
  60091. engine: ThinEngine;
  60092. /**
  60093. * Fragment shader for the effect
  60094. */
  60095. fragmentShader: string;
  60096. /**
  60097. * Use the shader store instead of direct source code
  60098. */
  60099. useShaderStore?: boolean;
  60100. /**
  60101. * Vertex shader for the effect
  60102. */
  60103. vertexShader?: string;
  60104. /**
  60105. * Attributes to use in the shader
  60106. */
  60107. attributeNames?: Array<string>;
  60108. /**
  60109. * Uniforms to use in the shader
  60110. */
  60111. uniformNames?: Array<string>;
  60112. /**
  60113. * Texture sampler names to use in the shader
  60114. */
  60115. samplerNames?: Array<string>;
  60116. /**
  60117. * Defines to use in the shader
  60118. */
  60119. defines?: Array<string>;
  60120. /**
  60121. * Callback when effect is compiled
  60122. */
  60123. onCompiled?: Nullable<(effect: Effect) => void>;
  60124. /**
  60125. * The friendly name of the effect displayed in Spector.
  60126. */
  60127. name?: string;
  60128. }
  60129. /**
  60130. * Wraps an effect to be used for rendering
  60131. */
  60132. export class EffectWrapper {
  60133. /**
  60134. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60135. */
  60136. onApplyObservable: Observable<{}>;
  60137. /**
  60138. * The underlying effect
  60139. */
  60140. effect: Effect;
  60141. /**
  60142. * Creates an effect to be renderer
  60143. * @param creationOptions options to create the effect
  60144. */
  60145. constructor(creationOptions: EffectWrapperCreationOptions);
  60146. /**
  60147. * Disposes of the effect wrapper
  60148. */
  60149. dispose(): void;
  60150. }
  60151. }
  60152. declare module BABYLON {
  60153. /** @hidden */
  60154. export var hdrFilteringVertexShader: {
  60155. name: string;
  60156. shader: string;
  60157. };
  60158. }
  60159. declare module BABYLON {
  60160. /** @hidden */
  60161. export var hdrFilteringPixelShader: {
  60162. name: string;
  60163. shader: string;
  60164. };
  60165. }
  60166. declare module BABYLON {
  60167. /**
  60168. * Options for texture filtering
  60169. */
  60170. interface IHDRFilteringOptions {
  60171. /**
  60172. * Scales pixel intensity for the input HDR map.
  60173. */
  60174. hdrScale?: number;
  60175. /**
  60176. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60177. */
  60178. quality?: number;
  60179. }
  60180. /**
  60181. * Filters HDR maps to get correct renderings of PBR reflections
  60182. */
  60183. export class HDRFiltering {
  60184. private _engine;
  60185. private _effectRenderer;
  60186. private _effectWrapper;
  60187. private _lodGenerationOffset;
  60188. private _lodGenerationScale;
  60189. /**
  60190. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60191. * you care about baking speed.
  60192. */
  60193. quality: number;
  60194. /**
  60195. * Scales pixel intensity for the input HDR map.
  60196. */
  60197. hdrScale: number;
  60198. /**
  60199. * Instantiates HDR filter for reflection maps
  60200. *
  60201. * @param engine Thin engine
  60202. * @param options Options
  60203. */
  60204. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60205. private _createRenderTarget;
  60206. private _prefilterInternal;
  60207. private _createEffect;
  60208. /**
  60209. * Get a value indicating if the filter is ready to be used
  60210. * @param texture Texture to filter
  60211. * @returns true if the filter is ready
  60212. */
  60213. isReady(texture: BaseTexture): boolean;
  60214. /**
  60215. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60216. * Prefiltering will be invoked at the end of next rendering pass.
  60217. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60218. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60219. * @param texture Texture to filter
  60220. * @param onFinished Callback when filtering is done
  60221. * @return Promise called when prefiltering is done
  60222. */
  60223. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60224. }
  60225. }
  60226. declare module BABYLON {
  60227. /**
  60228. * This represents a texture coming from an HDR input.
  60229. *
  60230. * The only supported format is currently panorama picture stored in RGBE format.
  60231. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60232. */
  60233. export class HDRCubeTexture extends BaseTexture {
  60234. private static _facesMapping;
  60235. private _generateHarmonics;
  60236. private _noMipmap;
  60237. private _prefilterOnLoad;
  60238. private _textureMatrix;
  60239. private _size;
  60240. private _onLoad;
  60241. private _onError;
  60242. /**
  60243. * The texture URL.
  60244. */
  60245. url: string;
  60246. protected _isBlocking: boolean;
  60247. /**
  60248. * Sets wether or not the texture is blocking during loading.
  60249. */
  60250. set isBlocking(value: boolean);
  60251. /**
  60252. * Gets wether or not the texture is blocking during loading.
  60253. */
  60254. get isBlocking(): boolean;
  60255. protected _rotationY: number;
  60256. /**
  60257. * Sets texture matrix rotation angle around Y axis in radians.
  60258. */
  60259. set rotationY(value: number);
  60260. /**
  60261. * Gets texture matrix rotation angle around Y axis radians.
  60262. */
  60263. get rotationY(): number;
  60264. /**
  60265. * Gets or sets the center of the bounding box associated with the cube texture
  60266. * It must define where the camera used to render the texture was set
  60267. */
  60268. boundingBoxPosition: Vector3;
  60269. private _boundingBoxSize;
  60270. /**
  60271. * Gets or sets the size of the bounding box associated with the cube texture
  60272. * When defined, the cubemap will switch to local mode
  60273. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60274. * @example https://www.babylonjs-playground.com/#RNASML
  60275. */
  60276. set boundingBoxSize(value: Vector3);
  60277. get boundingBoxSize(): Vector3;
  60278. /**
  60279. * Instantiates an HDRTexture from the following parameters.
  60280. *
  60281. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60282. * @param sceneOrEngine The scene or engine the texture will be used in
  60283. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60284. * @param noMipmap Forces to not generate the mipmap if true
  60285. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60286. * @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)
  60287. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60288. */
  60289. 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>);
  60290. /**
  60291. * Get the current class name of the texture useful for serialization or dynamic coding.
  60292. * @returns "HDRCubeTexture"
  60293. */
  60294. getClassName(): string;
  60295. /**
  60296. * Occurs when the file is raw .hdr file.
  60297. */
  60298. private loadTexture;
  60299. clone(): HDRCubeTexture;
  60300. delayLoad(): void;
  60301. /**
  60302. * Get the texture reflection matrix used to rotate/transform the reflection.
  60303. * @returns the reflection matrix
  60304. */
  60305. getReflectionTextureMatrix(): Matrix;
  60306. /**
  60307. * Set the texture reflection matrix used to rotate/transform the reflection.
  60308. * @param value Define the reflection matrix to set
  60309. */
  60310. setReflectionTextureMatrix(value: Matrix): void;
  60311. /**
  60312. * Parses a JSON representation of an HDR Texture in order to create the texture
  60313. * @param parsedTexture Define the JSON representation
  60314. * @param scene Define the scene the texture should be created in
  60315. * @param rootUrl Define the root url in case we need to load relative dependencies
  60316. * @returns the newly created texture after parsing
  60317. */
  60318. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60319. serialize(): any;
  60320. }
  60321. }
  60322. declare module BABYLON {
  60323. /**
  60324. * Class used to control physics engine
  60325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60326. */
  60327. export class PhysicsEngine implements IPhysicsEngine {
  60328. private _physicsPlugin;
  60329. /**
  60330. * Global value used to control the smallest number supported by the simulation
  60331. */
  60332. static Epsilon: number;
  60333. private _impostors;
  60334. private _joints;
  60335. private _subTimeStep;
  60336. /**
  60337. * Gets the gravity vector used by the simulation
  60338. */
  60339. gravity: Vector3;
  60340. /**
  60341. * Factory used to create the default physics plugin.
  60342. * @returns The default physics plugin
  60343. */
  60344. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60345. /**
  60346. * Creates a new Physics Engine
  60347. * @param gravity defines the gravity vector used by the simulation
  60348. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60349. */
  60350. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60351. /**
  60352. * Sets the gravity vector used by the simulation
  60353. * @param gravity defines the gravity vector to use
  60354. */
  60355. setGravity(gravity: Vector3): void;
  60356. /**
  60357. * Set the time step of the physics engine.
  60358. * Default is 1/60.
  60359. * To slow it down, enter 1/600 for example.
  60360. * To speed it up, 1/30
  60361. * @param newTimeStep defines the new timestep to apply to this world.
  60362. */
  60363. setTimeStep(newTimeStep?: number): void;
  60364. /**
  60365. * Get the time step of the physics engine.
  60366. * @returns the current time step
  60367. */
  60368. getTimeStep(): number;
  60369. /**
  60370. * Set the sub time step of the physics engine.
  60371. * Default is 0 meaning there is no sub steps
  60372. * To increase physics resolution precision, set a small value (like 1 ms)
  60373. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60374. */
  60375. setSubTimeStep(subTimeStep?: number): void;
  60376. /**
  60377. * Get the sub time step of the physics engine.
  60378. * @returns the current sub time step
  60379. */
  60380. getSubTimeStep(): number;
  60381. /**
  60382. * Release all resources
  60383. */
  60384. dispose(): void;
  60385. /**
  60386. * Gets the name of the current physics plugin
  60387. * @returns the name of the plugin
  60388. */
  60389. getPhysicsPluginName(): string;
  60390. /**
  60391. * Adding a new impostor for the impostor tracking.
  60392. * This will be done by the impostor itself.
  60393. * @param impostor the impostor to add
  60394. */
  60395. addImpostor(impostor: PhysicsImpostor): void;
  60396. /**
  60397. * Remove an impostor from the engine.
  60398. * This impostor and its mesh will not longer be updated by the physics engine.
  60399. * @param impostor the impostor to remove
  60400. */
  60401. removeImpostor(impostor: PhysicsImpostor): void;
  60402. /**
  60403. * Add a joint to the physics engine
  60404. * @param mainImpostor defines the main impostor to which the joint is added.
  60405. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60406. * @param joint defines the joint that will connect both impostors.
  60407. */
  60408. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60409. /**
  60410. * Removes a joint from the simulation
  60411. * @param mainImpostor defines the impostor used with the joint
  60412. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60413. * @param joint defines the joint to remove
  60414. */
  60415. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60416. /**
  60417. * Called by the scene. No need to call it.
  60418. * @param delta defines the timespam between frames
  60419. */
  60420. _step(delta: number): void;
  60421. /**
  60422. * Gets the current plugin used to run the simulation
  60423. * @returns current plugin
  60424. */
  60425. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60426. /**
  60427. * Gets the list of physic impostors
  60428. * @returns an array of PhysicsImpostor
  60429. */
  60430. getImpostors(): Array<PhysicsImpostor>;
  60431. /**
  60432. * Gets the impostor for a physics enabled object
  60433. * @param object defines the object impersonated by the impostor
  60434. * @returns the PhysicsImpostor or null if not found
  60435. */
  60436. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60437. /**
  60438. * Gets the impostor for a physics body object
  60439. * @param body defines physics body used by the impostor
  60440. * @returns the PhysicsImpostor or null if not found
  60441. */
  60442. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60443. /**
  60444. * Does a raycast in the physics world
  60445. * @param from when should the ray start?
  60446. * @param to when should the ray end?
  60447. * @returns PhysicsRaycastResult
  60448. */
  60449. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60450. }
  60451. }
  60452. declare module BABYLON {
  60453. /** @hidden */
  60454. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60455. private _useDeltaForWorldStep;
  60456. world: any;
  60457. name: string;
  60458. private _physicsMaterials;
  60459. private _fixedTimeStep;
  60460. private _cannonRaycastResult;
  60461. private _raycastResult;
  60462. private _physicsBodysToRemoveAfterStep;
  60463. private _firstFrame;
  60464. BJSCANNON: any;
  60465. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60466. setGravity(gravity: Vector3): void;
  60467. setTimeStep(timeStep: number): void;
  60468. getTimeStep(): number;
  60469. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60470. private _removeMarkedPhysicsBodiesFromWorld;
  60471. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60472. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60473. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60474. private _processChildMeshes;
  60475. removePhysicsBody(impostor: PhysicsImpostor): void;
  60476. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60477. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60478. private _addMaterial;
  60479. private _checkWithEpsilon;
  60480. private _createShape;
  60481. private _createHeightmap;
  60482. private _minus90X;
  60483. private _plus90X;
  60484. private _tmpPosition;
  60485. private _tmpDeltaPosition;
  60486. private _tmpUnityRotation;
  60487. private _updatePhysicsBodyTransformation;
  60488. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60489. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60490. isSupported(): boolean;
  60491. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60492. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60493. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60494. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60495. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60496. getBodyMass(impostor: PhysicsImpostor): number;
  60497. getBodyFriction(impostor: PhysicsImpostor): number;
  60498. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60499. getBodyRestitution(impostor: PhysicsImpostor): number;
  60500. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60501. sleepBody(impostor: PhysicsImpostor): void;
  60502. wakeUpBody(impostor: PhysicsImpostor): void;
  60503. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60504. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60505. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60506. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60507. getRadius(impostor: PhysicsImpostor): number;
  60508. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60509. dispose(): void;
  60510. private _extendNamespace;
  60511. /**
  60512. * Does a raycast in the physics world
  60513. * @param from when should the ray start?
  60514. * @param to when should the ray end?
  60515. * @returns PhysicsRaycastResult
  60516. */
  60517. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60518. }
  60519. }
  60520. declare module BABYLON {
  60521. /** @hidden */
  60522. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60523. private _useDeltaForWorldStep;
  60524. world: any;
  60525. name: string;
  60526. BJSOIMO: any;
  60527. private _raycastResult;
  60528. private _fixedTimeStep;
  60529. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60530. setGravity(gravity: Vector3): void;
  60531. setTimeStep(timeStep: number): void;
  60532. getTimeStep(): number;
  60533. private _tmpImpostorsArray;
  60534. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60535. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60536. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60537. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60538. private _tmpPositionVector;
  60539. removePhysicsBody(impostor: PhysicsImpostor): void;
  60540. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60541. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60542. isSupported(): boolean;
  60543. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60544. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60545. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60546. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60547. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60548. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60549. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60550. getBodyMass(impostor: PhysicsImpostor): number;
  60551. getBodyFriction(impostor: PhysicsImpostor): number;
  60552. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60553. getBodyRestitution(impostor: PhysicsImpostor): number;
  60554. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60555. sleepBody(impostor: PhysicsImpostor): void;
  60556. wakeUpBody(impostor: PhysicsImpostor): void;
  60557. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60558. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60559. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60560. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60561. getRadius(impostor: PhysicsImpostor): number;
  60562. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60563. dispose(): void;
  60564. /**
  60565. * Does a raycast in the physics world
  60566. * @param from when should the ray start?
  60567. * @param to when should the ray end?
  60568. * @returns PhysicsRaycastResult
  60569. */
  60570. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60571. }
  60572. }
  60573. declare module BABYLON {
  60574. /**
  60575. * AmmoJS Physics plugin
  60576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60577. * @see https://github.com/kripken/ammo.js/
  60578. */
  60579. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60580. private _useDeltaForWorldStep;
  60581. /**
  60582. * Reference to the Ammo library
  60583. */
  60584. bjsAMMO: any;
  60585. /**
  60586. * Created ammoJS world which physics bodies are added to
  60587. */
  60588. world: any;
  60589. /**
  60590. * Name of the plugin
  60591. */
  60592. name: string;
  60593. private _timeStep;
  60594. private _fixedTimeStep;
  60595. private _maxSteps;
  60596. private _tmpQuaternion;
  60597. private _tmpAmmoTransform;
  60598. private _tmpAmmoQuaternion;
  60599. private _tmpAmmoConcreteContactResultCallback;
  60600. private _collisionConfiguration;
  60601. private _dispatcher;
  60602. private _overlappingPairCache;
  60603. private _solver;
  60604. private _softBodySolver;
  60605. private _tmpAmmoVectorA;
  60606. private _tmpAmmoVectorB;
  60607. private _tmpAmmoVectorC;
  60608. private _tmpAmmoVectorD;
  60609. private _tmpContactCallbackResult;
  60610. private _tmpAmmoVectorRCA;
  60611. private _tmpAmmoVectorRCB;
  60612. private _raycastResult;
  60613. private static readonly DISABLE_COLLISION_FLAG;
  60614. private static readonly KINEMATIC_FLAG;
  60615. private static readonly DISABLE_DEACTIVATION_FLAG;
  60616. /**
  60617. * Initializes the ammoJS plugin
  60618. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60619. * @param ammoInjection can be used to inject your own ammo reference
  60620. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60621. */
  60622. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60623. /**
  60624. * Sets the gravity of the physics world (m/(s^2))
  60625. * @param gravity Gravity to set
  60626. */
  60627. setGravity(gravity: Vector3): void;
  60628. /**
  60629. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60630. * @param timeStep timestep to use in seconds
  60631. */
  60632. setTimeStep(timeStep: number): void;
  60633. /**
  60634. * 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)
  60635. * @param fixedTimeStep fixedTimeStep to use in seconds
  60636. */
  60637. setFixedTimeStep(fixedTimeStep: number): void;
  60638. /**
  60639. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60640. * @param maxSteps the maximum number of steps by the physics engine per frame
  60641. */
  60642. setMaxSteps(maxSteps: number): void;
  60643. /**
  60644. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60645. * @returns the current timestep in seconds
  60646. */
  60647. getTimeStep(): number;
  60648. /**
  60649. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60650. */
  60651. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60652. private _isImpostorInContact;
  60653. private _isImpostorPairInContact;
  60654. private _stepSimulation;
  60655. /**
  60656. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60657. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60658. * After the step the babylon meshes are set to the position of the physics imposters
  60659. * @param delta amount of time to step forward
  60660. * @param impostors array of imposters to update before/after the step
  60661. */
  60662. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60663. /**
  60664. * Update babylon mesh to match physics world object
  60665. * @param impostor imposter to match
  60666. */
  60667. private _afterSoftStep;
  60668. /**
  60669. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60670. * @param impostor imposter to match
  60671. */
  60672. private _ropeStep;
  60673. /**
  60674. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60675. * @param impostor imposter to match
  60676. */
  60677. private _softbodyOrClothStep;
  60678. private _tmpMatrix;
  60679. /**
  60680. * Applies an impulse on the imposter
  60681. * @param impostor imposter to apply impulse to
  60682. * @param force amount of force to be applied to the imposter
  60683. * @param contactPoint the location to apply the impulse on the imposter
  60684. */
  60685. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60686. /**
  60687. * Applies a force on the imposter
  60688. * @param impostor imposter to apply force
  60689. * @param force amount of force to be applied to the imposter
  60690. * @param contactPoint the location to apply the force on the imposter
  60691. */
  60692. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60693. /**
  60694. * Creates a physics body using the plugin
  60695. * @param impostor the imposter to create the physics body on
  60696. */
  60697. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60698. /**
  60699. * Removes the physics body from the imposter and disposes of the body's memory
  60700. * @param impostor imposter to remove the physics body from
  60701. */
  60702. removePhysicsBody(impostor: PhysicsImpostor): void;
  60703. /**
  60704. * Generates a joint
  60705. * @param impostorJoint the imposter joint to create the joint with
  60706. */
  60707. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60708. /**
  60709. * Removes a joint
  60710. * @param impostorJoint the imposter joint to remove the joint from
  60711. */
  60712. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60713. private _addMeshVerts;
  60714. /**
  60715. * Initialise the soft body vertices to match its object's (mesh) vertices
  60716. * Softbody vertices (nodes) are in world space and to match this
  60717. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60718. * @param impostor to create the softbody for
  60719. */
  60720. private _softVertexData;
  60721. /**
  60722. * Create an impostor's soft body
  60723. * @param impostor to create the softbody for
  60724. */
  60725. private _createSoftbody;
  60726. /**
  60727. * Create cloth for an impostor
  60728. * @param impostor to create the softbody for
  60729. */
  60730. private _createCloth;
  60731. /**
  60732. * Create rope for an impostor
  60733. * @param impostor to create the softbody for
  60734. */
  60735. private _createRope;
  60736. /**
  60737. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60738. * @param impostor to create the custom physics shape for
  60739. */
  60740. private _createCustom;
  60741. private _addHullVerts;
  60742. private _createShape;
  60743. /**
  60744. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60745. * @param impostor imposter containing the physics body and babylon object
  60746. */
  60747. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60748. /**
  60749. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60750. * @param impostor imposter containing the physics body and babylon object
  60751. * @param newPosition new position
  60752. * @param newRotation new rotation
  60753. */
  60754. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60755. /**
  60756. * If this plugin is supported
  60757. * @returns true if its supported
  60758. */
  60759. isSupported(): boolean;
  60760. /**
  60761. * Sets the linear velocity of the physics body
  60762. * @param impostor imposter to set the velocity on
  60763. * @param velocity velocity to set
  60764. */
  60765. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60766. /**
  60767. * Sets the angular velocity of the physics body
  60768. * @param impostor imposter to set the velocity on
  60769. * @param velocity velocity to set
  60770. */
  60771. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60772. /**
  60773. * gets the linear velocity
  60774. * @param impostor imposter to get linear velocity from
  60775. * @returns linear velocity
  60776. */
  60777. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60778. /**
  60779. * gets the angular velocity
  60780. * @param impostor imposter to get angular velocity from
  60781. * @returns angular velocity
  60782. */
  60783. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60784. /**
  60785. * Sets the mass of physics body
  60786. * @param impostor imposter to set the mass on
  60787. * @param mass mass to set
  60788. */
  60789. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60790. /**
  60791. * Gets the mass of the physics body
  60792. * @param impostor imposter to get the mass from
  60793. * @returns mass
  60794. */
  60795. getBodyMass(impostor: PhysicsImpostor): number;
  60796. /**
  60797. * Gets friction of the impostor
  60798. * @param impostor impostor to get friction from
  60799. * @returns friction value
  60800. */
  60801. getBodyFriction(impostor: PhysicsImpostor): number;
  60802. /**
  60803. * Sets friction of the impostor
  60804. * @param impostor impostor to set friction on
  60805. * @param friction friction value
  60806. */
  60807. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60808. /**
  60809. * Gets restitution of the impostor
  60810. * @param impostor impostor to get restitution from
  60811. * @returns restitution value
  60812. */
  60813. getBodyRestitution(impostor: PhysicsImpostor): number;
  60814. /**
  60815. * Sets resitution of the impostor
  60816. * @param impostor impostor to set resitution on
  60817. * @param restitution resitution value
  60818. */
  60819. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60820. /**
  60821. * Gets pressure inside the impostor
  60822. * @param impostor impostor to get pressure from
  60823. * @returns pressure value
  60824. */
  60825. getBodyPressure(impostor: PhysicsImpostor): number;
  60826. /**
  60827. * Sets pressure inside a soft body impostor
  60828. * Cloth and rope must remain 0 pressure
  60829. * @param impostor impostor to set pressure on
  60830. * @param pressure pressure value
  60831. */
  60832. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60833. /**
  60834. * Gets stiffness of the impostor
  60835. * @param impostor impostor to get stiffness from
  60836. * @returns pressure value
  60837. */
  60838. getBodyStiffness(impostor: PhysicsImpostor): number;
  60839. /**
  60840. * Sets stiffness of the impostor
  60841. * @param impostor impostor to set stiffness on
  60842. * @param stiffness stiffness value from 0 to 1
  60843. */
  60844. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60845. /**
  60846. * Gets velocityIterations of the impostor
  60847. * @param impostor impostor to get velocity iterations from
  60848. * @returns velocityIterations value
  60849. */
  60850. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60851. /**
  60852. * Sets velocityIterations of the impostor
  60853. * @param impostor impostor to set velocity iterations on
  60854. * @param velocityIterations velocityIterations value
  60855. */
  60856. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60857. /**
  60858. * Gets positionIterations of the impostor
  60859. * @param impostor impostor to get position iterations from
  60860. * @returns positionIterations value
  60861. */
  60862. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60863. /**
  60864. * Sets positionIterations of the impostor
  60865. * @param impostor impostor to set position on
  60866. * @param positionIterations positionIterations value
  60867. */
  60868. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60869. /**
  60870. * Append an anchor to a cloth object
  60871. * @param impostor is the cloth impostor to add anchor to
  60872. * @param otherImpostor is the rigid impostor to anchor to
  60873. * @param width ratio across width from 0 to 1
  60874. * @param height ratio up height from 0 to 1
  60875. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60876. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60877. */
  60878. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60879. /**
  60880. * Append an hook to a rope object
  60881. * @param impostor is the rope impostor to add hook to
  60882. * @param otherImpostor is the rigid impostor to hook to
  60883. * @param length ratio along the rope from 0 to 1
  60884. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60885. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60886. */
  60887. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60888. /**
  60889. * Sleeps the physics body and stops it from being active
  60890. * @param impostor impostor to sleep
  60891. */
  60892. sleepBody(impostor: PhysicsImpostor): void;
  60893. /**
  60894. * Activates the physics body
  60895. * @param impostor impostor to activate
  60896. */
  60897. wakeUpBody(impostor: PhysicsImpostor): void;
  60898. /**
  60899. * Updates the distance parameters of the joint
  60900. * @param joint joint to update
  60901. * @param maxDistance maximum distance of the joint
  60902. * @param minDistance minimum distance of the joint
  60903. */
  60904. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60905. /**
  60906. * Sets a motor on the joint
  60907. * @param joint joint to set motor on
  60908. * @param speed speed of the motor
  60909. * @param maxForce maximum force of the motor
  60910. * @param motorIndex index of the motor
  60911. */
  60912. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60913. /**
  60914. * Sets the motors limit
  60915. * @param joint joint to set limit on
  60916. * @param upperLimit upper limit
  60917. * @param lowerLimit lower limit
  60918. */
  60919. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60920. /**
  60921. * Syncs the position and rotation of a mesh with the impostor
  60922. * @param mesh mesh to sync
  60923. * @param impostor impostor to update the mesh with
  60924. */
  60925. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60926. /**
  60927. * Gets the radius of the impostor
  60928. * @param impostor impostor to get radius from
  60929. * @returns the radius
  60930. */
  60931. getRadius(impostor: PhysicsImpostor): number;
  60932. /**
  60933. * Gets the box size of the impostor
  60934. * @param impostor impostor to get box size from
  60935. * @param result the resulting box size
  60936. */
  60937. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60938. /**
  60939. * Disposes of the impostor
  60940. */
  60941. dispose(): void;
  60942. /**
  60943. * Does a raycast in the physics world
  60944. * @param from when should the ray start?
  60945. * @param to when should the ray end?
  60946. * @returns PhysicsRaycastResult
  60947. */
  60948. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60949. }
  60950. }
  60951. declare module BABYLON {
  60952. interface AbstractScene {
  60953. /**
  60954. * The list of reflection probes added to the scene
  60955. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60956. */
  60957. reflectionProbes: Array<ReflectionProbe>;
  60958. /**
  60959. * Removes the given reflection probe from this scene.
  60960. * @param toRemove The reflection probe to remove
  60961. * @returns The index of the removed reflection probe
  60962. */
  60963. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60964. /**
  60965. * Adds the given reflection probe to this scene.
  60966. * @param newReflectionProbe The reflection probe to add
  60967. */
  60968. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60969. }
  60970. /**
  60971. * Class used to generate realtime reflection / refraction cube textures
  60972. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60973. */
  60974. export class ReflectionProbe {
  60975. /** defines the name of the probe */
  60976. name: string;
  60977. private _scene;
  60978. private _renderTargetTexture;
  60979. private _projectionMatrix;
  60980. private _viewMatrix;
  60981. private _target;
  60982. private _add;
  60983. private _attachedMesh;
  60984. private _invertYAxis;
  60985. /** Gets or sets probe position (center of the cube map) */
  60986. position: Vector3;
  60987. /**
  60988. * Creates a new reflection probe
  60989. * @param name defines the name of the probe
  60990. * @param size defines the texture resolution (for each face)
  60991. * @param scene defines the hosting scene
  60992. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60993. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60994. */
  60995. constructor(
  60996. /** defines the name of the probe */
  60997. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60998. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60999. get samples(): number;
  61000. set samples(value: number);
  61001. /** Gets or sets the refresh rate to use (on every frame by default) */
  61002. get refreshRate(): number;
  61003. set refreshRate(value: number);
  61004. /**
  61005. * Gets the hosting scene
  61006. * @returns a Scene
  61007. */
  61008. getScene(): Scene;
  61009. /** Gets the internal CubeTexture used to render to */
  61010. get cubeTexture(): RenderTargetTexture;
  61011. /** Gets the list of meshes to render */
  61012. get renderList(): Nullable<AbstractMesh[]>;
  61013. /**
  61014. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61015. * @param mesh defines the mesh to attach to
  61016. */
  61017. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61018. /**
  61019. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61020. * @param renderingGroupId The rendering group id corresponding to its index
  61021. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61022. */
  61023. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61024. /**
  61025. * Clean all associated resources
  61026. */
  61027. dispose(): void;
  61028. /**
  61029. * Converts the reflection probe information to a readable string for debug purpose.
  61030. * @param fullDetails Supports for multiple levels of logging within scene loading
  61031. * @returns the human readable reflection probe info
  61032. */
  61033. toString(fullDetails?: boolean): string;
  61034. /**
  61035. * Get the class name of the relfection probe.
  61036. * @returns "ReflectionProbe"
  61037. */
  61038. getClassName(): string;
  61039. /**
  61040. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61041. * @returns The JSON representation of the texture
  61042. */
  61043. serialize(): any;
  61044. /**
  61045. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61046. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61047. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61048. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61049. * @returns The parsed reflection probe if successful
  61050. */
  61051. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61052. }
  61053. }
  61054. declare module BABYLON {
  61055. /** @hidden */
  61056. export var _BabylonLoaderRegistered: boolean;
  61057. /**
  61058. * Helps setting up some configuration for the babylon file loader.
  61059. */
  61060. export class BabylonFileLoaderConfiguration {
  61061. /**
  61062. * The loader does not allow injecting custom physix engine into the plugins.
  61063. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61064. * So you could set this variable to your engine import to make it work.
  61065. */
  61066. static LoaderInjectedPhysicsEngine: any;
  61067. }
  61068. }
  61069. declare module BABYLON {
  61070. /**
  61071. * The Physically based simple base material of BJS.
  61072. *
  61073. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61074. * It is used as the base class for both the specGloss and metalRough conventions.
  61075. */
  61076. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61077. /**
  61078. * Number of Simultaneous lights allowed on the material.
  61079. */
  61080. maxSimultaneousLights: number;
  61081. /**
  61082. * If sets to true, disables all the lights affecting the material.
  61083. */
  61084. disableLighting: boolean;
  61085. /**
  61086. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61087. */
  61088. environmentTexture: BaseTexture;
  61089. /**
  61090. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61091. */
  61092. invertNormalMapX: boolean;
  61093. /**
  61094. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61095. */
  61096. invertNormalMapY: boolean;
  61097. /**
  61098. * Normal map used in the model.
  61099. */
  61100. normalTexture: BaseTexture;
  61101. /**
  61102. * Emissivie color used to self-illuminate the model.
  61103. */
  61104. emissiveColor: Color3;
  61105. /**
  61106. * Emissivie texture used to self-illuminate the model.
  61107. */
  61108. emissiveTexture: BaseTexture;
  61109. /**
  61110. * Occlusion Channel Strenght.
  61111. */
  61112. occlusionStrength: number;
  61113. /**
  61114. * Occlusion Texture of the material (adding extra occlusion effects).
  61115. */
  61116. occlusionTexture: BaseTexture;
  61117. /**
  61118. * Defines the alpha limits in alpha test mode.
  61119. */
  61120. alphaCutOff: number;
  61121. /**
  61122. * Gets the current double sided mode.
  61123. */
  61124. get doubleSided(): boolean;
  61125. /**
  61126. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61127. */
  61128. set doubleSided(value: boolean);
  61129. /**
  61130. * Stores the pre-calculated light information of a mesh in a texture.
  61131. */
  61132. lightmapTexture: BaseTexture;
  61133. /**
  61134. * If true, the light map contains occlusion information instead of lighting info.
  61135. */
  61136. useLightmapAsShadowmap: boolean;
  61137. /**
  61138. * Instantiates a new PBRMaterial instance.
  61139. *
  61140. * @param name The material name
  61141. * @param scene The scene the material will be use in.
  61142. */
  61143. constructor(name: string, scene: Scene);
  61144. getClassName(): string;
  61145. }
  61146. }
  61147. declare module BABYLON {
  61148. /**
  61149. * The PBR material of BJS following the metal roughness convention.
  61150. *
  61151. * This fits to the PBR convention in the GLTF definition:
  61152. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61153. */
  61154. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61155. /**
  61156. * The base color has two different interpretations depending on the value of metalness.
  61157. * When the material is a metal, the base color is the specific measured reflectance value
  61158. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61159. * of the material.
  61160. */
  61161. baseColor: Color3;
  61162. /**
  61163. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61164. * well as opacity information in the alpha channel.
  61165. */
  61166. baseTexture: BaseTexture;
  61167. /**
  61168. * Specifies the metallic scalar value of the material.
  61169. * Can also be used to scale the metalness values of the metallic texture.
  61170. */
  61171. metallic: number;
  61172. /**
  61173. * Specifies the roughness scalar value of the material.
  61174. * Can also be used to scale the roughness values of the metallic texture.
  61175. */
  61176. roughness: number;
  61177. /**
  61178. * Texture containing both the metallic value in the B channel and the
  61179. * roughness value in the G channel to keep better precision.
  61180. */
  61181. metallicRoughnessTexture: BaseTexture;
  61182. /**
  61183. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61184. *
  61185. * @param name The material name
  61186. * @param scene The scene the material will be use in.
  61187. */
  61188. constructor(name: string, scene: Scene);
  61189. /**
  61190. * Return the currrent class name of the material.
  61191. */
  61192. getClassName(): string;
  61193. /**
  61194. * Makes a duplicate of the current material.
  61195. * @param name - name to use for the new material.
  61196. */
  61197. clone(name: string): PBRMetallicRoughnessMaterial;
  61198. /**
  61199. * Serialize the material to a parsable JSON object.
  61200. */
  61201. serialize(): any;
  61202. /**
  61203. * Parses a JSON object correponding to the serialize function.
  61204. */
  61205. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61206. }
  61207. }
  61208. declare module BABYLON {
  61209. /**
  61210. * The PBR material of BJS following the specular glossiness convention.
  61211. *
  61212. * This fits to the PBR convention in the GLTF definition:
  61213. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61214. */
  61215. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61216. /**
  61217. * Specifies the diffuse color of the material.
  61218. */
  61219. diffuseColor: Color3;
  61220. /**
  61221. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61222. * channel.
  61223. */
  61224. diffuseTexture: BaseTexture;
  61225. /**
  61226. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61227. */
  61228. specularColor: Color3;
  61229. /**
  61230. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61231. */
  61232. glossiness: number;
  61233. /**
  61234. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61235. */
  61236. specularGlossinessTexture: BaseTexture;
  61237. /**
  61238. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61239. *
  61240. * @param name The material name
  61241. * @param scene The scene the material will be use in.
  61242. */
  61243. constructor(name: string, scene: Scene);
  61244. /**
  61245. * Return the currrent class name of the material.
  61246. */
  61247. getClassName(): string;
  61248. /**
  61249. * Makes a duplicate of the current material.
  61250. * @param name - name to use for the new material.
  61251. */
  61252. clone(name: string): PBRSpecularGlossinessMaterial;
  61253. /**
  61254. * Serialize the material to a parsable JSON object.
  61255. */
  61256. serialize(): any;
  61257. /**
  61258. * Parses a JSON object correponding to the serialize function.
  61259. */
  61260. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61261. }
  61262. }
  61263. declare module BABYLON {
  61264. /**
  61265. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61266. * It can help converting any input color in a desired output one. This can then be used to create effects
  61267. * from sepia, black and white to sixties or futuristic rendering...
  61268. *
  61269. * The only supported format is currently 3dl.
  61270. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61271. */
  61272. export class ColorGradingTexture extends BaseTexture {
  61273. /**
  61274. * The texture URL.
  61275. */
  61276. url: string;
  61277. /**
  61278. * Empty line regex stored for GC.
  61279. */
  61280. private static _noneEmptyLineRegex;
  61281. private _textureMatrix;
  61282. private _onLoad;
  61283. /**
  61284. * Instantiates a ColorGradingTexture from the following parameters.
  61285. *
  61286. * @param url The location of the color gradind data (currently only supporting 3dl)
  61287. * @param sceneOrEngine The scene or engine the texture will be used in
  61288. * @param onLoad defines a callback triggered when the texture has been loaded
  61289. */
  61290. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61291. /**
  61292. * Fires the onload event from the constructor if requested.
  61293. */
  61294. private _triggerOnLoad;
  61295. /**
  61296. * Returns the texture matrix used in most of the material.
  61297. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61298. */
  61299. getTextureMatrix(): Matrix;
  61300. /**
  61301. * Occurs when the file being loaded is a .3dl LUT file.
  61302. */
  61303. private load3dlTexture;
  61304. /**
  61305. * Starts the loading process of the texture.
  61306. */
  61307. private loadTexture;
  61308. /**
  61309. * Clones the color gradind texture.
  61310. */
  61311. clone(): ColorGradingTexture;
  61312. /**
  61313. * Called during delayed load for textures.
  61314. */
  61315. delayLoad(): void;
  61316. /**
  61317. * Parses a color grading texture serialized by Babylon.
  61318. * @param parsedTexture The texture information being parsedTexture
  61319. * @param scene The scene to load the texture in
  61320. * @param rootUrl The root url of the data assets to load
  61321. * @return A color gradind texture
  61322. */
  61323. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61324. /**
  61325. * Serializes the LUT texture to json format.
  61326. */
  61327. serialize(): any;
  61328. }
  61329. }
  61330. declare module BABYLON {
  61331. /**
  61332. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61333. */
  61334. export class EquiRectangularCubeTexture extends BaseTexture {
  61335. /** The six faces of the cube. */
  61336. private static _FacesMapping;
  61337. private _noMipmap;
  61338. private _onLoad;
  61339. private _onError;
  61340. /** The size of the cubemap. */
  61341. private _size;
  61342. /** The buffer of the image. */
  61343. private _buffer;
  61344. /** The width of the input image. */
  61345. private _width;
  61346. /** The height of the input image. */
  61347. private _height;
  61348. /** The URL to the image. */
  61349. url: string;
  61350. /**
  61351. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61352. * @param url The location of the image
  61353. * @param scene The scene the texture will be used in
  61354. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61355. * @param noMipmap Forces to not generate the mipmap if true
  61356. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61357. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61358. * @param onLoad — defines a callback called when texture is loaded
  61359. * @param onError — defines a callback called if there is an error
  61360. */
  61361. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61362. /**
  61363. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61364. */
  61365. private loadImage;
  61366. /**
  61367. * Convert the image buffer into a cubemap and create a CubeTexture.
  61368. */
  61369. private loadTexture;
  61370. /**
  61371. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61372. * @param buffer The ArrayBuffer that should be converted.
  61373. * @returns The buffer as Float32Array.
  61374. */
  61375. private getFloat32ArrayFromArrayBuffer;
  61376. /**
  61377. * Get the current class name of the texture useful for serialization or dynamic coding.
  61378. * @returns "EquiRectangularCubeTexture"
  61379. */
  61380. getClassName(): string;
  61381. /**
  61382. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61383. * @returns A clone of the current EquiRectangularCubeTexture.
  61384. */
  61385. clone(): EquiRectangularCubeTexture;
  61386. }
  61387. }
  61388. declare module BABYLON {
  61389. /**
  61390. * Defines the options related to the creation of an HtmlElementTexture
  61391. */
  61392. export interface IHtmlElementTextureOptions {
  61393. /**
  61394. * Defines wether mip maps should be created or not.
  61395. */
  61396. generateMipMaps?: boolean;
  61397. /**
  61398. * Defines the sampling mode of the texture.
  61399. */
  61400. samplingMode?: number;
  61401. /**
  61402. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61403. */
  61404. engine: Nullable<ThinEngine>;
  61405. /**
  61406. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61407. */
  61408. scene: Nullable<Scene>;
  61409. }
  61410. /**
  61411. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61412. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61413. * is automatically managed.
  61414. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61415. * in your application.
  61416. *
  61417. * As the update is not automatic, you need to call them manually.
  61418. */
  61419. export class HtmlElementTexture extends BaseTexture {
  61420. /**
  61421. * The texture URL.
  61422. */
  61423. element: HTMLVideoElement | HTMLCanvasElement;
  61424. private static readonly DefaultOptions;
  61425. private _textureMatrix;
  61426. private _isVideo;
  61427. private _generateMipMaps;
  61428. private _samplingMode;
  61429. /**
  61430. * Instantiates a HtmlElementTexture from the following parameters.
  61431. *
  61432. * @param name Defines the name of the texture
  61433. * @param element Defines the video or canvas the texture is filled with
  61434. * @param options Defines the other none mandatory texture creation options
  61435. */
  61436. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61437. private _createInternalTexture;
  61438. /**
  61439. * Returns the texture matrix used in most of the material.
  61440. */
  61441. getTextureMatrix(): Matrix;
  61442. /**
  61443. * Updates the content of the texture.
  61444. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61445. */
  61446. update(invertY?: Nullable<boolean>): void;
  61447. }
  61448. }
  61449. declare module BABYLON {
  61450. /**
  61451. * Based on jsTGALoader - Javascript loader for TGA file
  61452. * By Vincent Thibault
  61453. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61454. */
  61455. export class TGATools {
  61456. private static _TYPE_INDEXED;
  61457. private static _TYPE_RGB;
  61458. private static _TYPE_GREY;
  61459. private static _TYPE_RLE_INDEXED;
  61460. private static _TYPE_RLE_RGB;
  61461. private static _TYPE_RLE_GREY;
  61462. private static _ORIGIN_MASK;
  61463. private static _ORIGIN_SHIFT;
  61464. private static _ORIGIN_BL;
  61465. private static _ORIGIN_BR;
  61466. private static _ORIGIN_UL;
  61467. private static _ORIGIN_UR;
  61468. /**
  61469. * Gets the header of a TGA file
  61470. * @param data defines the TGA data
  61471. * @returns the header
  61472. */
  61473. static GetTGAHeader(data: Uint8Array): any;
  61474. /**
  61475. * Uploads TGA content to a Babylon Texture
  61476. * @hidden
  61477. */
  61478. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61479. /** @hidden */
  61480. 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;
  61481. /** @hidden */
  61482. 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;
  61483. /** @hidden */
  61484. 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;
  61485. /** @hidden */
  61486. 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;
  61487. /** @hidden */
  61488. 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;
  61489. /** @hidden */
  61490. 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;
  61491. }
  61492. }
  61493. declare module BABYLON {
  61494. /**
  61495. * Implementation of the TGA Texture Loader.
  61496. * @hidden
  61497. */
  61498. export class _TGATextureLoader implements IInternalTextureLoader {
  61499. /**
  61500. * Defines wether the loader supports cascade loading the different faces.
  61501. */
  61502. readonly supportCascades: boolean;
  61503. /**
  61504. * This returns if the loader support the current file information.
  61505. * @param extension defines the file extension of the file being loaded
  61506. * @returns true if the loader can load the specified file
  61507. */
  61508. canLoad(extension: string): boolean;
  61509. /**
  61510. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61511. * @param data contains the texture data
  61512. * @param texture defines the BabylonJS internal texture
  61513. * @param createPolynomials will be true if polynomials have been requested
  61514. * @param onLoad defines the callback to trigger once the texture is ready
  61515. * @param onError defines the callback to trigger in case of error
  61516. */
  61517. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61518. /**
  61519. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61520. * @param data contains the texture data
  61521. * @param texture defines the BabylonJS internal texture
  61522. * @param callback defines the method to call once ready to upload
  61523. */
  61524. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61525. }
  61526. }
  61527. declare module BABYLON {
  61528. /**
  61529. * Info about the .basis files
  61530. */
  61531. class BasisFileInfo {
  61532. /**
  61533. * If the file has alpha
  61534. */
  61535. hasAlpha: boolean;
  61536. /**
  61537. * Info about each image of the basis file
  61538. */
  61539. images: Array<{
  61540. levels: Array<{
  61541. width: number;
  61542. height: number;
  61543. transcodedPixels: ArrayBufferView;
  61544. }>;
  61545. }>;
  61546. }
  61547. /**
  61548. * Result of transcoding a basis file
  61549. */
  61550. class TranscodeResult {
  61551. /**
  61552. * Info about the .basis file
  61553. */
  61554. fileInfo: BasisFileInfo;
  61555. /**
  61556. * Format to use when loading the file
  61557. */
  61558. format: number;
  61559. }
  61560. /**
  61561. * Configuration options for the Basis transcoder
  61562. */
  61563. export class BasisTranscodeConfiguration {
  61564. /**
  61565. * Supported compression formats used to determine the supported output format of the transcoder
  61566. */
  61567. supportedCompressionFormats?: {
  61568. /**
  61569. * etc1 compression format
  61570. */
  61571. etc1?: boolean;
  61572. /**
  61573. * s3tc compression format
  61574. */
  61575. s3tc?: boolean;
  61576. /**
  61577. * pvrtc compression format
  61578. */
  61579. pvrtc?: boolean;
  61580. /**
  61581. * etc2 compression format
  61582. */
  61583. etc2?: boolean;
  61584. };
  61585. /**
  61586. * If mipmap levels should be loaded for transcoded images (Default: true)
  61587. */
  61588. loadMipmapLevels?: boolean;
  61589. /**
  61590. * Index of a single image to load (Default: all images)
  61591. */
  61592. loadSingleImage?: number;
  61593. }
  61594. /**
  61595. * Used to load .Basis files
  61596. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61597. */
  61598. export class BasisTools {
  61599. private static _IgnoreSupportedFormats;
  61600. /**
  61601. * URL to use when loading the basis transcoder
  61602. */
  61603. static JSModuleURL: string;
  61604. /**
  61605. * URL to use when loading the wasm module for the transcoder
  61606. */
  61607. static WasmModuleURL: string;
  61608. /**
  61609. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61610. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61611. * @returns internal format corresponding to the Basis format
  61612. */
  61613. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61614. private static _WorkerPromise;
  61615. private static _Worker;
  61616. private static _actionId;
  61617. private static _CreateWorkerAsync;
  61618. /**
  61619. * Transcodes a loaded image file to compressed pixel data
  61620. * @param data image data to transcode
  61621. * @param config configuration options for the transcoding
  61622. * @returns a promise resulting in the transcoded image
  61623. */
  61624. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61625. /**
  61626. * Loads a texture from the transcode result
  61627. * @param texture texture load to
  61628. * @param transcodeResult the result of transcoding the basis file to load from
  61629. */
  61630. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61631. }
  61632. }
  61633. declare module BABYLON {
  61634. /**
  61635. * Loader for .basis file format
  61636. */
  61637. export class _BasisTextureLoader implements IInternalTextureLoader {
  61638. /**
  61639. * Defines whether the loader supports cascade loading the different faces.
  61640. */
  61641. readonly supportCascades: boolean;
  61642. /**
  61643. * This returns if the loader support the current file information.
  61644. * @param extension defines the file extension of the file being loaded
  61645. * @returns true if the loader can load the specified file
  61646. */
  61647. canLoad(extension: string): boolean;
  61648. /**
  61649. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61650. * @param data contains the texture data
  61651. * @param texture defines the BabylonJS internal texture
  61652. * @param createPolynomials will be true if polynomials have been requested
  61653. * @param onLoad defines the callback to trigger once the texture is ready
  61654. * @param onError defines the callback to trigger in case of error
  61655. */
  61656. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61657. /**
  61658. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61659. * @param data contains the texture data
  61660. * @param texture defines the BabylonJS internal texture
  61661. * @param callback defines the method to call once ready to upload
  61662. */
  61663. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61664. }
  61665. }
  61666. declare module BABYLON {
  61667. /**
  61668. * Defines the basic options interface of a TexturePacker Frame
  61669. */
  61670. export interface ITexturePackerFrame {
  61671. /**
  61672. * The frame ID
  61673. */
  61674. id: number;
  61675. /**
  61676. * The frames Scale
  61677. */
  61678. scale: Vector2;
  61679. /**
  61680. * The Frames offset
  61681. */
  61682. offset: Vector2;
  61683. }
  61684. /**
  61685. * This is a support class for frame Data on texture packer sets.
  61686. */
  61687. export class TexturePackerFrame implements ITexturePackerFrame {
  61688. /**
  61689. * The frame ID
  61690. */
  61691. id: number;
  61692. /**
  61693. * The frames Scale
  61694. */
  61695. scale: Vector2;
  61696. /**
  61697. * The Frames offset
  61698. */
  61699. offset: Vector2;
  61700. /**
  61701. * Initializes a texture package frame.
  61702. * @param id The numerical frame identifier
  61703. * @param scale Scalar Vector2 for UV frame
  61704. * @param offset Vector2 for the frame position in UV units.
  61705. * @returns TexturePackerFrame
  61706. */
  61707. constructor(id: number, scale: Vector2, offset: Vector2);
  61708. }
  61709. }
  61710. declare module BABYLON {
  61711. /**
  61712. * Defines the basic options interface of a TexturePacker
  61713. */
  61714. export interface ITexturePackerOptions {
  61715. /**
  61716. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61717. */
  61718. map?: string[];
  61719. /**
  61720. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61721. */
  61722. uvsIn?: string;
  61723. /**
  61724. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61725. */
  61726. uvsOut?: string;
  61727. /**
  61728. * number representing the layout style. Defaults to LAYOUT_STRIP
  61729. */
  61730. layout?: number;
  61731. /**
  61732. * number of columns if using custom column count layout(2). This defaults to 4.
  61733. */
  61734. colnum?: number;
  61735. /**
  61736. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61737. */
  61738. updateInputMeshes?: boolean;
  61739. /**
  61740. * boolean flag to dispose all the source textures. Defaults to true.
  61741. */
  61742. disposeSources?: boolean;
  61743. /**
  61744. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61745. */
  61746. fillBlanks?: boolean;
  61747. /**
  61748. * string value representing the context fill style color. Defaults to 'black'.
  61749. */
  61750. customFillColor?: string;
  61751. /**
  61752. * Width and Height Value of each Frame in the TexturePacker Sets
  61753. */
  61754. frameSize?: number;
  61755. /**
  61756. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61757. */
  61758. paddingRatio?: number;
  61759. /**
  61760. * Number that declares the fill method for the padding gutter.
  61761. */
  61762. paddingMode?: number;
  61763. /**
  61764. * If in SUBUV_COLOR padding mode what color to use.
  61765. */
  61766. paddingColor?: Color3 | Color4;
  61767. }
  61768. /**
  61769. * Defines the basic interface of a TexturePacker JSON File
  61770. */
  61771. export interface ITexturePackerJSON {
  61772. /**
  61773. * The frame ID
  61774. */
  61775. name: string;
  61776. /**
  61777. * The base64 channel data
  61778. */
  61779. sets: any;
  61780. /**
  61781. * The options of the Packer
  61782. */
  61783. options: ITexturePackerOptions;
  61784. /**
  61785. * The frame data of the Packer
  61786. */
  61787. frames: Array<number>;
  61788. }
  61789. /**
  61790. * This is a support class that generates a series of packed texture sets.
  61791. * @see https://doc.babylonjs.com/babylon101/materials
  61792. */
  61793. export class TexturePacker {
  61794. /** Packer Layout Constant 0 */
  61795. static readonly LAYOUT_STRIP: number;
  61796. /** Packer Layout Constant 1 */
  61797. static readonly LAYOUT_POWER2: number;
  61798. /** Packer Layout Constant 2 */
  61799. static readonly LAYOUT_COLNUM: number;
  61800. /** Packer Layout Constant 0 */
  61801. static readonly SUBUV_WRAP: number;
  61802. /** Packer Layout Constant 1 */
  61803. static readonly SUBUV_EXTEND: number;
  61804. /** Packer Layout Constant 2 */
  61805. static readonly SUBUV_COLOR: number;
  61806. /** The Name of the Texture Package */
  61807. name: string;
  61808. /** The scene scope of the TexturePacker */
  61809. scene: Scene;
  61810. /** The Meshes to target */
  61811. meshes: AbstractMesh[];
  61812. /** Arguments passed with the Constructor */
  61813. options: ITexturePackerOptions;
  61814. /** The promise that is started upon initialization */
  61815. promise: Nullable<Promise<TexturePacker | string>>;
  61816. /** The Container object for the channel sets that are generated */
  61817. sets: object;
  61818. /** The Container array for the frames that are generated */
  61819. frames: TexturePackerFrame[];
  61820. /** The expected number of textures the system is parsing. */
  61821. private _expecting;
  61822. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61823. private _paddingValue;
  61824. /**
  61825. * Initializes a texture package series from an array of meshes or a single mesh.
  61826. * @param name The name of the package
  61827. * @param meshes The target meshes to compose the package from
  61828. * @param options The arguments that texture packer should follow while building.
  61829. * @param scene The scene which the textures are scoped to.
  61830. * @returns TexturePacker
  61831. */
  61832. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61833. /**
  61834. * Starts the package process
  61835. * @param resolve The promises resolution function
  61836. * @returns TexturePacker
  61837. */
  61838. private _createFrames;
  61839. /**
  61840. * Calculates the Size of the Channel Sets
  61841. * @returns Vector2
  61842. */
  61843. private _calculateSize;
  61844. /**
  61845. * Calculates the UV data for the frames.
  61846. * @param baseSize the base frameSize
  61847. * @param padding the base frame padding
  61848. * @param dtSize size of the Dynamic Texture for that channel
  61849. * @param dtUnits is 1/dtSize
  61850. * @param update flag to update the input meshes
  61851. */
  61852. private _calculateMeshUVFrames;
  61853. /**
  61854. * Calculates the frames Offset.
  61855. * @param index of the frame
  61856. * @returns Vector2
  61857. */
  61858. private _getFrameOffset;
  61859. /**
  61860. * Updates a Mesh to the frame data
  61861. * @param mesh that is the target
  61862. * @param frameID or the frame index
  61863. */
  61864. private _updateMeshUV;
  61865. /**
  61866. * Updates a Meshes materials to use the texture packer channels
  61867. * @param m is the mesh to target
  61868. * @param force all channels on the packer to be set.
  61869. */
  61870. private _updateTextureReferences;
  61871. /**
  61872. * Public method to set a Mesh to a frame
  61873. * @param m that is the target
  61874. * @param frameID or the frame index
  61875. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61876. */
  61877. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61878. /**
  61879. * Starts the async promise to compile the texture packer.
  61880. * @returns Promise<void>
  61881. */
  61882. processAsync(): Promise<void>;
  61883. /**
  61884. * Disposes all textures associated with this packer
  61885. */
  61886. dispose(): void;
  61887. /**
  61888. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61889. * @param imageType is the image type to use.
  61890. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61891. */
  61892. download(imageType?: string, quality?: number): void;
  61893. /**
  61894. * Public method to load a texturePacker JSON file.
  61895. * @param data of the JSON file in string format.
  61896. */
  61897. updateFromJSON(data: string): void;
  61898. }
  61899. }
  61900. declare module BABYLON {
  61901. /**
  61902. * 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.
  61903. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61904. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61905. */
  61906. export class CustomProceduralTexture extends ProceduralTexture {
  61907. private _animate;
  61908. private _time;
  61909. private _config;
  61910. private _texturePath;
  61911. /**
  61912. * Instantiates a new Custom Procedural Texture.
  61913. * 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.
  61914. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61915. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61916. * @param name Define the name of the texture
  61917. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61918. * @param size Define the size of the texture to create
  61919. * @param scene Define the scene the texture belongs to
  61920. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61921. * @param generateMipMaps Define if the texture should creates mip maps or not
  61922. */
  61923. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61924. private _loadJson;
  61925. /**
  61926. * Is the texture ready to be used ? (rendered at least once)
  61927. * @returns true if ready, otherwise, false.
  61928. */
  61929. isReady(): boolean;
  61930. /**
  61931. * Render the texture to its associated render target.
  61932. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61933. */
  61934. render(useCameraPostProcess?: boolean): void;
  61935. /**
  61936. * Update the list of dependant textures samplers in the shader.
  61937. */
  61938. updateTextures(): void;
  61939. /**
  61940. * Update the uniform values of the procedural texture in the shader.
  61941. */
  61942. updateShaderUniforms(): void;
  61943. /**
  61944. * Define if the texture animates or not.
  61945. */
  61946. get animate(): boolean;
  61947. set animate(value: boolean);
  61948. }
  61949. }
  61950. declare module BABYLON {
  61951. /** @hidden */
  61952. export var noisePixelShader: {
  61953. name: string;
  61954. shader: string;
  61955. };
  61956. }
  61957. declare module BABYLON {
  61958. /**
  61959. * Class used to generate noise procedural textures
  61960. */
  61961. export class NoiseProceduralTexture extends ProceduralTexture {
  61962. private _time;
  61963. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61964. brightness: number;
  61965. /** Defines the number of octaves to process */
  61966. octaves: number;
  61967. /** Defines the level of persistence (0.8 by default) */
  61968. persistence: number;
  61969. /** Gets or sets animation speed factor (default is 1) */
  61970. animationSpeedFactor: number;
  61971. /**
  61972. * Creates a new NoiseProceduralTexture
  61973. * @param name defines the name fo the texture
  61974. * @param size defines the size of the texture (default is 256)
  61975. * @param scene defines the hosting scene
  61976. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61977. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61978. */
  61979. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61980. private _updateShaderUniforms;
  61981. protected _getDefines(): string;
  61982. /** Generate the current state of the procedural texture */
  61983. render(useCameraPostProcess?: boolean): void;
  61984. /**
  61985. * Serializes this noise procedural texture
  61986. * @returns a serialized noise procedural texture object
  61987. */
  61988. serialize(): any;
  61989. /**
  61990. * Clone the texture.
  61991. * @returns the cloned texture
  61992. */
  61993. clone(): NoiseProceduralTexture;
  61994. /**
  61995. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61996. * @param parsedTexture defines parsed texture data
  61997. * @param scene defines the current scene
  61998. * @param rootUrl defines the root URL containing noise procedural texture information
  61999. * @returns a parsed NoiseProceduralTexture
  62000. */
  62001. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62002. }
  62003. }
  62004. declare module BABYLON {
  62005. /**
  62006. * Raw cube texture where the raw buffers are passed in
  62007. */
  62008. export class RawCubeTexture extends CubeTexture {
  62009. /**
  62010. * Creates a cube texture where the raw buffers are passed in.
  62011. * @param scene defines the scene the texture is attached to
  62012. * @param data defines the array of data to use to create each face
  62013. * @param size defines the size of the textures
  62014. * @param format defines the format of the data
  62015. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62016. * @param generateMipMaps defines if the engine should generate the mip levels
  62017. * @param invertY defines if data must be stored with Y axis inverted
  62018. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62019. * @param compression defines the compression used (null by default)
  62020. */
  62021. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62022. /**
  62023. * Updates the raw cube texture.
  62024. * @param data defines the data to store
  62025. * @param format defines the data format
  62026. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62027. * @param invertY defines if data must be stored with Y axis inverted
  62028. * @param compression defines the compression used (null by default)
  62029. * @param level defines which level of the texture to update
  62030. */
  62031. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62032. /**
  62033. * Updates a raw cube texture with RGBD encoded data.
  62034. * @param data defines the array of data [mipmap][face] to use to create each face
  62035. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62036. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62037. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62038. * @returns a promsie that resolves when the operation is complete
  62039. */
  62040. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62041. /**
  62042. * Clones the raw cube texture.
  62043. * @return a new cube texture
  62044. */
  62045. clone(): CubeTexture;
  62046. /** @hidden */
  62047. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62048. }
  62049. }
  62050. declare module BABYLON {
  62051. /**
  62052. * Class used to store 2D array textures containing user data
  62053. */
  62054. export class RawTexture2DArray extends Texture {
  62055. /** Gets or sets the texture format to use */
  62056. format: number;
  62057. /**
  62058. * Create a new RawTexture2DArray
  62059. * @param data defines the data of the texture
  62060. * @param width defines the width of the texture
  62061. * @param height defines the height of the texture
  62062. * @param depth defines the number of layers of the texture
  62063. * @param format defines the texture format to use
  62064. * @param scene defines the hosting scene
  62065. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62066. * @param invertY defines if texture must be stored with Y axis inverted
  62067. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62068. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62069. */
  62070. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62071. /** Gets or sets the texture format to use */
  62072. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62073. /**
  62074. * Update the texture with new data
  62075. * @param data defines the data to store in the texture
  62076. */
  62077. update(data: ArrayBufferView): void;
  62078. }
  62079. }
  62080. declare module BABYLON {
  62081. /**
  62082. * Class used to store 3D textures containing user data
  62083. */
  62084. export class RawTexture3D extends Texture {
  62085. /** Gets or sets the texture format to use */
  62086. format: number;
  62087. /**
  62088. * Create a new RawTexture3D
  62089. * @param data defines the data of the texture
  62090. * @param width defines the width of the texture
  62091. * @param height defines the height of the texture
  62092. * @param depth defines the depth of the texture
  62093. * @param format defines the texture format to use
  62094. * @param scene defines the hosting scene
  62095. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62096. * @param invertY defines if texture must be stored with Y axis inverted
  62097. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62098. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62099. */
  62100. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62101. /** Gets or sets the texture format to use */
  62102. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62103. /**
  62104. * Update the texture with new data
  62105. * @param data defines the data to store in the texture
  62106. */
  62107. update(data: ArrayBufferView): void;
  62108. }
  62109. }
  62110. declare module BABYLON {
  62111. /**
  62112. * Creates a refraction texture used by refraction channel of the standard material.
  62113. * It is like a mirror but to see through a material.
  62114. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62115. */
  62116. export class RefractionTexture extends RenderTargetTexture {
  62117. /**
  62118. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62119. * 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.
  62120. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62121. */
  62122. refractionPlane: Plane;
  62123. /**
  62124. * Define how deep under the surface we should see.
  62125. */
  62126. depth: number;
  62127. /**
  62128. * Creates a refraction texture used by refraction channel of the standard material.
  62129. * It is like a mirror but to see through a material.
  62130. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62131. * @param name Define the texture name
  62132. * @param size Define the size of the underlying texture
  62133. * @param scene Define the scene the refraction belongs to
  62134. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62135. */
  62136. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62137. /**
  62138. * Clone the refraction texture.
  62139. * @returns the cloned texture
  62140. */
  62141. clone(): RefractionTexture;
  62142. /**
  62143. * Serialize the texture to a JSON representation you could use in Parse later on
  62144. * @returns the serialized JSON representation
  62145. */
  62146. serialize(): any;
  62147. }
  62148. }
  62149. declare module BABYLON {
  62150. /**
  62151. * Block used to add support for vertex skinning (bones)
  62152. */
  62153. export class BonesBlock extends NodeMaterialBlock {
  62154. /**
  62155. * Creates a new BonesBlock
  62156. * @param name defines the block name
  62157. */
  62158. constructor(name: string);
  62159. /**
  62160. * Initialize the block and prepare the context for build
  62161. * @param state defines the state that will be used for the build
  62162. */
  62163. initialize(state: NodeMaterialBuildState): void;
  62164. /**
  62165. * Gets the current class name
  62166. * @returns the class name
  62167. */
  62168. getClassName(): string;
  62169. /**
  62170. * Gets the matrix indices input component
  62171. */
  62172. get matricesIndices(): NodeMaterialConnectionPoint;
  62173. /**
  62174. * Gets the matrix weights input component
  62175. */
  62176. get matricesWeights(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the extra matrix indices input component
  62179. */
  62180. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62181. /**
  62182. * Gets the extra matrix weights input component
  62183. */
  62184. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the world input component
  62187. */
  62188. get world(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the output component
  62191. */
  62192. get output(): NodeMaterialConnectionPoint;
  62193. autoConfigure(material: NodeMaterial): void;
  62194. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62195. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62197. protected _buildBlock(state: NodeMaterialBuildState): this;
  62198. }
  62199. }
  62200. declare module BABYLON {
  62201. /**
  62202. * Block used to add support for instances
  62203. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62204. */
  62205. export class InstancesBlock extends NodeMaterialBlock {
  62206. /**
  62207. * Creates a new InstancesBlock
  62208. * @param name defines the block name
  62209. */
  62210. constructor(name: string);
  62211. /**
  62212. * Gets the current class name
  62213. * @returns the class name
  62214. */
  62215. getClassName(): string;
  62216. /**
  62217. * Gets the first world row input component
  62218. */
  62219. get world0(): NodeMaterialConnectionPoint;
  62220. /**
  62221. * Gets the second world row input component
  62222. */
  62223. get world1(): NodeMaterialConnectionPoint;
  62224. /**
  62225. * Gets the third world row input component
  62226. */
  62227. get world2(): NodeMaterialConnectionPoint;
  62228. /**
  62229. * Gets the forth world row input component
  62230. */
  62231. get world3(): NodeMaterialConnectionPoint;
  62232. /**
  62233. * Gets the world input component
  62234. */
  62235. get world(): NodeMaterialConnectionPoint;
  62236. /**
  62237. * Gets the output component
  62238. */
  62239. get output(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the isntanceID component
  62242. */
  62243. get instanceID(): NodeMaterialConnectionPoint;
  62244. autoConfigure(material: NodeMaterial): void;
  62245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62246. protected _buildBlock(state: NodeMaterialBuildState): this;
  62247. }
  62248. }
  62249. declare module BABYLON {
  62250. /**
  62251. * Block used to add morph targets support to vertex shader
  62252. */
  62253. export class MorphTargetsBlock extends NodeMaterialBlock {
  62254. private _repeatableContentAnchor;
  62255. /**
  62256. * Create a new MorphTargetsBlock
  62257. * @param name defines the block name
  62258. */
  62259. constructor(name: string);
  62260. /**
  62261. * Gets the current class name
  62262. * @returns the class name
  62263. */
  62264. getClassName(): string;
  62265. /**
  62266. * Gets the position input component
  62267. */
  62268. get position(): NodeMaterialConnectionPoint;
  62269. /**
  62270. * Gets the normal input component
  62271. */
  62272. get normal(): NodeMaterialConnectionPoint;
  62273. /**
  62274. * Gets the tangent input component
  62275. */
  62276. get tangent(): NodeMaterialConnectionPoint;
  62277. /**
  62278. * Gets the tangent input component
  62279. */
  62280. get uv(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the position output component
  62283. */
  62284. get positionOutput(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the normal output component
  62287. */
  62288. get normalOutput(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the tangent output component
  62291. */
  62292. get tangentOutput(): NodeMaterialConnectionPoint;
  62293. /**
  62294. * Gets the tangent output component
  62295. */
  62296. get uvOutput(): NodeMaterialConnectionPoint;
  62297. initialize(state: NodeMaterialBuildState): void;
  62298. autoConfigure(material: NodeMaterial): void;
  62299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62300. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62301. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62302. protected _buildBlock(state: NodeMaterialBuildState): this;
  62303. }
  62304. }
  62305. declare module BABYLON {
  62306. /**
  62307. * Block used to get data information from a light
  62308. */
  62309. export class LightInformationBlock extends NodeMaterialBlock {
  62310. private _lightDataUniformName;
  62311. private _lightColorUniformName;
  62312. private _lightTypeDefineName;
  62313. /**
  62314. * Gets or sets the light associated with this block
  62315. */
  62316. light: Nullable<Light>;
  62317. /**
  62318. * Creates a new LightInformationBlock
  62319. * @param name defines the block name
  62320. */
  62321. constructor(name: string);
  62322. /**
  62323. * Gets the current class name
  62324. * @returns the class name
  62325. */
  62326. getClassName(): string;
  62327. /**
  62328. * Gets the world position input component
  62329. */
  62330. get worldPosition(): NodeMaterialConnectionPoint;
  62331. /**
  62332. * Gets the direction output component
  62333. */
  62334. get direction(): NodeMaterialConnectionPoint;
  62335. /**
  62336. * Gets the direction output component
  62337. */
  62338. get color(): NodeMaterialConnectionPoint;
  62339. /**
  62340. * Gets the direction output component
  62341. */
  62342. get intensity(): NodeMaterialConnectionPoint;
  62343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62345. protected _buildBlock(state: NodeMaterialBuildState): this;
  62346. serialize(): any;
  62347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62348. }
  62349. }
  62350. declare module BABYLON {
  62351. /**
  62352. * Block used to add image processing support to fragment shader
  62353. */
  62354. export class ImageProcessingBlock extends NodeMaterialBlock {
  62355. /**
  62356. * Create a new ImageProcessingBlock
  62357. * @param name defines the block name
  62358. */
  62359. constructor(name: string);
  62360. /**
  62361. * Gets the current class name
  62362. * @returns the class name
  62363. */
  62364. getClassName(): string;
  62365. /**
  62366. * Gets the color input component
  62367. */
  62368. get color(): NodeMaterialConnectionPoint;
  62369. /**
  62370. * Gets the output component
  62371. */
  62372. get output(): NodeMaterialConnectionPoint;
  62373. /**
  62374. * Initialize the block and prepare the context for build
  62375. * @param state defines the state that will be used for the build
  62376. */
  62377. initialize(state: NodeMaterialBuildState): void;
  62378. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62379. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62380. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62381. protected _buildBlock(state: NodeMaterialBuildState): this;
  62382. }
  62383. }
  62384. declare module BABYLON {
  62385. /**
  62386. * Block used to pertub normals based on a normal map
  62387. */
  62388. export class PerturbNormalBlock extends NodeMaterialBlock {
  62389. private _tangentSpaceParameterName;
  62390. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62391. invertX: boolean;
  62392. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62393. invertY: boolean;
  62394. /**
  62395. * Create a new PerturbNormalBlock
  62396. * @param name defines the block name
  62397. */
  62398. constructor(name: string);
  62399. /**
  62400. * Gets the current class name
  62401. * @returns the class name
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the world position input component
  62406. */
  62407. get worldPosition(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the world normal input component
  62410. */
  62411. get worldNormal(): NodeMaterialConnectionPoint;
  62412. /**
  62413. * Gets the world tangent input component
  62414. */
  62415. get worldTangent(): NodeMaterialConnectionPoint;
  62416. /**
  62417. * Gets the uv input component
  62418. */
  62419. get uv(): NodeMaterialConnectionPoint;
  62420. /**
  62421. * Gets the normal map color input component
  62422. */
  62423. get normalMapColor(): NodeMaterialConnectionPoint;
  62424. /**
  62425. * Gets the strength input component
  62426. */
  62427. get strength(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the output component
  62430. */
  62431. get output(): NodeMaterialConnectionPoint;
  62432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62434. autoConfigure(material: NodeMaterial): void;
  62435. protected _buildBlock(state: NodeMaterialBuildState): this;
  62436. protected _dumpPropertiesCode(): string;
  62437. serialize(): any;
  62438. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62439. }
  62440. }
  62441. declare module BABYLON {
  62442. /**
  62443. * Block used to discard a pixel if a value is smaller than a cutoff
  62444. */
  62445. export class DiscardBlock extends NodeMaterialBlock {
  62446. /**
  62447. * Create a new DiscardBlock
  62448. * @param name defines the block name
  62449. */
  62450. constructor(name: string);
  62451. /**
  62452. * Gets the current class name
  62453. * @returns the class name
  62454. */
  62455. getClassName(): string;
  62456. /**
  62457. * Gets the color input component
  62458. */
  62459. get value(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the cutoff input component
  62462. */
  62463. get cutoff(): NodeMaterialConnectionPoint;
  62464. protected _buildBlock(state: NodeMaterialBuildState): this;
  62465. }
  62466. }
  62467. declare module BABYLON {
  62468. /**
  62469. * Block used to test if the fragment shader is front facing
  62470. */
  62471. export class FrontFacingBlock extends NodeMaterialBlock {
  62472. /**
  62473. * Creates a new FrontFacingBlock
  62474. * @param name defines the block name
  62475. */
  62476. constructor(name: string);
  62477. /**
  62478. * Gets the current class name
  62479. * @returns the class name
  62480. */
  62481. getClassName(): string;
  62482. /**
  62483. * Gets the output component
  62484. */
  62485. get output(): NodeMaterialConnectionPoint;
  62486. protected _buildBlock(state: NodeMaterialBuildState): this;
  62487. }
  62488. }
  62489. declare module BABYLON {
  62490. /**
  62491. * Block used to get the derivative value on x and y of a given input
  62492. */
  62493. export class DerivativeBlock extends NodeMaterialBlock {
  62494. /**
  62495. * Create a new DerivativeBlock
  62496. * @param name defines the block name
  62497. */
  62498. constructor(name: string);
  62499. /**
  62500. * Gets the current class name
  62501. * @returns the class name
  62502. */
  62503. getClassName(): string;
  62504. /**
  62505. * Gets the input component
  62506. */
  62507. get input(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the derivative output on x
  62510. */
  62511. get dx(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the derivative output on y
  62514. */
  62515. get dy(): NodeMaterialConnectionPoint;
  62516. protected _buildBlock(state: NodeMaterialBuildState): this;
  62517. }
  62518. }
  62519. declare module BABYLON {
  62520. /**
  62521. * Block used to make gl_FragCoord available
  62522. */
  62523. export class FragCoordBlock extends NodeMaterialBlock {
  62524. /**
  62525. * Creates a new FragCoordBlock
  62526. * @param name defines the block name
  62527. */
  62528. constructor(name: string);
  62529. /**
  62530. * Gets the current class name
  62531. * @returns the class name
  62532. */
  62533. getClassName(): string;
  62534. /**
  62535. * Gets the xy component
  62536. */
  62537. get xy(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the xyz component
  62540. */
  62541. get xyz(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the xyzw component
  62544. */
  62545. get xyzw(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the x component
  62548. */
  62549. get x(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the y component
  62552. */
  62553. get y(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the z component
  62556. */
  62557. get z(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the w component
  62560. */
  62561. get output(): NodeMaterialConnectionPoint;
  62562. protected writeOutputs(state: NodeMaterialBuildState): string;
  62563. protected _buildBlock(state: NodeMaterialBuildState): this;
  62564. }
  62565. }
  62566. declare module BABYLON {
  62567. /**
  62568. * Block used to get the screen sizes
  62569. */
  62570. export class ScreenSizeBlock extends NodeMaterialBlock {
  62571. private _varName;
  62572. private _scene;
  62573. /**
  62574. * Creates a new ScreenSizeBlock
  62575. * @param name defines the block name
  62576. */
  62577. constructor(name: string);
  62578. /**
  62579. * Gets the current class name
  62580. * @returns the class name
  62581. */
  62582. getClassName(): string;
  62583. /**
  62584. * Gets the xy component
  62585. */
  62586. get xy(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the x component
  62589. */
  62590. get x(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the y component
  62593. */
  62594. get y(): NodeMaterialConnectionPoint;
  62595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62596. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62597. protected _buildBlock(state: NodeMaterialBuildState): this;
  62598. }
  62599. }
  62600. declare module BABYLON {
  62601. /**
  62602. * Block used to add support for scene fog
  62603. */
  62604. export class FogBlock extends NodeMaterialBlock {
  62605. private _fogDistanceName;
  62606. private _fogParameters;
  62607. /**
  62608. * Create a new FogBlock
  62609. * @param name defines the block name
  62610. */
  62611. constructor(name: string);
  62612. /**
  62613. * Gets the current class name
  62614. * @returns the class name
  62615. */
  62616. getClassName(): string;
  62617. /**
  62618. * Gets the world position input component
  62619. */
  62620. get worldPosition(): NodeMaterialConnectionPoint;
  62621. /**
  62622. * Gets the view input component
  62623. */
  62624. get view(): NodeMaterialConnectionPoint;
  62625. /**
  62626. * Gets the color input component
  62627. */
  62628. get input(): NodeMaterialConnectionPoint;
  62629. /**
  62630. * Gets the fog color input component
  62631. */
  62632. get fogColor(): NodeMaterialConnectionPoint;
  62633. /**
  62634. * Gets the output component
  62635. */
  62636. get output(): NodeMaterialConnectionPoint;
  62637. autoConfigure(material: NodeMaterial): void;
  62638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62640. protected _buildBlock(state: NodeMaterialBuildState): this;
  62641. }
  62642. }
  62643. declare module BABYLON {
  62644. /**
  62645. * Block used to add light in the fragment shader
  62646. */
  62647. export class LightBlock extends NodeMaterialBlock {
  62648. private _lightId;
  62649. /**
  62650. * Gets or sets the light associated with this block
  62651. */
  62652. light: Nullable<Light>;
  62653. /**
  62654. * Create a new LightBlock
  62655. * @param name defines the block name
  62656. */
  62657. constructor(name: string);
  62658. /**
  62659. * Gets the current class name
  62660. * @returns the class name
  62661. */
  62662. getClassName(): string;
  62663. /**
  62664. * Gets the world position input component
  62665. */
  62666. get worldPosition(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the world normal input component
  62669. */
  62670. get worldNormal(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the camera (or eye) position component
  62673. */
  62674. get cameraPosition(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the glossiness component
  62677. */
  62678. get glossiness(): NodeMaterialConnectionPoint;
  62679. /**
  62680. * Gets the glossinness power component
  62681. */
  62682. get glossPower(): NodeMaterialConnectionPoint;
  62683. /**
  62684. * Gets the diffuse color component
  62685. */
  62686. get diffuseColor(): NodeMaterialConnectionPoint;
  62687. /**
  62688. * Gets the specular color component
  62689. */
  62690. get specularColor(): NodeMaterialConnectionPoint;
  62691. /**
  62692. * Gets the diffuse output component
  62693. */
  62694. get diffuseOutput(): NodeMaterialConnectionPoint;
  62695. /**
  62696. * Gets the specular output component
  62697. */
  62698. get specularOutput(): NodeMaterialConnectionPoint;
  62699. /**
  62700. * Gets the shadow output component
  62701. */
  62702. get shadow(): NodeMaterialConnectionPoint;
  62703. autoConfigure(material: NodeMaterial): void;
  62704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62705. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62707. private _injectVertexCode;
  62708. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62709. serialize(): any;
  62710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62711. }
  62712. }
  62713. declare module BABYLON {
  62714. /**
  62715. * Block used to read a reflection texture from a sampler
  62716. */
  62717. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62718. /**
  62719. * Create a new ReflectionTextureBlock
  62720. * @param name defines the block name
  62721. */
  62722. constructor(name: string);
  62723. /**
  62724. * Gets the current class name
  62725. * @returns the class name
  62726. */
  62727. getClassName(): string;
  62728. /**
  62729. * Gets the world position input component
  62730. */
  62731. get position(): NodeMaterialConnectionPoint;
  62732. /**
  62733. * Gets the world position input component
  62734. */
  62735. get worldPosition(): NodeMaterialConnectionPoint;
  62736. /**
  62737. * Gets the world normal input component
  62738. */
  62739. get worldNormal(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the world input component
  62742. */
  62743. get world(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the camera (or eye) position component
  62746. */
  62747. get cameraPosition(): NodeMaterialConnectionPoint;
  62748. /**
  62749. * Gets the view input component
  62750. */
  62751. get view(): NodeMaterialConnectionPoint;
  62752. /**
  62753. * Gets the rgb output component
  62754. */
  62755. get rgb(): NodeMaterialConnectionPoint;
  62756. /**
  62757. * Gets the rgba output component
  62758. */
  62759. get rgba(): NodeMaterialConnectionPoint;
  62760. /**
  62761. * Gets the r output component
  62762. */
  62763. get r(): NodeMaterialConnectionPoint;
  62764. /**
  62765. * Gets the g output component
  62766. */
  62767. get g(): NodeMaterialConnectionPoint;
  62768. /**
  62769. * Gets the b output component
  62770. */
  62771. get b(): NodeMaterialConnectionPoint;
  62772. /**
  62773. * Gets the a output component
  62774. */
  62775. get a(): NodeMaterialConnectionPoint;
  62776. autoConfigure(material: NodeMaterial): void;
  62777. protected _buildBlock(state: NodeMaterialBuildState): this;
  62778. }
  62779. }
  62780. declare module BABYLON {
  62781. /**
  62782. * Block used to add 2 vectors
  62783. */
  62784. export class AddBlock extends NodeMaterialBlock {
  62785. /**
  62786. * Creates a new AddBlock
  62787. * @param name defines the block name
  62788. */
  62789. constructor(name: string);
  62790. /**
  62791. * Gets the current class name
  62792. * @returns the class name
  62793. */
  62794. getClassName(): string;
  62795. /**
  62796. * Gets the left operand input component
  62797. */
  62798. get left(): NodeMaterialConnectionPoint;
  62799. /**
  62800. * Gets the right operand input component
  62801. */
  62802. get right(): NodeMaterialConnectionPoint;
  62803. /**
  62804. * Gets the output component
  62805. */
  62806. get output(): NodeMaterialConnectionPoint;
  62807. protected _buildBlock(state: NodeMaterialBuildState): this;
  62808. }
  62809. }
  62810. declare module BABYLON {
  62811. /**
  62812. * Block used to scale a vector by a float
  62813. */
  62814. export class ScaleBlock extends NodeMaterialBlock {
  62815. /**
  62816. * Creates a new ScaleBlock
  62817. * @param name defines the block name
  62818. */
  62819. constructor(name: string);
  62820. /**
  62821. * Gets the current class name
  62822. * @returns the class name
  62823. */
  62824. getClassName(): string;
  62825. /**
  62826. * Gets the input component
  62827. */
  62828. get input(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the factor input component
  62831. */
  62832. get factor(): NodeMaterialConnectionPoint;
  62833. /**
  62834. * Gets the output component
  62835. */
  62836. get output(): NodeMaterialConnectionPoint;
  62837. protected _buildBlock(state: NodeMaterialBuildState): this;
  62838. }
  62839. }
  62840. declare module BABYLON {
  62841. /**
  62842. * Block used to clamp a float
  62843. */
  62844. export class ClampBlock extends NodeMaterialBlock {
  62845. /** Gets or sets the minimum range */
  62846. minimum: number;
  62847. /** Gets or sets the maximum range */
  62848. maximum: number;
  62849. /**
  62850. * Creates a new ClampBlock
  62851. * @param name defines the block name
  62852. */
  62853. constructor(name: string);
  62854. /**
  62855. * Gets the current class name
  62856. * @returns the class name
  62857. */
  62858. getClassName(): string;
  62859. /**
  62860. * Gets the value input component
  62861. */
  62862. get value(): NodeMaterialConnectionPoint;
  62863. /**
  62864. * Gets the output component
  62865. */
  62866. get output(): NodeMaterialConnectionPoint;
  62867. protected _buildBlock(state: NodeMaterialBuildState): this;
  62868. protected _dumpPropertiesCode(): string;
  62869. serialize(): any;
  62870. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62871. }
  62872. }
  62873. declare module BABYLON {
  62874. /**
  62875. * Block used to apply a cross product between 2 vectors
  62876. */
  62877. export class CrossBlock extends NodeMaterialBlock {
  62878. /**
  62879. * Creates a new CrossBlock
  62880. * @param name defines the block name
  62881. */
  62882. constructor(name: string);
  62883. /**
  62884. * Gets the current class name
  62885. * @returns the class name
  62886. */
  62887. getClassName(): string;
  62888. /**
  62889. * Gets the left operand input component
  62890. */
  62891. get left(): NodeMaterialConnectionPoint;
  62892. /**
  62893. * Gets the right operand input component
  62894. */
  62895. get right(): NodeMaterialConnectionPoint;
  62896. /**
  62897. * Gets the output component
  62898. */
  62899. get output(): NodeMaterialConnectionPoint;
  62900. protected _buildBlock(state: NodeMaterialBuildState): this;
  62901. }
  62902. }
  62903. declare module BABYLON {
  62904. /**
  62905. * Block used to apply a dot product between 2 vectors
  62906. */
  62907. export class DotBlock extends NodeMaterialBlock {
  62908. /**
  62909. * Creates a new DotBlock
  62910. * @param name defines the block name
  62911. */
  62912. constructor(name: string);
  62913. /**
  62914. * Gets the current class name
  62915. * @returns the class name
  62916. */
  62917. getClassName(): string;
  62918. /**
  62919. * Gets the left operand input component
  62920. */
  62921. get left(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the right operand input component
  62924. */
  62925. get right(): NodeMaterialConnectionPoint;
  62926. /**
  62927. * Gets the output component
  62928. */
  62929. get output(): NodeMaterialConnectionPoint;
  62930. protected _buildBlock(state: NodeMaterialBuildState): this;
  62931. }
  62932. }
  62933. declare module BABYLON {
  62934. /**
  62935. * Block used to normalize a vector
  62936. */
  62937. export class NormalizeBlock extends NodeMaterialBlock {
  62938. /**
  62939. * Creates a new NormalizeBlock
  62940. * @param name defines the block name
  62941. */
  62942. constructor(name: string);
  62943. /**
  62944. * Gets the current class name
  62945. * @returns the class name
  62946. */
  62947. getClassName(): string;
  62948. /**
  62949. * Gets the input component
  62950. */
  62951. get input(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the output component
  62954. */
  62955. get output(): NodeMaterialConnectionPoint;
  62956. protected _buildBlock(state: NodeMaterialBuildState): this;
  62957. }
  62958. }
  62959. declare module BABYLON {
  62960. /**
  62961. * Operations supported by the Trigonometry block
  62962. */
  62963. export enum TrigonometryBlockOperations {
  62964. /** Cos */
  62965. Cos = 0,
  62966. /** Sin */
  62967. Sin = 1,
  62968. /** Abs */
  62969. Abs = 2,
  62970. /** Exp */
  62971. Exp = 3,
  62972. /** Exp2 */
  62973. Exp2 = 4,
  62974. /** Round */
  62975. Round = 5,
  62976. /** Floor */
  62977. Floor = 6,
  62978. /** Ceiling */
  62979. Ceiling = 7,
  62980. /** Square root */
  62981. Sqrt = 8,
  62982. /** Log */
  62983. Log = 9,
  62984. /** Tangent */
  62985. Tan = 10,
  62986. /** Arc tangent */
  62987. ArcTan = 11,
  62988. /** Arc cosinus */
  62989. ArcCos = 12,
  62990. /** Arc sinus */
  62991. ArcSin = 13,
  62992. /** Fraction */
  62993. Fract = 14,
  62994. /** Sign */
  62995. Sign = 15,
  62996. /** To radians (from degrees) */
  62997. Radians = 16,
  62998. /** To degrees (from radians) */
  62999. Degrees = 17
  63000. }
  63001. /**
  63002. * Block used to apply trigonometry operation to floats
  63003. */
  63004. export class TrigonometryBlock extends NodeMaterialBlock {
  63005. /**
  63006. * Gets or sets the operation applied by the block
  63007. */
  63008. operation: TrigonometryBlockOperations;
  63009. /**
  63010. * Creates a new TrigonometryBlock
  63011. * @param name defines the block name
  63012. */
  63013. constructor(name: string);
  63014. /**
  63015. * Gets the current class name
  63016. * @returns the class name
  63017. */
  63018. getClassName(): string;
  63019. /**
  63020. * Gets the input component
  63021. */
  63022. get input(): NodeMaterialConnectionPoint;
  63023. /**
  63024. * Gets the output component
  63025. */
  63026. get output(): NodeMaterialConnectionPoint;
  63027. protected _buildBlock(state: NodeMaterialBuildState): this;
  63028. serialize(): any;
  63029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63030. protected _dumpPropertiesCode(): string;
  63031. }
  63032. }
  63033. declare module BABYLON {
  63034. /**
  63035. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63036. */
  63037. export class ColorMergerBlock extends NodeMaterialBlock {
  63038. /**
  63039. * Create a new ColorMergerBlock
  63040. * @param name defines the block name
  63041. */
  63042. constructor(name: string);
  63043. /**
  63044. * Gets the current class name
  63045. * @returns the class name
  63046. */
  63047. getClassName(): string;
  63048. /**
  63049. * Gets the rgb component (input)
  63050. */
  63051. get rgbIn(): NodeMaterialConnectionPoint;
  63052. /**
  63053. * Gets the r component (input)
  63054. */
  63055. get r(): NodeMaterialConnectionPoint;
  63056. /**
  63057. * Gets the g component (input)
  63058. */
  63059. get g(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the b component (input)
  63062. */
  63063. get b(): NodeMaterialConnectionPoint;
  63064. /**
  63065. * Gets the a component (input)
  63066. */
  63067. get a(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the rgba component (output)
  63070. */
  63071. get rgba(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the rgb component (output)
  63074. */
  63075. get rgbOut(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the rgb component (output)
  63078. * @deprecated Please use rgbOut instead.
  63079. */
  63080. get rgb(): NodeMaterialConnectionPoint;
  63081. protected _buildBlock(state: NodeMaterialBuildState): this;
  63082. }
  63083. }
  63084. declare module BABYLON {
  63085. /**
  63086. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63087. */
  63088. export class VectorSplitterBlock extends NodeMaterialBlock {
  63089. /**
  63090. * Create a new VectorSplitterBlock
  63091. * @param name defines the block name
  63092. */
  63093. constructor(name: string);
  63094. /**
  63095. * Gets the current class name
  63096. * @returns the class name
  63097. */
  63098. getClassName(): string;
  63099. /**
  63100. * Gets the xyzw component (input)
  63101. */
  63102. get xyzw(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the xyz component (input)
  63105. */
  63106. get xyzIn(): NodeMaterialConnectionPoint;
  63107. /**
  63108. * Gets the xy component (input)
  63109. */
  63110. get xyIn(): NodeMaterialConnectionPoint;
  63111. /**
  63112. * Gets the xyz component (output)
  63113. */
  63114. get xyzOut(): NodeMaterialConnectionPoint;
  63115. /**
  63116. * Gets the xy component (output)
  63117. */
  63118. get xyOut(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the x component (output)
  63121. */
  63122. get x(): NodeMaterialConnectionPoint;
  63123. /**
  63124. * Gets the y component (output)
  63125. */
  63126. get y(): NodeMaterialConnectionPoint;
  63127. /**
  63128. * Gets the z component (output)
  63129. */
  63130. get z(): NodeMaterialConnectionPoint;
  63131. /**
  63132. * Gets the w component (output)
  63133. */
  63134. get w(): NodeMaterialConnectionPoint;
  63135. protected _inputRename(name: string): string;
  63136. protected _outputRename(name: string): string;
  63137. protected _buildBlock(state: NodeMaterialBuildState): this;
  63138. }
  63139. }
  63140. declare module BABYLON {
  63141. /**
  63142. * Block used to lerp between 2 values
  63143. */
  63144. export class LerpBlock extends NodeMaterialBlock {
  63145. /**
  63146. * Creates a new LerpBlock
  63147. * @param name defines the block name
  63148. */
  63149. constructor(name: string);
  63150. /**
  63151. * Gets the current class name
  63152. * @returns the class name
  63153. */
  63154. getClassName(): string;
  63155. /**
  63156. * Gets the left operand input component
  63157. */
  63158. get left(): NodeMaterialConnectionPoint;
  63159. /**
  63160. * Gets the right operand input component
  63161. */
  63162. get right(): NodeMaterialConnectionPoint;
  63163. /**
  63164. * Gets the gradient operand input component
  63165. */
  63166. get gradient(): NodeMaterialConnectionPoint;
  63167. /**
  63168. * Gets the output component
  63169. */
  63170. get output(): NodeMaterialConnectionPoint;
  63171. protected _buildBlock(state: NodeMaterialBuildState): this;
  63172. }
  63173. }
  63174. declare module BABYLON {
  63175. /**
  63176. * Block used to divide 2 vectors
  63177. */
  63178. export class DivideBlock extends NodeMaterialBlock {
  63179. /**
  63180. * Creates a new DivideBlock
  63181. * @param name defines the block name
  63182. */
  63183. constructor(name: string);
  63184. /**
  63185. * Gets the current class name
  63186. * @returns the class name
  63187. */
  63188. getClassName(): string;
  63189. /**
  63190. * Gets the left operand input component
  63191. */
  63192. get left(): NodeMaterialConnectionPoint;
  63193. /**
  63194. * Gets the right operand input component
  63195. */
  63196. get right(): NodeMaterialConnectionPoint;
  63197. /**
  63198. * Gets the output component
  63199. */
  63200. get output(): NodeMaterialConnectionPoint;
  63201. protected _buildBlock(state: NodeMaterialBuildState): this;
  63202. }
  63203. }
  63204. declare module BABYLON {
  63205. /**
  63206. * Block used to subtract 2 vectors
  63207. */
  63208. export class SubtractBlock extends NodeMaterialBlock {
  63209. /**
  63210. * Creates a new SubtractBlock
  63211. * @param name defines the block name
  63212. */
  63213. constructor(name: string);
  63214. /**
  63215. * Gets the current class name
  63216. * @returns the class name
  63217. */
  63218. getClassName(): string;
  63219. /**
  63220. * Gets the left operand input component
  63221. */
  63222. get left(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the right operand input component
  63225. */
  63226. get right(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the output component
  63229. */
  63230. get output(): NodeMaterialConnectionPoint;
  63231. protected _buildBlock(state: NodeMaterialBuildState): this;
  63232. }
  63233. }
  63234. declare module BABYLON {
  63235. /**
  63236. * Block used to step a value
  63237. */
  63238. export class StepBlock extends NodeMaterialBlock {
  63239. /**
  63240. * Creates a new StepBlock
  63241. * @param name defines the block name
  63242. */
  63243. constructor(name: string);
  63244. /**
  63245. * Gets the current class name
  63246. * @returns the class name
  63247. */
  63248. getClassName(): string;
  63249. /**
  63250. * Gets the value operand input component
  63251. */
  63252. get value(): NodeMaterialConnectionPoint;
  63253. /**
  63254. * Gets the edge operand input component
  63255. */
  63256. get edge(): NodeMaterialConnectionPoint;
  63257. /**
  63258. * Gets the output component
  63259. */
  63260. get output(): NodeMaterialConnectionPoint;
  63261. protected _buildBlock(state: NodeMaterialBuildState): this;
  63262. }
  63263. }
  63264. declare module BABYLON {
  63265. /**
  63266. * Block used to get the opposite (1 - x) of a value
  63267. */
  63268. export class OneMinusBlock extends NodeMaterialBlock {
  63269. /**
  63270. * Creates a new OneMinusBlock
  63271. * @param name defines the block name
  63272. */
  63273. constructor(name: string);
  63274. /**
  63275. * Gets the current class name
  63276. * @returns the class name
  63277. */
  63278. getClassName(): string;
  63279. /**
  63280. * Gets the input component
  63281. */
  63282. get input(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the output component
  63285. */
  63286. get output(): NodeMaterialConnectionPoint;
  63287. protected _buildBlock(state: NodeMaterialBuildState): this;
  63288. }
  63289. }
  63290. declare module BABYLON {
  63291. /**
  63292. * Block used to get the view direction
  63293. */
  63294. export class ViewDirectionBlock extends NodeMaterialBlock {
  63295. /**
  63296. * Creates a new ViewDirectionBlock
  63297. * @param name defines the block name
  63298. */
  63299. constructor(name: string);
  63300. /**
  63301. * Gets the current class name
  63302. * @returns the class name
  63303. */
  63304. getClassName(): string;
  63305. /**
  63306. * Gets the world position component
  63307. */
  63308. get worldPosition(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the camera position component
  63311. */
  63312. get cameraPosition(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the output component
  63315. */
  63316. get output(): NodeMaterialConnectionPoint;
  63317. autoConfigure(material: NodeMaterial): void;
  63318. protected _buildBlock(state: NodeMaterialBuildState): this;
  63319. }
  63320. }
  63321. declare module BABYLON {
  63322. /**
  63323. * Block used to compute fresnel value
  63324. */
  63325. export class FresnelBlock extends NodeMaterialBlock {
  63326. /**
  63327. * Create a new FresnelBlock
  63328. * @param name defines the block name
  63329. */
  63330. constructor(name: string);
  63331. /**
  63332. * Gets the current class name
  63333. * @returns the class name
  63334. */
  63335. getClassName(): string;
  63336. /**
  63337. * Gets the world normal input component
  63338. */
  63339. get worldNormal(): NodeMaterialConnectionPoint;
  63340. /**
  63341. * Gets the view direction input component
  63342. */
  63343. get viewDirection(): NodeMaterialConnectionPoint;
  63344. /**
  63345. * Gets the bias input component
  63346. */
  63347. get bias(): NodeMaterialConnectionPoint;
  63348. /**
  63349. * Gets the camera (or eye) position component
  63350. */
  63351. get power(): NodeMaterialConnectionPoint;
  63352. /**
  63353. * Gets the fresnel output component
  63354. */
  63355. get fresnel(): NodeMaterialConnectionPoint;
  63356. autoConfigure(material: NodeMaterial): void;
  63357. protected _buildBlock(state: NodeMaterialBuildState): this;
  63358. }
  63359. }
  63360. declare module BABYLON {
  63361. /**
  63362. * Block used to get the max of 2 values
  63363. */
  63364. export class MaxBlock extends NodeMaterialBlock {
  63365. /**
  63366. * Creates a new MaxBlock
  63367. * @param name defines the block name
  63368. */
  63369. constructor(name: string);
  63370. /**
  63371. * Gets the current class name
  63372. * @returns the class name
  63373. */
  63374. getClassName(): string;
  63375. /**
  63376. * Gets the left operand input component
  63377. */
  63378. get left(): NodeMaterialConnectionPoint;
  63379. /**
  63380. * Gets the right operand input component
  63381. */
  63382. get right(): NodeMaterialConnectionPoint;
  63383. /**
  63384. * Gets the output component
  63385. */
  63386. get output(): NodeMaterialConnectionPoint;
  63387. protected _buildBlock(state: NodeMaterialBuildState): this;
  63388. }
  63389. }
  63390. declare module BABYLON {
  63391. /**
  63392. * Block used to get the min of 2 values
  63393. */
  63394. export class MinBlock extends NodeMaterialBlock {
  63395. /**
  63396. * Creates a new MinBlock
  63397. * @param name defines the block name
  63398. */
  63399. constructor(name: string);
  63400. /**
  63401. * Gets the current class name
  63402. * @returns the class name
  63403. */
  63404. getClassName(): string;
  63405. /**
  63406. * Gets the left operand input component
  63407. */
  63408. get left(): NodeMaterialConnectionPoint;
  63409. /**
  63410. * Gets the right operand input component
  63411. */
  63412. get right(): NodeMaterialConnectionPoint;
  63413. /**
  63414. * Gets the output component
  63415. */
  63416. get output(): NodeMaterialConnectionPoint;
  63417. protected _buildBlock(state: NodeMaterialBuildState): this;
  63418. }
  63419. }
  63420. declare module BABYLON {
  63421. /**
  63422. * Block used to get the distance between 2 values
  63423. */
  63424. export class DistanceBlock extends NodeMaterialBlock {
  63425. /**
  63426. * Creates a new DistanceBlock
  63427. * @param name defines the block name
  63428. */
  63429. constructor(name: string);
  63430. /**
  63431. * Gets the current class name
  63432. * @returns the class name
  63433. */
  63434. getClassName(): string;
  63435. /**
  63436. * Gets the left operand input component
  63437. */
  63438. get left(): NodeMaterialConnectionPoint;
  63439. /**
  63440. * Gets the right operand input component
  63441. */
  63442. get right(): NodeMaterialConnectionPoint;
  63443. /**
  63444. * Gets the output component
  63445. */
  63446. get output(): NodeMaterialConnectionPoint;
  63447. protected _buildBlock(state: NodeMaterialBuildState): this;
  63448. }
  63449. }
  63450. declare module BABYLON {
  63451. /**
  63452. * Block used to get the length of a vector
  63453. */
  63454. export class LengthBlock extends NodeMaterialBlock {
  63455. /**
  63456. * Creates a new LengthBlock
  63457. * @param name defines the block name
  63458. */
  63459. constructor(name: string);
  63460. /**
  63461. * Gets the current class name
  63462. * @returns the class name
  63463. */
  63464. getClassName(): string;
  63465. /**
  63466. * Gets the value input component
  63467. */
  63468. get value(): NodeMaterialConnectionPoint;
  63469. /**
  63470. * Gets the output component
  63471. */
  63472. get output(): NodeMaterialConnectionPoint;
  63473. protected _buildBlock(state: NodeMaterialBuildState): this;
  63474. }
  63475. }
  63476. declare module BABYLON {
  63477. /**
  63478. * Block used to get negative version of a value (i.e. x * -1)
  63479. */
  63480. export class NegateBlock extends NodeMaterialBlock {
  63481. /**
  63482. * Creates a new NegateBlock
  63483. * @param name defines the block name
  63484. */
  63485. constructor(name: string);
  63486. /**
  63487. * Gets the current class name
  63488. * @returns the class name
  63489. */
  63490. getClassName(): string;
  63491. /**
  63492. * Gets the value input component
  63493. */
  63494. get value(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the output component
  63497. */
  63498. get output(): NodeMaterialConnectionPoint;
  63499. protected _buildBlock(state: NodeMaterialBuildState): this;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * Block used to get the value of the first parameter raised to the power of the second
  63505. */
  63506. export class PowBlock extends NodeMaterialBlock {
  63507. /**
  63508. * Creates a new PowBlock
  63509. * @param name defines the block name
  63510. */
  63511. constructor(name: string);
  63512. /**
  63513. * Gets the current class name
  63514. * @returns the class name
  63515. */
  63516. getClassName(): string;
  63517. /**
  63518. * Gets the value operand input component
  63519. */
  63520. get value(): NodeMaterialConnectionPoint;
  63521. /**
  63522. * Gets the power operand input component
  63523. */
  63524. get power(): NodeMaterialConnectionPoint;
  63525. /**
  63526. * Gets the output component
  63527. */
  63528. get output(): NodeMaterialConnectionPoint;
  63529. protected _buildBlock(state: NodeMaterialBuildState): this;
  63530. }
  63531. }
  63532. declare module BABYLON {
  63533. /**
  63534. * Block used to get a random number
  63535. */
  63536. export class RandomNumberBlock extends NodeMaterialBlock {
  63537. /**
  63538. * Creates a new RandomNumberBlock
  63539. * @param name defines the block name
  63540. */
  63541. constructor(name: string);
  63542. /**
  63543. * Gets the current class name
  63544. * @returns the class name
  63545. */
  63546. getClassName(): string;
  63547. /**
  63548. * Gets the seed input component
  63549. */
  63550. get seed(): NodeMaterialConnectionPoint;
  63551. /**
  63552. * Gets the output component
  63553. */
  63554. get output(): NodeMaterialConnectionPoint;
  63555. protected _buildBlock(state: NodeMaterialBuildState): this;
  63556. }
  63557. }
  63558. declare module BABYLON {
  63559. /**
  63560. * Block used to compute arc tangent of 2 values
  63561. */
  63562. export class ArcTan2Block extends NodeMaterialBlock {
  63563. /**
  63564. * Creates a new ArcTan2Block
  63565. * @param name defines the block name
  63566. */
  63567. constructor(name: string);
  63568. /**
  63569. * Gets the current class name
  63570. * @returns the class name
  63571. */
  63572. getClassName(): string;
  63573. /**
  63574. * Gets the x operand input component
  63575. */
  63576. get x(): NodeMaterialConnectionPoint;
  63577. /**
  63578. * Gets the y operand input component
  63579. */
  63580. get y(): NodeMaterialConnectionPoint;
  63581. /**
  63582. * Gets the output component
  63583. */
  63584. get output(): NodeMaterialConnectionPoint;
  63585. protected _buildBlock(state: NodeMaterialBuildState): this;
  63586. }
  63587. }
  63588. declare module BABYLON {
  63589. /**
  63590. * Block used to smooth step a value
  63591. */
  63592. export class SmoothStepBlock extends NodeMaterialBlock {
  63593. /**
  63594. * Creates a new SmoothStepBlock
  63595. * @param name defines the block name
  63596. */
  63597. constructor(name: string);
  63598. /**
  63599. * Gets the current class name
  63600. * @returns the class name
  63601. */
  63602. getClassName(): string;
  63603. /**
  63604. * Gets the value operand input component
  63605. */
  63606. get value(): NodeMaterialConnectionPoint;
  63607. /**
  63608. * Gets the first edge operand input component
  63609. */
  63610. get edge0(): NodeMaterialConnectionPoint;
  63611. /**
  63612. * Gets the second edge operand input component
  63613. */
  63614. get edge1(): NodeMaterialConnectionPoint;
  63615. /**
  63616. * Gets the output component
  63617. */
  63618. get output(): NodeMaterialConnectionPoint;
  63619. protected _buildBlock(state: NodeMaterialBuildState): this;
  63620. }
  63621. }
  63622. declare module BABYLON {
  63623. /**
  63624. * Block used to get the reciprocal (1 / x) of a value
  63625. */
  63626. export class ReciprocalBlock extends NodeMaterialBlock {
  63627. /**
  63628. * Creates a new ReciprocalBlock
  63629. * @param name defines the block name
  63630. */
  63631. constructor(name: string);
  63632. /**
  63633. * Gets the current class name
  63634. * @returns the class name
  63635. */
  63636. getClassName(): string;
  63637. /**
  63638. * Gets the input component
  63639. */
  63640. get input(): NodeMaterialConnectionPoint;
  63641. /**
  63642. * Gets the output component
  63643. */
  63644. get output(): NodeMaterialConnectionPoint;
  63645. protected _buildBlock(state: NodeMaterialBuildState): this;
  63646. }
  63647. }
  63648. declare module BABYLON {
  63649. /**
  63650. * Block used to replace a color by another one
  63651. */
  63652. export class ReplaceColorBlock extends NodeMaterialBlock {
  63653. /**
  63654. * Creates a new ReplaceColorBlock
  63655. * @param name defines the block name
  63656. */
  63657. constructor(name: string);
  63658. /**
  63659. * Gets the current class name
  63660. * @returns the class name
  63661. */
  63662. getClassName(): string;
  63663. /**
  63664. * Gets the value input component
  63665. */
  63666. get value(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the reference input component
  63669. */
  63670. get reference(): NodeMaterialConnectionPoint;
  63671. /**
  63672. * Gets the distance input component
  63673. */
  63674. get distance(): NodeMaterialConnectionPoint;
  63675. /**
  63676. * Gets the replacement input component
  63677. */
  63678. get replacement(): NodeMaterialConnectionPoint;
  63679. /**
  63680. * Gets the output component
  63681. */
  63682. get output(): NodeMaterialConnectionPoint;
  63683. protected _buildBlock(state: NodeMaterialBuildState): this;
  63684. }
  63685. }
  63686. declare module BABYLON {
  63687. /**
  63688. * Block used to posterize a value
  63689. * @see https://en.wikipedia.org/wiki/Posterization
  63690. */
  63691. export class PosterizeBlock extends NodeMaterialBlock {
  63692. /**
  63693. * Creates a new PosterizeBlock
  63694. * @param name defines the block name
  63695. */
  63696. constructor(name: string);
  63697. /**
  63698. * Gets the current class name
  63699. * @returns the class name
  63700. */
  63701. getClassName(): string;
  63702. /**
  63703. * Gets the value input component
  63704. */
  63705. get value(): NodeMaterialConnectionPoint;
  63706. /**
  63707. * Gets the steps input component
  63708. */
  63709. get steps(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the output component
  63712. */
  63713. get output(): NodeMaterialConnectionPoint;
  63714. protected _buildBlock(state: NodeMaterialBuildState): this;
  63715. }
  63716. }
  63717. declare module BABYLON {
  63718. /**
  63719. * Operations supported by the Wave block
  63720. */
  63721. export enum WaveBlockKind {
  63722. /** SawTooth */
  63723. SawTooth = 0,
  63724. /** Square */
  63725. Square = 1,
  63726. /** Triangle */
  63727. Triangle = 2
  63728. }
  63729. /**
  63730. * Block used to apply wave operation to floats
  63731. */
  63732. export class WaveBlock extends NodeMaterialBlock {
  63733. /**
  63734. * Gets or sets the kibnd of wave to be applied by the block
  63735. */
  63736. kind: WaveBlockKind;
  63737. /**
  63738. * Creates a new WaveBlock
  63739. * @param name defines the block name
  63740. */
  63741. constructor(name: string);
  63742. /**
  63743. * Gets the current class name
  63744. * @returns the class name
  63745. */
  63746. getClassName(): string;
  63747. /**
  63748. * Gets the input component
  63749. */
  63750. get input(): NodeMaterialConnectionPoint;
  63751. /**
  63752. * Gets the output component
  63753. */
  63754. get output(): NodeMaterialConnectionPoint;
  63755. protected _buildBlock(state: NodeMaterialBuildState): this;
  63756. serialize(): any;
  63757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63758. }
  63759. }
  63760. declare module BABYLON {
  63761. /**
  63762. * Class used to store a color step for the GradientBlock
  63763. */
  63764. export class GradientBlockColorStep {
  63765. /**
  63766. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63767. */
  63768. step: number;
  63769. /**
  63770. * Gets or sets the color associated with this step
  63771. */
  63772. color: Color3;
  63773. /**
  63774. * Creates a new GradientBlockColorStep
  63775. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63776. * @param color defines the color associated with this step
  63777. */
  63778. constructor(
  63779. /**
  63780. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63781. */
  63782. step: number,
  63783. /**
  63784. * Gets or sets the color associated with this step
  63785. */
  63786. color: Color3);
  63787. }
  63788. /**
  63789. * Block used to return a color from a gradient based on an input value between 0 and 1
  63790. */
  63791. export class GradientBlock extends NodeMaterialBlock {
  63792. /**
  63793. * Gets or sets the list of color steps
  63794. */
  63795. colorSteps: GradientBlockColorStep[];
  63796. /**
  63797. * Creates a new GradientBlock
  63798. * @param name defines the block name
  63799. */
  63800. constructor(name: string);
  63801. /**
  63802. * Gets the current class name
  63803. * @returns the class name
  63804. */
  63805. getClassName(): string;
  63806. /**
  63807. * Gets the gradient input component
  63808. */
  63809. get gradient(): NodeMaterialConnectionPoint;
  63810. /**
  63811. * Gets the output component
  63812. */
  63813. get output(): NodeMaterialConnectionPoint;
  63814. private _writeColorConstant;
  63815. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63816. serialize(): any;
  63817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63818. protected _dumpPropertiesCode(): string;
  63819. }
  63820. }
  63821. declare module BABYLON {
  63822. /**
  63823. * Block used to normalize lerp between 2 values
  63824. */
  63825. export class NLerpBlock extends NodeMaterialBlock {
  63826. /**
  63827. * Creates a new NLerpBlock
  63828. * @param name defines the block name
  63829. */
  63830. constructor(name: string);
  63831. /**
  63832. * Gets the current class name
  63833. * @returns the class name
  63834. */
  63835. getClassName(): string;
  63836. /**
  63837. * Gets the left operand input component
  63838. */
  63839. get left(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the right operand input component
  63842. */
  63843. get right(): NodeMaterialConnectionPoint;
  63844. /**
  63845. * Gets the gradient operand input component
  63846. */
  63847. get gradient(): NodeMaterialConnectionPoint;
  63848. /**
  63849. * Gets the output component
  63850. */
  63851. get output(): NodeMaterialConnectionPoint;
  63852. protected _buildBlock(state: NodeMaterialBuildState): this;
  63853. }
  63854. }
  63855. declare module BABYLON {
  63856. /**
  63857. * block used to Generate a Worley Noise 3D Noise Pattern
  63858. */
  63859. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63860. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63861. manhattanDistance: boolean;
  63862. /**
  63863. * Creates a new WorleyNoise3DBlock
  63864. * @param name defines the block name
  63865. */
  63866. constructor(name: string);
  63867. /**
  63868. * Gets the current class name
  63869. * @returns the class name
  63870. */
  63871. getClassName(): string;
  63872. /**
  63873. * Gets the seed input component
  63874. */
  63875. get seed(): NodeMaterialConnectionPoint;
  63876. /**
  63877. * Gets the jitter input component
  63878. */
  63879. get jitter(): NodeMaterialConnectionPoint;
  63880. /**
  63881. * Gets the output component
  63882. */
  63883. get output(): NodeMaterialConnectionPoint;
  63884. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63885. /**
  63886. * Exposes the properties to the UI?
  63887. */
  63888. protected _dumpPropertiesCode(): string;
  63889. /**
  63890. * Exposes the properties to the Seralize?
  63891. */
  63892. serialize(): any;
  63893. /**
  63894. * Exposes the properties to the deseralize?
  63895. */
  63896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63897. }
  63898. }
  63899. declare module BABYLON {
  63900. /**
  63901. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63902. */
  63903. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63904. /**
  63905. * Creates a new SimplexPerlin3DBlock
  63906. * @param name defines the block name
  63907. */
  63908. constructor(name: string);
  63909. /**
  63910. * Gets the current class name
  63911. * @returns the class name
  63912. */
  63913. getClassName(): string;
  63914. /**
  63915. * Gets the seed operand input component
  63916. */
  63917. get seed(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the output component
  63920. */
  63921. get output(): NodeMaterialConnectionPoint;
  63922. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63923. }
  63924. }
  63925. declare module BABYLON {
  63926. /**
  63927. * Block used to blend normals
  63928. */
  63929. export class NormalBlendBlock extends NodeMaterialBlock {
  63930. /**
  63931. * Creates a new NormalBlendBlock
  63932. * @param name defines the block name
  63933. */
  63934. constructor(name: string);
  63935. /**
  63936. * Gets the current class name
  63937. * @returns the class name
  63938. */
  63939. getClassName(): string;
  63940. /**
  63941. * Gets the first input component
  63942. */
  63943. get normalMap0(): NodeMaterialConnectionPoint;
  63944. /**
  63945. * Gets the second input component
  63946. */
  63947. get normalMap1(): NodeMaterialConnectionPoint;
  63948. /**
  63949. * Gets the output component
  63950. */
  63951. get output(): NodeMaterialConnectionPoint;
  63952. protected _buildBlock(state: NodeMaterialBuildState): this;
  63953. }
  63954. }
  63955. declare module BABYLON {
  63956. /**
  63957. * Block used to rotate a 2d vector by a given angle
  63958. */
  63959. export class Rotate2dBlock extends NodeMaterialBlock {
  63960. /**
  63961. * Creates a new Rotate2dBlock
  63962. * @param name defines the block name
  63963. */
  63964. constructor(name: string);
  63965. /**
  63966. * Gets the current class name
  63967. * @returns the class name
  63968. */
  63969. getClassName(): string;
  63970. /**
  63971. * Gets the input vector
  63972. */
  63973. get input(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the input angle
  63976. */
  63977. get angle(): NodeMaterialConnectionPoint;
  63978. /**
  63979. * Gets the output component
  63980. */
  63981. get output(): NodeMaterialConnectionPoint;
  63982. autoConfigure(material: NodeMaterial): void;
  63983. protected _buildBlock(state: NodeMaterialBuildState): this;
  63984. }
  63985. }
  63986. declare module BABYLON {
  63987. /**
  63988. * Block used to get the reflected vector from a direction and a normal
  63989. */
  63990. export class ReflectBlock extends NodeMaterialBlock {
  63991. /**
  63992. * Creates a new ReflectBlock
  63993. * @param name defines the block name
  63994. */
  63995. constructor(name: string);
  63996. /**
  63997. * Gets the current class name
  63998. * @returns the class name
  63999. */
  64000. getClassName(): string;
  64001. /**
  64002. * Gets the incident component
  64003. */
  64004. get incident(): NodeMaterialConnectionPoint;
  64005. /**
  64006. * Gets the normal component
  64007. */
  64008. get normal(): NodeMaterialConnectionPoint;
  64009. /**
  64010. * Gets the output component
  64011. */
  64012. get output(): NodeMaterialConnectionPoint;
  64013. protected _buildBlock(state: NodeMaterialBuildState): this;
  64014. }
  64015. }
  64016. declare module BABYLON {
  64017. /**
  64018. * Block used to get the refracted vector from a direction and a normal
  64019. */
  64020. export class RefractBlock extends NodeMaterialBlock {
  64021. /**
  64022. * Creates a new RefractBlock
  64023. * @param name defines the block name
  64024. */
  64025. constructor(name: string);
  64026. /**
  64027. * Gets the current class name
  64028. * @returns the class name
  64029. */
  64030. getClassName(): string;
  64031. /**
  64032. * Gets the incident component
  64033. */
  64034. get incident(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the normal component
  64037. */
  64038. get normal(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the index of refraction component
  64041. */
  64042. get ior(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the output component
  64045. */
  64046. get output(): NodeMaterialConnectionPoint;
  64047. protected _buildBlock(state: NodeMaterialBuildState): this;
  64048. }
  64049. }
  64050. declare module BABYLON {
  64051. /**
  64052. * Block used to desaturate a color
  64053. */
  64054. export class DesaturateBlock extends NodeMaterialBlock {
  64055. /**
  64056. * Creates a new DesaturateBlock
  64057. * @param name defines the block name
  64058. */
  64059. constructor(name: string);
  64060. /**
  64061. * Gets the current class name
  64062. * @returns the class name
  64063. */
  64064. getClassName(): string;
  64065. /**
  64066. * Gets the color operand input component
  64067. */
  64068. get color(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the level operand input component
  64071. */
  64072. get level(): NodeMaterialConnectionPoint;
  64073. /**
  64074. * Gets the output component
  64075. */
  64076. get output(): NodeMaterialConnectionPoint;
  64077. protected _buildBlock(state: NodeMaterialBuildState): this;
  64078. }
  64079. }
  64080. declare module BABYLON {
  64081. /**
  64082. * Block used to implement the ambient occlusion module of the PBR material
  64083. */
  64084. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64085. /**
  64086. * Create a new AmbientOcclusionBlock
  64087. * @param name defines the block name
  64088. */
  64089. constructor(name: string);
  64090. /**
  64091. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64092. */
  64093. useAmbientInGrayScale: boolean;
  64094. /**
  64095. * Initialize the block and prepare the context for build
  64096. * @param state defines the state that will be used for the build
  64097. */
  64098. initialize(state: NodeMaterialBuildState): void;
  64099. /**
  64100. * Gets the current class name
  64101. * @returns the class name
  64102. */
  64103. getClassName(): string;
  64104. /**
  64105. * Gets the texture input component
  64106. */
  64107. get texture(): NodeMaterialConnectionPoint;
  64108. /**
  64109. * Gets the texture intensity component
  64110. */
  64111. get intensity(): NodeMaterialConnectionPoint;
  64112. /**
  64113. * Gets the direct light intensity input component
  64114. */
  64115. get directLightIntensity(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the ambient occlusion object output component
  64118. */
  64119. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the main code of the block (fragment side)
  64122. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64123. * @returns the shader code
  64124. */
  64125. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64127. protected _buildBlock(state: NodeMaterialBuildState): this;
  64128. protected _dumpPropertiesCode(): string;
  64129. serialize(): any;
  64130. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64131. }
  64132. }
  64133. declare module BABYLON {
  64134. /**
  64135. * Block used to implement the reflection module of the PBR material
  64136. */
  64137. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64138. /** @hidden */
  64139. _defineLODReflectionAlpha: string;
  64140. /** @hidden */
  64141. _defineLinearSpecularReflection: string;
  64142. private _vEnvironmentIrradianceName;
  64143. /** @hidden */
  64144. _vReflectionMicrosurfaceInfosName: string;
  64145. /** @hidden */
  64146. _vReflectionInfosName: string;
  64147. /** @hidden */
  64148. _vReflectionFilteringInfoName: string;
  64149. private _scene;
  64150. /**
  64151. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64152. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64153. * It's less burden on the user side in the editor part.
  64154. */
  64155. /** @hidden */
  64156. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64157. /** @hidden */
  64158. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64159. /** @hidden */
  64160. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64161. /**
  64162. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64163. * diffuse part of the IBL.
  64164. */
  64165. useSphericalHarmonics: boolean;
  64166. /**
  64167. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64168. */
  64169. forceIrradianceInFragment: boolean;
  64170. /**
  64171. * Create a new ReflectionBlock
  64172. * @param name defines the block name
  64173. */
  64174. constructor(name: string);
  64175. /**
  64176. * Gets the current class name
  64177. * @returns the class name
  64178. */
  64179. getClassName(): string;
  64180. /**
  64181. * Gets the position input component
  64182. */
  64183. get position(): NodeMaterialConnectionPoint;
  64184. /**
  64185. * Gets the world position input component
  64186. */
  64187. get worldPosition(): NodeMaterialConnectionPoint;
  64188. /**
  64189. * Gets the world normal input component
  64190. */
  64191. get worldNormal(): NodeMaterialConnectionPoint;
  64192. /**
  64193. * Gets the world input component
  64194. */
  64195. get world(): NodeMaterialConnectionPoint;
  64196. /**
  64197. * Gets the camera (or eye) position component
  64198. */
  64199. get cameraPosition(): NodeMaterialConnectionPoint;
  64200. /**
  64201. * Gets the view input component
  64202. */
  64203. get view(): NodeMaterialConnectionPoint;
  64204. /**
  64205. * Gets the color input component
  64206. */
  64207. get color(): NodeMaterialConnectionPoint;
  64208. /**
  64209. * Gets the reflection object output component
  64210. */
  64211. get reflection(): NodeMaterialConnectionPoint;
  64212. /**
  64213. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64214. */
  64215. get hasTexture(): boolean;
  64216. /**
  64217. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64218. */
  64219. get reflectionColor(): string;
  64220. protected _getTexture(): Nullable<BaseTexture>;
  64221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64222. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64223. /**
  64224. * Gets the code to inject in the vertex shader
  64225. * @param state current state of the node material building
  64226. * @returns the shader code
  64227. */
  64228. handleVertexSide(state: NodeMaterialBuildState): string;
  64229. /**
  64230. * Gets the main code of the block (fragment side)
  64231. * @param state current state of the node material building
  64232. * @param normalVarName name of the existing variable corresponding to the normal
  64233. * @returns the shader code
  64234. */
  64235. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64236. protected _buildBlock(state: NodeMaterialBuildState): this;
  64237. protected _dumpPropertiesCode(): string;
  64238. serialize(): any;
  64239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64240. }
  64241. }
  64242. declare module BABYLON {
  64243. /**
  64244. * Block used to implement the sheen module of the PBR material
  64245. */
  64246. export class SheenBlock extends NodeMaterialBlock {
  64247. /**
  64248. * Create a new SheenBlock
  64249. * @param name defines the block name
  64250. */
  64251. constructor(name: string);
  64252. /**
  64253. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64254. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64255. * making it easier to setup and tweak the effect
  64256. */
  64257. albedoScaling: boolean;
  64258. /**
  64259. * Defines if the sheen is linked to the sheen color.
  64260. */
  64261. linkSheenWithAlbedo: boolean;
  64262. /**
  64263. * Initialize the block and prepare the context for build
  64264. * @param state defines the state that will be used for the build
  64265. */
  64266. initialize(state: NodeMaterialBuildState): void;
  64267. /**
  64268. * Gets the current class name
  64269. * @returns the class name
  64270. */
  64271. getClassName(): string;
  64272. /**
  64273. * Gets the intensity input component
  64274. */
  64275. get intensity(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the color input component
  64278. */
  64279. get color(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the roughness input component
  64282. */
  64283. get roughness(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the sheen object output component
  64286. */
  64287. get sheen(): NodeMaterialConnectionPoint;
  64288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64289. /**
  64290. * Gets the main code of the block (fragment side)
  64291. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64292. * @returns the shader code
  64293. */
  64294. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64295. protected _buildBlock(state: NodeMaterialBuildState): this;
  64296. protected _dumpPropertiesCode(): string;
  64297. serialize(): any;
  64298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64299. }
  64300. }
  64301. declare module BABYLON {
  64302. /**
  64303. * Block used to implement the reflectivity module of the PBR material
  64304. */
  64305. export class ReflectivityBlock extends NodeMaterialBlock {
  64306. private _metallicReflectanceColor;
  64307. private _metallicF0Factor;
  64308. /** @hidden */
  64309. _vMetallicReflectanceFactorsName: string;
  64310. /**
  64311. * The property below is set by the main PBR block prior to calling methods of this class.
  64312. */
  64313. /** @hidden */
  64314. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64315. /**
  64316. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64317. */
  64318. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64319. /**
  64320. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64321. */
  64322. useMetallnessFromMetallicTextureBlue: boolean;
  64323. /**
  64324. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64325. */
  64326. useRoughnessFromMetallicTextureAlpha: boolean;
  64327. /**
  64328. * Specifies if the metallic texture contains the roughness information in its green channel.
  64329. */
  64330. useRoughnessFromMetallicTextureGreen: boolean;
  64331. /**
  64332. * Create a new ReflectivityBlock
  64333. * @param name defines the block name
  64334. */
  64335. constructor(name: string);
  64336. /**
  64337. * Initialize the block and prepare the context for build
  64338. * @param state defines the state that will be used for the build
  64339. */
  64340. initialize(state: NodeMaterialBuildState): void;
  64341. /**
  64342. * Gets the current class name
  64343. * @returns the class name
  64344. */
  64345. getClassName(): string;
  64346. /**
  64347. * Gets the metallic input component
  64348. */
  64349. get metallic(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the roughness input component
  64352. */
  64353. get roughness(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the texture input component
  64356. */
  64357. get texture(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the reflectivity object output component
  64360. */
  64361. get reflectivity(): NodeMaterialConnectionPoint;
  64362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64363. /**
  64364. * Gets the main code of the block (fragment side)
  64365. * @param state current state of the node material building
  64366. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64367. * @returns the shader code
  64368. */
  64369. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64370. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64371. protected _buildBlock(state: NodeMaterialBuildState): this;
  64372. protected _dumpPropertiesCode(): string;
  64373. serialize(): any;
  64374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64375. }
  64376. }
  64377. declare module BABYLON {
  64378. /**
  64379. * Block used to implement the anisotropy module of the PBR material
  64380. */
  64381. export class AnisotropyBlock extends NodeMaterialBlock {
  64382. /**
  64383. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64384. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64385. * It's less burden on the user side in the editor part.
  64386. */
  64387. /** @hidden */
  64388. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64389. /** @hidden */
  64390. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64391. /**
  64392. * Create a new AnisotropyBlock
  64393. * @param name defines the block name
  64394. */
  64395. constructor(name: string);
  64396. /**
  64397. * Initialize the block and prepare the context for build
  64398. * @param state defines the state that will be used for the build
  64399. */
  64400. initialize(state: NodeMaterialBuildState): void;
  64401. /**
  64402. * Gets the current class name
  64403. * @returns the class name
  64404. */
  64405. getClassName(): string;
  64406. /**
  64407. * Gets the intensity input component
  64408. */
  64409. get intensity(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the direction input component
  64412. */
  64413. get direction(): NodeMaterialConnectionPoint;
  64414. /**
  64415. * Gets the texture input component
  64416. */
  64417. get texture(): NodeMaterialConnectionPoint;
  64418. /**
  64419. * Gets the uv input component
  64420. */
  64421. get uv(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the worldTangent input component
  64424. */
  64425. get worldTangent(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Gets the anisotropy object output component
  64428. */
  64429. get anisotropy(): NodeMaterialConnectionPoint;
  64430. private _generateTBNSpace;
  64431. /**
  64432. * Gets the main code of the block (fragment side)
  64433. * @param state current state of the node material building
  64434. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64435. * @returns the shader code
  64436. */
  64437. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64439. protected _buildBlock(state: NodeMaterialBuildState): this;
  64440. }
  64441. }
  64442. declare module BABYLON {
  64443. /**
  64444. * Block used to implement the clear coat module of the PBR material
  64445. */
  64446. export class ClearCoatBlock extends NodeMaterialBlock {
  64447. private _scene;
  64448. /**
  64449. * Create a new ClearCoatBlock
  64450. * @param name defines the block name
  64451. */
  64452. constructor(name: string);
  64453. /**
  64454. * Initialize the block and prepare the context for build
  64455. * @param state defines the state that will be used for the build
  64456. */
  64457. initialize(state: NodeMaterialBuildState): void;
  64458. /**
  64459. * Gets the current class name
  64460. * @returns the class name
  64461. */
  64462. getClassName(): string;
  64463. /**
  64464. * Gets the intensity input component
  64465. */
  64466. get intensity(): NodeMaterialConnectionPoint;
  64467. /**
  64468. * Gets the roughness input component
  64469. */
  64470. get roughness(): NodeMaterialConnectionPoint;
  64471. /**
  64472. * Gets the ior input component
  64473. */
  64474. get ior(): NodeMaterialConnectionPoint;
  64475. /**
  64476. * Gets the texture input component
  64477. */
  64478. get texture(): NodeMaterialConnectionPoint;
  64479. /**
  64480. * Gets the bump texture input component
  64481. */
  64482. get bumpTexture(): NodeMaterialConnectionPoint;
  64483. /**
  64484. * Gets the uv input component
  64485. */
  64486. get uv(): NodeMaterialConnectionPoint;
  64487. /**
  64488. * Gets the tint color input component
  64489. */
  64490. get tintColor(): NodeMaterialConnectionPoint;
  64491. /**
  64492. * Gets the tint "at distance" input component
  64493. */
  64494. get tintAtDistance(): NodeMaterialConnectionPoint;
  64495. /**
  64496. * Gets the tint thickness input component
  64497. */
  64498. get tintThickness(): NodeMaterialConnectionPoint;
  64499. /**
  64500. * Gets the world tangent input component
  64501. */
  64502. get worldTangent(): NodeMaterialConnectionPoint;
  64503. /**
  64504. * Gets the clear coat object output component
  64505. */
  64506. get clearcoat(): NodeMaterialConnectionPoint;
  64507. autoConfigure(material: NodeMaterial): void;
  64508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64509. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64510. private _generateTBNSpace;
  64511. /**
  64512. * Gets the main code of the block (fragment side)
  64513. * @param state current state of the node material building
  64514. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64515. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64516. * @param worldPosVarName name of the variable holding the world position
  64517. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64518. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64519. * @param worldNormalVarName name of the variable holding the world normal
  64520. * @returns the shader code
  64521. */
  64522. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64523. protected _buildBlock(state: NodeMaterialBuildState): this;
  64524. }
  64525. }
  64526. declare module BABYLON {
  64527. /**
  64528. * Block used to implement the sub surface module of the PBR material
  64529. */
  64530. export class SubSurfaceBlock extends NodeMaterialBlock {
  64531. /**
  64532. * Create a new SubSurfaceBlock
  64533. * @param name defines the block name
  64534. */
  64535. constructor(name: string);
  64536. /**
  64537. * Stores the intensity of the different subsurface effects in the thickness texture.
  64538. * * the green channel is the translucency intensity.
  64539. * * the blue channel is the scattering intensity.
  64540. * * the alpha channel is the refraction intensity.
  64541. */
  64542. useMaskFromThicknessTexture: boolean;
  64543. /**
  64544. * Initialize the block and prepare the context for build
  64545. * @param state defines the state that will be used for the build
  64546. */
  64547. initialize(state: NodeMaterialBuildState): void;
  64548. /**
  64549. * Gets the current class name
  64550. * @returns the class name
  64551. */
  64552. getClassName(): string;
  64553. /**
  64554. * Gets the min thickness input component
  64555. */
  64556. get minThickness(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the max thickness input component
  64559. */
  64560. get maxThickness(): NodeMaterialConnectionPoint;
  64561. /**
  64562. * Gets the thickness texture component
  64563. */
  64564. get thicknessTexture(): NodeMaterialConnectionPoint;
  64565. /**
  64566. * Gets the tint color input component
  64567. */
  64568. get tintColor(): NodeMaterialConnectionPoint;
  64569. /**
  64570. * Gets the translucency intensity input component
  64571. */
  64572. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the translucency diffusion distance input component
  64575. */
  64576. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the refraction object parameters
  64579. */
  64580. get refraction(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the sub surface object output component
  64583. */
  64584. get subsurface(): NodeMaterialConnectionPoint;
  64585. autoConfigure(material: NodeMaterial): void;
  64586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64587. /**
  64588. * Gets the main code of the block (fragment side)
  64589. * @param state current state of the node material building
  64590. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64591. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64592. * @param worldPosVarName name of the variable holding the world position
  64593. * @returns the shader code
  64594. */
  64595. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64596. protected _buildBlock(state: NodeMaterialBuildState): this;
  64597. }
  64598. }
  64599. declare module BABYLON {
  64600. /**
  64601. * Block used to implement the PBR metallic/roughness model
  64602. */
  64603. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64604. /**
  64605. * Gets or sets the light associated with this block
  64606. */
  64607. light: Nullable<Light>;
  64608. private _lightId;
  64609. private _scene;
  64610. private _environmentBRDFTexture;
  64611. private _environmentBrdfSamplerName;
  64612. private _vNormalWName;
  64613. private _invertNormalName;
  64614. /**
  64615. * Create a new ReflectionBlock
  64616. * @param name defines the block name
  64617. */
  64618. constructor(name: string);
  64619. /**
  64620. * Intensity of the direct lights e.g. the four lights available in your scene.
  64621. * This impacts both the direct diffuse and specular highlights.
  64622. */
  64623. directIntensity: number;
  64624. /**
  64625. * Intensity of the environment e.g. how much the environment will light the object
  64626. * either through harmonics for rough material or through the refelction for shiny ones.
  64627. */
  64628. environmentIntensity: number;
  64629. /**
  64630. * This is a special control allowing the reduction of the specular highlights coming from the
  64631. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64632. */
  64633. specularIntensity: number;
  64634. /**
  64635. * Defines the falloff type used in this material.
  64636. * It by default is Physical.
  64637. */
  64638. lightFalloff: number;
  64639. /**
  64640. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64641. */
  64642. useAlphaFromAlbedoTexture: boolean;
  64643. /**
  64644. * Specifies that alpha test should be used
  64645. */
  64646. useAlphaTest: boolean;
  64647. /**
  64648. * Defines the alpha limits in alpha test mode.
  64649. */
  64650. alphaTestCutoff: number;
  64651. /**
  64652. * Specifies that alpha blending should be used
  64653. */
  64654. useAlphaBlending: boolean;
  64655. /**
  64656. * Defines if the alpha value should be determined via the rgb values.
  64657. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64658. */
  64659. opacityRGB: boolean;
  64660. /**
  64661. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64662. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64663. */
  64664. useRadianceOverAlpha: boolean;
  64665. /**
  64666. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64667. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64668. */
  64669. useSpecularOverAlpha: boolean;
  64670. /**
  64671. * Enables specular anti aliasing in the PBR shader.
  64672. * It will both interacts on the Geometry for analytical and IBL lighting.
  64673. * It also prefilter the roughness map based on the bump values.
  64674. */
  64675. enableSpecularAntiAliasing: boolean;
  64676. /**
  64677. * Enables realtime filtering on the texture.
  64678. */
  64679. realTimeFiltering: boolean;
  64680. /**
  64681. * Quality switch for realtime filtering
  64682. */
  64683. realTimeFilteringQuality: number;
  64684. /**
  64685. * Defines if the material uses energy conservation.
  64686. */
  64687. useEnergyConservation: boolean;
  64688. /**
  64689. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64690. * too much the area relying on ambient texture to define their ambient occlusion.
  64691. */
  64692. useRadianceOcclusion: boolean;
  64693. /**
  64694. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64695. * makes the reflect vector face the model (under horizon).
  64696. */
  64697. useHorizonOcclusion: boolean;
  64698. /**
  64699. * If set to true, no lighting calculations will be applied.
  64700. */
  64701. unlit: boolean;
  64702. /**
  64703. * Force normal to face away from face.
  64704. */
  64705. forceNormalForward: boolean;
  64706. /**
  64707. * Defines the material debug mode.
  64708. * It helps seeing only some components of the material while troubleshooting.
  64709. */
  64710. debugMode: number;
  64711. /**
  64712. * Specify from where on screen the debug mode should start.
  64713. * The value goes from -1 (full screen) to 1 (not visible)
  64714. * It helps with side by side comparison against the final render
  64715. * This defaults to 0
  64716. */
  64717. debugLimit: number;
  64718. /**
  64719. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64720. * You can use the factor to better multiply the final value.
  64721. */
  64722. debugFactor: number;
  64723. /**
  64724. * Initialize the block and prepare the context for build
  64725. * @param state defines the state that will be used for the build
  64726. */
  64727. initialize(state: NodeMaterialBuildState): void;
  64728. /**
  64729. * Gets the current class name
  64730. * @returns the class name
  64731. */
  64732. getClassName(): string;
  64733. /**
  64734. * Gets the world position input component
  64735. */
  64736. get worldPosition(): NodeMaterialConnectionPoint;
  64737. /**
  64738. * Gets the world normal input component
  64739. */
  64740. get worldNormal(): NodeMaterialConnectionPoint;
  64741. /**
  64742. * Gets the perturbed normal input component
  64743. */
  64744. get perturbedNormal(): NodeMaterialConnectionPoint;
  64745. /**
  64746. * Gets the camera position input component
  64747. */
  64748. get cameraPosition(): NodeMaterialConnectionPoint;
  64749. /**
  64750. * Gets the base color input component
  64751. */
  64752. get baseColor(): NodeMaterialConnectionPoint;
  64753. /**
  64754. * Gets the opacity texture input component
  64755. */
  64756. get opacityTexture(): NodeMaterialConnectionPoint;
  64757. /**
  64758. * Gets the ambient color input component
  64759. */
  64760. get ambientColor(): NodeMaterialConnectionPoint;
  64761. /**
  64762. * Gets the reflectivity object parameters
  64763. */
  64764. get reflectivity(): NodeMaterialConnectionPoint;
  64765. /**
  64766. * Gets the ambient occlusion object parameters
  64767. */
  64768. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64769. /**
  64770. * Gets the reflection object parameters
  64771. */
  64772. get reflection(): NodeMaterialConnectionPoint;
  64773. /**
  64774. * Gets the sheen object parameters
  64775. */
  64776. get sheen(): NodeMaterialConnectionPoint;
  64777. /**
  64778. * Gets the clear coat object parameters
  64779. */
  64780. get clearcoat(): NodeMaterialConnectionPoint;
  64781. /**
  64782. * Gets the sub surface object parameters
  64783. */
  64784. get subsurface(): NodeMaterialConnectionPoint;
  64785. /**
  64786. * Gets the anisotropy object parameters
  64787. */
  64788. get anisotropy(): NodeMaterialConnectionPoint;
  64789. /**
  64790. * Gets the ambient output component
  64791. */
  64792. get ambient(): NodeMaterialConnectionPoint;
  64793. /**
  64794. * Gets the diffuse output component
  64795. */
  64796. get diffuse(): NodeMaterialConnectionPoint;
  64797. /**
  64798. * Gets the specular output component
  64799. */
  64800. get specular(): NodeMaterialConnectionPoint;
  64801. /**
  64802. * Gets the sheen output component
  64803. */
  64804. get sheenDir(): NodeMaterialConnectionPoint;
  64805. /**
  64806. * Gets the clear coat output component
  64807. */
  64808. get clearcoatDir(): NodeMaterialConnectionPoint;
  64809. /**
  64810. * Gets the indirect diffuse output component
  64811. */
  64812. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64813. /**
  64814. * Gets the indirect specular output component
  64815. */
  64816. get specularIndirect(): NodeMaterialConnectionPoint;
  64817. /**
  64818. * Gets the indirect sheen output component
  64819. */
  64820. get sheenIndirect(): NodeMaterialConnectionPoint;
  64821. /**
  64822. * Gets the indirect clear coat output component
  64823. */
  64824. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64825. /**
  64826. * Gets the refraction output component
  64827. */
  64828. get refraction(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the global lighting output component
  64831. */
  64832. get lighting(): NodeMaterialConnectionPoint;
  64833. /**
  64834. * Gets the shadow output component
  64835. */
  64836. get shadow(): NodeMaterialConnectionPoint;
  64837. /**
  64838. * Gets the alpha output component
  64839. */
  64840. get alpha(): NodeMaterialConnectionPoint;
  64841. autoConfigure(material: NodeMaterial): void;
  64842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64843. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64845. private _injectVertexCode;
  64846. /**
  64847. * Gets the code corresponding to the albedo/opacity module
  64848. * @returns the shader code
  64849. */
  64850. getAlbedoOpacityCode(): string;
  64851. protected _buildBlock(state: NodeMaterialBuildState): this;
  64852. protected _dumpPropertiesCode(): string;
  64853. serialize(): any;
  64854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64855. }
  64856. }
  64857. declare module BABYLON {
  64858. /**
  64859. * Block used to compute value of one parameter modulo another
  64860. */
  64861. export class ModBlock extends NodeMaterialBlock {
  64862. /**
  64863. * Creates a new ModBlock
  64864. * @param name defines the block name
  64865. */
  64866. constructor(name: string);
  64867. /**
  64868. * Gets the current class name
  64869. * @returns the class name
  64870. */
  64871. getClassName(): string;
  64872. /**
  64873. * Gets the left operand input component
  64874. */
  64875. get left(): NodeMaterialConnectionPoint;
  64876. /**
  64877. * Gets the right operand input component
  64878. */
  64879. get right(): NodeMaterialConnectionPoint;
  64880. /**
  64881. * Gets the output component
  64882. */
  64883. get output(): NodeMaterialConnectionPoint;
  64884. protected _buildBlock(state: NodeMaterialBuildState): this;
  64885. }
  64886. }
  64887. declare module BABYLON {
  64888. /**
  64889. * Helper class to push actions to a pool of workers.
  64890. */
  64891. export class WorkerPool implements IDisposable {
  64892. private _workerInfos;
  64893. private _pendingActions;
  64894. /**
  64895. * Constructor
  64896. * @param workers Array of workers to use for actions
  64897. */
  64898. constructor(workers: Array<Worker>);
  64899. /**
  64900. * Terminates all workers and clears any pending actions.
  64901. */
  64902. dispose(): void;
  64903. /**
  64904. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64905. * pended until a worker has completed its action.
  64906. * @param action The action to perform. Call onComplete when the action is complete.
  64907. */
  64908. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64909. private _execute;
  64910. }
  64911. }
  64912. declare module BABYLON {
  64913. /**
  64914. * Configuration for Draco compression
  64915. */
  64916. export interface IDracoCompressionConfiguration {
  64917. /**
  64918. * Configuration for the decoder.
  64919. */
  64920. decoder: {
  64921. /**
  64922. * The url to the WebAssembly module.
  64923. */
  64924. wasmUrl?: string;
  64925. /**
  64926. * The url to the WebAssembly binary.
  64927. */
  64928. wasmBinaryUrl?: string;
  64929. /**
  64930. * The url to the fallback JavaScript module.
  64931. */
  64932. fallbackUrl?: string;
  64933. };
  64934. }
  64935. /**
  64936. * Draco compression (https://google.github.io/draco/)
  64937. *
  64938. * This class wraps the Draco module.
  64939. *
  64940. * **Encoder**
  64941. *
  64942. * The encoder is not currently implemented.
  64943. *
  64944. * **Decoder**
  64945. *
  64946. * 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.
  64947. *
  64948. * To update the configuration, use the following code:
  64949. * ```javascript
  64950. * DracoCompression.Configuration = {
  64951. * decoder: {
  64952. * wasmUrl: "<url to the WebAssembly library>",
  64953. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64954. * fallbackUrl: "<url to the fallback JavaScript library>",
  64955. * }
  64956. * };
  64957. * ```
  64958. *
  64959. * 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.
  64960. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64961. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64962. *
  64963. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64964. * ```javascript
  64965. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64966. * ```
  64967. *
  64968. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64969. */
  64970. export class DracoCompression implements IDisposable {
  64971. private _workerPoolPromise?;
  64972. private _decoderModulePromise?;
  64973. /**
  64974. * The configuration. Defaults to the following urls:
  64975. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64976. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64977. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64978. */
  64979. static Configuration: IDracoCompressionConfiguration;
  64980. /**
  64981. * Returns true if the decoder configuration is available.
  64982. */
  64983. static get DecoderAvailable(): boolean;
  64984. /**
  64985. * Default number of workers to create when creating the draco compression object.
  64986. */
  64987. static DefaultNumWorkers: number;
  64988. private static GetDefaultNumWorkers;
  64989. private static _Default;
  64990. /**
  64991. * Default instance for the draco compression object.
  64992. */
  64993. static get Default(): DracoCompression;
  64994. /**
  64995. * Constructor
  64996. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64997. */
  64998. constructor(numWorkers?: number);
  64999. /**
  65000. * Stop all async operations and release resources.
  65001. */
  65002. dispose(): void;
  65003. /**
  65004. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65005. * @returns a promise that resolves when ready
  65006. */
  65007. whenReadyAsync(): Promise<void>;
  65008. /**
  65009. * Decode Draco compressed mesh data to vertex data.
  65010. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65011. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65012. * @returns A promise that resolves with the decoded vertex data
  65013. */
  65014. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65015. [kind: string]: number;
  65016. }): Promise<VertexData>;
  65017. }
  65018. }
  65019. declare module BABYLON {
  65020. /**
  65021. * Class for building Constructive Solid Geometry
  65022. */
  65023. export class CSG {
  65024. private polygons;
  65025. /**
  65026. * The world matrix
  65027. */
  65028. matrix: Matrix;
  65029. /**
  65030. * Stores the position
  65031. */
  65032. position: Vector3;
  65033. /**
  65034. * Stores the rotation
  65035. */
  65036. rotation: Vector3;
  65037. /**
  65038. * Stores the rotation quaternion
  65039. */
  65040. rotationQuaternion: Nullable<Quaternion>;
  65041. /**
  65042. * Stores the scaling vector
  65043. */
  65044. scaling: Vector3;
  65045. /**
  65046. * Convert the Mesh to CSG
  65047. * @param mesh The Mesh to convert to CSG
  65048. * @returns A new CSG from the Mesh
  65049. */
  65050. static FromMesh(mesh: Mesh): CSG;
  65051. /**
  65052. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65053. * @param polygons Polygons used to construct a CSG solid
  65054. */
  65055. private static FromPolygons;
  65056. /**
  65057. * Clones, or makes a deep copy, of the CSG
  65058. * @returns A new CSG
  65059. */
  65060. clone(): CSG;
  65061. /**
  65062. * Unions this CSG with another CSG
  65063. * @param csg The CSG to union against this CSG
  65064. * @returns The unioned CSG
  65065. */
  65066. union(csg: CSG): CSG;
  65067. /**
  65068. * Unions this CSG with another CSG in place
  65069. * @param csg The CSG to union against this CSG
  65070. */
  65071. unionInPlace(csg: CSG): void;
  65072. /**
  65073. * Subtracts this CSG with another CSG
  65074. * @param csg The CSG to subtract against this CSG
  65075. * @returns A new CSG
  65076. */
  65077. subtract(csg: CSG): CSG;
  65078. /**
  65079. * Subtracts this CSG with another CSG in place
  65080. * @param csg The CSG to subtact against this CSG
  65081. */
  65082. subtractInPlace(csg: CSG): void;
  65083. /**
  65084. * Intersect this CSG with another CSG
  65085. * @param csg The CSG to intersect against this CSG
  65086. * @returns A new CSG
  65087. */
  65088. intersect(csg: CSG): CSG;
  65089. /**
  65090. * Intersects this CSG with another CSG in place
  65091. * @param csg The CSG to intersect against this CSG
  65092. */
  65093. intersectInPlace(csg: CSG): void;
  65094. /**
  65095. * Return a new CSG solid with solid and empty space switched. This solid is
  65096. * not modified.
  65097. * @returns A new CSG solid with solid and empty space switched
  65098. */
  65099. inverse(): CSG;
  65100. /**
  65101. * Inverses the CSG in place
  65102. */
  65103. inverseInPlace(): void;
  65104. /**
  65105. * This is used to keep meshes transformations so they can be restored
  65106. * when we build back a Babylon Mesh
  65107. * NB : All CSG operations are performed in world coordinates
  65108. * @param csg The CSG to copy the transform attributes from
  65109. * @returns This CSG
  65110. */
  65111. copyTransformAttributes(csg: CSG): CSG;
  65112. /**
  65113. * Build Raw mesh from CSG
  65114. * Coordinates here are in world space
  65115. * @param name The name of the mesh geometry
  65116. * @param scene The Scene
  65117. * @param keepSubMeshes Specifies if the submeshes should be kept
  65118. * @returns A new Mesh
  65119. */
  65120. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65121. /**
  65122. * Build Mesh from CSG taking material and transforms into account
  65123. * @param name The name of the Mesh
  65124. * @param material The material of the Mesh
  65125. * @param scene The Scene
  65126. * @param keepSubMeshes Specifies if submeshes should be kept
  65127. * @returns The new Mesh
  65128. */
  65129. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65130. }
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * Class used to create a trail following a mesh
  65135. */
  65136. export class TrailMesh extends Mesh {
  65137. private _generator;
  65138. private _autoStart;
  65139. private _running;
  65140. private _diameter;
  65141. private _length;
  65142. private _sectionPolygonPointsCount;
  65143. private _sectionVectors;
  65144. private _sectionNormalVectors;
  65145. private _beforeRenderObserver;
  65146. /**
  65147. * @constructor
  65148. * @param name The value used by scene.getMeshByName() to do a lookup.
  65149. * @param generator The mesh or transform node to generate a trail.
  65150. * @param scene The scene to add this mesh to.
  65151. * @param diameter Diameter of trailing mesh. Default is 1.
  65152. * @param length Length of trailing mesh. Default is 60.
  65153. * @param autoStart Automatically start trailing mesh. Default true.
  65154. */
  65155. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65156. /**
  65157. * "TrailMesh"
  65158. * @returns "TrailMesh"
  65159. */
  65160. getClassName(): string;
  65161. private _createMesh;
  65162. /**
  65163. * Start trailing mesh.
  65164. */
  65165. start(): void;
  65166. /**
  65167. * Stop trailing mesh.
  65168. */
  65169. stop(): void;
  65170. /**
  65171. * Update trailing mesh geometry.
  65172. */
  65173. update(): void;
  65174. /**
  65175. * Returns a new TrailMesh object.
  65176. * @param name is a string, the name given to the new mesh
  65177. * @param newGenerator use new generator object for cloned trail mesh
  65178. * @returns a new mesh
  65179. */
  65180. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65181. /**
  65182. * Serializes this trail mesh
  65183. * @param serializationObject object to write serialization to
  65184. */
  65185. serialize(serializationObject: any): void;
  65186. /**
  65187. * Parses a serialized trail mesh
  65188. * @param parsedMesh the serialized mesh
  65189. * @param scene the scene to create the trail mesh in
  65190. * @returns the created trail mesh
  65191. */
  65192. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65193. }
  65194. }
  65195. declare module BABYLON {
  65196. /**
  65197. * Class containing static functions to help procedurally build meshes
  65198. */
  65199. export class TiledBoxBuilder {
  65200. /**
  65201. * Creates a box mesh
  65202. * 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)
  65203. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65205. * * 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
  65206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65207. * @param name defines the name of the mesh
  65208. * @param options defines the options used to create the mesh
  65209. * @param scene defines the hosting scene
  65210. * @returns the box mesh
  65211. */
  65212. static CreateTiledBox(name: string, options: {
  65213. pattern?: number;
  65214. width?: number;
  65215. height?: number;
  65216. depth?: number;
  65217. tileSize?: number;
  65218. tileWidth?: number;
  65219. tileHeight?: number;
  65220. alignHorizontal?: number;
  65221. alignVertical?: number;
  65222. faceUV?: Vector4[];
  65223. faceColors?: Color4[];
  65224. sideOrientation?: number;
  65225. updatable?: boolean;
  65226. }, scene?: Nullable<Scene>): Mesh;
  65227. }
  65228. }
  65229. declare module BABYLON {
  65230. /**
  65231. * Class containing static functions to help procedurally build meshes
  65232. */
  65233. export class TorusKnotBuilder {
  65234. /**
  65235. * Creates a torus knot mesh
  65236. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65237. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65238. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65239. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65241. * * 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
  65242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65243. * @param name defines the name of the mesh
  65244. * @param options defines the options used to create the mesh
  65245. * @param scene defines the hosting scene
  65246. * @returns the torus knot mesh
  65247. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65248. */
  65249. static CreateTorusKnot(name: string, options: {
  65250. radius?: number;
  65251. tube?: number;
  65252. radialSegments?: number;
  65253. tubularSegments?: number;
  65254. p?: number;
  65255. q?: number;
  65256. updatable?: boolean;
  65257. sideOrientation?: number;
  65258. frontUVs?: Vector4;
  65259. backUVs?: Vector4;
  65260. }, scene: any): Mesh;
  65261. }
  65262. }
  65263. declare module BABYLON {
  65264. /**
  65265. * Polygon
  65266. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65267. */
  65268. export class Polygon {
  65269. /**
  65270. * Creates a rectangle
  65271. * @param xmin bottom X coord
  65272. * @param ymin bottom Y coord
  65273. * @param xmax top X coord
  65274. * @param ymax top Y coord
  65275. * @returns points that make the resulting rectation
  65276. */
  65277. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65278. /**
  65279. * Creates a circle
  65280. * @param radius radius of circle
  65281. * @param cx scale in x
  65282. * @param cy scale in y
  65283. * @param numberOfSides number of sides that make up the circle
  65284. * @returns points that make the resulting circle
  65285. */
  65286. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65287. /**
  65288. * Creates a polygon from input string
  65289. * @param input Input polygon data
  65290. * @returns the parsed points
  65291. */
  65292. static Parse(input: string): Vector2[];
  65293. /**
  65294. * Starts building a polygon from x and y coordinates
  65295. * @param x x coordinate
  65296. * @param y y coordinate
  65297. * @returns the started path2
  65298. */
  65299. static StartingAt(x: number, y: number): Path2;
  65300. }
  65301. /**
  65302. * Builds a polygon
  65303. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65304. */
  65305. export class PolygonMeshBuilder {
  65306. private _points;
  65307. private _outlinepoints;
  65308. private _holes;
  65309. private _name;
  65310. private _scene;
  65311. private _epoints;
  65312. private _eholes;
  65313. private _addToepoint;
  65314. /**
  65315. * Babylon reference to the earcut plugin.
  65316. */
  65317. bjsEarcut: any;
  65318. /**
  65319. * Creates a PolygonMeshBuilder
  65320. * @param name name of the builder
  65321. * @param contours Path of the polygon
  65322. * @param scene scene to add to when creating the mesh
  65323. * @param earcutInjection can be used to inject your own earcut reference
  65324. */
  65325. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65326. /**
  65327. * Adds a whole within the polygon
  65328. * @param hole Array of points defining the hole
  65329. * @returns this
  65330. */
  65331. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65332. /**
  65333. * Creates the polygon
  65334. * @param updatable If the mesh should be updatable
  65335. * @param depth The depth of the mesh created
  65336. * @returns the created mesh
  65337. */
  65338. build(updatable?: boolean, depth?: number): Mesh;
  65339. /**
  65340. * Creates the polygon
  65341. * @param depth The depth of the mesh created
  65342. * @returns the created VertexData
  65343. */
  65344. buildVertexData(depth?: number): VertexData;
  65345. /**
  65346. * Adds a side to the polygon
  65347. * @param positions points that make the polygon
  65348. * @param normals normals of the polygon
  65349. * @param uvs uvs of the polygon
  65350. * @param indices indices of the polygon
  65351. * @param bounds bounds of the polygon
  65352. * @param points points of the polygon
  65353. * @param depth depth of the polygon
  65354. * @param flip flip of the polygon
  65355. */
  65356. private addSide;
  65357. }
  65358. }
  65359. declare module BABYLON {
  65360. /**
  65361. * Class containing static functions to help procedurally build meshes
  65362. */
  65363. export class PolygonBuilder {
  65364. /**
  65365. * Creates a polygon mesh
  65366. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65367. * * 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
  65368. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65370. * * 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)
  65371. * * Remember you can only change the shape positions, not their number when updating a polygon
  65372. * @param name defines the name of the mesh
  65373. * @param options defines the options used to create the mesh
  65374. * @param scene defines the hosting scene
  65375. * @param earcutInjection can be used to inject your own earcut reference
  65376. * @returns the polygon mesh
  65377. */
  65378. static CreatePolygon(name: string, options: {
  65379. shape: Vector3[];
  65380. holes?: Vector3[][];
  65381. depth?: number;
  65382. faceUV?: Vector4[];
  65383. faceColors?: Color4[];
  65384. updatable?: boolean;
  65385. sideOrientation?: number;
  65386. frontUVs?: Vector4;
  65387. backUVs?: Vector4;
  65388. wrap?: boolean;
  65389. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65390. /**
  65391. * Creates an extruded polygon mesh, with depth in the Y direction.
  65392. * * 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)
  65393. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65394. * @param name defines the name of the mesh
  65395. * @param options defines the options used to create the mesh
  65396. * @param scene defines the hosting scene
  65397. * @param earcutInjection can be used to inject your own earcut reference
  65398. * @returns the polygon mesh
  65399. */
  65400. static ExtrudePolygon(name: string, options: {
  65401. shape: Vector3[];
  65402. holes?: Vector3[][];
  65403. depth?: number;
  65404. faceUV?: Vector4[];
  65405. faceColors?: Color4[];
  65406. updatable?: boolean;
  65407. sideOrientation?: number;
  65408. frontUVs?: Vector4;
  65409. backUVs?: Vector4;
  65410. wrap?: boolean;
  65411. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65412. }
  65413. }
  65414. declare module BABYLON {
  65415. /**
  65416. * Class containing static functions to help procedurally build meshes
  65417. */
  65418. export class LatheBuilder {
  65419. /**
  65420. * Creates lathe mesh.
  65421. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65422. * * 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
  65423. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65424. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65425. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65426. * * 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
  65427. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65428. * * 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
  65429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65430. * * 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
  65431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65433. * @param name defines the name of the mesh
  65434. * @param options defines the options used to create the mesh
  65435. * @param scene defines the hosting scene
  65436. * @returns the lathe mesh
  65437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65438. */
  65439. static CreateLathe(name: string, options: {
  65440. shape: Vector3[];
  65441. radius?: number;
  65442. tessellation?: number;
  65443. clip?: number;
  65444. arc?: number;
  65445. closed?: boolean;
  65446. updatable?: boolean;
  65447. sideOrientation?: number;
  65448. frontUVs?: Vector4;
  65449. backUVs?: Vector4;
  65450. cap?: number;
  65451. invertUV?: boolean;
  65452. }, scene?: Nullable<Scene>): Mesh;
  65453. }
  65454. }
  65455. declare module BABYLON {
  65456. /**
  65457. * Class containing static functions to help procedurally build meshes
  65458. */
  65459. export class TiledPlaneBuilder {
  65460. /**
  65461. * Creates a tiled plane mesh
  65462. * * The parameter `pattern` will, depending on value, do nothing or
  65463. * * * flip (reflect about central vertical) alternate tiles across and up
  65464. * * * flip every tile on alternate rows
  65465. * * * rotate (180 degs) alternate tiles across and up
  65466. * * * rotate every tile on alternate rows
  65467. * * * flip and rotate alternate tiles across and up
  65468. * * * flip and rotate every tile on alternate rows
  65469. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65470. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65471. * * 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
  65472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65473. * * 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)
  65474. * * 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)
  65475. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65476. * @param name defines the name of the mesh
  65477. * @param options defines the options used to create the mesh
  65478. * @param scene defines the hosting scene
  65479. * @returns the box mesh
  65480. */
  65481. static CreateTiledPlane(name: string, options: {
  65482. pattern?: number;
  65483. tileSize?: number;
  65484. tileWidth?: number;
  65485. tileHeight?: number;
  65486. size?: number;
  65487. width?: number;
  65488. height?: number;
  65489. alignHorizontal?: number;
  65490. alignVertical?: number;
  65491. sideOrientation?: number;
  65492. frontUVs?: Vector4;
  65493. backUVs?: Vector4;
  65494. updatable?: boolean;
  65495. }, scene?: Nullable<Scene>): Mesh;
  65496. }
  65497. }
  65498. declare module BABYLON {
  65499. /**
  65500. * Class containing static functions to help procedurally build meshes
  65501. */
  65502. export class TubeBuilder {
  65503. /**
  65504. * Creates a tube mesh.
  65505. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65506. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65507. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65508. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65509. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65510. * * 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)
  65511. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65512. * * 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
  65513. * * 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
  65514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65515. * * 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
  65516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65518. * @param name defines the name of the mesh
  65519. * @param options defines the options used to create the mesh
  65520. * @param scene defines the hosting scene
  65521. * @returns the tube mesh
  65522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65523. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65524. */
  65525. static CreateTube(name: string, options: {
  65526. path: Vector3[];
  65527. radius?: number;
  65528. tessellation?: number;
  65529. radiusFunction?: {
  65530. (i: number, distance: number): number;
  65531. };
  65532. cap?: number;
  65533. arc?: number;
  65534. updatable?: boolean;
  65535. sideOrientation?: number;
  65536. frontUVs?: Vector4;
  65537. backUVs?: Vector4;
  65538. instance?: Mesh;
  65539. invertUV?: boolean;
  65540. }, scene?: Nullable<Scene>): Mesh;
  65541. }
  65542. }
  65543. declare module BABYLON {
  65544. /**
  65545. * Class containing static functions to help procedurally build meshes
  65546. */
  65547. export class IcoSphereBuilder {
  65548. /**
  65549. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65550. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65551. * * 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`)
  65552. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65553. * * 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
  65554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65555. * * 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
  65556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65557. * @param name defines the name of the mesh
  65558. * @param options defines the options used to create the mesh
  65559. * @param scene defines the hosting scene
  65560. * @returns the icosahedron mesh
  65561. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65562. */
  65563. static CreateIcoSphere(name: string, options: {
  65564. radius?: number;
  65565. radiusX?: number;
  65566. radiusY?: number;
  65567. radiusZ?: number;
  65568. flat?: boolean;
  65569. subdivisions?: number;
  65570. sideOrientation?: number;
  65571. frontUVs?: Vector4;
  65572. backUVs?: Vector4;
  65573. updatable?: boolean;
  65574. }, scene?: Nullable<Scene>): Mesh;
  65575. }
  65576. }
  65577. declare module BABYLON {
  65578. /**
  65579. * Class containing static functions to help procedurally build meshes
  65580. */
  65581. export class DecalBuilder {
  65582. /**
  65583. * Creates a decal mesh.
  65584. * 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
  65585. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65586. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65587. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65588. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65589. * @param name defines the name of the mesh
  65590. * @param sourceMesh defines the mesh where the decal must be applied
  65591. * @param options defines the options used to create the mesh
  65592. * @param scene defines the hosting scene
  65593. * @returns the decal mesh
  65594. * @see https://doc.babylonjs.com/how_to/decals
  65595. */
  65596. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65597. position?: Vector3;
  65598. normal?: Vector3;
  65599. size?: Vector3;
  65600. angle?: number;
  65601. }): Mesh;
  65602. }
  65603. }
  65604. declare module BABYLON {
  65605. /**
  65606. * Class containing static functions to help procedurally build meshes
  65607. */
  65608. export class MeshBuilder {
  65609. /**
  65610. * Creates a box mesh
  65611. * * The parameter `size` sets the size (float) of each box side (default 1)
  65612. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65613. * * 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)
  65614. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65616. * * 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
  65617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65618. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65619. * @param name defines the name of the mesh
  65620. * @param options defines the options used to create the mesh
  65621. * @param scene defines the hosting scene
  65622. * @returns the box mesh
  65623. */
  65624. static CreateBox(name: string, options: {
  65625. size?: number;
  65626. width?: number;
  65627. height?: number;
  65628. depth?: number;
  65629. faceUV?: Vector4[];
  65630. faceColors?: Color4[];
  65631. sideOrientation?: number;
  65632. frontUVs?: Vector4;
  65633. backUVs?: Vector4;
  65634. wrap?: boolean;
  65635. topBaseAt?: number;
  65636. bottomBaseAt?: number;
  65637. updatable?: boolean;
  65638. }, scene?: Nullable<Scene>): Mesh;
  65639. /**
  65640. * Creates a tiled box mesh
  65641. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65643. * @param name defines the name of the mesh
  65644. * @param options defines the options used to create the mesh
  65645. * @param scene defines the hosting scene
  65646. * @returns the tiled box mesh
  65647. */
  65648. static CreateTiledBox(name: string, options: {
  65649. pattern?: number;
  65650. size?: number;
  65651. width?: number;
  65652. height?: number;
  65653. depth: number;
  65654. tileSize?: number;
  65655. tileWidth?: number;
  65656. tileHeight?: number;
  65657. faceUV?: Vector4[];
  65658. faceColors?: Color4[];
  65659. alignHorizontal?: number;
  65660. alignVertical?: number;
  65661. sideOrientation?: number;
  65662. updatable?: boolean;
  65663. }, scene?: Nullable<Scene>): Mesh;
  65664. /**
  65665. * Creates a sphere mesh
  65666. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65667. * * 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`)
  65668. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65669. * * 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
  65670. * * 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)
  65671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65672. * * 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
  65673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65674. * @param name defines the name of the mesh
  65675. * @param options defines the options used to create the mesh
  65676. * @param scene defines the hosting scene
  65677. * @returns the sphere mesh
  65678. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65679. */
  65680. static CreateSphere(name: string, options: {
  65681. segments?: number;
  65682. diameter?: number;
  65683. diameterX?: number;
  65684. diameterY?: number;
  65685. diameterZ?: number;
  65686. arc?: number;
  65687. slice?: number;
  65688. sideOrientation?: number;
  65689. frontUVs?: Vector4;
  65690. backUVs?: Vector4;
  65691. updatable?: boolean;
  65692. }, scene?: Nullable<Scene>): Mesh;
  65693. /**
  65694. * Creates a plane polygonal mesh. By default, this is a disc
  65695. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65696. * * 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
  65697. * * 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
  65698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65699. * * 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
  65700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65701. * @param name defines the name of the mesh
  65702. * @param options defines the options used to create the mesh
  65703. * @param scene defines the hosting scene
  65704. * @returns the plane polygonal mesh
  65705. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65706. */
  65707. static CreateDisc(name: string, options: {
  65708. radius?: number;
  65709. tessellation?: number;
  65710. arc?: number;
  65711. updatable?: boolean;
  65712. sideOrientation?: number;
  65713. frontUVs?: Vector4;
  65714. backUVs?: Vector4;
  65715. }, scene?: Nullable<Scene>): Mesh;
  65716. /**
  65717. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65718. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65719. * * 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`)
  65720. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65721. * * 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
  65722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65723. * * 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
  65724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65725. * @param name defines the name of the mesh
  65726. * @param options defines the options used to create the mesh
  65727. * @param scene defines the hosting scene
  65728. * @returns the icosahedron mesh
  65729. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65730. */
  65731. static CreateIcoSphere(name: string, options: {
  65732. radius?: number;
  65733. radiusX?: number;
  65734. radiusY?: number;
  65735. radiusZ?: number;
  65736. flat?: boolean;
  65737. subdivisions?: number;
  65738. sideOrientation?: number;
  65739. frontUVs?: Vector4;
  65740. backUVs?: Vector4;
  65741. updatable?: boolean;
  65742. }, scene?: Nullable<Scene>): Mesh;
  65743. /**
  65744. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65745. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65746. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65747. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65748. * * 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
  65749. * * 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
  65750. * * 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
  65751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65752. * * 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
  65753. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65754. * * 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
  65755. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65756. * * 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
  65757. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65759. * @param name defines the name of the mesh
  65760. * @param options defines the options used to create the mesh
  65761. * @param scene defines the hosting scene
  65762. * @returns the ribbon mesh
  65763. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65765. */
  65766. static CreateRibbon(name: string, options: {
  65767. pathArray: Vector3[][];
  65768. closeArray?: boolean;
  65769. closePath?: boolean;
  65770. offset?: number;
  65771. updatable?: boolean;
  65772. sideOrientation?: number;
  65773. frontUVs?: Vector4;
  65774. backUVs?: Vector4;
  65775. instance?: Mesh;
  65776. invertUV?: boolean;
  65777. uvs?: Vector2[];
  65778. colors?: Color4[];
  65779. }, scene?: Nullable<Scene>): Mesh;
  65780. /**
  65781. * Creates a cylinder or a cone mesh
  65782. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65783. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65784. * * 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.
  65785. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65786. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65787. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65788. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65789. * * 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).
  65790. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65791. * * 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).
  65792. * * 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
  65793. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65794. * * 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
  65795. * * 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.
  65796. * * If `enclose` is false, a ring surface is one element.
  65797. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65798. * * 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
  65799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65800. * * 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
  65801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65802. * @param name defines the name of the mesh
  65803. * @param options defines the options used to create the mesh
  65804. * @param scene defines the hosting scene
  65805. * @returns the cylinder mesh
  65806. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65807. */
  65808. static CreateCylinder(name: string, options: {
  65809. height?: number;
  65810. diameterTop?: number;
  65811. diameterBottom?: number;
  65812. diameter?: number;
  65813. tessellation?: number;
  65814. subdivisions?: number;
  65815. arc?: number;
  65816. faceColors?: Color4[];
  65817. faceUV?: Vector4[];
  65818. updatable?: boolean;
  65819. hasRings?: boolean;
  65820. enclose?: boolean;
  65821. cap?: number;
  65822. sideOrientation?: number;
  65823. frontUVs?: Vector4;
  65824. backUVs?: Vector4;
  65825. }, scene?: Nullable<Scene>): Mesh;
  65826. /**
  65827. * Creates a torus mesh
  65828. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65829. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65830. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65832. * * 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
  65833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65834. * @param name defines the name of the mesh
  65835. * @param options defines the options used to create the mesh
  65836. * @param scene defines the hosting scene
  65837. * @returns the torus mesh
  65838. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65839. */
  65840. static CreateTorus(name: string, options: {
  65841. diameter?: number;
  65842. thickness?: number;
  65843. tessellation?: number;
  65844. updatable?: boolean;
  65845. sideOrientation?: number;
  65846. frontUVs?: Vector4;
  65847. backUVs?: Vector4;
  65848. }, scene?: Nullable<Scene>): Mesh;
  65849. /**
  65850. * Creates a torus knot mesh
  65851. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65852. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65853. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65854. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65856. * * 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
  65857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65858. * @param name defines the name of the mesh
  65859. * @param options defines the options used to create the mesh
  65860. * @param scene defines the hosting scene
  65861. * @returns the torus knot mesh
  65862. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65863. */
  65864. static CreateTorusKnot(name: string, options: {
  65865. radius?: number;
  65866. tube?: number;
  65867. radialSegments?: number;
  65868. tubularSegments?: number;
  65869. p?: number;
  65870. q?: number;
  65871. updatable?: boolean;
  65872. sideOrientation?: number;
  65873. frontUVs?: Vector4;
  65874. backUVs?: Vector4;
  65875. }, scene?: Nullable<Scene>): Mesh;
  65876. /**
  65877. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65878. * * 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
  65879. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65880. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65881. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65882. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65883. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65884. * * 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
  65885. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65888. * @param name defines the name of the new line system
  65889. * @param options defines the options used to create the line system
  65890. * @param scene defines the hosting scene
  65891. * @returns a new line system mesh
  65892. */
  65893. static CreateLineSystem(name: string, options: {
  65894. lines: Vector3[][];
  65895. updatable?: boolean;
  65896. instance?: Nullable<LinesMesh>;
  65897. colors?: Nullable<Color4[][]>;
  65898. useVertexAlpha?: boolean;
  65899. }, scene: Nullable<Scene>): LinesMesh;
  65900. /**
  65901. * Creates a line mesh
  65902. * 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
  65903. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65904. * * The parameter `points` is an array successive Vector3
  65905. * * 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
  65906. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65907. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65908. * * When updating an instance, remember that only point positions can change, not the number of points
  65909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65911. * @param name defines the name of the new line system
  65912. * @param options defines the options used to create the line system
  65913. * @param scene defines the hosting scene
  65914. * @returns a new line mesh
  65915. */
  65916. static CreateLines(name: string, options: {
  65917. points: Vector3[];
  65918. updatable?: boolean;
  65919. instance?: Nullable<LinesMesh>;
  65920. colors?: Color4[];
  65921. useVertexAlpha?: boolean;
  65922. }, scene?: Nullable<Scene>): LinesMesh;
  65923. /**
  65924. * Creates a dashed line mesh
  65925. * * 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
  65926. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65927. * * The parameter `points` is an array successive Vector3
  65928. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65929. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65930. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65931. * * 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
  65932. * * When updating an instance, remember that only point positions can change, not the number of points
  65933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65934. * @param name defines the name of the mesh
  65935. * @param options defines the options used to create the mesh
  65936. * @param scene defines the hosting scene
  65937. * @returns the dashed line mesh
  65938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65939. */
  65940. static CreateDashedLines(name: string, options: {
  65941. points: Vector3[];
  65942. dashSize?: number;
  65943. gapSize?: number;
  65944. dashNb?: number;
  65945. updatable?: boolean;
  65946. instance?: LinesMesh;
  65947. }, scene?: Nullable<Scene>): LinesMesh;
  65948. /**
  65949. * 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.
  65950. * * 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.
  65951. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65952. * * 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.
  65953. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65954. * * 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
  65955. * * 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
  65956. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65958. * * 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
  65959. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65961. * @param name defines the name of the mesh
  65962. * @param options defines the options used to create the mesh
  65963. * @param scene defines the hosting scene
  65964. * @returns the extruded shape mesh
  65965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65967. */
  65968. static ExtrudeShape(name: string, options: {
  65969. shape: Vector3[];
  65970. path: Vector3[];
  65971. scale?: number;
  65972. rotation?: number;
  65973. cap?: number;
  65974. updatable?: boolean;
  65975. sideOrientation?: number;
  65976. frontUVs?: Vector4;
  65977. backUVs?: Vector4;
  65978. instance?: Mesh;
  65979. invertUV?: boolean;
  65980. }, scene?: Nullable<Scene>): Mesh;
  65981. /**
  65982. * Creates an custom extruded shape mesh.
  65983. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65984. * * 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.
  65985. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65986. * * 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
  65987. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65988. * * 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
  65989. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65990. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65991. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65992. * * 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
  65993. * * 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
  65994. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65996. * * 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
  65997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65999. * @param name defines the name of the mesh
  66000. * @param options defines the options used to create the mesh
  66001. * @param scene defines the hosting scene
  66002. * @returns the custom extruded shape mesh
  66003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66006. */
  66007. static ExtrudeShapeCustom(name: string, options: {
  66008. shape: Vector3[];
  66009. path: Vector3[];
  66010. scaleFunction?: any;
  66011. rotationFunction?: any;
  66012. ribbonCloseArray?: boolean;
  66013. ribbonClosePath?: boolean;
  66014. cap?: number;
  66015. updatable?: boolean;
  66016. sideOrientation?: number;
  66017. frontUVs?: Vector4;
  66018. backUVs?: Vector4;
  66019. instance?: Mesh;
  66020. invertUV?: boolean;
  66021. }, scene?: Nullable<Scene>): Mesh;
  66022. /**
  66023. * Creates lathe mesh.
  66024. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66025. * * 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
  66026. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66027. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66028. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66029. * * 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
  66030. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66031. * * 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
  66032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66033. * * 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
  66034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66036. * @param name defines the name of the mesh
  66037. * @param options defines the options used to create the mesh
  66038. * @param scene defines the hosting scene
  66039. * @returns the lathe mesh
  66040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66041. */
  66042. static CreateLathe(name: string, options: {
  66043. shape: Vector3[];
  66044. radius?: number;
  66045. tessellation?: number;
  66046. clip?: number;
  66047. arc?: number;
  66048. closed?: boolean;
  66049. updatable?: boolean;
  66050. sideOrientation?: number;
  66051. frontUVs?: Vector4;
  66052. backUVs?: Vector4;
  66053. cap?: number;
  66054. invertUV?: boolean;
  66055. }, scene?: Nullable<Scene>): Mesh;
  66056. /**
  66057. * Creates a tiled plane mesh
  66058. * * You can set a limited pattern arrangement with the tiles
  66059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66060. * * 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
  66061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66062. * @param name defines the name of the mesh
  66063. * @param options defines the options used to create the mesh
  66064. * @param scene defines the hosting scene
  66065. * @returns the plane mesh
  66066. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66067. */
  66068. static CreateTiledPlane(name: string, options: {
  66069. pattern?: number;
  66070. tileSize?: number;
  66071. tileWidth?: number;
  66072. tileHeight?: number;
  66073. size?: number;
  66074. width?: number;
  66075. height?: number;
  66076. alignHorizontal?: number;
  66077. alignVertical?: number;
  66078. sideOrientation?: number;
  66079. frontUVs?: Vector4;
  66080. backUVs?: Vector4;
  66081. updatable?: boolean;
  66082. }, scene?: Nullable<Scene>): Mesh;
  66083. /**
  66084. * Creates a plane mesh
  66085. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66086. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66087. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66089. * * 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
  66090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66091. * @param name defines the name of the mesh
  66092. * @param options defines the options used to create the mesh
  66093. * @param scene defines the hosting scene
  66094. * @returns the plane mesh
  66095. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66096. */
  66097. static CreatePlane(name: string, options: {
  66098. size?: number;
  66099. width?: number;
  66100. height?: number;
  66101. sideOrientation?: number;
  66102. frontUVs?: Vector4;
  66103. backUVs?: Vector4;
  66104. updatable?: boolean;
  66105. sourcePlane?: Plane;
  66106. }, scene?: Nullable<Scene>): Mesh;
  66107. /**
  66108. * Creates a ground mesh
  66109. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66110. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66112. * @param name defines the name of the mesh
  66113. * @param options defines the options used to create the mesh
  66114. * @param scene defines the hosting scene
  66115. * @returns the ground mesh
  66116. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66117. */
  66118. static CreateGround(name: string, options: {
  66119. width?: number;
  66120. height?: number;
  66121. subdivisions?: number;
  66122. subdivisionsX?: number;
  66123. subdivisionsY?: number;
  66124. updatable?: boolean;
  66125. }, scene?: Nullable<Scene>): Mesh;
  66126. /**
  66127. * Creates a tiled ground mesh
  66128. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66129. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66130. * * 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
  66131. * * 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
  66132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66133. * @param name defines the name of the mesh
  66134. * @param options defines the options used to create the mesh
  66135. * @param scene defines the hosting scene
  66136. * @returns the tiled ground mesh
  66137. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66138. */
  66139. static CreateTiledGround(name: string, options: {
  66140. xmin: number;
  66141. zmin: number;
  66142. xmax: number;
  66143. zmax: number;
  66144. subdivisions?: {
  66145. w: number;
  66146. h: number;
  66147. };
  66148. precision?: {
  66149. w: number;
  66150. h: number;
  66151. };
  66152. updatable?: boolean;
  66153. }, scene?: Nullable<Scene>): Mesh;
  66154. /**
  66155. * Creates a ground mesh from a height map
  66156. * * The parameter `url` sets the URL of the height map image resource.
  66157. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66158. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66159. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66160. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66161. * * 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.
  66162. * * 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).
  66163. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66165. * @param name defines the name of the mesh
  66166. * @param url defines the url to the height map
  66167. * @param options defines the options used to create the mesh
  66168. * @param scene defines the hosting scene
  66169. * @returns the ground mesh
  66170. * @see https://doc.babylonjs.com/babylon101/height_map
  66171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66172. */
  66173. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66174. width?: number;
  66175. height?: number;
  66176. subdivisions?: number;
  66177. minHeight?: number;
  66178. maxHeight?: number;
  66179. colorFilter?: Color3;
  66180. alphaFilter?: number;
  66181. updatable?: boolean;
  66182. onReady?: (mesh: GroundMesh) => void;
  66183. }, scene?: Nullable<Scene>): GroundMesh;
  66184. /**
  66185. * Creates a polygon mesh
  66186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66187. * * 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
  66188. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66190. * * 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)
  66191. * * Remember you can only change the shape positions, not their number when updating a polygon
  66192. * @param name defines the name of the mesh
  66193. * @param options defines the options used to create the mesh
  66194. * @param scene defines the hosting scene
  66195. * @param earcutInjection can be used to inject your own earcut reference
  66196. * @returns the polygon mesh
  66197. */
  66198. static CreatePolygon(name: string, options: {
  66199. shape: Vector3[];
  66200. holes?: Vector3[][];
  66201. depth?: number;
  66202. faceUV?: Vector4[];
  66203. faceColors?: Color4[];
  66204. updatable?: boolean;
  66205. sideOrientation?: number;
  66206. frontUVs?: Vector4;
  66207. backUVs?: Vector4;
  66208. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66209. /**
  66210. * Creates an extruded polygon mesh, with depth in the Y direction.
  66211. * * 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)
  66212. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66213. * @param name defines the name of the mesh
  66214. * @param options defines the options used to create the mesh
  66215. * @param scene defines the hosting scene
  66216. * @param earcutInjection can be used to inject your own earcut reference
  66217. * @returns the polygon mesh
  66218. */
  66219. static ExtrudePolygon(name: string, options: {
  66220. shape: Vector3[];
  66221. holes?: Vector3[][];
  66222. depth?: number;
  66223. faceUV?: Vector4[];
  66224. faceColors?: Color4[];
  66225. updatable?: boolean;
  66226. sideOrientation?: number;
  66227. frontUVs?: Vector4;
  66228. backUVs?: Vector4;
  66229. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66230. /**
  66231. * Creates a tube mesh.
  66232. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66233. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66234. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66235. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66236. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66237. * * 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)
  66238. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66239. * * 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
  66240. * * 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
  66241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66242. * * 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
  66243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66245. * @param name defines the name of the mesh
  66246. * @param options defines the options used to create the mesh
  66247. * @param scene defines the hosting scene
  66248. * @returns the tube mesh
  66249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66250. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66251. */
  66252. static CreateTube(name: string, options: {
  66253. path: Vector3[];
  66254. radius?: number;
  66255. tessellation?: number;
  66256. radiusFunction?: {
  66257. (i: number, distance: number): number;
  66258. };
  66259. cap?: number;
  66260. arc?: number;
  66261. updatable?: boolean;
  66262. sideOrientation?: number;
  66263. frontUVs?: Vector4;
  66264. backUVs?: Vector4;
  66265. instance?: Mesh;
  66266. invertUV?: boolean;
  66267. }, scene?: Nullable<Scene>): Mesh;
  66268. /**
  66269. * Creates a polyhedron mesh
  66270. * * 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
  66271. * * The parameter `size` (positive float, default 1) sets the polygon size
  66272. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66273. * * 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`
  66274. * * 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
  66275. * * 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)`)
  66276. * * 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
  66277. * * 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
  66278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66279. * * 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
  66280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66281. * @param name defines the name of the mesh
  66282. * @param options defines the options used to create the mesh
  66283. * @param scene defines the hosting scene
  66284. * @returns the polyhedron mesh
  66285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66286. */
  66287. static CreatePolyhedron(name: string, options: {
  66288. type?: number;
  66289. size?: number;
  66290. sizeX?: number;
  66291. sizeY?: number;
  66292. sizeZ?: number;
  66293. custom?: any;
  66294. faceUV?: Vector4[];
  66295. faceColors?: Color4[];
  66296. flat?: boolean;
  66297. updatable?: boolean;
  66298. sideOrientation?: number;
  66299. frontUVs?: Vector4;
  66300. backUVs?: Vector4;
  66301. }, scene?: Nullable<Scene>): Mesh;
  66302. /**
  66303. * Creates a decal mesh.
  66304. * 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
  66305. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66306. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66307. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66308. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66309. * @param name defines the name of the mesh
  66310. * @param sourceMesh defines the mesh where the decal must be applied
  66311. * @param options defines the options used to create the mesh
  66312. * @param scene defines the hosting scene
  66313. * @returns the decal mesh
  66314. * @see https://doc.babylonjs.com/how_to/decals
  66315. */
  66316. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66317. position?: Vector3;
  66318. normal?: Vector3;
  66319. size?: Vector3;
  66320. angle?: number;
  66321. }): Mesh;
  66322. }
  66323. }
  66324. declare module BABYLON {
  66325. /**
  66326. * A simplifier interface for future simplification implementations
  66327. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66328. */
  66329. export interface ISimplifier {
  66330. /**
  66331. * Simplification of a given mesh according to the given settings.
  66332. * Since this requires computation, it is assumed that the function runs async.
  66333. * @param settings The settings of the simplification, including quality and distance
  66334. * @param successCallback A callback that will be called after the mesh was simplified.
  66335. * @param errorCallback in case of an error, this callback will be called. optional.
  66336. */
  66337. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66338. }
  66339. /**
  66340. * Expected simplification settings.
  66341. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66342. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66343. */
  66344. export interface ISimplificationSettings {
  66345. /**
  66346. * Gets or sets the expected quality
  66347. */
  66348. quality: number;
  66349. /**
  66350. * Gets or sets the distance when this optimized version should be used
  66351. */
  66352. distance: number;
  66353. /**
  66354. * Gets an already optimized mesh
  66355. */
  66356. optimizeMesh?: boolean;
  66357. }
  66358. /**
  66359. * Class used to specify simplification options
  66360. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66361. */
  66362. export class SimplificationSettings implements ISimplificationSettings {
  66363. /** expected quality */
  66364. quality: number;
  66365. /** distance when this optimized version should be used */
  66366. distance: number;
  66367. /** already optimized mesh */
  66368. optimizeMesh?: boolean | undefined;
  66369. /**
  66370. * Creates a SimplificationSettings
  66371. * @param quality expected quality
  66372. * @param distance distance when this optimized version should be used
  66373. * @param optimizeMesh already optimized mesh
  66374. */
  66375. constructor(
  66376. /** expected quality */
  66377. quality: number,
  66378. /** distance when this optimized version should be used */
  66379. distance: number,
  66380. /** already optimized mesh */
  66381. optimizeMesh?: boolean | undefined);
  66382. }
  66383. /**
  66384. * Interface used to define a simplification task
  66385. */
  66386. export interface ISimplificationTask {
  66387. /**
  66388. * Array of settings
  66389. */
  66390. settings: Array<ISimplificationSettings>;
  66391. /**
  66392. * Simplification type
  66393. */
  66394. simplificationType: SimplificationType;
  66395. /**
  66396. * Mesh to simplify
  66397. */
  66398. mesh: Mesh;
  66399. /**
  66400. * Callback called on success
  66401. */
  66402. successCallback?: () => void;
  66403. /**
  66404. * Defines if parallel processing can be used
  66405. */
  66406. parallelProcessing: boolean;
  66407. }
  66408. /**
  66409. * Queue used to order the simplification tasks
  66410. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66411. */
  66412. export class SimplificationQueue {
  66413. private _simplificationArray;
  66414. /**
  66415. * Gets a boolean indicating that the process is still running
  66416. */
  66417. running: boolean;
  66418. /**
  66419. * Creates a new queue
  66420. */
  66421. constructor();
  66422. /**
  66423. * Adds a new simplification task
  66424. * @param task defines a task to add
  66425. */
  66426. addTask(task: ISimplificationTask): void;
  66427. /**
  66428. * Execute next task
  66429. */
  66430. executeNext(): void;
  66431. /**
  66432. * Execute a simplification task
  66433. * @param task defines the task to run
  66434. */
  66435. runSimplification(task: ISimplificationTask): void;
  66436. private getSimplifier;
  66437. }
  66438. /**
  66439. * The implemented types of simplification
  66440. * At the moment only Quadratic Error Decimation is implemented
  66441. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66442. */
  66443. export enum SimplificationType {
  66444. /** Quadratic error decimation */
  66445. QUADRATIC = 0
  66446. }
  66447. /**
  66448. * An implementation of the Quadratic Error simplification algorithm.
  66449. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66450. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66451. * @author RaananW
  66452. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66453. */
  66454. export class QuadraticErrorSimplification implements ISimplifier {
  66455. private _mesh;
  66456. private triangles;
  66457. private vertices;
  66458. private references;
  66459. private _reconstructedMesh;
  66460. /** Gets or sets the number pf sync interations */
  66461. syncIterations: number;
  66462. /** Gets or sets the aggressiveness of the simplifier */
  66463. aggressiveness: number;
  66464. /** Gets or sets the number of allowed iterations for decimation */
  66465. decimationIterations: number;
  66466. /** Gets or sets the espilon to use for bounding box computation */
  66467. boundingBoxEpsilon: number;
  66468. /**
  66469. * Creates a new QuadraticErrorSimplification
  66470. * @param _mesh defines the target mesh
  66471. */
  66472. constructor(_mesh: Mesh);
  66473. /**
  66474. * Simplification of a given mesh according to the given settings.
  66475. * Since this requires computation, it is assumed that the function runs async.
  66476. * @param settings The settings of the simplification, including quality and distance
  66477. * @param successCallback A callback that will be called after the mesh was simplified.
  66478. */
  66479. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66480. private runDecimation;
  66481. private initWithMesh;
  66482. private init;
  66483. private reconstructMesh;
  66484. private initDecimatedMesh;
  66485. private isFlipped;
  66486. private updateTriangles;
  66487. private identifyBorder;
  66488. private updateMesh;
  66489. private vertexError;
  66490. private calculateError;
  66491. }
  66492. }
  66493. declare module BABYLON {
  66494. interface Scene {
  66495. /** @hidden (Backing field) */
  66496. _simplificationQueue: SimplificationQueue;
  66497. /**
  66498. * Gets or sets the simplification queue attached to the scene
  66499. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66500. */
  66501. simplificationQueue: SimplificationQueue;
  66502. }
  66503. interface Mesh {
  66504. /**
  66505. * Simplify the mesh according to the given array of settings.
  66506. * Function will return immediately and will simplify async
  66507. * @param settings a collection of simplification settings
  66508. * @param parallelProcessing should all levels calculate parallel or one after the other
  66509. * @param simplificationType the type of simplification to run
  66510. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66511. * @returns the current mesh
  66512. */
  66513. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66514. }
  66515. /**
  66516. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66517. * created in a scene
  66518. */
  66519. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66520. /**
  66521. * The component name helpfull to identify the component in the list of scene components.
  66522. */
  66523. readonly name: string;
  66524. /**
  66525. * The scene the component belongs to.
  66526. */
  66527. scene: Scene;
  66528. /**
  66529. * Creates a new instance of the component for the given scene
  66530. * @param scene Defines the scene to register the component in
  66531. */
  66532. constructor(scene: Scene);
  66533. /**
  66534. * Registers the component in a given scene
  66535. */
  66536. register(): void;
  66537. /**
  66538. * Rebuilds the elements related to this component in case of
  66539. * context lost for instance.
  66540. */
  66541. rebuild(): void;
  66542. /**
  66543. * Disposes the component and the associated ressources
  66544. */
  66545. dispose(): void;
  66546. private _beforeCameraUpdate;
  66547. }
  66548. }
  66549. declare module BABYLON {
  66550. interface Mesh {
  66551. /**
  66552. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66553. */
  66554. thinInstanceEnablePicking: boolean;
  66555. /**
  66556. * Creates a new thin instance
  66557. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66558. * @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
  66559. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66560. */
  66561. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66562. /**
  66563. * Adds the transformation (matrix) of the current mesh as a thin instance
  66564. * @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
  66565. * @returns the thin instance index number
  66566. */
  66567. thinInstanceAddSelf(refresh: boolean): number;
  66568. /**
  66569. * Registers a custom attribute to be used with thin instances
  66570. * @param kind name of the attribute
  66571. * @param stride size in floats of the attribute
  66572. */
  66573. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66574. /**
  66575. * Sets the matrix of a thin instance
  66576. * @param index index of the thin instance
  66577. * @param matrix matrix to set
  66578. * @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
  66579. */
  66580. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66581. /**
  66582. * Sets the value of a custom attribute for a thin instance
  66583. * @param kind name of the attribute
  66584. * @param index index of the thin instance
  66585. * @param value value to set
  66586. * @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
  66587. */
  66588. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66589. /**
  66590. * 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.
  66591. */
  66592. thinInstanceCount: number;
  66593. /**
  66594. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66595. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66596. * @param buffer buffer to set
  66597. * @param stride size in floats of each value of the buffer
  66598. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66599. */
  66600. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66601. /**
  66602. * Gets the list of world matrices
  66603. * @return an array containing all the world matrices from the thin instances
  66604. */
  66605. thinInstanceGetWorldMatrices(): Matrix[];
  66606. /**
  66607. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66608. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66609. */
  66610. thinInstanceBufferUpdated(kind: string): void;
  66611. /**
  66612. * Refreshes the bounding info, taking into account all the thin instances defined
  66613. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66614. */
  66615. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66616. /** @hidden */
  66617. _thinInstanceInitializeUserStorage(): void;
  66618. /** @hidden */
  66619. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66620. /** @hidden */
  66621. _userThinInstanceBuffersStorage: {
  66622. data: {
  66623. [key: string]: Float32Array;
  66624. };
  66625. sizes: {
  66626. [key: string]: number;
  66627. };
  66628. vertexBuffers: {
  66629. [key: string]: Nullable<VertexBuffer>;
  66630. };
  66631. strides: {
  66632. [key: string]: number;
  66633. };
  66634. };
  66635. }
  66636. }
  66637. declare module BABYLON {
  66638. /**
  66639. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66640. */
  66641. export interface INavigationEnginePlugin {
  66642. /**
  66643. * plugin name
  66644. */
  66645. name: string;
  66646. /**
  66647. * Creates a navigation mesh
  66648. * @param meshes array of all the geometry used to compute the navigatio mesh
  66649. * @param parameters bunch of parameters used to filter geometry
  66650. */
  66651. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66652. /**
  66653. * Create a navigation mesh debug mesh
  66654. * @param scene is where the mesh will be added
  66655. * @returns debug display mesh
  66656. */
  66657. createDebugNavMesh(scene: Scene): Mesh;
  66658. /**
  66659. * Get a navigation mesh constrained position, closest to the parameter position
  66660. * @param position world position
  66661. * @returns the closest point to position constrained by the navigation mesh
  66662. */
  66663. getClosestPoint(position: Vector3): Vector3;
  66664. /**
  66665. * Get a navigation mesh constrained position, closest to the parameter position
  66666. * @param position world position
  66667. * @param result output the closest point to position constrained by the navigation mesh
  66668. */
  66669. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66670. /**
  66671. * Get a navigation mesh constrained position, within a particular radius
  66672. * @param position world position
  66673. * @param maxRadius the maximum distance to the constrained world position
  66674. * @returns the closest point to position constrained by the navigation mesh
  66675. */
  66676. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66677. /**
  66678. * Get a navigation mesh constrained position, within a particular radius
  66679. * @param position world position
  66680. * @param maxRadius the maximum distance to the constrained world position
  66681. * @param result output the closest point to position constrained by the navigation mesh
  66682. */
  66683. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66684. /**
  66685. * Compute the final position from a segment made of destination-position
  66686. * @param position world position
  66687. * @param destination world position
  66688. * @returns the resulting point along the navmesh
  66689. */
  66690. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66691. /**
  66692. * Compute the final position from a segment made of destination-position
  66693. * @param position world position
  66694. * @param destination world position
  66695. * @param result output the resulting point along the navmesh
  66696. */
  66697. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66698. /**
  66699. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66700. * @param start world position
  66701. * @param end world position
  66702. * @returns array containing world position composing the path
  66703. */
  66704. computePath(start: Vector3, end: Vector3): Vector3[];
  66705. /**
  66706. * If this plugin is supported
  66707. * @returns true if plugin is supported
  66708. */
  66709. isSupported(): boolean;
  66710. /**
  66711. * Create a new Crowd so you can add agents
  66712. * @param maxAgents the maximum agent count in the crowd
  66713. * @param maxAgentRadius the maximum radius an agent can have
  66714. * @param scene to attach the crowd to
  66715. * @returns the crowd you can add agents to
  66716. */
  66717. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66718. /**
  66719. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66720. * The queries will try to find a solution within those bounds
  66721. * default is (1,1,1)
  66722. * @param extent x,y,z value that define the extent around the queries point of reference
  66723. */
  66724. setDefaultQueryExtent(extent: Vector3): void;
  66725. /**
  66726. * Get the Bounding box extent specified by setDefaultQueryExtent
  66727. * @returns the box extent values
  66728. */
  66729. getDefaultQueryExtent(): Vector3;
  66730. /**
  66731. * build the navmesh from a previously saved state using getNavmeshData
  66732. * @param data the Uint8Array returned by getNavmeshData
  66733. */
  66734. buildFromNavmeshData(data: Uint8Array): void;
  66735. /**
  66736. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66737. * @returns data the Uint8Array that can be saved and reused
  66738. */
  66739. getNavmeshData(): Uint8Array;
  66740. /**
  66741. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66742. * @param result output the box extent values
  66743. */
  66744. getDefaultQueryExtentToRef(result: Vector3): void;
  66745. /**
  66746. * Release all resources
  66747. */
  66748. dispose(): void;
  66749. }
  66750. /**
  66751. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66752. */
  66753. export interface ICrowd {
  66754. /**
  66755. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66756. * You can attach anything to that node. The node position is updated in the scene update tick.
  66757. * @param pos world position that will be constrained by the navigation mesh
  66758. * @param parameters agent parameters
  66759. * @param transform hooked to the agent that will be update by the scene
  66760. * @returns agent index
  66761. */
  66762. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66763. /**
  66764. * Returns the agent position in world space
  66765. * @param index agent index returned by addAgent
  66766. * @returns world space position
  66767. */
  66768. getAgentPosition(index: number): Vector3;
  66769. /**
  66770. * Gets the agent position result in world space
  66771. * @param index agent index returned by addAgent
  66772. * @param result output world space position
  66773. */
  66774. getAgentPositionToRef(index: number, result: Vector3): void;
  66775. /**
  66776. * Gets the agent velocity in world space
  66777. * @param index agent index returned by addAgent
  66778. * @returns world space velocity
  66779. */
  66780. getAgentVelocity(index: number): Vector3;
  66781. /**
  66782. * Gets the agent velocity result in world space
  66783. * @param index agent index returned by addAgent
  66784. * @param result output world space velocity
  66785. */
  66786. getAgentVelocityToRef(index: number, result: Vector3): void;
  66787. /**
  66788. * remove a particular agent previously created
  66789. * @param index agent index returned by addAgent
  66790. */
  66791. removeAgent(index: number): void;
  66792. /**
  66793. * get the list of all agents attached to this crowd
  66794. * @returns list of agent indices
  66795. */
  66796. getAgents(): number[];
  66797. /**
  66798. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66799. * @param deltaTime in seconds
  66800. */
  66801. update(deltaTime: number): void;
  66802. /**
  66803. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66804. * @param index agent index returned by addAgent
  66805. * @param destination targeted world position
  66806. */
  66807. agentGoto(index: number, destination: Vector3): void;
  66808. /**
  66809. * Teleport the agent to a new position
  66810. * @param index agent index returned by addAgent
  66811. * @param destination targeted world position
  66812. */
  66813. agentTeleport(index: number, destination: Vector3): void;
  66814. /**
  66815. * Update agent parameters
  66816. * @param index agent index returned by addAgent
  66817. * @param parameters agent parameters
  66818. */
  66819. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66820. /**
  66821. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66822. * The queries will try to find a solution within those bounds
  66823. * default is (1,1,1)
  66824. * @param extent x,y,z value that define the extent around the queries point of reference
  66825. */
  66826. setDefaultQueryExtent(extent: Vector3): void;
  66827. /**
  66828. * Get the Bounding box extent specified by setDefaultQueryExtent
  66829. * @returns the box extent values
  66830. */
  66831. getDefaultQueryExtent(): Vector3;
  66832. /**
  66833. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66834. * @param result output the box extent values
  66835. */
  66836. getDefaultQueryExtentToRef(result: Vector3): void;
  66837. /**
  66838. * Release all resources
  66839. */
  66840. dispose(): void;
  66841. }
  66842. /**
  66843. * Configures an agent
  66844. */
  66845. export interface IAgentParameters {
  66846. /**
  66847. * Agent radius. [Limit: >= 0]
  66848. */
  66849. radius: number;
  66850. /**
  66851. * Agent height. [Limit: > 0]
  66852. */
  66853. height: number;
  66854. /**
  66855. * Maximum allowed acceleration. [Limit: >= 0]
  66856. */
  66857. maxAcceleration: number;
  66858. /**
  66859. * Maximum allowed speed. [Limit: >= 0]
  66860. */
  66861. maxSpeed: number;
  66862. /**
  66863. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66864. */
  66865. collisionQueryRange: number;
  66866. /**
  66867. * The path visibility optimization range. [Limit: > 0]
  66868. */
  66869. pathOptimizationRange: number;
  66870. /**
  66871. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66872. */
  66873. separationWeight: number;
  66874. }
  66875. /**
  66876. * Configures the navigation mesh creation
  66877. */
  66878. export interface INavMeshParameters {
  66879. /**
  66880. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66881. */
  66882. cs: number;
  66883. /**
  66884. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66885. */
  66886. ch: number;
  66887. /**
  66888. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66889. */
  66890. walkableSlopeAngle: number;
  66891. /**
  66892. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66893. * be considered walkable. [Limit: >= 3] [Units: vx]
  66894. */
  66895. walkableHeight: number;
  66896. /**
  66897. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66898. */
  66899. walkableClimb: number;
  66900. /**
  66901. * The distance to erode/shrink the walkable area of the heightfield away from
  66902. * obstructions. [Limit: >=0] [Units: vx]
  66903. */
  66904. walkableRadius: number;
  66905. /**
  66906. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66907. */
  66908. maxEdgeLen: number;
  66909. /**
  66910. * The maximum distance a simplfied contour's border edges should deviate
  66911. * the original raw contour. [Limit: >=0] [Units: vx]
  66912. */
  66913. maxSimplificationError: number;
  66914. /**
  66915. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66916. */
  66917. minRegionArea: number;
  66918. /**
  66919. * Any regions with a span count smaller than this value will, if possible,
  66920. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66921. */
  66922. mergeRegionArea: number;
  66923. /**
  66924. * The maximum number of vertices allowed for polygons generated during the
  66925. * contour to polygon conversion process. [Limit: >= 3]
  66926. */
  66927. maxVertsPerPoly: number;
  66928. /**
  66929. * Sets the sampling distance to use when generating the detail mesh.
  66930. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66931. */
  66932. detailSampleDist: number;
  66933. /**
  66934. * The maximum distance the detail mesh surface should deviate from heightfield
  66935. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66936. */
  66937. detailSampleMaxError: number;
  66938. }
  66939. }
  66940. declare module BABYLON {
  66941. /**
  66942. * RecastJS navigation plugin
  66943. */
  66944. export class RecastJSPlugin implements INavigationEnginePlugin {
  66945. /**
  66946. * Reference to the Recast library
  66947. */
  66948. bjsRECAST: any;
  66949. /**
  66950. * plugin name
  66951. */
  66952. name: string;
  66953. /**
  66954. * the first navmesh created. We might extend this to support multiple navmeshes
  66955. */
  66956. navMesh: any;
  66957. /**
  66958. * Initializes the recastJS plugin
  66959. * @param recastInjection can be used to inject your own recast reference
  66960. */
  66961. constructor(recastInjection?: any);
  66962. /**
  66963. * Creates a navigation mesh
  66964. * @param meshes array of all the geometry used to compute the navigatio mesh
  66965. * @param parameters bunch of parameters used to filter geometry
  66966. */
  66967. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66968. /**
  66969. * Create a navigation mesh debug mesh
  66970. * @param scene is where the mesh will be added
  66971. * @returns debug display mesh
  66972. */
  66973. createDebugNavMesh(scene: Scene): Mesh;
  66974. /**
  66975. * Get a navigation mesh constrained position, closest to the parameter position
  66976. * @param position world position
  66977. * @returns the closest point to position constrained by the navigation mesh
  66978. */
  66979. getClosestPoint(position: Vector3): Vector3;
  66980. /**
  66981. * Get a navigation mesh constrained position, closest to the parameter position
  66982. * @param position world position
  66983. * @param result output the closest point to position constrained by the navigation mesh
  66984. */
  66985. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66986. /**
  66987. * Get a navigation mesh constrained position, within a particular radius
  66988. * @param position world position
  66989. * @param maxRadius the maximum distance to the constrained world position
  66990. * @returns the closest point to position constrained by the navigation mesh
  66991. */
  66992. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66993. /**
  66994. * Get a navigation mesh constrained position, within a particular radius
  66995. * @param position world position
  66996. * @param maxRadius the maximum distance to the constrained world position
  66997. * @param result output the closest point to position constrained by the navigation mesh
  66998. */
  66999. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67000. /**
  67001. * Compute the final position from a segment made of destination-position
  67002. * @param position world position
  67003. * @param destination world position
  67004. * @returns the resulting point along the navmesh
  67005. */
  67006. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67007. /**
  67008. * Compute the final position from a segment made of destination-position
  67009. * @param position world position
  67010. * @param destination world position
  67011. * @param result output the resulting point along the navmesh
  67012. */
  67013. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67014. /**
  67015. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67016. * @param start world position
  67017. * @param end world position
  67018. * @returns array containing world position composing the path
  67019. */
  67020. computePath(start: Vector3, end: Vector3): Vector3[];
  67021. /**
  67022. * Create a new Crowd so you can add agents
  67023. * @param maxAgents the maximum agent count in the crowd
  67024. * @param maxAgentRadius the maximum radius an agent can have
  67025. * @param scene to attach the crowd to
  67026. * @returns the crowd you can add agents to
  67027. */
  67028. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67029. /**
  67030. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67031. * The queries will try to find a solution within those bounds
  67032. * default is (1,1,1)
  67033. * @param extent x,y,z value that define the extent around the queries point of reference
  67034. */
  67035. setDefaultQueryExtent(extent: Vector3): void;
  67036. /**
  67037. * Get the Bounding box extent specified by setDefaultQueryExtent
  67038. * @returns the box extent values
  67039. */
  67040. getDefaultQueryExtent(): Vector3;
  67041. /**
  67042. * build the navmesh from a previously saved state using getNavmeshData
  67043. * @param data the Uint8Array returned by getNavmeshData
  67044. */
  67045. buildFromNavmeshData(data: Uint8Array): void;
  67046. /**
  67047. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67048. * @returns data the Uint8Array that can be saved and reused
  67049. */
  67050. getNavmeshData(): Uint8Array;
  67051. /**
  67052. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67053. * @param result output the box extent values
  67054. */
  67055. getDefaultQueryExtentToRef(result: Vector3): void;
  67056. /**
  67057. * Disposes
  67058. */
  67059. dispose(): void;
  67060. /**
  67061. * If this plugin is supported
  67062. * @returns true if plugin is supported
  67063. */
  67064. isSupported(): boolean;
  67065. }
  67066. /**
  67067. * Recast detour crowd implementation
  67068. */
  67069. export class RecastJSCrowd implements ICrowd {
  67070. /**
  67071. * Recast/detour plugin
  67072. */
  67073. bjsRECASTPlugin: RecastJSPlugin;
  67074. /**
  67075. * Link to the detour crowd
  67076. */
  67077. recastCrowd: any;
  67078. /**
  67079. * One transform per agent
  67080. */
  67081. transforms: TransformNode[];
  67082. /**
  67083. * All agents created
  67084. */
  67085. agents: number[];
  67086. /**
  67087. * Link to the scene is kept to unregister the crowd from the scene
  67088. */
  67089. private _scene;
  67090. /**
  67091. * Observer for crowd updates
  67092. */
  67093. private _onBeforeAnimationsObserver;
  67094. /**
  67095. * Constructor
  67096. * @param plugin recastJS plugin
  67097. * @param maxAgents the maximum agent count in the crowd
  67098. * @param maxAgentRadius the maximum radius an agent can have
  67099. * @param scene to attach the crowd to
  67100. * @returns the crowd you can add agents to
  67101. */
  67102. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67103. /**
  67104. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67105. * You can attach anything to that node. The node position is updated in the scene update tick.
  67106. * @param pos world position that will be constrained by the navigation mesh
  67107. * @param parameters agent parameters
  67108. * @param transform hooked to the agent that will be update by the scene
  67109. * @returns agent index
  67110. */
  67111. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67112. /**
  67113. * Returns the agent position in world space
  67114. * @param index agent index returned by addAgent
  67115. * @returns world space position
  67116. */
  67117. getAgentPosition(index: number): Vector3;
  67118. /**
  67119. * Returns the agent position result in world space
  67120. * @param index agent index returned by addAgent
  67121. * @param result output world space position
  67122. */
  67123. getAgentPositionToRef(index: number, result: Vector3): void;
  67124. /**
  67125. * Returns the agent velocity in world space
  67126. * @param index agent index returned by addAgent
  67127. * @returns world space velocity
  67128. */
  67129. getAgentVelocity(index: number): Vector3;
  67130. /**
  67131. * Returns the agent velocity result in world space
  67132. * @param index agent index returned by addAgent
  67133. * @param result output world space velocity
  67134. */
  67135. getAgentVelocityToRef(index: number, result: Vector3): void;
  67136. /**
  67137. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67138. * @param index agent index returned by addAgent
  67139. * @param destination targeted world position
  67140. */
  67141. agentGoto(index: number, destination: Vector3): void;
  67142. /**
  67143. * Teleport the agent to a new position
  67144. * @param index agent index returned by addAgent
  67145. * @param destination targeted world position
  67146. */
  67147. agentTeleport(index: number, destination: Vector3): void;
  67148. /**
  67149. * Update agent parameters
  67150. * @param index agent index returned by addAgent
  67151. * @param parameters agent parameters
  67152. */
  67153. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67154. /**
  67155. * remove a particular agent previously created
  67156. * @param index agent index returned by addAgent
  67157. */
  67158. removeAgent(index: number): void;
  67159. /**
  67160. * get the list of all agents attached to this crowd
  67161. * @returns list of agent indices
  67162. */
  67163. getAgents(): number[];
  67164. /**
  67165. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67166. * @param deltaTime in seconds
  67167. */
  67168. update(deltaTime: number): void;
  67169. /**
  67170. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67171. * The queries will try to find a solution within those bounds
  67172. * default is (1,1,1)
  67173. * @param extent x,y,z value that define the extent around the queries point of reference
  67174. */
  67175. setDefaultQueryExtent(extent: Vector3): void;
  67176. /**
  67177. * Get the Bounding box extent specified by setDefaultQueryExtent
  67178. * @returns the box extent values
  67179. */
  67180. getDefaultQueryExtent(): Vector3;
  67181. /**
  67182. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67183. * @param result output the box extent values
  67184. */
  67185. getDefaultQueryExtentToRef(result: Vector3): void;
  67186. /**
  67187. * Release all resources
  67188. */
  67189. dispose(): void;
  67190. }
  67191. }
  67192. declare module BABYLON {
  67193. /**
  67194. * Class used to enable access to IndexedDB
  67195. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67196. */
  67197. export class Database implements IOfflineProvider {
  67198. private _callbackManifestChecked;
  67199. private _currentSceneUrl;
  67200. private _db;
  67201. private _enableSceneOffline;
  67202. private _enableTexturesOffline;
  67203. private _manifestVersionFound;
  67204. private _mustUpdateRessources;
  67205. private _hasReachedQuota;
  67206. private _isSupported;
  67207. private _idbFactory;
  67208. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67209. private static IsUASupportingBlobStorage;
  67210. /**
  67211. * Gets a boolean indicating if Database storate is enabled (off by default)
  67212. */
  67213. static IDBStorageEnabled: boolean;
  67214. /**
  67215. * Gets a boolean indicating if scene must be saved in the database
  67216. */
  67217. get enableSceneOffline(): boolean;
  67218. /**
  67219. * Gets a boolean indicating if textures must be saved in the database
  67220. */
  67221. get enableTexturesOffline(): boolean;
  67222. /**
  67223. * Creates a new Database
  67224. * @param urlToScene defines the url to load the scene
  67225. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67226. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67227. */
  67228. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67229. private static _ParseURL;
  67230. private static _ReturnFullUrlLocation;
  67231. private _checkManifestFile;
  67232. /**
  67233. * Open the database and make it available
  67234. * @param successCallback defines the callback to call on success
  67235. * @param errorCallback defines the callback to call on error
  67236. */
  67237. open(successCallback: () => void, errorCallback: () => void): void;
  67238. /**
  67239. * Loads an image from the database
  67240. * @param url defines the url to load from
  67241. * @param image defines the target DOM image
  67242. */
  67243. loadImage(url: string, image: HTMLImageElement): void;
  67244. private _loadImageFromDBAsync;
  67245. private _saveImageIntoDBAsync;
  67246. private _checkVersionFromDB;
  67247. private _loadVersionFromDBAsync;
  67248. private _saveVersionIntoDBAsync;
  67249. /**
  67250. * Loads a file from database
  67251. * @param url defines the URL to load from
  67252. * @param sceneLoaded defines a callback to call on success
  67253. * @param progressCallBack defines a callback to call when progress changed
  67254. * @param errorCallback defines a callback to call on error
  67255. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67256. */
  67257. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67258. private _loadFileAsync;
  67259. private _saveFileAsync;
  67260. /**
  67261. * Validates if xhr data is correct
  67262. * @param xhr defines the request to validate
  67263. * @param dataType defines the expected data type
  67264. * @returns true if data is correct
  67265. */
  67266. private static _ValidateXHRData;
  67267. }
  67268. }
  67269. declare module BABYLON {
  67270. /** @hidden */
  67271. export var gpuUpdateParticlesPixelShader: {
  67272. name: string;
  67273. shader: string;
  67274. };
  67275. }
  67276. declare module BABYLON {
  67277. /** @hidden */
  67278. export var gpuUpdateParticlesVertexShader: {
  67279. name: string;
  67280. shader: string;
  67281. };
  67282. }
  67283. declare module BABYLON {
  67284. /** @hidden */
  67285. export var clipPlaneFragmentDeclaration2: {
  67286. name: string;
  67287. shader: string;
  67288. };
  67289. }
  67290. declare module BABYLON {
  67291. /** @hidden */
  67292. export var gpuRenderParticlesPixelShader: {
  67293. name: string;
  67294. shader: string;
  67295. };
  67296. }
  67297. declare module BABYLON {
  67298. /** @hidden */
  67299. export var clipPlaneVertexDeclaration2: {
  67300. name: string;
  67301. shader: string;
  67302. };
  67303. }
  67304. declare module BABYLON {
  67305. /** @hidden */
  67306. export var gpuRenderParticlesVertexShader: {
  67307. name: string;
  67308. shader: string;
  67309. };
  67310. }
  67311. declare module BABYLON {
  67312. /**
  67313. * This represents a GPU particle system in Babylon
  67314. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67315. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67316. */
  67317. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67318. /**
  67319. * The layer mask we are rendering the particles through.
  67320. */
  67321. layerMask: number;
  67322. private _capacity;
  67323. private _activeCount;
  67324. private _currentActiveCount;
  67325. private _accumulatedCount;
  67326. private _renderEffect;
  67327. private _updateEffect;
  67328. private _buffer0;
  67329. private _buffer1;
  67330. private _spriteBuffer;
  67331. private _updateVAO;
  67332. private _renderVAO;
  67333. private _targetIndex;
  67334. private _sourceBuffer;
  67335. private _targetBuffer;
  67336. private _currentRenderId;
  67337. private _started;
  67338. private _stopped;
  67339. private _timeDelta;
  67340. private _randomTexture;
  67341. private _randomTexture2;
  67342. private _attributesStrideSize;
  67343. private _updateEffectOptions;
  67344. private _randomTextureSize;
  67345. private _actualFrame;
  67346. private _customEffect;
  67347. private readonly _rawTextureWidth;
  67348. /**
  67349. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67350. */
  67351. static get IsSupported(): boolean;
  67352. /**
  67353. * An event triggered when the system is disposed.
  67354. */
  67355. onDisposeObservable: Observable<IParticleSystem>;
  67356. /**
  67357. * Gets the maximum number of particles active at the same time.
  67358. * @returns The max number of active particles.
  67359. */
  67360. getCapacity(): number;
  67361. /**
  67362. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67363. * to override the particles.
  67364. */
  67365. forceDepthWrite: boolean;
  67366. /**
  67367. * Gets or set the number of active particles
  67368. */
  67369. get activeParticleCount(): number;
  67370. set activeParticleCount(value: number);
  67371. private _preWarmDone;
  67372. /**
  67373. * Specifies if the particles are updated in emitter local space or world space.
  67374. */
  67375. isLocal: boolean;
  67376. /** Gets or sets a matrix to use to compute projection */
  67377. defaultProjectionMatrix: Matrix;
  67378. /**
  67379. * Is this system ready to be used/rendered
  67380. * @return true if the system is ready
  67381. */
  67382. isReady(): boolean;
  67383. /**
  67384. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67385. * @returns True if it has been started, otherwise false.
  67386. */
  67387. isStarted(): boolean;
  67388. /**
  67389. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67390. * @returns True if it has been stopped, otherwise false.
  67391. */
  67392. isStopped(): boolean;
  67393. /**
  67394. * Gets a boolean indicating that the system is stopping
  67395. * @returns true if the system is currently stopping
  67396. */
  67397. isStopping(): boolean;
  67398. /**
  67399. * Gets the number of particles active at the same time.
  67400. * @returns The number of active particles.
  67401. */
  67402. getActiveCount(): number;
  67403. /**
  67404. * Starts the particle system and begins to emit
  67405. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67406. */
  67407. start(delay?: number): void;
  67408. /**
  67409. * Stops the particle system.
  67410. */
  67411. stop(): void;
  67412. /**
  67413. * Remove all active particles
  67414. */
  67415. reset(): void;
  67416. /**
  67417. * Returns the string "GPUParticleSystem"
  67418. * @returns a string containing the class name
  67419. */
  67420. getClassName(): string;
  67421. /**
  67422. * Gets the custom effect used to render the particles
  67423. * @param blendMode Blend mode for which the effect should be retrieved
  67424. * @returns The effect
  67425. */
  67426. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67427. /**
  67428. * Sets the custom effect used to render the particles
  67429. * @param effect The effect to set
  67430. * @param blendMode Blend mode for which the effect should be set
  67431. */
  67432. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67433. /** @hidden */
  67434. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67435. /**
  67436. * Observable that will be called just before the particles are drawn
  67437. */
  67438. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67439. /**
  67440. * Gets the name of the particle vertex shader
  67441. */
  67442. get vertexShaderName(): string;
  67443. private _colorGradientsTexture;
  67444. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67445. /**
  67446. * Adds a new color gradient
  67447. * @param gradient defines the gradient to use (between 0 and 1)
  67448. * @param color1 defines the color to affect to the specified gradient
  67449. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67450. * @returns the current particle system
  67451. */
  67452. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67453. private _refreshColorGradient;
  67454. /** Force the system to rebuild all gradients that need to be resync */
  67455. forceRefreshGradients(): void;
  67456. /**
  67457. * Remove a specific color gradient
  67458. * @param gradient defines the gradient to remove
  67459. * @returns the current particle system
  67460. */
  67461. removeColorGradient(gradient: number): GPUParticleSystem;
  67462. private _angularSpeedGradientsTexture;
  67463. private _sizeGradientsTexture;
  67464. private _velocityGradientsTexture;
  67465. private _limitVelocityGradientsTexture;
  67466. private _dragGradientsTexture;
  67467. private _addFactorGradient;
  67468. /**
  67469. * Adds a new size gradient
  67470. * @param gradient defines the gradient to use (between 0 and 1)
  67471. * @param factor defines the size factor to affect to the specified gradient
  67472. * @returns the current particle system
  67473. */
  67474. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67475. /**
  67476. * Remove a specific size gradient
  67477. * @param gradient defines the gradient to remove
  67478. * @returns the current particle system
  67479. */
  67480. removeSizeGradient(gradient: number): GPUParticleSystem;
  67481. private _refreshFactorGradient;
  67482. /**
  67483. * Adds a new angular speed gradient
  67484. * @param gradient defines the gradient to use (between 0 and 1)
  67485. * @param factor defines the angular speed to affect to the specified gradient
  67486. * @returns the current particle system
  67487. */
  67488. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67489. /**
  67490. * Remove a specific angular speed gradient
  67491. * @param gradient defines the gradient to remove
  67492. * @returns the current particle system
  67493. */
  67494. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67495. /**
  67496. * Adds a new velocity gradient
  67497. * @param gradient defines the gradient to use (between 0 and 1)
  67498. * @param factor defines the velocity to affect to the specified gradient
  67499. * @returns the current particle system
  67500. */
  67501. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67502. /**
  67503. * Remove a specific velocity gradient
  67504. * @param gradient defines the gradient to remove
  67505. * @returns the current particle system
  67506. */
  67507. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67508. /**
  67509. * Adds a new limit velocity gradient
  67510. * @param gradient defines the gradient to use (between 0 and 1)
  67511. * @param factor defines the limit velocity value to affect to the specified gradient
  67512. * @returns the current particle system
  67513. */
  67514. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67515. /**
  67516. * Remove a specific limit velocity gradient
  67517. * @param gradient defines the gradient to remove
  67518. * @returns the current particle system
  67519. */
  67520. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67521. /**
  67522. * Adds a new drag gradient
  67523. * @param gradient defines the gradient to use (between 0 and 1)
  67524. * @param factor defines the drag value to affect to the specified gradient
  67525. * @returns the current particle system
  67526. */
  67527. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67528. /**
  67529. * Remove a specific drag gradient
  67530. * @param gradient defines the gradient to remove
  67531. * @returns the current particle system
  67532. */
  67533. removeDragGradient(gradient: number): GPUParticleSystem;
  67534. /**
  67535. * Not supported by GPUParticleSystem
  67536. * @param gradient defines the gradient to use (between 0 and 1)
  67537. * @param factor defines the emit rate value to affect to the specified gradient
  67538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67539. * @returns the current particle system
  67540. */
  67541. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67542. /**
  67543. * Not supported by GPUParticleSystem
  67544. * @param gradient defines the gradient to remove
  67545. * @returns the current particle system
  67546. */
  67547. removeEmitRateGradient(gradient: number): IParticleSystem;
  67548. /**
  67549. * Not supported by GPUParticleSystem
  67550. * @param gradient defines the gradient to use (between 0 and 1)
  67551. * @param factor defines the start size value to affect to the specified gradient
  67552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67553. * @returns the current particle system
  67554. */
  67555. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67556. /**
  67557. * Not supported by GPUParticleSystem
  67558. * @param gradient defines the gradient to remove
  67559. * @returns the current particle system
  67560. */
  67561. removeStartSizeGradient(gradient: number): IParticleSystem;
  67562. /**
  67563. * Not supported by GPUParticleSystem
  67564. * @param gradient defines the gradient to use (between 0 and 1)
  67565. * @param min defines the color remap minimal range
  67566. * @param max defines the color remap maximal range
  67567. * @returns the current particle system
  67568. */
  67569. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67570. /**
  67571. * Not supported by GPUParticleSystem
  67572. * @param gradient defines the gradient to remove
  67573. * @returns the current particle system
  67574. */
  67575. removeColorRemapGradient(): IParticleSystem;
  67576. /**
  67577. * Not supported by GPUParticleSystem
  67578. * @param gradient defines the gradient to use (between 0 and 1)
  67579. * @param min defines the alpha remap minimal range
  67580. * @param max defines the alpha remap maximal range
  67581. * @returns the current particle system
  67582. */
  67583. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67584. /**
  67585. * Not supported by GPUParticleSystem
  67586. * @param gradient defines the gradient to remove
  67587. * @returns the current particle system
  67588. */
  67589. removeAlphaRemapGradient(): IParticleSystem;
  67590. /**
  67591. * Not supported by GPUParticleSystem
  67592. * @param gradient defines the gradient to use (between 0 and 1)
  67593. * @param color defines the color to affect to the specified gradient
  67594. * @returns the current particle system
  67595. */
  67596. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67597. /**
  67598. * Not supported by GPUParticleSystem
  67599. * @param gradient defines the gradient to remove
  67600. * @returns the current particle system
  67601. */
  67602. removeRampGradient(): IParticleSystem;
  67603. /**
  67604. * Not supported by GPUParticleSystem
  67605. * @returns the list of ramp gradients
  67606. */
  67607. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67608. /**
  67609. * Not supported by GPUParticleSystem
  67610. * Gets or sets a boolean indicating that ramp gradients must be used
  67611. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67612. */
  67613. get useRampGradients(): boolean;
  67614. set useRampGradients(value: boolean);
  67615. /**
  67616. * Not supported by GPUParticleSystem
  67617. * @param gradient defines the gradient to use (between 0 and 1)
  67618. * @param factor defines the life time factor to affect to the specified gradient
  67619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67620. * @returns the current particle system
  67621. */
  67622. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67623. /**
  67624. * Not supported by GPUParticleSystem
  67625. * @param gradient defines the gradient to remove
  67626. * @returns the current particle system
  67627. */
  67628. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67629. /**
  67630. * Instantiates a GPU particle system.
  67631. * 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.
  67632. * @param name The name of the particle system
  67633. * @param options The options used to create the system
  67634. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67635. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67636. * @param customEffect a custom effect used to change the way particles are rendered by default
  67637. */
  67638. constructor(name: string, options: Partial<{
  67639. capacity: number;
  67640. randomTextureSize: number;
  67641. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67642. protected _reset(): void;
  67643. private _createUpdateVAO;
  67644. private _createRenderVAO;
  67645. private _initialize;
  67646. /** @hidden */
  67647. _recreateUpdateEffect(): void;
  67648. private _getEffect;
  67649. /**
  67650. * Fill the defines array according to the current settings of the particle system
  67651. * @param defines Array to be updated
  67652. * @param blendMode blend mode to take into account when updating the array
  67653. */
  67654. fillDefines(defines: Array<string>, blendMode?: number): void;
  67655. /**
  67656. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67657. * @param uniforms Uniforms array to fill
  67658. * @param attributes Attributes array to fill
  67659. * @param samplers Samplers array to fill
  67660. */
  67661. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67662. /** @hidden */
  67663. _recreateRenderEffect(): Effect;
  67664. /**
  67665. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67666. * @param preWarm defines if we are in the pre-warmimg phase
  67667. */
  67668. animate(preWarm?: boolean): void;
  67669. private _createFactorGradientTexture;
  67670. private _createSizeGradientTexture;
  67671. private _createAngularSpeedGradientTexture;
  67672. private _createVelocityGradientTexture;
  67673. private _createLimitVelocityGradientTexture;
  67674. private _createDragGradientTexture;
  67675. private _createColorGradientTexture;
  67676. /**
  67677. * Renders the particle system in its current state
  67678. * @param preWarm defines if the system should only update the particles but not render them
  67679. * @returns the current number of particles
  67680. */
  67681. render(preWarm?: boolean): number;
  67682. /**
  67683. * Rebuilds the particle system
  67684. */
  67685. rebuild(): void;
  67686. private _releaseBuffers;
  67687. private _releaseVAOs;
  67688. /**
  67689. * Disposes the particle system and free the associated resources
  67690. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67691. */
  67692. dispose(disposeTexture?: boolean): void;
  67693. /**
  67694. * Clones the particle system.
  67695. * @param name The name of the cloned object
  67696. * @param newEmitter The new emitter to use
  67697. * @returns the cloned particle system
  67698. */
  67699. clone(name: string, newEmitter: any): GPUParticleSystem;
  67700. /**
  67701. * Serializes the particle system to a JSON object
  67702. * @param serializeTexture defines if the texture must be serialized as well
  67703. * @returns the JSON object
  67704. */
  67705. serialize(serializeTexture?: boolean): any;
  67706. /**
  67707. * Parses a JSON object to create a GPU particle system.
  67708. * @param parsedParticleSystem The JSON object to parse
  67709. * @param sceneOrEngine The scene or the engine to create the particle system in
  67710. * @param rootUrl The root url to use to load external dependencies like texture
  67711. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67712. * @returns the parsed GPU particle system
  67713. */
  67714. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67715. }
  67716. }
  67717. declare module BABYLON {
  67718. /**
  67719. * Represents a set of particle systems working together to create a specific effect
  67720. */
  67721. export class ParticleSystemSet implements IDisposable {
  67722. /**
  67723. * Gets or sets base Assets URL
  67724. */
  67725. static BaseAssetsUrl: string;
  67726. private _emitterCreationOptions;
  67727. private _emitterNode;
  67728. /**
  67729. * Gets the particle system list
  67730. */
  67731. systems: IParticleSystem[];
  67732. /**
  67733. * Gets the emitter node used with this set
  67734. */
  67735. get emitterNode(): Nullable<TransformNode>;
  67736. /**
  67737. * Creates a new emitter mesh as a sphere
  67738. * @param options defines the options used to create the sphere
  67739. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67740. * @param scene defines the hosting scene
  67741. */
  67742. setEmitterAsSphere(options: {
  67743. diameter: number;
  67744. segments: number;
  67745. color: Color3;
  67746. }, renderingGroupId: number, scene: Scene): void;
  67747. /**
  67748. * Starts all particle systems of the set
  67749. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67750. */
  67751. start(emitter?: AbstractMesh): void;
  67752. /**
  67753. * Release all associated resources
  67754. */
  67755. dispose(): void;
  67756. /**
  67757. * Serialize the set into a JSON compatible object
  67758. * @param serializeTexture defines if the texture must be serialized as well
  67759. * @returns a JSON compatible representation of the set
  67760. */
  67761. serialize(serializeTexture?: boolean): any;
  67762. /**
  67763. * Parse a new ParticleSystemSet from a serialized source
  67764. * @param data defines a JSON compatible representation of the set
  67765. * @param scene defines the hosting scene
  67766. * @param gpu defines if we want GPU particles or CPU particles
  67767. * @returns a new ParticleSystemSet
  67768. */
  67769. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67770. }
  67771. }
  67772. declare module BABYLON {
  67773. /**
  67774. * This class is made for on one-liner static method to help creating particle system set.
  67775. */
  67776. export class ParticleHelper {
  67777. /**
  67778. * Gets or sets base Assets URL
  67779. */
  67780. static BaseAssetsUrl: string;
  67781. /** Define the Url to load snippets */
  67782. static SnippetUrl: string;
  67783. /**
  67784. * Create a default particle system that you can tweak
  67785. * @param emitter defines the emitter to use
  67786. * @param capacity defines the system capacity (default is 500 particles)
  67787. * @param scene defines the hosting scene
  67788. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67789. * @returns the new Particle system
  67790. */
  67791. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67792. /**
  67793. * This is the main static method (one-liner) of this helper to create different particle systems
  67794. * @param type This string represents the type to the particle system to create
  67795. * @param scene The scene where the particle system should live
  67796. * @param gpu If the system will use gpu
  67797. * @returns the ParticleSystemSet created
  67798. */
  67799. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67800. /**
  67801. * Static function used to export a particle system to a ParticleSystemSet variable.
  67802. * Please note that the emitter shape is not exported
  67803. * @param systems defines the particle systems to export
  67804. * @returns the created particle system set
  67805. */
  67806. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67807. /**
  67808. * Creates a particle system from a snippet saved in a remote file
  67809. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67810. * @param url defines the url to load from
  67811. * @param scene defines the hosting scene
  67812. * @param gpu If the system will use gpu
  67813. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67814. * @returns a promise that will resolve to the new particle system
  67815. */
  67816. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67817. /**
  67818. * Creates a particle system from a snippet saved by the particle system editor
  67819. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67820. * @param scene defines the hosting scene
  67821. * @param gpu If the system will use gpu
  67822. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67823. * @returns a promise that will resolve to the new particle system
  67824. */
  67825. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67826. }
  67827. }
  67828. declare module BABYLON {
  67829. interface Engine {
  67830. /**
  67831. * Create an effect to use with particle systems.
  67832. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67833. * the particle system for which you want to create a custom effect in the last parameter
  67834. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67835. * @param uniformsNames defines a list of attribute names
  67836. * @param samplers defines an array of string used to represent textures
  67837. * @param defines defines the string containing the defines to use to compile the shaders
  67838. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67839. * @param onCompiled defines a function to call when the effect creation is successful
  67840. * @param onError defines a function to call when the effect creation has failed
  67841. * @param particleSystem the particle system you want to create the effect for
  67842. * @returns the new Effect
  67843. */
  67844. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67845. }
  67846. interface Mesh {
  67847. /**
  67848. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67849. * @returns an array of IParticleSystem
  67850. */
  67851. getEmittedParticleSystems(): IParticleSystem[];
  67852. /**
  67853. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67854. * @returns an array of IParticleSystem
  67855. */
  67856. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67857. }
  67858. }
  67859. declare module BABYLON {
  67860. /** Defines the 4 color options */
  67861. export enum PointColor {
  67862. /** color value */
  67863. Color = 2,
  67864. /** uv value */
  67865. UV = 1,
  67866. /** random value */
  67867. Random = 0,
  67868. /** stated value */
  67869. Stated = 3
  67870. }
  67871. /**
  67872. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67873. * 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.
  67874. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67875. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67876. *
  67877. * Full documentation here : TO BE ENTERED
  67878. */
  67879. export class PointsCloudSystem implements IDisposable {
  67880. /**
  67881. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67882. * Example : var p = SPS.particles[i];
  67883. */
  67884. particles: CloudPoint[];
  67885. /**
  67886. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67887. */
  67888. nbParticles: number;
  67889. /**
  67890. * This a counter for your own usage. It's not set by any SPS functions.
  67891. */
  67892. counter: number;
  67893. /**
  67894. * The PCS name. This name is also given to the underlying mesh.
  67895. */
  67896. name: string;
  67897. /**
  67898. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67899. */
  67900. mesh: Mesh;
  67901. /**
  67902. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67903. * Please read :
  67904. */
  67905. vars: any;
  67906. /**
  67907. * @hidden
  67908. */
  67909. _size: number;
  67910. private _scene;
  67911. private _promises;
  67912. private _positions;
  67913. private _indices;
  67914. private _normals;
  67915. private _colors;
  67916. private _uvs;
  67917. private _indices32;
  67918. private _positions32;
  67919. private _colors32;
  67920. private _uvs32;
  67921. private _updatable;
  67922. private _isVisibilityBoxLocked;
  67923. private _alwaysVisible;
  67924. private _groups;
  67925. private _groupCounter;
  67926. private _computeParticleColor;
  67927. private _computeParticleTexture;
  67928. private _computeParticleRotation;
  67929. private _computeBoundingBox;
  67930. private _isReady;
  67931. /**
  67932. * Creates a PCS (Points Cloud System) object
  67933. * @param name (String) is the PCS name, this will be the underlying mesh name
  67934. * @param pointSize (number) is the size for each point
  67935. * @param scene (Scene) is the scene in which the PCS is added
  67936. * @param options defines the options of the PCS e.g.
  67937. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67938. */
  67939. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67940. updatable?: boolean;
  67941. });
  67942. /**
  67943. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67944. * If no points were added to the PCS, the returned mesh is just a single point.
  67945. * @returns a promise for the created mesh
  67946. */
  67947. buildMeshAsync(): Promise<Mesh>;
  67948. /**
  67949. * @hidden
  67950. */
  67951. private _buildMesh;
  67952. private _addParticle;
  67953. private _randomUnitVector;
  67954. private _getColorIndicesForCoord;
  67955. private _setPointsColorOrUV;
  67956. private _colorFromTexture;
  67957. private _calculateDensity;
  67958. /**
  67959. * Adds points to the PCS in random positions within a unit sphere
  67960. * @param nb (positive integer) the number of particles to be created from this model
  67961. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67962. * @returns the number of groups in the system
  67963. */
  67964. addPoints(nb: number, pointFunction?: any): number;
  67965. /**
  67966. * Adds points to the PCS from the surface of the model shape
  67967. * @param mesh is any Mesh object that will be used as a surface model for the points
  67968. * @param nb (positive integer) the number of particles to be created from this model
  67969. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67970. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67971. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67972. * @returns the number of groups in the system
  67973. */
  67974. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67975. /**
  67976. * Adds points to the PCS inside the model shape
  67977. * @param mesh is any Mesh object that will be used as a surface model for the points
  67978. * @param nb (positive integer) the number of particles to be created from this model
  67979. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67980. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67981. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67982. * @returns the number of groups in the system
  67983. */
  67984. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67985. /**
  67986. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67987. * This method calls `updateParticle()` for each particle of the SPS.
  67988. * For an animated SPS, it is usually called within the render loop.
  67989. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67990. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67991. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67992. * @returns the PCS.
  67993. */
  67994. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67995. /**
  67996. * Disposes the PCS.
  67997. */
  67998. dispose(): void;
  67999. /**
  68000. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68001. * doc :
  68002. * @returns the PCS.
  68003. */
  68004. refreshVisibleSize(): PointsCloudSystem;
  68005. /**
  68006. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68007. * @param size the size (float) of the visibility box
  68008. * note : this doesn't lock the PCS mesh bounding box.
  68009. * doc :
  68010. */
  68011. setVisibilityBox(size: number): void;
  68012. /**
  68013. * Gets whether the PCS is always visible or not
  68014. * doc :
  68015. */
  68016. get isAlwaysVisible(): boolean;
  68017. /**
  68018. * Sets the PCS as always visible or not
  68019. * doc :
  68020. */
  68021. set isAlwaysVisible(val: boolean);
  68022. /**
  68023. * Tells to `setParticles()` to compute the particle rotations or not
  68024. * Default value : false. The PCS is faster when it's set to false
  68025. * Note : particle rotations are only applied to parent particles
  68026. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68027. */
  68028. set computeParticleRotation(val: boolean);
  68029. /**
  68030. * Tells to `setParticles()` to compute the particle colors or not.
  68031. * Default value : true. The PCS is faster when it's set to false.
  68032. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68033. */
  68034. set computeParticleColor(val: boolean);
  68035. set computeParticleTexture(val: boolean);
  68036. /**
  68037. * Gets if `setParticles()` computes the particle colors or not.
  68038. * Default value : false. The PCS is faster when it's set to false.
  68039. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68040. */
  68041. get computeParticleColor(): boolean;
  68042. /**
  68043. * Gets if `setParticles()` computes the particle textures or not.
  68044. * Default value : false. The PCS is faster when it's set to false.
  68045. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68046. */
  68047. get computeParticleTexture(): boolean;
  68048. /**
  68049. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68050. */
  68051. set computeBoundingBox(val: boolean);
  68052. /**
  68053. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68054. */
  68055. get computeBoundingBox(): boolean;
  68056. /**
  68057. * This function does nothing. It may be overwritten to set all the particle first values.
  68058. * The PCS doesn't call this function, you may have to call it by your own.
  68059. * doc :
  68060. */
  68061. initParticles(): void;
  68062. /**
  68063. * This function does nothing. It may be overwritten to recycle a particle
  68064. * The PCS doesn't call this function, you can to call it
  68065. * doc :
  68066. * @param particle The particle to recycle
  68067. * @returns the recycled particle
  68068. */
  68069. recycleParticle(particle: CloudPoint): CloudPoint;
  68070. /**
  68071. * Updates a particle : this function should be overwritten by the user.
  68072. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68073. * doc :
  68074. * @example : just set a particle position or velocity and recycle conditions
  68075. * @param particle The particle to update
  68076. * @returns the updated particle
  68077. */
  68078. updateParticle(particle: CloudPoint): CloudPoint;
  68079. /**
  68080. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68081. * This does nothing and may be overwritten by the user.
  68082. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68083. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68084. * @param update the boolean update value actually passed to setParticles()
  68085. */
  68086. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68087. /**
  68088. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68089. * This will be passed three parameters.
  68090. * This does nothing and may be overwritten by the user.
  68091. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68092. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68093. * @param update the boolean update value actually passed to setParticles()
  68094. */
  68095. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68096. }
  68097. }
  68098. declare module BABYLON {
  68099. /**
  68100. * Represents one particle of a points cloud system.
  68101. */
  68102. export class CloudPoint {
  68103. /**
  68104. * particle global index
  68105. */
  68106. idx: number;
  68107. /**
  68108. * The color of the particle
  68109. */
  68110. color: Nullable<Color4>;
  68111. /**
  68112. * The world space position of the particle.
  68113. */
  68114. position: Vector3;
  68115. /**
  68116. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68117. */
  68118. rotation: Vector3;
  68119. /**
  68120. * The world space rotation quaternion of the particle.
  68121. */
  68122. rotationQuaternion: Nullable<Quaternion>;
  68123. /**
  68124. * The uv of the particle.
  68125. */
  68126. uv: Nullable<Vector2>;
  68127. /**
  68128. * The current speed of the particle.
  68129. */
  68130. velocity: Vector3;
  68131. /**
  68132. * The pivot point in the particle local space.
  68133. */
  68134. pivot: Vector3;
  68135. /**
  68136. * Must the particle be translated from its pivot point in its local space ?
  68137. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68138. * Default : false
  68139. */
  68140. translateFromPivot: boolean;
  68141. /**
  68142. * Index of this particle in the global "positions" array (Internal use)
  68143. * @hidden
  68144. */
  68145. _pos: number;
  68146. /**
  68147. * @hidden Index of this particle in the global "indices" array (Internal use)
  68148. */
  68149. _ind: number;
  68150. /**
  68151. * Group this particle belongs to
  68152. */
  68153. _group: PointsGroup;
  68154. /**
  68155. * Group id of this particle
  68156. */
  68157. groupId: number;
  68158. /**
  68159. * Index of the particle in its group id (Internal use)
  68160. */
  68161. idxInGroup: number;
  68162. /**
  68163. * @hidden Particle BoundingInfo object (Internal use)
  68164. */
  68165. _boundingInfo: BoundingInfo;
  68166. /**
  68167. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68168. */
  68169. _pcs: PointsCloudSystem;
  68170. /**
  68171. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68172. */
  68173. _stillInvisible: boolean;
  68174. /**
  68175. * @hidden Last computed particle rotation matrix
  68176. */
  68177. _rotationMatrix: number[];
  68178. /**
  68179. * Parent particle Id, if any.
  68180. * Default null.
  68181. */
  68182. parentId: Nullable<number>;
  68183. /**
  68184. * @hidden Internal global position in the PCS.
  68185. */
  68186. _globalPosition: Vector3;
  68187. /**
  68188. * Creates a Point Cloud object.
  68189. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68190. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68191. * @param group (PointsGroup) is the group the particle belongs to
  68192. * @param groupId (integer) is the group identifier in the PCS.
  68193. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68194. * @param pcs defines the PCS it is associated to
  68195. */
  68196. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68197. /**
  68198. * get point size
  68199. */
  68200. get size(): Vector3;
  68201. /**
  68202. * Set point size
  68203. */
  68204. set size(scale: Vector3);
  68205. /**
  68206. * Legacy support, changed quaternion to rotationQuaternion
  68207. */
  68208. get quaternion(): Nullable<Quaternion>;
  68209. /**
  68210. * Legacy support, changed quaternion to rotationQuaternion
  68211. */
  68212. set quaternion(q: Nullable<Quaternion>);
  68213. /**
  68214. * Returns a boolean. True if the particle intersects a mesh, else false
  68215. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68216. * @param target is the object (point or mesh) what the intersection is computed against
  68217. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68218. * @returns true if it intersects
  68219. */
  68220. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68221. /**
  68222. * get the rotation matrix of the particle
  68223. * @hidden
  68224. */
  68225. getRotationMatrix(m: Matrix): void;
  68226. }
  68227. /**
  68228. * Represents a group of points in a points cloud system
  68229. * * PCS internal tool, don't use it manually.
  68230. */
  68231. export class PointsGroup {
  68232. /**
  68233. * The group id
  68234. * @hidden
  68235. */
  68236. groupID: number;
  68237. /**
  68238. * image data for group (internal use)
  68239. * @hidden
  68240. */
  68241. _groupImageData: Nullable<ArrayBufferView>;
  68242. /**
  68243. * Image Width (internal use)
  68244. * @hidden
  68245. */
  68246. _groupImgWidth: number;
  68247. /**
  68248. * Image Height (internal use)
  68249. * @hidden
  68250. */
  68251. _groupImgHeight: number;
  68252. /**
  68253. * Custom position function (internal use)
  68254. * @hidden
  68255. */
  68256. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68257. /**
  68258. * density per facet for surface points
  68259. * @hidden
  68260. */
  68261. _groupDensity: number[];
  68262. /**
  68263. * Only when points are colored by texture carries pointer to texture list array
  68264. * @hidden
  68265. */
  68266. _textureNb: number;
  68267. /**
  68268. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68269. * PCS internal tool, don't use it manually.
  68270. * @hidden
  68271. */
  68272. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68273. }
  68274. }
  68275. declare module BABYLON {
  68276. interface Scene {
  68277. /** @hidden (Backing field) */
  68278. _physicsEngine: Nullable<IPhysicsEngine>;
  68279. /** @hidden */
  68280. _physicsTimeAccumulator: number;
  68281. /**
  68282. * Gets the current physics engine
  68283. * @returns a IPhysicsEngine or null if none attached
  68284. */
  68285. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68286. /**
  68287. * Enables physics to the current scene
  68288. * @param gravity defines the scene's gravity for the physics engine
  68289. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68290. * @return a boolean indicating if the physics engine was initialized
  68291. */
  68292. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68293. /**
  68294. * Disables and disposes the physics engine associated with the scene
  68295. */
  68296. disablePhysicsEngine(): void;
  68297. /**
  68298. * Gets a boolean indicating if there is an active physics engine
  68299. * @returns a boolean indicating if there is an active physics engine
  68300. */
  68301. isPhysicsEnabled(): boolean;
  68302. /**
  68303. * Deletes a physics compound impostor
  68304. * @param compound defines the compound to delete
  68305. */
  68306. deleteCompoundImpostor(compound: any): void;
  68307. /**
  68308. * An event triggered when physic simulation is about to be run
  68309. */
  68310. onBeforePhysicsObservable: Observable<Scene>;
  68311. /**
  68312. * An event triggered when physic simulation has been done
  68313. */
  68314. onAfterPhysicsObservable: Observable<Scene>;
  68315. }
  68316. interface AbstractMesh {
  68317. /** @hidden */
  68318. _physicsImpostor: Nullable<PhysicsImpostor>;
  68319. /**
  68320. * Gets or sets impostor used for physic simulation
  68321. * @see https://doc.babylonjs.com/features/physics_engine
  68322. */
  68323. physicsImpostor: Nullable<PhysicsImpostor>;
  68324. /**
  68325. * Gets the current physics impostor
  68326. * @see https://doc.babylonjs.com/features/physics_engine
  68327. * @returns a physics impostor or null
  68328. */
  68329. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68330. /** Apply a physic impulse to the mesh
  68331. * @param force defines the force to apply
  68332. * @param contactPoint defines where to apply the force
  68333. * @returns the current mesh
  68334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68335. */
  68336. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68337. /**
  68338. * Creates a physic joint between two meshes
  68339. * @param otherMesh defines the other mesh to use
  68340. * @param pivot1 defines the pivot to use on this mesh
  68341. * @param pivot2 defines the pivot to use on the other mesh
  68342. * @param options defines additional options (can be plugin dependent)
  68343. * @returns the current mesh
  68344. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68345. */
  68346. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68347. /** @hidden */
  68348. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68349. }
  68350. /**
  68351. * Defines the physics engine scene component responsible to manage a physics engine
  68352. */
  68353. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68354. /**
  68355. * The component name helpful to identify the component in the list of scene components.
  68356. */
  68357. readonly name: string;
  68358. /**
  68359. * The scene the component belongs to.
  68360. */
  68361. scene: Scene;
  68362. /**
  68363. * Creates a new instance of the component for the given scene
  68364. * @param scene Defines the scene to register the component in
  68365. */
  68366. constructor(scene: Scene);
  68367. /**
  68368. * Registers the component in a given scene
  68369. */
  68370. register(): void;
  68371. /**
  68372. * Rebuilds the elements related to this component in case of
  68373. * context lost for instance.
  68374. */
  68375. rebuild(): void;
  68376. /**
  68377. * Disposes the component and the associated ressources
  68378. */
  68379. dispose(): void;
  68380. }
  68381. }
  68382. declare module BABYLON {
  68383. /**
  68384. * A helper for physics simulations
  68385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68386. */
  68387. export class PhysicsHelper {
  68388. private _scene;
  68389. private _physicsEngine;
  68390. /**
  68391. * Initializes the Physics helper
  68392. * @param scene Babylon.js scene
  68393. */
  68394. constructor(scene: Scene);
  68395. /**
  68396. * Applies a radial explosion impulse
  68397. * @param origin the origin of the explosion
  68398. * @param radiusOrEventOptions the radius or the options of radial explosion
  68399. * @param strength the explosion strength
  68400. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68401. * @returns A physics radial explosion event, or null
  68402. */
  68403. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68404. /**
  68405. * Applies a radial explosion force
  68406. * @param origin the origin of the explosion
  68407. * @param radiusOrEventOptions the radius or the options of radial explosion
  68408. * @param strength the explosion strength
  68409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68410. * @returns A physics radial explosion event, or null
  68411. */
  68412. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68413. /**
  68414. * Creates a gravitational field
  68415. * @param origin the origin of the explosion
  68416. * @param radiusOrEventOptions the radius or the options of radial explosion
  68417. * @param strength the explosion strength
  68418. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68419. * @returns A physics gravitational field event, or null
  68420. */
  68421. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68422. /**
  68423. * Creates a physics updraft event
  68424. * @param origin the origin of the updraft
  68425. * @param radiusOrEventOptions the radius or the options of the updraft
  68426. * @param strength the strength of the updraft
  68427. * @param height the height of the updraft
  68428. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68429. * @returns A physics updraft event, or null
  68430. */
  68431. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68432. /**
  68433. * Creates a physics vortex event
  68434. * @param origin the of the vortex
  68435. * @param radiusOrEventOptions the radius or the options of the vortex
  68436. * @param strength the strength of the vortex
  68437. * @param height the height of the vortex
  68438. * @returns a Physics vortex event, or null
  68439. * A physics vortex event or null
  68440. */
  68441. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68442. }
  68443. /**
  68444. * Represents a physics radial explosion event
  68445. */
  68446. class PhysicsRadialExplosionEvent {
  68447. private _scene;
  68448. private _options;
  68449. private _sphere;
  68450. private _dataFetched;
  68451. /**
  68452. * Initializes a radial explosioin event
  68453. * @param _scene BabylonJS scene
  68454. * @param _options The options for the vortex event
  68455. */
  68456. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68457. /**
  68458. * Returns the data related to the radial explosion event (sphere).
  68459. * @returns The radial explosion event data
  68460. */
  68461. getData(): PhysicsRadialExplosionEventData;
  68462. /**
  68463. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68464. * @param impostor A physics imposter
  68465. * @param origin the origin of the explosion
  68466. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68467. */
  68468. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68469. /**
  68470. * Triggers affecterd impostors callbacks
  68471. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68472. */
  68473. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68474. /**
  68475. * Disposes the sphere.
  68476. * @param force Specifies if the sphere should be disposed by force
  68477. */
  68478. dispose(force?: boolean): void;
  68479. /*** Helpers ***/
  68480. private _prepareSphere;
  68481. private _intersectsWithSphere;
  68482. }
  68483. /**
  68484. * Represents a gravitational field event
  68485. */
  68486. class PhysicsGravitationalFieldEvent {
  68487. private _physicsHelper;
  68488. private _scene;
  68489. private _origin;
  68490. private _options;
  68491. private _tickCallback;
  68492. private _sphere;
  68493. private _dataFetched;
  68494. /**
  68495. * Initializes the physics gravitational field event
  68496. * @param _physicsHelper A physics helper
  68497. * @param _scene BabylonJS scene
  68498. * @param _origin The origin position of the gravitational field event
  68499. * @param _options The options for the vortex event
  68500. */
  68501. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68502. /**
  68503. * Returns the data related to the gravitational field event (sphere).
  68504. * @returns A gravitational field event
  68505. */
  68506. getData(): PhysicsGravitationalFieldEventData;
  68507. /**
  68508. * Enables the gravitational field.
  68509. */
  68510. enable(): void;
  68511. /**
  68512. * Disables the gravitational field.
  68513. */
  68514. disable(): void;
  68515. /**
  68516. * Disposes the sphere.
  68517. * @param force The force to dispose from the gravitational field event
  68518. */
  68519. dispose(force?: boolean): void;
  68520. private _tick;
  68521. }
  68522. /**
  68523. * Represents a physics updraft event
  68524. */
  68525. class PhysicsUpdraftEvent {
  68526. private _scene;
  68527. private _origin;
  68528. private _options;
  68529. private _physicsEngine;
  68530. private _originTop;
  68531. private _originDirection;
  68532. private _tickCallback;
  68533. private _cylinder;
  68534. private _cylinderPosition;
  68535. private _dataFetched;
  68536. /**
  68537. * Initializes the physics updraft event
  68538. * @param _scene BabylonJS scene
  68539. * @param _origin The origin position of the updraft
  68540. * @param _options The options for the updraft event
  68541. */
  68542. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68543. /**
  68544. * Returns the data related to the updraft event (cylinder).
  68545. * @returns A physics updraft event
  68546. */
  68547. getData(): PhysicsUpdraftEventData;
  68548. /**
  68549. * Enables the updraft.
  68550. */
  68551. enable(): void;
  68552. /**
  68553. * Disables the updraft.
  68554. */
  68555. disable(): void;
  68556. /**
  68557. * Disposes the cylinder.
  68558. * @param force Specifies if the updraft should be disposed by force
  68559. */
  68560. dispose(force?: boolean): void;
  68561. private getImpostorHitData;
  68562. private _tick;
  68563. /*** Helpers ***/
  68564. private _prepareCylinder;
  68565. private _intersectsWithCylinder;
  68566. }
  68567. /**
  68568. * Represents a physics vortex event
  68569. */
  68570. class PhysicsVortexEvent {
  68571. private _scene;
  68572. private _origin;
  68573. private _options;
  68574. private _physicsEngine;
  68575. private _originTop;
  68576. private _tickCallback;
  68577. private _cylinder;
  68578. private _cylinderPosition;
  68579. private _dataFetched;
  68580. /**
  68581. * Initializes the physics vortex event
  68582. * @param _scene The BabylonJS scene
  68583. * @param _origin The origin position of the vortex
  68584. * @param _options The options for the vortex event
  68585. */
  68586. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68587. /**
  68588. * Returns the data related to the vortex event (cylinder).
  68589. * @returns The physics vortex event data
  68590. */
  68591. getData(): PhysicsVortexEventData;
  68592. /**
  68593. * Enables the vortex.
  68594. */
  68595. enable(): void;
  68596. /**
  68597. * Disables the cortex.
  68598. */
  68599. disable(): void;
  68600. /**
  68601. * Disposes the sphere.
  68602. * @param force
  68603. */
  68604. dispose(force?: boolean): void;
  68605. private getImpostorHitData;
  68606. private _tick;
  68607. /*** Helpers ***/
  68608. private _prepareCylinder;
  68609. private _intersectsWithCylinder;
  68610. }
  68611. /**
  68612. * Options fot the radial explosion event
  68613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68614. */
  68615. export class PhysicsRadialExplosionEventOptions {
  68616. /**
  68617. * The radius of the sphere for the radial explosion.
  68618. */
  68619. radius: number;
  68620. /**
  68621. * The strenth of the explosion.
  68622. */
  68623. strength: number;
  68624. /**
  68625. * The strenght of the force in correspondence to the distance of the affected object
  68626. */
  68627. falloff: PhysicsRadialImpulseFalloff;
  68628. /**
  68629. * Sphere options for the radial explosion.
  68630. */
  68631. sphere: {
  68632. segments: number;
  68633. diameter: number;
  68634. };
  68635. /**
  68636. * Sphere options for the radial explosion.
  68637. */
  68638. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68639. }
  68640. /**
  68641. * Options fot the updraft event
  68642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68643. */
  68644. export class PhysicsUpdraftEventOptions {
  68645. /**
  68646. * The radius of the cylinder for the vortex
  68647. */
  68648. radius: number;
  68649. /**
  68650. * The strenth of the updraft.
  68651. */
  68652. strength: number;
  68653. /**
  68654. * The height of the cylinder for the updraft.
  68655. */
  68656. height: number;
  68657. /**
  68658. * The mode for the the updraft.
  68659. */
  68660. updraftMode: PhysicsUpdraftMode;
  68661. }
  68662. /**
  68663. * Options fot the vortex event
  68664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68665. */
  68666. export class PhysicsVortexEventOptions {
  68667. /**
  68668. * The radius of the cylinder for the vortex
  68669. */
  68670. radius: number;
  68671. /**
  68672. * The strenth of the vortex.
  68673. */
  68674. strength: number;
  68675. /**
  68676. * The height of the cylinder for the vortex.
  68677. */
  68678. height: number;
  68679. /**
  68680. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68681. */
  68682. centripetalForceThreshold: number;
  68683. /**
  68684. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68685. */
  68686. centripetalForceMultiplier: number;
  68687. /**
  68688. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68689. */
  68690. centrifugalForceMultiplier: number;
  68691. /**
  68692. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68693. */
  68694. updraftForceMultiplier: number;
  68695. }
  68696. /**
  68697. * The strenght of the force in correspondence to the distance of the affected object
  68698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68699. */
  68700. export enum PhysicsRadialImpulseFalloff {
  68701. /** Defines that impulse is constant in strength across it's whole radius */
  68702. Constant = 0,
  68703. /** Defines that impulse gets weaker if it's further from the origin */
  68704. Linear = 1
  68705. }
  68706. /**
  68707. * The strength of the force in correspondence to the distance of the affected object
  68708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68709. */
  68710. export enum PhysicsUpdraftMode {
  68711. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68712. Center = 0,
  68713. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68714. Perpendicular = 1
  68715. }
  68716. /**
  68717. * Interface for a physics hit data
  68718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68719. */
  68720. export interface PhysicsHitData {
  68721. /**
  68722. * The force applied at the contact point
  68723. */
  68724. force: Vector3;
  68725. /**
  68726. * The contact point
  68727. */
  68728. contactPoint: Vector3;
  68729. /**
  68730. * The distance from the origin to the contact point
  68731. */
  68732. distanceFromOrigin: number;
  68733. }
  68734. /**
  68735. * Interface for radial explosion event data
  68736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68737. */
  68738. export interface PhysicsRadialExplosionEventData {
  68739. /**
  68740. * A sphere used for the radial explosion event
  68741. */
  68742. sphere: Mesh;
  68743. }
  68744. /**
  68745. * Interface for gravitational field event data
  68746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68747. */
  68748. export interface PhysicsGravitationalFieldEventData {
  68749. /**
  68750. * A sphere mesh used for the gravitational field event
  68751. */
  68752. sphere: Mesh;
  68753. }
  68754. /**
  68755. * Interface for updraft event data
  68756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68757. */
  68758. export interface PhysicsUpdraftEventData {
  68759. /**
  68760. * A cylinder used for the updraft event
  68761. */
  68762. cylinder: Mesh;
  68763. }
  68764. /**
  68765. * Interface for vortex event data
  68766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68767. */
  68768. export interface PhysicsVortexEventData {
  68769. /**
  68770. * A cylinder used for the vortex event
  68771. */
  68772. cylinder: Mesh;
  68773. }
  68774. /**
  68775. * Interface for an affected physics impostor
  68776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68777. */
  68778. export interface PhysicsAffectedImpostorWithData {
  68779. /**
  68780. * The impostor affected by the effect
  68781. */
  68782. impostor: PhysicsImpostor;
  68783. /**
  68784. * The data about the hit/horce from the explosion
  68785. */
  68786. hitData: PhysicsHitData;
  68787. }
  68788. }
  68789. declare module BABYLON {
  68790. /** @hidden */
  68791. export var blackAndWhitePixelShader: {
  68792. name: string;
  68793. shader: string;
  68794. };
  68795. }
  68796. declare module BABYLON {
  68797. /**
  68798. * Post process used to render in black and white
  68799. */
  68800. export class BlackAndWhitePostProcess extends PostProcess {
  68801. /**
  68802. * Linear about to convert he result to black and white (default: 1)
  68803. */
  68804. degree: number;
  68805. /**
  68806. * Gets a string identifying the name of the class
  68807. * @returns "BlackAndWhitePostProcess" string
  68808. */
  68809. getClassName(): string;
  68810. /**
  68811. * Creates a black and white post process
  68812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68813. * @param name The name of the effect.
  68814. * @param options The required width/height ratio to downsize to before computing the render pass.
  68815. * @param camera The camera to apply the render pass to.
  68816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68817. * @param engine The engine which the post process will be applied. (default: current engine)
  68818. * @param reusable If the post process can be reused on the same frame. (default: false)
  68819. */
  68820. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68821. /** @hidden */
  68822. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68823. }
  68824. }
  68825. declare module BABYLON {
  68826. /**
  68827. * This represents a set of one or more post processes in Babylon.
  68828. * A post process can be used to apply a shader to a texture after it is rendered.
  68829. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68830. */
  68831. export class PostProcessRenderEffect {
  68832. private _postProcesses;
  68833. private _getPostProcesses;
  68834. private _singleInstance;
  68835. private _cameras;
  68836. private _indicesForCamera;
  68837. /**
  68838. * Name of the effect
  68839. * @hidden
  68840. */
  68841. _name: string;
  68842. /**
  68843. * Instantiates a post process render effect.
  68844. * A post process can be used to apply a shader to a texture after it is rendered.
  68845. * @param engine The engine the effect is tied to
  68846. * @param name The name of the effect
  68847. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68848. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68849. */
  68850. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68851. /**
  68852. * Checks if all the post processes in the effect are supported.
  68853. */
  68854. get isSupported(): boolean;
  68855. /**
  68856. * Updates the current state of the effect
  68857. * @hidden
  68858. */
  68859. _update(): void;
  68860. /**
  68861. * Attaches the effect on cameras
  68862. * @param cameras The camera to attach to.
  68863. * @hidden
  68864. */
  68865. _attachCameras(cameras: Camera): void;
  68866. /**
  68867. * Attaches the effect on cameras
  68868. * @param cameras The camera to attach to.
  68869. * @hidden
  68870. */
  68871. _attachCameras(cameras: Camera[]): void;
  68872. /**
  68873. * Detaches the effect on cameras
  68874. * @param cameras The camera to detatch from.
  68875. * @hidden
  68876. */
  68877. _detachCameras(cameras: Camera): void;
  68878. /**
  68879. * Detatches the effect on cameras
  68880. * @param cameras The camera to detatch from.
  68881. * @hidden
  68882. */
  68883. _detachCameras(cameras: Camera[]): void;
  68884. /**
  68885. * Enables the effect on given cameras
  68886. * @param cameras The camera to enable.
  68887. * @hidden
  68888. */
  68889. _enable(cameras: Camera): void;
  68890. /**
  68891. * Enables the effect on given cameras
  68892. * @param cameras The camera to enable.
  68893. * @hidden
  68894. */
  68895. _enable(cameras: Nullable<Camera[]>): void;
  68896. /**
  68897. * Disables the effect on the given cameras
  68898. * @param cameras The camera to disable.
  68899. * @hidden
  68900. */
  68901. _disable(cameras: Camera): void;
  68902. /**
  68903. * Disables the effect on the given cameras
  68904. * @param cameras The camera to disable.
  68905. * @hidden
  68906. */
  68907. _disable(cameras: Nullable<Camera[]>): void;
  68908. /**
  68909. * Gets a list of the post processes contained in the effect.
  68910. * @param camera The camera to get the post processes on.
  68911. * @returns The list of the post processes in the effect.
  68912. */
  68913. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68914. }
  68915. }
  68916. declare module BABYLON {
  68917. /** @hidden */
  68918. export var extractHighlightsPixelShader: {
  68919. name: string;
  68920. shader: string;
  68921. };
  68922. }
  68923. declare module BABYLON {
  68924. /**
  68925. * 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.
  68926. */
  68927. export class ExtractHighlightsPostProcess extends PostProcess {
  68928. /**
  68929. * The luminance threshold, pixels below this value will be set to black.
  68930. */
  68931. threshold: number;
  68932. /** @hidden */
  68933. _exposure: number;
  68934. /**
  68935. * Post process which has the input texture to be used when performing highlight extraction
  68936. * @hidden
  68937. */
  68938. _inputPostProcess: Nullable<PostProcess>;
  68939. /**
  68940. * Gets a string identifying the name of the class
  68941. * @returns "ExtractHighlightsPostProcess" string
  68942. */
  68943. getClassName(): string;
  68944. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68945. }
  68946. }
  68947. declare module BABYLON {
  68948. /** @hidden */
  68949. export var bloomMergePixelShader: {
  68950. name: string;
  68951. shader: string;
  68952. };
  68953. }
  68954. declare module BABYLON {
  68955. /**
  68956. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68957. */
  68958. export class BloomMergePostProcess extends PostProcess {
  68959. /** Weight of the bloom to be added to the original input. */
  68960. weight: number;
  68961. /**
  68962. * Gets a string identifying the name of the class
  68963. * @returns "BloomMergePostProcess" string
  68964. */
  68965. getClassName(): string;
  68966. /**
  68967. * Creates a new instance of @see BloomMergePostProcess
  68968. * @param name The name of the effect.
  68969. * @param originalFromInput Post process which's input will be used for the merge.
  68970. * @param blurred Blurred highlights post process which's output will be used.
  68971. * @param weight Weight of the bloom to be added to the original input.
  68972. * @param options The required width/height ratio to downsize to before computing the render pass.
  68973. * @param camera The camera to apply the render pass to.
  68974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68975. * @param engine The engine which the post process will be applied. (default: current engine)
  68976. * @param reusable If the post process can be reused on the same frame. (default: false)
  68977. * @param textureType Type of textures used when performing the post process. (default: 0)
  68978. * @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)
  68979. */
  68980. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68981. /** Weight of the bloom to be added to the original input. */
  68982. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68983. }
  68984. }
  68985. declare module BABYLON {
  68986. /**
  68987. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68988. */
  68989. export class BloomEffect extends PostProcessRenderEffect {
  68990. private bloomScale;
  68991. /**
  68992. * @hidden Internal
  68993. */
  68994. _effects: Array<PostProcess>;
  68995. /**
  68996. * @hidden Internal
  68997. */
  68998. _downscale: ExtractHighlightsPostProcess;
  68999. private _blurX;
  69000. private _blurY;
  69001. private _merge;
  69002. /**
  69003. * The luminance threshold to find bright areas of the image to bloom.
  69004. */
  69005. get threshold(): number;
  69006. set threshold(value: number);
  69007. /**
  69008. * The strength of the bloom.
  69009. */
  69010. get weight(): number;
  69011. set weight(value: number);
  69012. /**
  69013. * Specifies the size of the bloom blur kernel, relative to the final output size
  69014. */
  69015. get kernel(): number;
  69016. set kernel(value: number);
  69017. /**
  69018. * Creates a new instance of @see BloomEffect
  69019. * @param scene The scene the effect belongs to.
  69020. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69021. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69022. * @param bloomWeight The the strength of bloom.
  69023. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69024. * @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)
  69025. */
  69026. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69027. /**
  69028. * Disposes each of the internal effects for a given camera.
  69029. * @param camera The camera to dispose the effect on.
  69030. */
  69031. disposeEffects(camera: Camera): void;
  69032. /**
  69033. * @hidden Internal
  69034. */
  69035. _updateEffects(): void;
  69036. /**
  69037. * Internal
  69038. * @returns if all the contained post processes are ready.
  69039. * @hidden
  69040. */
  69041. _isReady(): boolean;
  69042. }
  69043. }
  69044. declare module BABYLON {
  69045. /** @hidden */
  69046. export var chromaticAberrationPixelShader: {
  69047. name: string;
  69048. shader: string;
  69049. };
  69050. }
  69051. declare module BABYLON {
  69052. /**
  69053. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69054. */
  69055. export class ChromaticAberrationPostProcess extends PostProcess {
  69056. /**
  69057. * The amount of seperation of rgb channels (default: 30)
  69058. */
  69059. aberrationAmount: number;
  69060. /**
  69061. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69062. */
  69063. radialIntensity: number;
  69064. /**
  69065. * 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))
  69066. */
  69067. direction: Vector2;
  69068. /**
  69069. * 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))
  69070. */
  69071. centerPosition: Vector2;
  69072. /** The width of the screen to apply the effect on */
  69073. screenWidth: number;
  69074. /** The height of the screen to apply the effect on */
  69075. screenHeight: number;
  69076. /**
  69077. * Gets a string identifying the name of the class
  69078. * @returns "ChromaticAberrationPostProcess" string
  69079. */
  69080. getClassName(): string;
  69081. /**
  69082. * Creates a new instance ChromaticAberrationPostProcess
  69083. * @param name The name of the effect.
  69084. * @param screenWidth The width of the screen to apply the effect on.
  69085. * @param screenHeight The height of the screen to apply the effect on.
  69086. * @param options The required width/height ratio to downsize to before computing the render pass.
  69087. * @param camera The camera to apply the render pass to.
  69088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69089. * @param engine The engine which the post process will be applied. (default: current engine)
  69090. * @param reusable If the post process can be reused on the same frame. (default: false)
  69091. * @param textureType Type of textures used when performing the post process. (default: 0)
  69092. * @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)
  69093. */
  69094. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69095. /** @hidden */
  69096. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69097. }
  69098. }
  69099. declare module BABYLON {
  69100. /** @hidden */
  69101. export var circleOfConfusionPixelShader: {
  69102. name: string;
  69103. shader: string;
  69104. };
  69105. }
  69106. declare module BABYLON {
  69107. /**
  69108. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69109. */
  69110. export class CircleOfConfusionPostProcess extends PostProcess {
  69111. /**
  69112. * 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.
  69113. */
  69114. lensSize: number;
  69115. /**
  69116. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69117. */
  69118. fStop: number;
  69119. /**
  69120. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69121. */
  69122. focusDistance: number;
  69123. /**
  69124. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69125. */
  69126. focalLength: number;
  69127. /**
  69128. * Gets a string identifying the name of the class
  69129. * @returns "CircleOfConfusionPostProcess" string
  69130. */
  69131. getClassName(): string;
  69132. private _depthTexture;
  69133. /**
  69134. * Creates a new instance CircleOfConfusionPostProcess
  69135. * @param name The name of the effect.
  69136. * @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.
  69137. * @param options The required width/height ratio to downsize to before computing the render pass.
  69138. * @param camera The camera to apply the render pass to.
  69139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69140. * @param engine The engine which the post process will be applied. (default: current engine)
  69141. * @param reusable If the post process can be reused on the same frame. (default: false)
  69142. * @param textureType Type of textures used when performing the post process. (default: 0)
  69143. * @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)
  69144. */
  69145. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69146. /**
  69147. * 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.
  69148. */
  69149. set depthTexture(value: RenderTargetTexture);
  69150. }
  69151. }
  69152. declare module BABYLON {
  69153. /** @hidden */
  69154. export var colorCorrectionPixelShader: {
  69155. name: string;
  69156. shader: string;
  69157. };
  69158. }
  69159. declare module BABYLON {
  69160. /**
  69161. *
  69162. * This post-process allows the modification of rendered colors by using
  69163. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69164. *
  69165. * The object needs to be provided an url to a texture containing the color
  69166. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69167. * Use an image editing software to tweak the LUT to match your needs.
  69168. *
  69169. * For an example of a color LUT, see here:
  69170. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69171. * For explanations on color grading, see here:
  69172. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69173. *
  69174. */
  69175. export class ColorCorrectionPostProcess extends PostProcess {
  69176. private _colorTableTexture;
  69177. /**
  69178. * Gets the color table url used to create the LUT texture
  69179. */
  69180. colorTableUrl: string;
  69181. /**
  69182. * Gets a string identifying the name of the class
  69183. * @returns "ColorCorrectionPostProcess" string
  69184. */
  69185. getClassName(): string;
  69186. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69187. /** @hidden */
  69188. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69189. }
  69190. }
  69191. declare module BABYLON {
  69192. /** @hidden */
  69193. export var convolutionPixelShader: {
  69194. name: string;
  69195. shader: string;
  69196. };
  69197. }
  69198. declare module BABYLON {
  69199. /**
  69200. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69201. * input texture to perform effects such as edge detection or sharpening
  69202. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69203. */
  69204. export class ConvolutionPostProcess extends PostProcess {
  69205. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69206. kernel: number[];
  69207. /**
  69208. * Gets a string identifying the name of the class
  69209. * @returns "ConvolutionPostProcess" string
  69210. */
  69211. getClassName(): string;
  69212. /**
  69213. * Creates a new instance ConvolutionPostProcess
  69214. * @param name The name of the effect.
  69215. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69216. * @param options The required width/height ratio to downsize to before computing the render pass.
  69217. * @param camera The camera to apply the render pass to.
  69218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69219. * @param engine The engine which the post process will be applied. (default: current engine)
  69220. * @param reusable If the post process can be reused on the same frame. (default: false)
  69221. * @param textureType Type of textures used when performing the post process. (default: 0)
  69222. */
  69223. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69224. /** @hidden */
  69225. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69226. /**
  69227. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69228. */
  69229. static EdgeDetect0Kernel: number[];
  69230. /**
  69231. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69232. */
  69233. static EdgeDetect1Kernel: number[];
  69234. /**
  69235. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69236. */
  69237. static EdgeDetect2Kernel: number[];
  69238. /**
  69239. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69240. */
  69241. static SharpenKernel: number[];
  69242. /**
  69243. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69244. */
  69245. static EmbossKernel: number[];
  69246. /**
  69247. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69248. */
  69249. static GaussianKernel: number[];
  69250. }
  69251. }
  69252. declare module BABYLON {
  69253. /**
  69254. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69255. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69256. * based on samples that have a large difference in distance than the center pixel.
  69257. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69258. */
  69259. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69260. /**
  69261. * The direction the blur should be applied
  69262. */
  69263. direction: Vector2;
  69264. /**
  69265. * Gets a string identifying the name of the class
  69266. * @returns "DepthOfFieldBlurPostProcess" string
  69267. */
  69268. getClassName(): string;
  69269. /**
  69270. * Creates a new instance CircleOfConfusionPostProcess
  69271. * @param name The name of the effect.
  69272. * @param scene The scene the effect belongs to.
  69273. * @param direction The direction the blur should be applied.
  69274. * @param kernel The size of the kernel used to blur.
  69275. * @param options The required width/height ratio to downsize to before computing the render pass.
  69276. * @param camera The camera to apply the render pass to.
  69277. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69278. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69280. * @param engine The engine which the post process will be applied. (default: current engine)
  69281. * @param reusable If the post process can be reused on the same frame. (default: false)
  69282. * @param textureType Type of textures used when performing the post process. (default: 0)
  69283. * @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)
  69284. */
  69285. 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);
  69286. }
  69287. }
  69288. declare module BABYLON {
  69289. /** @hidden */
  69290. export var depthOfFieldMergePixelShader: {
  69291. name: string;
  69292. shader: string;
  69293. };
  69294. }
  69295. declare module BABYLON {
  69296. /**
  69297. * Options to be set when merging outputs from the default pipeline.
  69298. */
  69299. export class DepthOfFieldMergePostProcessOptions {
  69300. /**
  69301. * The original image to merge on top of
  69302. */
  69303. originalFromInput: PostProcess;
  69304. /**
  69305. * Parameters to perform the merge of the depth of field effect
  69306. */
  69307. depthOfField?: {
  69308. circleOfConfusion: PostProcess;
  69309. blurSteps: Array<PostProcess>;
  69310. };
  69311. /**
  69312. * Parameters to perform the merge of bloom effect
  69313. */
  69314. bloom?: {
  69315. blurred: PostProcess;
  69316. weight: number;
  69317. };
  69318. }
  69319. /**
  69320. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69321. */
  69322. export class DepthOfFieldMergePostProcess extends PostProcess {
  69323. private blurSteps;
  69324. /**
  69325. * Gets a string identifying the name of the class
  69326. * @returns "DepthOfFieldMergePostProcess" string
  69327. */
  69328. getClassName(): string;
  69329. /**
  69330. * Creates a new instance of DepthOfFieldMergePostProcess
  69331. * @param name The name of the effect.
  69332. * @param originalFromInput Post process which's input will be used for the merge.
  69333. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69334. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69335. * @param options The required width/height ratio to downsize to before computing the render pass.
  69336. * @param camera The camera to apply the render pass to.
  69337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69338. * @param engine The engine which the post process will be applied. (default: current engine)
  69339. * @param reusable If the post process can be reused on the same frame. (default: false)
  69340. * @param textureType Type of textures used when performing the post process. (default: 0)
  69341. * @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)
  69342. */
  69343. 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);
  69344. /**
  69345. * Updates the effect with the current post process compile time values and recompiles the shader.
  69346. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69347. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69348. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69349. * @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
  69350. * @param onCompiled Called when the shader has been compiled.
  69351. * @param onError Called if there is an error when compiling a shader.
  69352. */
  69353. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69354. }
  69355. }
  69356. declare module BABYLON {
  69357. /**
  69358. * Specifies the level of max blur that should be applied when using the depth of field effect
  69359. */
  69360. export enum DepthOfFieldEffectBlurLevel {
  69361. /**
  69362. * Subtle blur
  69363. */
  69364. Low = 0,
  69365. /**
  69366. * Medium blur
  69367. */
  69368. Medium = 1,
  69369. /**
  69370. * Large blur
  69371. */
  69372. High = 2
  69373. }
  69374. /**
  69375. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69376. */
  69377. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69378. private _circleOfConfusion;
  69379. /**
  69380. * @hidden Internal, blurs from high to low
  69381. */
  69382. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69383. private _depthOfFieldBlurY;
  69384. private _dofMerge;
  69385. /**
  69386. * @hidden Internal post processes in depth of field effect
  69387. */
  69388. _effects: Array<PostProcess>;
  69389. /**
  69390. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69391. */
  69392. set focalLength(value: number);
  69393. get focalLength(): number;
  69394. /**
  69395. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69396. */
  69397. set fStop(value: number);
  69398. get fStop(): number;
  69399. /**
  69400. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69401. */
  69402. set focusDistance(value: number);
  69403. get focusDistance(): number;
  69404. /**
  69405. * 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.
  69406. */
  69407. set lensSize(value: number);
  69408. get lensSize(): number;
  69409. /**
  69410. * Creates a new instance DepthOfFieldEffect
  69411. * @param scene The scene the effect belongs to.
  69412. * @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.
  69413. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69414. * @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)
  69415. */
  69416. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69417. /**
  69418. * Get the current class name of the current effet
  69419. * @returns "DepthOfFieldEffect"
  69420. */
  69421. getClassName(): string;
  69422. /**
  69423. * 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.
  69424. */
  69425. set depthTexture(value: RenderTargetTexture);
  69426. /**
  69427. * Disposes each of the internal effects for a given camera.
  69428. * @param camera The camera to dispose the effect on.
  69429. */
  69430. disposeEffects(camera: Camera): void;
  69431. /**
  69432. * @hidden Internal
  69433. */
  69434. _updateEffects(): void;
  69435. /**
  69436. * Internal
  69437. * @returns if all the contained post processes are ready.
  69438. * @hidden
  69439. */
  69440. _isReady(): boolean;
  69441. }
  69442. }
  69443. declare module BABYLON {
  69444. /** @hidden */
  69445. export var displayPassPixelShader: {
  69446. name: string;
  69447. shader: string;
  69448. };
  69449. }
  69450. declare module BABYLON {
  69451. /**
  69452. * DisplayPassPostProcess which produces an output the same as it's input
  69453. */
  69454. export class DisplayPassPostProcess extends PostProcess {
  69455. /**
  69456. * Gets a string identifying the name of the class
  69457. * @returns "DisplayPassPostProcess" string
  69458. */
  69459. getClassName(): string;
  69460. /**
  69461. * Creates the DisplayPassPostProcess
  69462. * @param name The name of the effect.
  69463. * @param options The required width/height ratio to downsize to before computing the render pass.
  69464. * @param camera The camera to apply the render pass to.
  69465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69466. * @param engine The engine which the post process will be applied. (default: current engine)
  69467. * @param reusable If the post process can be reused on the same frame. (default: false)
  69468. */
  69469. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69470. /** @hidden */
  69471. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69472. }
  69473. }
  69474. declare module BABYLON {
  69475. /** @hidden */
  69476. export var filterPixelShader: {
  69477. name: string;
  69478. shader: string;
  69479. };
  69480. }
  69481. declare module BABYLON {
  69482. /**
  69483. * Applies a kernel filter to the image
  69484. */
  69485. export class FilterPostProcess extends PostProcess {
  69486. /** The matrix to be applied to the image */
  69487. kernelMatrix: Matrix;
  69488. /**
  69489. * Gets a string identifying the name of the class
  69490. * @returns "FilterPostProcess" string
  69491. */
  69492. getClassName(): string;
  69493. /**
  69494. *
  69495. * @param name The name of the effect.
  69496. * @param kernelMatrix The matrix to be applied to the image
  69497. * @param options The required width/height ratio to downsize to before computing the render pass.
  69498. * @param camera The camera to apply the render pass to.
  69499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69500. * @param engine The engine which the post process will be applied. (default: current engine)
  69501. * @param reusable If the post process can be reused on the same frame. (default: false)
  69502. */
  69503. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69504. /** @hidden */
  69505. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69506. }
  69507. }
  69508. declare module BABYLON {
  69509. /** @hidden */
  69510. export var fxaaPixelShader: {
  69511. name: string;
  69512. shader: string;
  69513. };
  69514. }
  69515. declare module BABYLON {
  69516. /** @hidden */
  69517. export var fxaaVertexShader: {
  69518. name: string;
  69519. shader: string;
  69520. };
  69521. }
  69522. declare module BABYLON {
  69523. /**
  69524. * Fxaa post process
  69525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69526. */
  69527. export class FxaaPostProcess extends PostProcess {
  69528. /**
  69529. * Gets a string identifying the name of the class
  69530. * @returns "FxaaPostProcess" string
  69531. */
  69532. getClassName(): string;
  69533. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69534. private _getDefines;
  69535. /** @hidden */
  69536. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69537. }
  69538. }
  69539. declare module BABYLON {
  69540. /** @hidden */
  69541. export var grainPixelShader: {
  69542. name: string;
  69543. shader: string;
  69544. };
  69545. }
  69546. declare module BABYLON {
  69547. /**
  69548. * The GrainPostProcess adds noise to the image at mid luminance levels
  69549. */
  69550. export class GrainPostProcess extends PostProcess {
  69551. /**
  69552. * The intensity of the grain added (default: 30)
  69553. */
  69554. intensity: number;
  69555. /**
  69556. * If the grain should be randomized on every frame
  69557. */
  69558. animated: boolean;
  69559. /**
  69560. * Gets a string identifying the name of the class
  69561. * @returns "GrainPostProcess" string
  69562. */
  69563. getClassName(): string;
  69564. /**
  69565. * Creates a new instance of @see GrainPostProcess
  69566. * @param name The name of the effect.
  69567. * @param options The required width/height ratio to downsize to before computing the render pass.
  69568. * @param camera The camera to apply the render pass to.
  69569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69570. * @param engine The engine which the post process will be applied. (default: current engine)
  69571. * @param reusable If the post process can be reused on the same frame. (default: false)
  69572. * @param textureType Type of textures used when performing the post process. (default: 0)
  69573. * @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)
  69574. */
  69575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69576. /** @hidden */
  69577. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69578. }
  69579. }
  69580. declare module BABYLON {
  69581. /** @hidden */
  69582. export var highlightsPixelShader: {
  69583. name: string;
  69584. shader: string;
  69585. };
  69586. }
  69587. declare module BABYLON {
  69588. /**
  69589. * Extracts highlights from the image
  69590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69591. */
  69592. export class HighlightsPostProcess extends PostProcess {
  69593. /**
  69594. * Gets a string identifying the name of the class
  69595. * @returns "HighlightsPostProcess" string
  69596. */
  69597. getClassName(): string;
  69598. /**
  69599. * Extracts highlights from the image
  69600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69601. * @param name The name of the effect.
  69602. * @param options The required width/height ratio to downsize to before computing the render pass.
  69603. * @param camera The camera to apply the render pass to.
  69604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69605. * @param engine The engine which the post process will be applied. (default: current engine)
  69606. * @param reusable If the post process can be reused on the same frame. (default: false)
  69607. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69608. */
  69609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69610. }
  69611. }
  69612. declare module BABYLON {
  69613. /** @hidden */
  69614. export var mrtFragmentDeclaration: {
  69615. name: string;
  69616. shader: string;
  69617. };
  69618. }
  69619. declare module BABYLON {
  69620. /** @hidden */
  69621. export var geometryPixelShader: {
  69622. name: string;
  69623. shader: string;
  69624. };
  69625. }
  69626. declare module BABYLON {
  69627. /** @hidden */
  69628. export var geometryVertexShader: {
  69629. name: string;
  69630. shader: string;
  69631. };
  69632. }
  69633. declare module BABYLON {
  69634. /** @hidden */
  69635. interface ISavedTransformationMatrix {
  69636. world: Matrix;
  69637. viewProjection: Matrix;
  69638. }
  69639. /**
  69640. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69641. */
  69642. export class GeometryBufferRenderer {
  69643. /**
  69644. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69645. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69646. */
  69647. static readonly POSITION_TEXTURE_TYPE: number;
  69648. /**
  69649. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69650. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69651. */
  69652. static readonly VELOCITY_TEXTURE_TYPE: number;
  69653. /**
  69654. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69655. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69656. */
  69657. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69658. /**
  69659. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69660. * in order to compute objects velocities when enableVelocity is set to "true"
  69661. * @hidden
  69662. */
  69663. _previousTransformationMatrices: {
  69664. [index: number]: ISavedTransformationMatrix;
  69665. };
  69666. /**
  69667. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69668. * in order to compute objects velocities when enableVelocity is set to "true"
  69669. * @hidden
  69670. */
  69671. _previousBonesTransformationMatrices: {
  69672. [index: number]: Float32Array;
  69673. };
  69674. /**
  69675. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69676. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69677. */
  69678. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69679. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69680. renderTransparentMeshes: boolean;
  69681. private _scene;
  69682. private _resizeObserver;
  69683. private _multiRenderTarget;
  69684. private _ratio;
  69685. private _enablePosition;
  69686. private _enableVelocity;
  69687. private _enableReflectivity;
  69688. private _positionIndex;
  69689. private _velocityIndex;
  69690. private _reflectivityIndex;
  69691. protected _effect: Effect;
  69692. protected _cachedDefines: string;
  69693. /**
  69694. * Set the render list (meshes to be rendered) used in the G buffer.
  69695. */
  69696. set renderList(meshes: Mesh[]);
  69697. /**
  69698. * Gets wether or not G buffer are supported by the running hardware.
  69699. * This requires draw buffer supports
  69700. */
  69701. get isSupported(): boolean;
  69702. /**
  69703. * Returns the index of the given texture type in the G-Buffer textures array
  69704. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69705. * @returns the index of the given texture type in the G-Buffer textures array
  69706. */
  69707. getTextureIndex(textureType: number): number;
  69708. /**
  69709. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69710. */
  69711. get enablePosition(): boolean;
  69712. /**
  69713. * Sets whether or not objects positions are enabled for the G buffer.
  69714. */
  69715. set enablePosition(enable: boolean);
  69716. /**
  69717. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69718. */
  69719. get enableVelocity(): boolean;
  69720. /**
  69721. * Sets wether or not objects velocities are enabled for the G buffer.
  69722. */
  69723. set enableVelocity(enable: boolean);
  69724. /**
  69725. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69726. */
  69727. get enableReflectivity(): boolean;
  69728. /**
  69729. * Sets wether or not objects roughness are enabled for the G buffer.
  69730. */
  69731. set enableReflectivity(enable: boolean);
  69732. /**
  69733. * Gets the scene associated with the buffer.
  69734. */
  69735. get scene(): Scene;
  69736. /**
  69737. * Gets the ratio used by the buffer during its creation.
  69738. * How big is the buffer related to the main canvas.
  69739. */
  69740. get ratio(): number;
  69741. /** @hidden */
  69742. static _SceneComponentInitialization: (scene: Scene) => void;
  69743. /**
  69744. * Creates a new G Buffer for the scene
  69745. * @param scene The scene the buffer belongs to
  69746. * @param ratio How big is the buffer related to the main canvas.
  69747. */
  69748. constructor(scene: Scene, ratio?: number);
  69749. /**
  69750. * Checks wether everything is ready to render a submesh to the G buffer.
  69751. * @param subMesh the submesh to check readiness for
  69752. * @param useInstances is the mesh drawn using instance or not
  69753. * @returns true if ready otherwise false
  69754. */
  69755. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69756. /**
  69757. * Gets the current underlying G Buffer.
  69758. * @returns the buffer
  69759. */
  69760. getGBuffer(): MultiRenderTarget;
  69761. /**
  69762. * Gets the number of samples used to render the buffer (anti aliasing).
  69763. */
  69764. get samples(): number;
  69765. /**
  69766. * Sets the number of samples used to render the buffer (anti aliasing).
  69767. */
  69768. set samples(value: number);
  69769. /**
  69770. * Disposes the renderer and frees up associated resources.
  69771. */
  69772. dispose(): void;
  69773. protected _createRenderTargets(): void;
  69774. private _copyBonesTransformationMatrices;
  69775. }
  69776. }
  69777. declare module BABYLON {
  69778. interface Scene {
  69779. /** @hidden (Backing field) */
  69780. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69781. /**
  69782. * Gets or Sets the current geometry buffer associated to the scene.
  69783. */
  69784. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69785. /**
  69786. * Enables a GeometryBufferRender and associates it with the scene
  69787. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69788. * @returns the GeometryBufferRenderer
  69789. */
  69790. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69791. /**
  69792. * Disables the GeometryBufferRender associated with the scene
  69793. */
  69794. disableGeometryBufferRenderer(): void;
  69795. }
  69796. /**
  69797. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69798. * in several rendering techniques.
  69799. */
  69800. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69801. /**
  69802. * The component name helpful to identify the component in the list of scene components.
  69803. */
  69804. readonly name: string;
  69805. /**
  69806. * The scene the component belongs to.
  69807. */
  69808. scene: Scene;
  69809. /**
  69810. * Creates a new instance of the component for the given scene
  69811. * @param scene Defines the scene to register the component in
  69812. */
  69813. constructor(scene: Scene);
  69814. /**
  69815. * Registers the component in a given scene
  69816. */
  69817. register(): void;
  69818. /**
  69819. * Rebuilds the elements related to this component in case of
  69820. * context lost for instance.
  69821. */
  69822. rebuild(): void;
  69823. /**
  69824. * Disposes the component and the associated ressources
  69825. */
  69826. dispose(): void;
  69827. private _gatherRenderTargets;
  69828. }
  69829. }
  69830. declare module BABYLON {
  69831. /** @hidden */
  69832. export var motionBlurPixelShader: {
  69833. name: string;
  69834. shader: string;
  69835. };
  69836. }
  69837. declare module BABYLON {
  69838. /**
  69839. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69840. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69841. * As an example, all you have to do is to create the post-process:
  69842. * var mb = new BABYLON.MotionBlurPostProcess(
  69843. * 'mb', // The name of the effect.
  69844. * scene, // The scene containing the objects to blur according to their velocity.
  69845. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69846. * camera // The camera to apply the render pass to.
  69847. * );
  69848. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69849. */
  69850. export class MotionBlurPostProcess extends PostProcess {
  69851. /**
  69852. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69853. */
  69854. motionStrength: number;
  69855. /**
  69856. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69857. */
  69858. get motionBlurSamples(): number;
  69859. /**
  69860. * Sets the number of iterations to be used for motion blur quality
  69861. */
  69862. set motionBlurSamples(samples: number);
  69863. private _motionBlurSamples;
  69864. private _geometryBufferRenderer;
  69865. /**
  69866. * Gets a string identifying the name of the class
  69867. * @returns "MotionBlurPostProcess" string
  69868. */
  69869. getClassName(): string;
  69870. /**
  69871. * Creates a new instance MotionBlurPostProcess
  69872. * @param name The name of the effect.
  69873. * @param scene The scene containing the objects to blur according to their velocity.
  69874. * @param options The required width/height ratio to downsize to before computing the render pass.
  69875. * @param camera The camera to apply the render pass to.
  69876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69877. * @param engine The engine which the post process will be applied. (default: current engine)
  69878. * @param reusable If the post process can be reused on the same frame. (default: false)
  69879. * @param textureType Type of textures used when performing the post process. (default: 0)
  69880. * @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)
  69881. */
  69882. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69883. /**
  69884. * Excludes the given skinned mesh from computing bones velocities.
  69885. * 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.
  69886. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69887. */
  69888. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69889. /**
  69890. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69891. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69892. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69893. */
  69894. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69895. /**
  69896. * Disposes the post process.
  69897. * @param camera The camera to dispose the post process on.
  69898. */
  69899. dispose(camera?: Camera): void;
  69900. /** @hidden */
  69901. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. /** @hidden */
  69906. export var refractionPixelShader: {
  69907. name: string;
  69908. shader: string;
  69909. };
  69910. }
  69911. declare module BABYLON {
  69912. /**
  69913. * Post process which applies a refractin texture
  69914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69915. */
  69916. export class RefractionPostProcess extends PostProcess {
  69917. private _refTexture;
  69918. private _ownRefractionTexture;
  69919. /** the base color of the refraction (used to taint the rendering) */
  69920. color: Color3;
  69921. /** simulated refraction depth */
  69922. depth: number;
  69923. /** the coefficient of the base color (0 to remove base color tainting) */
  69924. colorLevel: number;
  69925. /** Gets the url used to load the refraction texture */
  69926. refractionTextureUrl: string;
  69927. /**
  69928. * Gets or sets the refraction texture
  69929. * Please note that you are responsible for disposing the texture if you set it manually
  69930. */
  69931. get refractionTexture(): Texture;
  69932. set refractionTexture(value: Texture);
  69933. /**
  69934. * Gets a string identifying the name of the class
  69935. * @returns "RefractionPostProcess" string
  69936. */
  69937. getClassName(): string;
  69938. /**
  69939. * Initializes the RefractionPostProcess
  69940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69941. * @param name The name of the effect.
  69942. * @param refractionTextureUrl Url of the refraction texture to use
  69943. * @param color the base color of the refraction (used to taint the rendering)
  69944. * @param depth simulated refraction depth
  69945. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69946. * @param camera The camera to apply the render pass to.
  69947. * @param options The required width/height ratio to downsize to before computing the render pass.
  69948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69949. * @param engine The engine which the post process will be applied. (default: current engine)
  69950. * @param reusable If the post process can be reused on the same frame. (default: false)
  69951. */
  69952. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69953. /**
  69954. * Disposes of the post process
  69955. * @param camera Camera to dispose post process on
  69956. */
  69957. dispose(camera: Camera): void;
  69958. /** @hidden */
  69959. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  69960. }
  69961. }
  69962. declare module BABYLON {
  69963. /** @hidden */
  69964. export var sharpenPixelShader: {
  69965. name: string;
  69966. shader: string;
  69967. };
  69968. }
  69969. declare module BABYLON {
  69970. /**
  69971. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69972. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69973. */
  69974. export class SharpenPostProcess extends PostProcess {
  69975. /**
  69976. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69977. */
  69978. colorAmount: number;
  69979. /**
  69980. * How much sharpness should be applied (default: 0.3)
  69981. */
  69982. edgeAmount: number;
  69983. /**
  69984. * Gets a string identifying the name of the class
  69985. * @returns "SharpenPostProcess" string
  69986. */
  69987. getClassName(): string;
  69988. /**
  69989. * Creates a new instance ConvolutionPostProcess
  69990. * @param name The name of the effect.
  69991. * @param options The required width/height ratio to downsize to before computing the render pass.
  69992. * @param camera The camera to apply the render pass to.
  69993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69994. * @param engine The engine which the post process will be applied. (default: current engine)
  69995. * @param reusable If the post process can be reused on the same frame. (default: false)
  69996. * @param textureType Type of textures used when performing the post process. (default: 0)
  69997. * @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)
  69998. */
  69999. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70000. /** @hidden */
  70001. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70002. }
  70003. }
  70004. declare module BABYLON {
  70005. /**
  70006. * PostProcessRenderPipeline
  70007. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70008. */
  70009. export class PostProcessRenderPipeline {
  70010. private engine;
  70011. private _renderEffects;
  70012. private _renderEffectsForIsolatedPass;
  70013. /**
  70014. * List of inspectable custom properties (used by the Inspector)
  70015. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70016. */
  70017. inspectableCustomProperties: IInspectable[];
  70018. /**
  70019. * @hidden
  70020. */
  70021. protected _cameras: Camera[];
  70022. /** @hidden */
  70023. _name: string;
  70024. /**
  70025. * Gets pipeline name
  70026. */
  70027. get name(): string;
  70028. /** Gets the list of attached cameras */
  70029. get cameras(): Camera[];
  70030. /**
  70031. * Initializes a PostProcessRenderPipeline
  70032. * @param engine engine to add the pipeline to
  70033. * @param name name of the pipeline
  70034. */
  70035. constructor(engine: Engine, name: string);
  70036. /**
  70037. * Gets the class name
  70038. * @returns "PostProcessRenderPipeline"
  70039. */
  70040. getClassName(): string;
  70041. /**
  70042. * If all the render effects in the pipeline are supported
  70043. */
  70044. get isSupported(): boolean;
  70045. /**
  70046. * Adds an effect to the pipeline
  70047. * @param renderEffect the effect to add
  70048. */
  70049. addEffect(renderEffect: PostProcessRenderEffect): void;
  70050. /** @hidden */
  70051. _rebuild(): void;
  70052. /** @hidden */
  70053. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70054. /** @hidden */
  70055. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70056. /** @hidden */
  70057. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70058. /** @hidden */
  70059. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70060. /** @hidden */
  70061. _attachCameras(cameras: Camera, unique: boolean): void;
  70062. /** @hidden */
  70063. _attachCameras(cameras: Camera[], unique: boolean): void;
  70064. /** @hidden */
  70065. _detachCameras(cameras: Camera): void;
  70066. /** @hidden */
  70067. _detachCameras(cameras: Nullable<Camera[]>): void;
  70068. /** @hidden */
  70069. _update(): void;
  70070. /** @hidden */
  70071. _reset(): void;
  70072. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70073. /**
  70074. * Sets the required values to the prepass renderer.
  70075. * @param prePassRenderer defines the prepass renderer to setup.
  70076. * @returns true if the pre pass is needed.
  70077. */
  70078. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70079. /**
  70080. * Disposes of the pipeline
  70081. */
  70082. dispose(): void;
  70083. }
  70084. }
  70085. declare module BABYLON {
  70086. /**
  70087. * PostProcessRenderPipelineManager class
  70088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70089. */
  70090. export class PostProcessRenderPipelineManager {
  70091. private _renderPipelines;
  70092. /**
  70093. * Initializes a PostProcessRenderPipelineManager
  70094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70095. */
  70096. constructor();
  70097. /**
  70098. * Gets the list of supported render pipelines
  70099. */
  70100. get supportedPipelines(): PostProcessRenderPipeline[];
  70101. /**
  70102. * Adds a pipeline to the manager
  70103. * @param renderPipeline The pipeline to add
  70104. */
  70105. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70106. /**
  70107. * Attaches a camera to the pipeline
  70108. * @param renderPipelineName The name of the pipeline to attach to
  70109. * @param cameras the camera to attach
  70110. * @param unique if the camera can be attached multiple times to the pipeline
  70111. */
  70112. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70113. /**
  70114. * Detaches a camera from the pipeline
  70115. * @param renderPipelineName The name of the pipeline to detach from
  70116. * @param cameras the camera to detach
  70117. */
  70118. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70119. /**
  70120. * Enables an effect by name on a pipeline
  70121. * @param renderPipelineName the name of the pipeline to enable the effect in
  70122. * @param renderEffectName the name of the effect to enable
  70123. * @param cameras the cameras that the effect should be enabled on
  70124. */
  70125. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70126. /**
  70127. * Disables an effect by name on a pipeline
  70128. * @param renderPipelineName the name of the pipeline to disable the effect in
  70129. * @param renderEffectName the name of the effect to disable
  70130. * @param cameras the cameras that the effect should be disabled on
  70131. */
  70132. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70133. /**
  70134. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70135. */
  70136. update(): void;
  70137. /** @hidden */
  70138. _rebuild(): void;
  70139. /**
  70140. * Disposes of the manager and pipelines
  70141. */
  70142. dispose(): void;
  70143. }
  70144. }
  70145. declare module BABYLON {
  70146. interface Scene {
  70147. /** @hidden (Backing field) */
  70148. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70149. /**
  70150. * Gets the postprocess render pipeline manager
  70151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70152. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70153. */
  70154. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70155. }
  70156. /**
  70157. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70158. */
  70159. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70160. /**
  70161. * The component name helpfull to identify the component in the list of scene components.
  70162. */
  70163. readonly name: string;
  70164. /**
  70165. * The scene the component belongs to.
  70166. */
  70167. scene: Scene;
  70168. /**
  70169. * Creates a new instance of the component for the given scene
  70170. * @param scene Defines the scene to register the component in
  70171. */
  70172. constructor(scene: Scene);
  70173. /**
  70174. * Registers the component in a given scene
  70175. */
  70176. register(): void;
  70177. /**
  70178. * Rebuilds the elements related to this component in case of
  70179. * context lost for instance.
  70180. */
  70181. rebuild(): void;
  70182. /**
  70183. * Disposes the component and the associated ressources
  70184. */
  70185. dispose(): void;
  70186. private _gatherRenderTargets;
  70187. }
  70188. }
  70189. declare module BABYLON {
  70190. /**
  70191. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70192. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70193. */
  70194. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70195. private _scene;
  70196. private _camerasToBeAttached;
  70197. /**
  70198. * ID of the sharpen post process,
  70199. */
  70200. private readonly SharpenPostProcessId;
  70201. /**
  70202. * @ignore
  70203. * ID of the image processing post process;
  70204. */
  70205. readonly ImageProcessingPostProcessId: string;
  70206. /**
  70207. * @ignore
  70208. * ID of the Fast Approximate Anti-Aliasing post process;
  70209. */
  70210. readonly FxaaPostProcessId: string;
  70211. /**
  70212. * ID of the chromatic aberration post process,
  70213. */
  70214. private readonly ChromaticAberrationPostProcessId;
  70215. /**
  70216. * ID of the grain post process
  70217. */
  70218. private readonly GrainPostProcessId;
  70219. /**
  70220. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70221. */
  70222. sharpen: SharpenPostProcess;
  70223. private _sharpenEffect;
  70224. private bloom;
  70225. /**
  70226. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70227. */
  70228. depthOfField: DepthOfFieldEffect;
  70229. /**
  70230. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70231. */
  70232. fxaa: FxaaPostProcess;
  70233. /**
  70234. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70235. */
  70236. imageProcessing: ImageProcessingPostProcess;
  70237. /**
  70238. * Chromatic aberration post process which will shift rgb colors in the image
  70239. */
  70240. chromaticAberration: ChromaticAberrationPostProcess;
  70241. private _chromaticAberrationEffect;
  70242. /**
  70243. * Grain post process which add noise to the image
  70244. */
  70245. grain: GrainPostProcess;
  70246. private _grainEffect;
  70247. /**
  70248. * Glow post process which adds a glow to emissive areas of the image
  70249. */
  70250. private _glowLayer;
  70251. /**
  70252. * Animations which can be used to tweak settings over a period of time
  70253. */
  70254. animations: Animation[];
  70255. private _imageProcessingConfigurationObserver;
  70256. private _sharpenEnabled;
  70257. private _bloomEnabled;
  70258. private _depthOfFieldEnabled;
  70259. private _depthOfFieldBlurLevel;
  70260. private _fxaaEnabled;
  70261. private _imageProcessingEnabled;
  70262. private _defaultPipelineTextureType;
  70263. private _bloomScale;
  70264. private _chromaticAberrationEnabled;
  70265. private _grainEnabled;
  70266. private _buildAllowed;
  70267. /**
  70268. * Gets active scene
  70269. */
  70270. get scene(): Scene;
  70271. /**
  70272. * Enable or disable the sharpen process from the pipeline
  70273. */
  70274. set sharpenEnabled(enabled: boolean);
  70275. get sharpenEnabled(): boolean;
  70276. private _resizeObserver;
  70277. private _hardwareScaleLevel;
  70278. private _bloomKernel;
  70279. /**
  70280. * Specifies the size of the bloom blur kernel, relative to the final output size
  70281. */
  70282. get bloomKernel(): number;
  70283. set bloomKernel(value: number);
  70284. /**
  70285. * Specifies the weight of the bloom in the final rendering
  70286. */
  70287. private _bloomWeight;
  70288. /**
  70289. * Specifies the luma threshold for the area that will be blurred by the bloom
  70290. */
  70291. private _bloomThreshold;
  70292. private _hdr;
  70293. /**
  70294. * The strength of the bloom.
  70295. */
  70296. set bloomWeight(value: number);
  70297. get bloomWeight(): number;
  70298. /**
  70299. * The strength of the bloom.
  70300. */
  70301. set bloomThreshold(value: number);
  70302. get bloomThreshold(): number;
  70303. /**
  70304. * The scale of the bloom, lower value will provide better performance.
  70305. */
  70306. set bloomScale(value: number);
  70307. get bloomScale(): number;
  70308. /**
  70309. * Enable or disable the bloom from the pipeline
  70310. */
  70311. set bloomEnabled(enabled: boolean);
  70312. get bloomEnabled(): boolean;
  70313. private _rebuildBloom;
  70314. /**
  70315. * If the depth of field is enabled.
  70316. */
  70317. get depthOfFieldEnabled(): boolean;
  70318. set depthOfFieldEnabled(enabled: boolean);
  70319. /**
  70320. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70321. */
  70322. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70323. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70324. /**
  70325. * If the anti aliasing is enabled.
  70326. */
  70327. set fxaaEnabled(enabled: boolean);
  70328. get fxaaEnabled(): boolean;
  70329. private _samples;
  70330. /**
  70331. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70332. */
  70333. set samples(sampleCount: number);
  70334. get samples(): number;
  70335. /**
  70336. * If image processing is enabled.
  70337. */
  70338. set imageProcessingEnabled(enabled: boolean);
  70339. get imageProcessingEnabled(): boolean;
  70340. /**
  70341. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70342. */
  70343. set glowLayerEnabled(enabled: boolean);
  70344. get glowLayerEnabled(): boolean;
  70345. /**
  70346. * Gets the glow layer (or null if not defined)
  70347. */
  70348. get glowLayer(): Nullable<GlowLayer>;
  70349. /**
  70350. * Enable or disable the chromaticAberration process from the pipeline
  70351. */
  70352. set chromaticAberrationEnabled(enabled: boolean);
  70353. get chromaticAberrationEnabled(): boolean;
  70354. /**
  70355. * Enable or disable the grain process from the pipeline
  70356. */
  70357. set grainEnabled(enabled: boolean);
  70358. get grainEnabled(): boolean;
  70359. /**
  70360. * @constructor
  70361. * @param name - The rendering pipeline name (default: "")
  70362. * @param hdr - If high dynamic range textures should be used (default: true)
  70363. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70364. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70365. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70366. */
  70367. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70368. /**
  70369. * Get the class name
  70370. * @returns "DefaultRenderingPipeline"
  70371. */
  70372. getClassName(): string;
  70373. /**
  70374. * Force the compilation of the entire pipeline.
  70375. */
  70376. prepare(): void;
  70377. private _hasCleared;
  70378. private _prevPostProcess;
  70379. private _prevPrevPostProcess;
  70380. private _setAutoClearAndTextureSharing;
  70381. private _depthOfFieldSceneObserver;
  70382. private _buildPipeline;
  70383. private _disposePostProcesses;
  70384. /**
  70385. * Adds a camera to the pipeline
  70386. * @param camera the camera to be added
  70387. */
  70388. addCamera(camera: Camera): void;
  70389. /**
  70390. * Removes a camera from the pipeline
  70391. * @param camera the camera to remove
  70392. */
  70393. removeCamera(camera: Camera): void;
  70394. /**
  70395. * Dispose of the pipeline and stop all post processes
  70396. */
  70397. dispose(): void;
  70398. /**
  70399. * Serialize the rendering pipeline (Used when exporting)
  70400. * @returns the serialized object
  70401. */
  70402. serialize(): any;
  70403. /**
  70404. * Parse the serialized pipeline
  70405. * @param source Source pipeline.
  70406. * @param scene The scene to load the pipeline to.
  70407. * @param rootUrl The URL of the serialized pipeline.
  70408. * @returns An instantiated pipeline from the serialized object.
  70409. */
  70410. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70411. }
  70412. }
  70413. declare module BABYLON {
  70414. /** @hidden */
  70415. export var lensHighlightsPixelShader: {
  70416. name: string;
  70417. shader: string;
  70418. };
  70419. }
  70420. declare module BABYLON {
  70421. /** @hidden */
  70422. export var depthOfFieldPixelShader: {
  70423. name: string;
  70424. shader: string;
  70425. };
  70426. }
  70427. declare module BABYLON {
  70428. /**
  70429. * BABYLON.JS Chromatic Aberration GLSL Shader
  70430. * Author: Olivier Guyot
  70431. * Separates very slightly R, G and B colors on the edges of the screen
  70432. * Inspired by Francois Tarlier & Martins Upitis
  70433. */
  70434. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70435. /**
  70436. * @ignore
  70437. * The chromatic aberration PostProcess id in the pipeline
  70438. */
  70439. LensChromaticAberrationEffect: string;
  70440. /**
  70441. * @ignore
  70442. * The highlights enhancing PostProcess id in the pipeline
  70443. */
  70444. HighlightsEnhancingEffect: string;
  70445. /**
  70446. * @ignore
  70447. * The depth-of-field PostProcess id in the pipeline
  70448. */
  70449. LensDepthOfFieldEffect: string;
  70450. private _scene;
  70451. private _depthTexture;
  70452. private _grainTexture;
  70453. private _chromaticAberrationPostProcess;
  70454. private _highlightsPostProcess;
  70455. private _depthOfFieldPostProcess;
  70456. private _edgeBlur;
  70457. private _grainAmount;
  70458. private _chromaticAberration;
  70459. private _distortion;
  70460. private _highlightsGain;
  70461. private _highlightsThreshold;
  70462. private _dofDistance;
  70463. private _dofAperture;
  70464. private _dofDarken;
  70465. private _dofPentagon;
  70466. private _blurNoise;
  70467. /**
  70468. * @constructor
  70469. *
  70470. * Effect parameters are as follow:
  70471. * {
  70472. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70473. * edge_blur: number; // from 0 to x (1 for realism)
  70474. * distortion: number; // from 0 to x (1 for realism)
  70475. * grain_amount: number; // from 0 to 1
  70476. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70477. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70478. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70479. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70480. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70481. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70482. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70483. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70484. * }
  70485. * Note: if an effect parameter is unset, effect is disabled
  70486. *
  70487. * @param name The rendering pipeline name
  70488. * @param parameters - An object containing all parameters (see above)
  70489. * @param scene The scene linked to this pipeline
  70490. * @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)
  70491. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70492. */
  70493. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70494. /**
  70495. * Get the class name
  70496. * @returns "LensRenderingPipeline"
  70497. */
  70498. getClassName(): string;
  70499. /**
  70500. * Gets associated scene
  70501. */
  70502. get scene(): Scene;
  70503. /**
  70504. * Gets or sets the edge blur
  70505. */
  70506. get edgeBlur(): number;
  70507. set edgeBlur(value: number);
  70508. /**
  70509. * Gets or sets the grain amount
  70510. */
  70511. get grainAmount(): number;
  70512. set grainAmount(value: number);
  70513. /**
  70514. * Gets or sets the chromatic aberration amount
  70515. */
  70516. get chromaticAberration(): number;
  70517. set chromaticAberration(value: number);
  70518. /**
  70519. * Gets or sets the depth of field aperture
  70520. */
  70521. get dofAperture(): number;
  70522. set dofAperture(value: number);
  70523. /**
  70524. * Gets or sets the edge distortion
  70525. */
  70526. get edgeDistortion(): number;
  70527. set edgeDistortion(value: number);
  70528. /**
  70529. * Gets or sets the depth of field distortion
  70530. */
  70531. get dofDistortion(): number;
  70532. set dofDistortion(value: number);
  70533. /**
  70534. * Gets or sets the darken out of focus amount
  70535. */
  70536. get darkenOutOfFocus(): number;
  70537. set darkenOutOfFocus(value: number);
  70538. /**
  70539. * Gets or sets a boolean indicating if blur noise is enabled
  70540. */
  70541. get blurNoise(): boolean;
  70542. set blurNoise(value: boolean);
  70543. /**
  70544. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70545. */
  70546. get pentagonBokeh(): boolean;
  70547. set pentagonBokeh(value: boolean);
  70548. /**
  70549. * Gets or sets the highlight grain amount
  70550. */
  70551. get highlightsGain(): number;
  70552. set highlightsGain(value: number);
  70553. /**
  70554. * Gets or sets the highlight threshold
  70555. */
  70556. get highlightsThreshold(): number;
  70557. set highlightsThreshold(value: number);
  70558. /**
  70559. * Sets the amount of blur at the edges
  70560. * @param amount blur amount
  70561. */
  70562. setEdgeBlur(amount: number): void;
  70563. /**
  70564. * Sets edge blur to 0
  70565. */
  70566. disableEdgeBlur(): void;
  70567. /**
  70568. * Sets the amout of grain
  70569. * @param amount Amount of grain
  70570. */
  70571. setGrainAmount(amount: number): void;
  70572. /**
  70573. * Set grain amount to 0
  70574. */
  70575. disableGrain(): void;
  70576. /**
  70577. * Sets the chromatic aberration amount
  70578. * @param amount amount of chromatic aberration
  70579. */
  70580. setChromaticAberration(amount: number): void;
  70581. /**
  70582. * Sets chromatic aberration amount to 0
  70583. */
  70584. disableChromaticAberration(): void;
  70585. /**
  70586. * Sets the EdgeDistortion amount
  70587. * @param amount amount of EdgeDistortion
  70588. */
  70589. setEdgeDistortion(amount: number): void;
  70590. /**
  70591. * Sets edge distortion to 0
  70592. */
  70593. disableEdgeDistortion(): void;
  70594. /**
  70595. * Sets the FocusDistance amount
  70596. * @param amount amount of FocusDistance
  70597. */
  70598. setFocusDistance(amount: number): void;
  70599. /**
  70600. * Disables depth of field
  70601. */
  70602. disableDepthOfField(): void;
  70603. /**
  70604. * Sets the Aperture amount
  70605. * @param amount amount of Aperture
  70606. */
  70607. setAperture(amount: number): void;
  70608. /**
  70609. * Sets the DarkenOutOfFocus amount
  70610. * @param amount amount of DarkenOutOfFocus
  70611. */
  70612. setDarkenOutOfFocus(amount: number): void;
  70613. private _pentagonBokehIsEnabled;
  70614. /**
  70615. * Creates a pentagon bokeh effect
  70616. */
  70617. enablePentagonBokeh(): void;
  70618. /**
  70619. * Disables the pentagon bokeh effect
  70620. */
  70621. disablePentagonBokeh(): void;
  70622. /**
  70623. * Enables noise blur
  70624. */
  70625. enableNoiseBlur(): void;
  70626. /**
  70627. * Disables noise blur
  70628. */
  70629. disableNoiseBlur(): void;
  70630. /**
  70631. * Sets the HighlightsGain amount
  70632. * @param amount amount of HighlightsGain
  70633. */
  70634. setHighlightsGain(amount: number): void;
  70635. /**
  70636. * Sets the HighlightsThreshold amount
  70637. * @param amount amount of HighlightsThreshold
  70638. */
  70639. setHighlightsThreshold(amount: number): void;
  70640. /**
  70641. * Disables highlights
  70642. */
  70643. disableHighlights(): void;
  70644. /**
  70645. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70646. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70647. */
  70648. dispose(disableDepthRender?: boolean): void;
  70649. private _createChromaticAberrationPostProcess;
  70650. private _createHighlightsPostProcess;
  70651. private _createDepthOfFieldPostProcess;
  70652. private _createGrainTexture;
  70653. }
  70654. }
  70655. declare module BABYLON {
  70656. /** @hidden */
  70657. export var ssao2PixelShader: {
  70658. name: string;
  70659. shader: string;
  70660. };
  70661. }
  70662. declare module BABYLON {
  70663. /** @hidden */
  70664. export var ssaoCombinePixelShader: {
  70665. name: string;
  70666. shader: string;
  70667. };
  70668. }
  70669. declare module BABYLON {
  70670. /**
  70671. * Render pipeline to produce ssao effect
  70672. */
  70673. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70674. /**
  70675. * @ignore
  70676. * The PassPostProcess id in the pipeline that contains the original scene color
  70677. */
  70678. SSAOOriginalSceneColorEffect: string;
  70679. /**
  70680. * @ignore
  70681. * The SSAO PostProcess id in the pipeline
  70682. */
  70683. SSAORenderEffect: string;
  70684. /**
  70685. * @ignore
  70686. * The horizontal blur PostProcess id in the pipeline
  70687. */
  70688. SSAOBlurHRenderEffect: string;
  70689. /**
  70690. * @ignore
  70691. * The vertical blur PostProcess id in the pipeline
  70692. */
  70693. SSAOBlurVRenderEffect: string;
  70694. /**
  70695. * @ignore
  70696. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70697. */
  70698. SSAOCombineRenderEffect: string;
  70699. /**
  70700. * The output strength of the SSAO post-process. Default value is 1.0.
  70701. */
  70702. totalStrength: number;
  70703. /**
  70704. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70705. */
  70706. maxZ: number;
  70707. /**
  70708. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70709. */
  70710. minZAspect: number;
  70711. private _samples;
  70712. /**
  70713. * Number of samples used for the SSAO calculations. Default value is 8
  70714. */
  70715. set samples(n: number);
  70716. get samples(): number;
  70717. private _textureSamples;
  70718. /**
  70719. * Number of samples to use for antialiasing
  70720. */
  70721. set textureSamples(n: number);
  70722. get textureSamples(): number;
  70723. /**
  70724. * Force rendering the geometry through geometry buffer
  70725. */
  70726. private _forceGeometryBuffer;
  70727. /**
  70728. * Ratio object used for SSAO ratio and blur ratio
  70729. */
  70730. private _ratio;
  70731. /**
  70732. * Dynamically generated sphere sampler.
  70733. */
  70734. private _sampleSphere;
  70735. /**
  70736. * Blur filter offsets
  70737. */
  70738. private _samplerOffsets;
  70739. private _expensiveBlur;
  70740. /**
  70741. * If bilateral blur should be used
  70742. */
  70743. set expensiveBlur(b: boolean);
  70744. get expensiveBlur(): boolean;
  70745. /**
  70746. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70747. */
  70748. radius: number;
  70749. /**
  70750. * The base color of the SSAO post-process
  70751. * The final result is "base + ssao" between [0, 1]
  70752. */
  70753. base: number;
  70754. /**
  70755. * Support test.
  70756. */
  70757. static get IsSupported(): boolean;
  70758. private _scene;
  70759. private _randomTexture;
  70760. private _originalColorPostProcess;
  70761. private _ssaoPostProcess;
  70762. private _blurHPostProcess;
  70763. private _blurVPostProcess;
  70764. private _ssaoCombinePostProcess;
  70765. private _prePassRenderer;
  70766. /**
  70767. * Gets active scene
  70768. */
  70769. get scene(): Scene;
  70770. /**
  70771. * @constructor
  70772. * @param name The rendering pipeline name
  70773. * @param scene The scene linked to this pipeline
  70774. * @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 }
  70775. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70776. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70777. */
  70778. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70779. /**
  70780. * Get the class name
  70781. * @returns "SSAO2RenderingPipeline"
  70782. */
  70783. getClassName(): string;
  70784. /**
  70785. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70786. */
  70787. dispose(disableGeometryBufferRenderer?: boolean): void;
  70788. private _createBlurPostProcess;
  70789. /** @hidden */
  70790. _rebuild(): void;
  70791. private _bits;
  70792. private _radicalInverse_VdC;
  70793. private _hammersley;
  70794. private _hemisphereSample_uniform;
  70795. private _generateHemisphere;
  70796. private _getDefinesForSSAO;
  70797. private _createSSAOPostProcess;
  70798. private _createSSAOCombinePostProcess;
  70799. private _createRandomTexture;
  70800. /**
  70801. * Serialize the rendering pipeline (Used when exporting)
  70802. * @returns the serialized object
  70803. */
  70804. serialize(): any;
  70805. /**
  70806. * Parse the serialized pipeline
  70807. * @param source Source pipeline.
  70808. * @param scene The scene to load the pipeline to.
  70809. * @param rootUrl The URL of the serialized pipeline.
  70810. * @returns An instantiated pipeline from the serialized object.
  70811. */
  70812. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70813. /**
  70814. * Sets the required values to the prepass renderer.
  70815. * @param prePassRenderer defines the prepass renderer to setup
  70816. * @returns true if the pre pass is needed.
  70817. */
  70818. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70819. }
  70820. }
  70821. declare module BABYLON {
  70822. /** @hidden */
  70823. export var ssaoPixelShader: {
  70824. name: string;
  70825. shader: string;
  70826. };
  70827. }
  70828. declare module BABYLON {
  70829. /**
  70830. * Render pipeline to produce ssao effect
  70831. */
  70832. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70833. /**
  70834. * @ignore
  70835. * The PassPostProcess id in the pipeline that contains the original scene color
  70836. */
  70837. SSAOOriginalSceneColorEffect: string;
  70838. /**
  70839. * @ignore
  70840. * The SSAO PostProcess id in the pipeline
  70841. */
  70842. SSAORenderEffect: string;
  70843. /**
  70844. * @ignore
  70845. * The horizontal blur PostProcess id in the pipeline
  70846. */
  70847. SSAOBlurHRenderEffect: string;
  70848. /**
  70849. * @ignore
  70850. * The vertical blur PostProcess id in the pipeline
  70851. */
  70852. SSAOBlurVRenderEffect: string;
  70853. /**
  70854. * @ignore
  70855. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70856. */
  70857. SSAOCombineRenderEffect: string;
  70858. /**
  70859. * The output strength of the SSAO post-process. Default value is 1.0.
  70860. */
  70861. totalStrength: number;
  70862. /**
  70863. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70864. */
  70865. radius: number;
  70866. /**
  70867. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70868. * Must not be equal to fallOff and superior to fallOff.
  70869. * Default value is 0.0075
  70870. */
  70871. area: number;
  70872. /**
  70873. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70874. * Must not be equal to area and inferior to area.
  70875. * Default value is 0.000001
  70876. */
  70877. fallOff: number;
  70878. /**
  70879. * The base color of the SSAO post-process
  70880. * The final result is "base + ssao" between [0, 1]
  70881. */
  70882. base: number;
  70883. private _scene;
  70884. private _depthTexture;
  70885. private _randomTexture;
  70886. private _originalColorPostProcess;
  70887. private _ssaoPostProcess;
  70888. private _blurHPostProcess;
  70889. private _blurVPostProcess;
  70890. private _ssaoCombinePostProcess;
  70891. private _firstUpdate;
  70892. /**
  70893. * Gets active scene
  70894. */
  70895. get scene(): Scene;
  70896. /**
  70897. * @constructor
  70898. * @param name - The rendering pipeline name
  70899. * @param scene - The scene linked to this pipeline
  70900. * @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 }
  70901. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70902. */
  70903. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70904. /**
  70905. * Get the class name
  70906. * @returns "SSAORenderingPipeline"
  70907. */
  70908. getClassName(): string;
  70909. /**
  70910. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70911. */
  70912. dispose(disableDepthRender?: boolean): void;
  70913. private _createBlurPostProcess;
  70914. /** @hidden */
  70915. _rebuild(): void;
  70916. private _createSSAOPostProcess;
  70917. private _createSSAOCombinePostProcess;
  70918. private _createRandomTexture;
  70919. }
  70920. }
  70921. declare module BABYLON {
  70922. /** @hidden */
  70923. export var screenSpaceReflectionPixelShader: {
  70924. name: string;
  70925. shader: string;
  70926. };
  70927. }
  70928. declare module BABYLON {
  70929. /**
  70930. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70931. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70932. */
  70933. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70934. /**
  70935. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70936. */
  70937. threshold: number;
  70938. /**
  70939. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70940. */
  70941. strength: number;
  70942. /**
  70943. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70944. */
  70945. reflectionSpecularFalloffExponent: number;
  70946. /**
  70947. * 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]
  70948. */
  70949. step: number;
  70950. /**
  70951. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70952. */
  70953. roughnessFactor: number;
  70954. private _geometryBufferRenderer;
  70955. private _enableSmoothReflections;
  70956. private _reflectionSamples;
  70957. private _smoothSteps;
  70958. /**
  70959. * Gets a string identifying the name of the class
  70960. * @returns "ScreenSpaceReflectionPostProcess" string
  70961. */
  70962. getClassName(): string;
  70963. /**
  70964. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70965. * @param name The name of the effect.
  70966. * @param scene The scene containing the objects to calculate reflections.
  70967. * @param options The required width/height ratio to downsize to before computing the render pass.
  70968. * @param camera The camera to apply the render pass to.
  70969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70970. * @param engine The engine which the post process will be applied. (default: current engine)
  70971. * @param reusable If the post process can be reused on the same frame. (default: false)
  70972. * @param textureType Type of textures used when performing the post process. (default: 0)
  70973. * @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)
  70974. */
  70975. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70976. /**
  70977. * Gets wether or not smoothing reflections is enabled.
  70978. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70979. */
  70980. get enableSmoothReflections(): boolean;
  70981. /**
  70982. * Sets wether or not smoothing reflections is enabled.
  70983. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70984. */
  70985. set enableSmoothReflections(enabled: boolean);
  70986. /**
  70987. * Gets the number of samples taken while computing reflections. More samples count is high,
  70988. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70989. */
  70990. get reflectionSamples(): number;
  70991. /**
  70992. * Sets the number of samples taken while computing reflections. More samples count is high,
  70993. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70994. */
  70995. set reflectionSamples(samples: number);
  70996. /**
  70997. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70998. * more the post-process will require GPU power and can generate a drop in FPS.
  70999. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71000. */
  71001. get smoothSteps(): number;
  71002. set smoothSteps(steps: number);
  71003. private _updateEffectDefines;
  71004. /** @hidden */
  71005. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71006. }
  71007. }
  71008. declare module BABYLON {
  71009. /** @hidden */
  71010. export var standardPixelShader: {
  71011. name: string;
  71012. shader: string;
  71013. };
  71014. }
  71015. declare module BABYLON {
  71016. /**
  71017. * Standard rendering pipeline
  71018. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71019. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71020. */
  71021. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71022. /**
  71023. * Public members
  71024. */
  71025. /**
  71026. * Post-process which contains the original scene color before the pipeline applies all the effects
  71027. */
  71028. originalPostProcess: Nullable<PostProcess>;
  71029. /**
  71030. * Post-process used to down scale an image x4
  71031. */
  71032. downSampleX4PostProcess: Nullable<PostProcess>;
  71033. /**
  71034. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71035. */
  71036. brightPassPostProcess: Nullable<PostProcess>;
  71037. /**
  71038. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71039. */
  71040. blurHPostProcesses: PostProcess[];
  71041. /**
  71042. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71043. */
  71044. blurVPostProcesses: PostProcess[];
  71045. /**
  71046. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71047. */
  71048. textureAdderPostProcess: Nullable<PostProcess>;
  71049. /**
  71050. * Post-process used to create volumetric lighting effect
  71051. */
  71052. volumetricLightPostProcess: Nullable<PostProcess>;
  71053. /**
  71054. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71055. */
  71056. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71057. /**
  71058. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71059. */
  71060. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71061. /**
  71062. * Post-process used to merge the volumetric light effect and the real scene color
  71063. */
  71064. volumetricLightMergePostProces: Nullable<PostProcess>;
  71065. /**
  71066. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71067. */
  71068. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71069. /**
  71070. * Base post-process used to calculate the average luminance of the final image for HDR
  71071. */
  71072. luminancePostProcess: Nullable<PostProcess>;
  71073. /**
  71074. * Post-processes used to create down sample post-processes in order to get
  71075. * the average luminance of the final image for HDR
  71076. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71077. */
  71078. luminanceDownSamplePostProcesses: PostProcess[];
  71079. /**
  71080. * Post-process used to create a HDR effect (light adaptation)
  71081. */
  71082. hdrPostProcess: Nullable<PostProcess>;
  71083. /**
  71084. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71085. */
  71086. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71087. /**
  71088. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71089. */
  71090. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71091. /**
  71092. * Post-process used to merge the final HDR post-process and the real scene color
  71093. */
  71094. hdrFinalPostProcess: Nullable<PostProcess>;
  71095. /**
  71096. * Post-process used to create a lens flare effect
  71097. */
  71098. lensFlarePostProcess: Nullable<PostProcess>;
  71099. /**
  71100. * Post-process that merges the result of the lens flare post-process and the real scene color
  71101. */
  71102. lensFlareComposePostProcess: Nullable<PostProcess>;
  71103. /**
  71104. * Post-process used to create a motion blur effect
  71105. */
  71106. motionBlurPostProcess: Nullable<PostProcess>;
  71107. /**
  71108. * Post-process used to create a depth of field effect
  71109. */
  71110. depthOfFieldPostProcess: Nullable<PostProcess>;
  71111. /**
  71112. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71113. */
  71114. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71115. /**
  71116. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71117. */
  71118. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71119. /**
  71120. * Represents the brightness threshold in order to configure the illuminated surfaces
  71121. */
  71122. brightThreshold: number;
  71123. /**
  71124. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71125. */
  71126. blurWidth: number;
  71127. /**
  71128. * Sets if the blur for highlighted surfaces must be only horizontal
  71129. */
  71130. horizontalBlur: boolean;
  71131. /**
  71132. * Gets the overall exposure used by the pipeline
  71133. */
  71134. get exposure(): number;
  71135. /**
  71136. * Sets the overall exposure used by the pipeline
  71137. */
  71138. set exposure(value: number);
  71139. /**
  71140. * Texture used typically to simulate "dirty" on camera lens
  71141. */
  71142. lensTexture: Nullable<Texture>;
  71143. /**
  71144. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71145. */
  71146. volumetricLightCoefficient: number;
  71147. /**
  71148. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71149. */
  71150. volumetricLightPower: number;
  71151. /**
  71152. * Used the set the blur intensity to smooth the volumetric lights
  71153. */
  71154. volumetricLightBlurScale: number;
  71155. /**
  71156. * Light (spot or directional) used to generate the volumetric lights rays
  71157. * The source light must have a shadow generate so the pipeline can get its
  71158. * depth map
  71159. */
  71160. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71161. /**
  71162. * For eye adaptation, represents the minimum luminance the eye can see
  71163. */
  71164. hdrMinimumLuminance: number;
  71165. /**
  71166. * For eye adaptation, represents the decrease luminance speed
  71167. */
  71168. hdrDecreaseRate: number;
  71169. /**
  71170. * For eye adaptation, represents the increase luminance speed
  71171. */
  71172. hdrIncreaseRate: number;
  71173. /**
  71174. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71175. */
  71176. get hdrAutoExposure(): boolean;
  71177. /**
  71178. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71179. */
  71180. set hdrAutoExposure(value: boolean);
  71181. /**
  71182. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71183. */
  71184. lensColorTexture: Nullable<Texture>;
  71185. /**
  71186. * The overall strengh for the lens flare effect
  71187. */
  71188. lensFlareStrength: number;
  71189. /**
  71190. * Dispersion coefficient for lens flare ghosts
  71191. */
  71192. lensFlareGhostDispersal: number;
  71193. /**
  71194. * Main lens flare halo width
  71195. */
  71196. lensFlareHaloWidth: number;
  71197. /**
  71198. * Based on the lens distortion effect, defines how much the lens flare result
  71199. * is distorted
  71200. */
  71201. lensFlareDistortionStrength: number;
  71202. /**
  71203. * Configures the blur intensity used for for lens flare (halo)
  71204. */
  71205. lensFlareBlurWidth: number;
  71206. /**
  71207. * Lens star texture must be used to simulate rays on the flares and is available
  71208. * in the documentation
  71209. */
  71210. lensStarTexture: Nullable<Texture>;
  71211. /**
  71212. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71213. * flare effect by taking account of the dirt texture
  71214. */
  71215. lensFlareDirtTexture: Nullable<Texture>;
  71216. /**
  71217. * Represents the focal length for the depth of field effect
  71218. */
  71219. depthOfFieldDistance: number;
  71220. /**
  71221. * Represents the blur intensity for the blurred part of the depth of field effect
  71222. */
  71223. depthOfFieldBlurWidth: number;
  71224. /**
  71225. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71226. */
  71227. get motionStrength(): number;
  71228. /**
  71229. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71230. */
  71231. set motionStrength(strength: number);
  71232. /**
  71233. * Gets wether or not the motion blur post-process is object based or screen based.
  71234. */
  71235. get objectBasedMotionBlur(): boolean;
  71236. /**
  71237. * Sets wether or not the motion blur post-process should be object based or screen based
  71238. */
  71239. set objectBasedMotionBlur(value: boolean);
  71240. /**
  71241. * List of animations for the pipeline (IAnimatable implementation)
  71242. */
  71243. animations: Animation[];
  71244. /**
  71245. * Private members
  71246. */
  71247. private _scene;
  71248. private _currentDepthOfFieldSource;
  71249. private _basePostProcess;
  71250. private _fixedExposure;
  71251. private _currentExposure;
  71252. private _hdrAutoExposure;
  71253. private _hdrCurrentLuminance;
  71254. private _motionStrength;
  71255. private _isObjectBasedMotionBlur;
  71256. private _floatTextureType;
  71257. private _camerasToBeAttached;
  71258. private _ratio;
  71259. private _bloomEnabled;
  71260. private _depthOfFieldEnabled;
  71261. private _vlsEnabled;
  71262. private _lensFlareEnabled;
  71263. private _hdrEnabled;
  71264. private _motionBlurEnabled;
  71265. private _fxaaEnabled;
  71266. private _screenSpaceReflectionsEnabled;
  71267. private _motionBlurSamples;
  71268. private _volumetricLightStepsCount;
  71269. private _samples;
  71270. /**
  71271. * @ignore
  71272. * Specifies if the bloom pipeline is enabled
  71273. */
  71274. get BloomEnabled(): boolean;
  71275. set BloomEnabled(enabled: boolean);
  71276. /**
  71277. * @ignore
  71278. * Specifies if the depth of field pipeline is enabed
  71279. */
  71280. get DepthOfFieldEnabled(): boolean;
  71281. set DepthOfFieldEnabled(enabled: boolean);
  71282. /**
  71283. * @ignore
  71284. * Specifies if the lens flare pipeline is enabed
  71285. */
  71286. get LensFlareEnabled(): boolean;
  71287. set LensFlareEnabled(enabled: boolean);
  71288. /**
  71289. * @ignore
  71290. * Specifies if the HDR pipeline is enabled
  71291. */
  71292. get HDREnabled(): boolean;
  71293. set HDREnabled(enabled: boolean);
  71294. /**
  71295. * @ignore
  71296. * Specifies if the volumetric lights scattering effect is enabled
  71297. */
  71298. get VLSEnabled(): boolean;
  71299. set VLSEnabled(enabled: boolean);
  71300. /**
  71301. * @ignore
  71302. * Specifies if the motion blur effect is enabled
  71303. */
  71304. get MotionBlurEnabled(): boolean;
  71305. set MotionBlurEnabled(enabled: boolean);
  71306. /**
  71307. * Specifies if anti-aliasing is enabled
  71308. */
  71309. get fxaaEnabled(): boolean;
  71310. set fxaaEnabled(enabled: boolean);
  71311. /**
  71312. * Specifies if screen space reflections are enabled.
  71313. */
  71314. get screenSpaceReflectionsEnabled(): boolean;
  71315. set screenSpaceReflectionsEnabled(enabled: boolean);
  71316. /**
  71317. * Specifies the number of steps used to calculate the volumetric lights
  71318. * Typically in interval [50, 200]
  71319. */
  71320. get volumetricLightStepsCount(): number;
  71321. set volumetricLightStepsCount(count: number);
  71322. /**
  71323. * Specifies the number of samples used for the motion blur effect
  71324. * Typically in interval [16, 64]
  71325. */
  71326. get motionBlurSamples(): number;
  71327. set motionBlurSamples(samples: number);
  71328. /**
  71329. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71330. */
  71331. get samples(): number;
  71332. set samples(sampleCount: number);
  71333. /**
  71334. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71335. * @constructor
  71336. * @param name The rendering pipeline name
  71337. * @param scene The scene linked to this pipeline
  71338. * @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)
  71339. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71340. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71341. */
  71342. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71343. private _buildPipeline;
  71344. private _createDownSampleX4PostProcess;
  71345. private _createBrightPassPostProcess;
  71346. private _createBlurPostProcesses;
  71347. private _createTextureAdderPostProcess;
  71348. private _createVolumetricLightPostProcess;
  71349. private _createLuminancePostProcesses;
  71350. private _createHdrPostProcess;
  71351. private _createLensFlarePostProcess;
  71352. private _createDepthOfFieldPostProcess;
  71353. private _createMotionBlurPostProcess;
  71354. private _getDepthTexture;
  71355. private _disposePostProcesses;
  71356. /**
  71357. * Dispose of the pipeline and stop all post processes
  71358. */
  71359. dispose(): void;
  71360. /**
  71361. * Serialize the rendering pipeline (Used when exporting)
  71362. * @returns the serialized object
  71363. */
  71364. serialize(): any;
  71365. /**
  71366. * Parse the serialized pipeline
  71367. * @param source Source pipeline.
  71368. * @param scene The scene to load the pipeline to.
  71369. * @param rootUrl The URL of the serialized pipeline.
  71370. * @returns An instantiated pipeline from the serialized object.
  71371. */
  71372. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71373. /**
  71374. * Luminance steps
  71375. */
  71376. static LuminanceSteps: number;
  71377. }
  71378. }
  71379. declare module BABYLON {
  71380. /** @hidden */
  71381. export var stereoscopicInterlacePixelShader: {
  71382. name: string;
  71383. shader: string;
  71384. };
  71385. }
  71386. declare module BABYLON {
  71387. /**
  71388. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71389. */
  71390. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71391. private _stepSize;
  71392. private _passedProcess;
  71393. /**
  71394. * Gets a string identifying the name of the class
  71395. * @returns "StereoscopicInterlacePostProcessI" string
  71396. */
  71397. getClassName(): string;
  71398. /**
  71399. * Initializes a StereoscopicInterlacePostProcessI
  71400. * @param name The name of the effect.
  71401. * @param rigCameras The rig cameras to be appled to the post process
  71402. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71403. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71405. * @param engine The engine which the post process will be applied. (default: current engine)
  71406. * @param reusable If the post process can be reused on the same frame. (default: false)
  71407. */
  71408. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71409. }
  71410. /**
  71411. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71412. */
  71413. export class StereoscopicInterlacePostProcess extends PostProcess {
  71414. private _stepSize;
  71415. private _passedProcess;
  71416. /**
  71417. * Gets a string identifying the name of the class
  71418. * @returns "StereoscopicInterlacePostProcess" string
  71419. */
  71420. getClassName(): string;
  71421. /**
  71422. * Initializes a StereoscopicInterlacePostProcess
  71423. * @param name The name of the effect.
  71424. * @param rigCameras The rig cameras to be appled to the post process
  71425. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71427. * @param engine The engine which the post process will be applied. (default: current engine)
  71428. * @param reusable If the post process can be reused on the same frame. (default: false)
  71429. */
  71430. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71431. }
  71432. }
  71433. declare module BABYLON {
  71434. /** @hidden */
  71435. export var tonemapPixelShader: {
  71436. name: string;
  71437. shader: string;
  71438. };
  71439. }
  71440. declare module BABYLON {
  71441. /** Defines operator used for tonemapping */
  71442. export enum TonemappingOperator {
  71443. /** Hable */
  71444. Hable = 0,
  71445. /** Reinhard */
  71446. Reinhard = 1,
  71447. /** HejiDawson */
  71448. HejiDawson = 2,
  71449. /** Photographic */
  71450. Photographic = 3
  71451. }
  71452. /**
  71453. * Defines a post process to apply tone mapping
  71454. */
  71455. export class TonemapPostProcess extends PostProcess {
  71456. private _operator;
  71457. /** Defines the required exposure adjustement */
  71458. exposureAdjustment: number;
  71459. /**
  71460. * Gets a string identifying the name of the class
  71461. * @returns "TonemapPostProcess" string
  71462. */
  71463. getClassName(): string;
  71464. /**
  71465. * Creates a new TonemapPostProcess
  71466. * @param name defines the name of the postprocess
  71467. * @param _operator defines the operator to use
  71468. * @param exposureAdjustment defines the required exposure adjustement
  71469. * @param camera defines the camera to use (can be null)
  71470. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71471. * @param engine defines the hosting engine (can be ignore if camera is set)
  71472. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71473. */
  71474. constructor(name: string, _operator: TonemappingOperator,
  71475. /** Defines the required exposure adjustement */
  71476. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71477. }
  71478. }
  71479. declare module BABYLON {
  71480. /** @hidden */
  71481. export var volumetricLightScatteringPixelShader: {
  71482. name: string;
  71483. shader: string;
  71484. };
  71485. }
  71486. declare module BABYLON {
  71487. /** @hidden */
  71488. export var volumetricLightScatteringPassVertexShader: {
  71489. name: string;
  71490. shader: string;
  71491. };
  71492. }
  71493. declare module BABYLON {
  71494. /** @hidden */
  71495. export var volumetricLightScatteringPassPixelShader: {
  71496. name: string;
  71497. shader: string;
  71498. };
  71499. }
  71500. declare module BABYLON {
  71501. /**
  71502. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71503. */
  71504. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71505. private _volumetricLightScatteringPass;
  71506. private _volumetricLightScatteringRTT;
  71507. private _viewPort;
  71508. private _screenCoordinates;
  71509. private _cachedDefines;
  71510. /**
  71511. * If not undefined, the mesh position is computed from the attached node position
  71512. */
  71513. attachedNode: {
  71514. position: Vector3;
  71515. };
  71516. /**
  71517. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71518. */
  71519. customMeshPosition: Vector3;
  71520. /**
  71521. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71522. */
  71523. useCustomMeshPosition: boolean;
  71524. /**
  71525. * If the post-process should inverse the light scattering direction
  71526. */
  71527. invert: boolean;
  71528. /**
  71529. * The internal mesh used by the post-process
  71530. */
  71531. mesh: Mesh;
  71532. /**
  71533. * @hidden
  71534. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71535. */
  71536. get useDiffuseColor(): boolean;
  71537. set useDiffuseColor(useDiffuseColor: boolean);
  71538. /**
  71539. * Array containing the excluded meshes not rendered in the internal pass
  71540. */
  71541. excludedMeshes: AbstractMesh[];
  71542. /**
  71543. * Controls the overall intensity of the post-process
  71544. */
  71545. exposure: number;
  71546. /**
  71547. * Dissipates each sample's contribution in range [0, 1]
  71548. */
  71549. decay: number;
  71550. /**
  71551. * Controls the overall intensity of each sample
  71552. */
  71553. weight: number;
  71554. /**
  71555. * Controls the density of each sample
  71556. */
  71557. density: number;
  71558. /**
  71559. * @constructor
  71560. * @param name The post-process name
  71561. * @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)
  71562. * @param camera The camera that the post-process will be attached to
  71563. * @param mesh The mesh used to create the light scattering
  71564. * @param samples The post-process quality, default 100
  71565. * @param samplingModeThe post-process filtering mode
  71566. * @param engine The babylon engine
  71567. * @param reusable If the post-process is reusable
  71568. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71569. */
  71570. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71571. /**
  71572. * Returns the string "VolumetricLightScatteringPostProcess"
  71573. * @returns "VolumetricLightScatteringPostProcess"
  71574. */
  71575. getClassName(): string;
  71576. private _isReady;
  71577. /**
  71578. * Sets the new light position for light scattering effect
  71579. * @param position The new custom light position
  71580. */
  71581. setCustomMeshPosition(position: Vector3): void;
  71582. /**
  71583. * Returns the light position for light scattering effect
  71584. * @return Vector3 The custom light position
  71585. */
  71586. getCustomMeshPosition(): Vector3;
  71587. /**
  71588. * Disposes the internal assets and detaches the post-process from the camera
  71589. */
  71590. dispose(camera: Camera): void;
  71591. /**
  71592. * Returns the render target texture used by the post-process
  71593. * @return the render target texture used by the post-process
  71594. */
  71595. getPass(): RenderTargetTexture;
  71596. private _meshExcluded;
  71597. private _createPass;
  71598. private _updateMeshScreenCoordinates;
  71599. /**
  71600. * Creates a default mesh for the Volumeric Light Scattering post-process
  71601. * @param name The mesh name
  71602. * @param scene The scene where to create the mesh
  71603. * @return the default mesh
  71604. */
  71605. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71606. }
  71607. }
  71608. declare module BABYLON {
  71609. /** @hidden */
  71610. export var screenSpaceCurvaturePixelShader: {
  71611. name: string;
  71612. shader: string;
  71613. };
  71614. }
  71615. declare module BABYLON {
  71616. /**
  71617. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71618. */
  71619. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71620. /**
  71621. * Defines how much ridge the curvature effect displays.
  71622. */
  71623. ridge: number;
  71624. /**
  71625. * Defines how much valley the curvature effect displays.
  71626. */
  71627. valley: number;
  71628. private _geometryBufferRenderer;
  71629. /**
  71630. * Gets a string identifying the name of the class
  71631. * @returns "ScreenSpaceCurvaturePostProcess" string
  71632. */
  71633. getClassName(): string;
  71634. /**
  71635. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71636. * @param name The name of the effect.
  71637. * @param scene The scene containing the objects to blur according to their velocity.
  71638. * @param options The required width/height ratio to downsize to before computing the render pass.
  71639. * @param camera The camera to apply the render pass to.
  71640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71641. * @param engine The engine which the post process will be applied. (default: current engine)
  71642. * @param reusable If the post process can be reused on the same frame. (default: false)
  71643. * @param textureType Type of textures used when performing the post process. (default: 0)
  71644. * @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)
  71645. */
  71646. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71647. /**
  71648. * Support test.
  71649. */
  71650. static get IsSupported(): boolean;
  71651. /** @hidden */
  71652. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71653. }
  71654. }
  71655. declare module BABYLON {
  71656. interface Scene {
  71657. /** @hidden (Backing field) */
  71658. _boundingBoxRenderer: BoundingBoxRenderer;
  71659. /** @hidden (Backing field) */
  71660. _forceShowBoundingBoxes: boolean;
  71661. /**
  71662. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71663. */
  71664. forceShowBoundingBoxes: boolean;
  71665. /**
  71666. * Gets the bounding box renderer associated with the scene
  71667. * @returns a BoundingBoxRenderer
  71668. */
  71669. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71670. }
  71671. interface AbstractMesh {
  71672. /** @hidden (Backing field) */
  71673. _showBoundingBox: boolean;
  71674. /**
  71675. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71676. */
  71677. showBoundingBox: boolean;
  71678. }
  71679. /**
  71680. * Component responsible of rendering the bounding box of the meshes in a scene.
  71681. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71682. */
  71683. export class BoundingBoxRenderer implements ISceneComponent {
  71684. /**
  71685. * The component name helpfull to identify the component in the list of scene components.
  71686. */
  71687. readonly name: string;
  71688. /**
  71689. * The scene the component belongs to.
  71690. */
  71691. scene: Scene;
  71692. /**
  71693. * Color of the bounding box lines placed in front of an object
  71694. */
  71695. frontColor: Color3;
  71696. /**
  71697. * Color of the bounding box lines placed behind an object
  71698. */
  71699. backColor: Color3;
  71700. /**
  71701. * Defines if the renderer should show the back lines or not
  71702. */
  71703. showBackLines: boolean;
  71704. /**
  71705. * Observable raised before rendering a bounding box
  71706. */
  71707. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71708. /**
  71709. * Observable raised after rendering a bounding box
  71710. */
  71711. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71712. /**
  71713. * @hidden
  71714. */
  71715. renderList: SmartArray<BoundingBox>;
  71716. private _colorShader;
  71717. private _vertexBuffers;
  71718. private _indexBuffer;
  71719. private _fillIndexBuffer;
  71720. private _fillIndexData;
  71721. /**
  71722. * Instantiates a new bounding box renderer in a scene.
  71723. * @param scene the scene the renderer renders in
  71724. */
  71725. constructor(scene: Scene);
  71726. /**
  71727. * Registers the component in a given scene
  71728. */
  71729. register(): void;
  71730. private _evaluateSubMesh;
  71731. private _activeMesh;
  71732. private _prepareRessources;
  71733. private _createIndexBuffer;
  71734. /**
  71735. * Rebuilds the elements related to this component in case of
  71736. * context lost for instance.
  71737. */
  71738. rebuild(): void;
  71739. /**
  71740. * @hidden
  71741. */
  71742. reset(): void;
  71743. /**
  71744. * Render the bounding boxes of a specific rendering group
  71745. * @param renderingGroupId defines the rendering group to render
  71746. */
  71747. render(renderingGroupId: number): void;
  71748. /**
  71749. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71750. * @param mesh Define the mesh to render the occlusion bounding box for
  71751. */
  71752. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71753. /**
  71754. * Dispose and release the resources attached to this renderer.
  71755. */
  71756. dispose(): void;
  71757. }
  71758. }
  71759. declare module BABYLON {
  71760. interface Scene {
  71761. /** @hidden (Backing field) */
  71762. _depthRenderer: {
  71763. [id: string]: DepthRenderer;
  71764. };
  71765. /**
  71766. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71767. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71768. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71769. * @returns the created depth renderer
  71770. */
  71771. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71772. /**
  71773. * Disables a depth renderer for a given camera
  71774. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71775. */
  71776. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71777. }
  71778. /**
  71779. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71780. * in several rendering techniques.
  71781. */
  71782. export class DepthRendererSceneComponent implements ISceneComponent {
  71783. /**
  71784. * The component name helpfull to identify the component in the list of scene components.
  71785. */
  71786. readonly name: string;
  71787. /**
  71788. * The scene the component belongs to.
  71789. */
  71790. scene: Scene;
  71791. /**
  71792. * Creates a new instance of the component for the given scene
  71793. * @param scene Defines the scene to register the component in
  71794. */
  71795. constructor(scene: Scene);
  71796. /**
  71797. * Registers the component in a given scene
  71798. */
  71799. register(): void;
  71800. /**
  71801. * Rebuilds the elements related to this component in case of
  71802. * context lost for instance.
  71803. */
  71804. rebuild(): void;
  71805. /**
  71806. * Disposes the component and the associated ressources
  71807. */
  71808. dispose(): void;
  71809. private _gatherRenderTargets;
  71810. private _gatherActiveCameraRenderTargets;
  71811. }
  71812. }
  71813. declare module BABYLON {
  71814. interface AbstractScene {
  71815. /** @hidden (Backing field) */
  71816. _prePassRenderer: Nullable<PrePassRenderer>;
  71817. /**
  71818. * Gets or Sets the current prepass renderer associated to the scene.
  71819. */
  71820. prePassRenderer: Nullable<PrePassRenderer>;
  71821. /**
  71822. * Enables the prepass and associates it with the scene
  71823. * @returns the PrePassRenderer
  71824. */
  71825. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71826. /**
  71827. * Disables the prepass associated with the scene
  71828. */
  71829. disablePrePassRenderer(): void;
  71830. }
  71831. /**
  71832. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71833. * in several rendering techniques.
  71834. */
  71835. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71836. /**
  71837. * The component name helpful to identify the component in the list of scene components.
  71838. */
  71839. readonly name: string;
  71840. /**
  71841. * The scene the component belongs to.
  71842. */
  71843. scene: Scene;
  71844. /**
  71845. * Creates a new instance of the component for the given scene
  71846. * @param scene Defines the scene to register the component in
  71847. */
  71848. constructor(scene: Scene);
  71849. /**
  71850. * Registers the component in a given scene
  71851. */
  71852. register(): void;
  71853. private _beforeCameraDraw;
  71854. private _afterCameraDraw;
  71855. private _beforeClearStage;
  71856. /**
  71857. * Serializes the component data to the specified json object
  71858. * @param serializationObject The object to serialize to
  71859. */
  71860. serialize(serializationObject: any): void;
  71861. /**
  71862. * Adds all the elements from the container to the scene
  71863. * @param container the container holding the elements
  71864. */
  71865. addFromContainer(container: AbstractScene): void;
  71866. /**
  71867. * Removes all the elements in the container from the scene
  71868. * @param container contains the elements to remove
  71869. * @param dispose if the removed element should be disposed (default: false)
  71870. */
  71871. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71872. /**
  71873. * Rebuilds the elements related to this component in case of
  71874. * context lost for instance.
  71875. */
  71876. rebuild(): void;
  71877. /**
  71878. * Disposes the component and the associated ressources
  71879. */
  71880. dispose(): void;
  71881. }
  71882. }
  71883. declare module BABYLON {
  71884. /** @hidden */
  71885. export var outlinePixelShader: {
  71886. name: string;
  71887. shader: string;
  71888. };
  71889. }
  71890. declare module BABYLON {
  71891. /** @hidden */
  71892. export var outlineVertexShader: {
  71893. name: string;
  71894. shader: string;
  71895. };
  71896. }
  71897. declare module BABYLON {
  71898. interface Scene {
  71899. /** @hidden */
  71900. _outlineRenderer: OutlineRenderer;
  71901. /**
  71902. * Gets the outline renderer associated with the scene
  71903. * @returns a OutlineRenderer
  71904. */
  71905. getOutlineRenderer(): OutlineRenderer;
  71906. }
  71907. interface AbstractMesh {
  71908. /** @hidden (Backing field) */
  71909. _renderOutline: boolean;
  71910. /**
  71911. * Gets or sets a boolean indicating if the outline must be rendered as well
  71912. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71913. */
  71914. renderOutline: boolean;
  71915. /** @hidden (Backing field) */
  71916. _renderOverlay: boolean;
  71917. /**
  71918. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71919. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71920. */
  71921. renderOverlay: boolean;
  71922. }
  71923. /**
  71924. * This class is responsible to draw bothe outline/overlay of meshes.
  71925. * It should not be used directly but through the available method on mesh.
  71926. */
  71927. export class OutlineRenderer implements ISceneComponent {
  71928. /**
  71929. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71930. */
  71931. private static _StencilReference;
  71932. /**
  71933. * The name of the component. Each component must have a unique name.
  71934. */
  71935. name: string;
  71936. /**
  71937. * The scene the component belongs to.
  71938. */
  71939. scene: Scene;
  71940. /**
  71941. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71942. */
  71943. zOffset: number;
  71944. private _engine;
  71945. private _effect;
  71946. private _cachedDefines;
  71947. private _savedDepthWrite;
  71948. /**
  71949. * Instantiates a new outline renderer. (There could be only one per scene).
  71950. * @param scene Defines the scene it belongs to
  71951. */
  71952. constructor(scene: Scene);
  71953. /**
  71954. * Register the component to one instance of a scene.
  71955. */
  71956. register(): void;
  71957. /**
  71958. * Rebuilds the elements related to this component in case of
  71959. * context lost for instance.
  71960. */
  71961. rebuild(): void;
  71962. /**
  71963. * Disposes the component and the associated ressources.
  71964. */
  71965. dispose(): void;
  71966. /**
  71967. * Renders the outline in the canvas.
  71968. * @param subMesh Defines the sumesh to render
  71969. * @param batch Defines the batch of meshes in case of instances
  71970. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71971. */
  71972. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71973. /**
  71974. * Returns whether or not the outline renderer is ready for a given submesh.
  71975. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71976. * @param subMesh Defines the submesh to check readyness for
  71977. * @param useInstances Defines wheter wee are trying to render instances or not
  71978. * @returns true if ready otherwise false
  71979. */
  71980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71981. private _beforeRenderingMesh;
  71982. private _afterRenderingMesh;
  71983. }
  71984. }
  71985. declare module BABYLON {
  71986. /**
  71987. * Defines the basic options interface of a Sprite Frame Source Size.
  71988. */
  71989. export interface ISpriteJSONSpriteSourceSize {
  71990. /**
  71991. * number of the original width of the Frame
  71992. */
  71993. w: number;
  71994. /**
  71995. * number of the original height of the Frame
  71996. */
  71997. h: number;
  71998. }
  71999. /**
  72000. * Defines the basic options interface of a Sprite Frame Data.
  72001. */
  72002. export interface ISpriteJSONSpriteFrameData {
  72003. /**
  72004. * number of the x offset of the Frame
  72005. */
  72006. x: number;
  72007. /**
  72008. * number of the y offset of the Frame
  72009. */
  72010. y: number;
  72011. /**
  72012. * number of the width of the Frame
  72013. */
  72014. w: number;
  72015. /**
  72016. * number of the height of the Frame
  72017. */
  72018. h: number;
  72019. }
  72020. /**
  72021. * Defines the basic options interface of a JSON Sprite.
  72022. */
  72023. export interface ISpriteJSONSprite {
  72024. /**
  72025. * string name of the Frame
  72026. */
  72027. filename: string;
  72028. /**
  72029. * ISpriteJSONSpriteFrame basic object of the frame data
  72030. */
  72031. frame: ISpriteJSONSpriteFrameData;
  72032. /**
  72033. * boolean to flag is the frame was rotated.
  72034. */
  72035. rotated: boolean;
  72036. /**
  72037. * boolean to flag is the frame was trimmed.
  72038. */
  72039. trimmed: boolean;
  72040. /**
  72041. * ISpriteJSONSpriteFrame basic object of the source data
  72042. */
  72043. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72044. /**
  72045. * ISpriteJSONSpriteFrame basic object of the source data
  72046. */
  72047. sourceSize: ISpriteJSONSpriteSourceSize;
  72048. }
  72049. /**
  72050. * Defines the basic options interface of a JSON atlas.
  72051. */
  72052. export interface ISpriteJSONAtlas {
  72053. /**
  72054. * Array of objects that contain the frame data.
  72055. */
  72056. frames: Array<ISpriteJSONSprite>;
  72057. /**
  72058. * object basic object containing the sprite meta data.
  72059. */
  72060. meta?: object;
  72061. }
  72062. }
  72063. declare module BABYLON {
  72064. /** @hidden */
  72065. export var spriteMapPixelShader: {
  72066. name: string;
  72067. shader: string;
  72068. };
  72069. }
  72070. declare module BABYLON {
  72071. /** @hidden */
  72072. export var spriteMapVertexShader: {
  72073. name: string;
  72074. shader: string;
  72075. };
  72076. }
  72077. declare module BABYLON {
  72078. /**
  72079. * Defines the basic options interface of a SpriteMap
  72080. */
  72081. export interface ISpriteMapOptions {
  72082. /**
  72083. * Vector2 of the number of cells in the grid.
  72084. */
  72085. stageSize?: Vector2;
  72086. /**
  72087. * Vector2 of the size of the output plane in World Units.
  72088. */
  72089. outputSize?: Vector2;
  72090. /**
  72091. * Vector3 of the position of the output plane in World Units.
  72092. */
  72093. outputPosition?: Vector3;
  72094. /**
  72095. * Vector3 of the rotation of the output plane.
  72096. */
  72097. outputRotation?: Vector3;
  72098. /**
  72099. * number of layers that the system will reserve in resources.
  72100. */
  72101. layerCount?: number;
  72102. /**
  72103. * number of max animation frames a single cell will reserve in resources.
  72104. */
  72105. maxAnimationFrames?: number;
  72106. /**
  72107. * number cell index of the base tile when the system compiles.
  72108. */
  72109. baseTile?: number;
  72110. /**
  72111. * boolean flip the sprite after its been repositioned by the framing data.
  72112. */
  72113. flipU?: boolean;
  72114. /**
  72115. * Vector3 scalar of the global RGB values of the SpriteMap.
  72116. */
  72117. colorMultiply?: Vector3;
  72118. }
  72119. /**
  72120. * Defines the IDisposable interface in order to be cleanable from resources.
  72121. */
  72122. export interface ISpriteMap extends IDisposable {
  72123. /**
  72124. * String name of the SpriteMap.
  72125. */
  72126. name: string;
  72127. /**
  72128. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72129. */
  72130. atlasJSON: ISpriteJSONAtlas;
  72131. /**
  72132. * Texture of the SpriteMap.
  72133. */
  72134. spriteSheet: Texture;
  72135. /**
  72136. * The parameters to initialize the SpriteMap with.
  72137. */
  72138. options: ISpriteMapOptions;
  72139. }
  72140. /**
  72141. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72142. */
  72143. export class SpriteMap implements ISpriteMap {
  72144. /** The Name of the spriteMap */
  72145. name: string;
  72146. /** The JSON file with the frame and meta data */
  72147. atlasJSON: ISpriteJSONAtlas;
  72148. /** The systems Sprite Sheet Texture */
  72149. spriteSheet: Texture;
  72150. /** Arguments passed with the Constructor */
  72151. options: ISpriteMapOptions;
  72152. /** Public Sprite Storage array, parsed from atlasJSON */
  72153. sprites: Array<ISpriteJSONSprite>;
  72154. /** Returns the Number of Sprites in the System */
  72155. get spriteCount(): number;
  72156. /** Returns the Position of Output Plane*/
  72157. get position(): Vector3;
  72158. /** Returns the Position of Output Plane*/
  72159. set position(v: Vector3);
  72160. /** Returns the Rotation of Output Plane*/
  72161. get rotation(): Vector3;
  72162. /** Returns the Rotation of Output Plane*/
  72163. set rotation(v: Vector3);
  72164. /** Sets the AnimationMap*/
  72165. get animationMap(): RawTexture;
  72166. /** Sets the AnimationMap*/
  72167. set animationMap(v: RawTexture);
  72168. /** Scene that the SpriteMap was created in */
  72169. private _scene;
  72170. /** Texture Buffer of Float32 that holds tile frame data*/
  72171. private _frameMap;
  72172. /** Texture Buffers of Float32 that holds tileMap data*/
  72173. private _tileMaps;
  72174. /** Texture Buffer of Float32 that holds Animation Data*/
  72175. private _animationMap;
  72176. /** Custom ShaderMaterial Central to the System*/
  72177. private _material;
  72178. /** Custom ShaderMaterial Central to the System*/
  72179. private _output;
  72180. /** Systems Time Ticker*/
  72181. private _time;
  72182. /**
  72183. * Creates a new SpriteMap
  72184. * @param name defines the SpriteMaps Name
  72185. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72186. * @param spriteSheet is the Texture that the Sprites are on.
  72187. * @param options a basic deployment configuration
  72188. * @param scene The Scene that the map is deployed on
  72189. */
  72190. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72191. /**
  72192. * Returns tileID location
  72193. * @returns Vector2 the cell position ID
  72194. */
  72195. getTileID(): Vector2;
  72196. /**
  72197. * Gets the UV location of the mouse over the SpriteMap.
  72198. * @returns Vector2 the UV position of the mouse interaction
  72199. */
  72200. getMousePosition(): Vector2;
  72201. /**
  72202. * Creates the "frame" texture Buffer
  72203. * -------------------------------------
  72204. * Structure of frames
  72205. * "filename": "Falling-Water-2.png",
  72206. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72207. * "rotated": true,
  72208. * "trimmed": true,
  72209. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72210. * "sourceSize": {"w":32,"h":32}
  72211. * @returns RawTexture of the frameMap
  72212. */
  72213. private _createFrameBuffer;
  72214. /**
  72215. * Creates the tileMap texture Buffer
  72216. * @param buffer normally and array of numbers, or a false to generate from scratch
  72217. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72218. * @returns RawTexture of the tileMap
  72219. */
  72220. private _createTileBuffer;
  72221. /**
  72222. * Modifies the data of the tileMaps
  72223. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72224. * @param pos is the iVector2 Coordinates of the Tile
  72225. * @param tile The SpriteIndex of the new Tile
  72226. */
  72227. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72228. /**
  72229. * Creates the animationMap texture Buffer
  72230. * @param buffer normally and array of numbers, or a false to generate from scratch
  72231. * @returns RawTexture of the animationMap
  72232. */
  72233. private _createTileAnimationBuffer;
  72234. /**
  72235. * Modifies the data of the animationMap
  72236. * @param cellID is the Index of the Sprite
  72237. * @param _frame is the target Animation frame
  72238. * @param toCell is the Target Index of the next frame of the animation
  72239. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72240. * @param speed is a global scalar of the time variable on the map.
  72241. */
  72242. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72243. /**
  72244. * Exports the .tilemaps file
  72245. */
  72246. saveTileMaps(): void;
  72247. /**
  72248. * Imports the .tilemaps file
  72249. * @param url of the .tilemaps file
  72250. */
  72251. loadTileMaps(url: string): void;
  72252. /**
  72253. * Release associated resources
  72254. */
  72255. dispose(): void;
  72256. }
  72257. }
  72258. declare module BABYLON {
  72259. /**
  72260. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72261. * @see https://doc.babylonjs.com/babylon101/sprites
  72262. */
  72263. export class SpritePackedManager extends SpriteManager {
  72264. /** defines the packed manager's name */
  72265. name: string;
  72266. /**
  72267. * Creates a new sprite manager from a packed sprite sheet
  72268. * @param name defines the manager's name
  72269. * @param imgUrl defines the sprite sheet url
  72270. * @param capacity defines the maximum allowed number of sprites
  72271. * @param scene defines the hosting scene
  72272. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72273. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72274. * @param samplingMode defines the smapling mode to use with spritesheet
  72275. * @param fromPacked set to true; do not alter
  72276. */
  72277. constructor(
  72278. /** defines the packed manager's name */
  72279. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72280. }
  72281. }
  72282. declare module BABYLON {
  72283. /**
  72284. * Defines the list of states available for a task inside a AssetsManager
  72285. */
  72286. export enum AssetTaskState {
  72287. /**
  72288. * Initialization
  72289. */
  72290. INIT = 0,
  72291. /**
  72292. * Running
  72293. */
  72294. RUNNING = 1,
  72295. /**
  72296. * Done
  72297. */
  72298. DONE = 2,
  72299. /**
  72300. * Error
  72301. */
  72302. ERROR = 3
  72303. }
  72304. /**
  72305. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72306. */
  72307. export abstract class AbstractAssetTask {
  72308. /**
  72309. * Task name
  72310. */ name: string;
  72311. /**
  72312. * Callback called when the task is successful
  72313. */
  72314. onSuccess: (task: any) => void;
  72315. /**
  72316. * Callback called when the task is not successful
  72317. */
  72318. onError: (task: any, message?: string, exception?: any) => void;
  72319. /**
  72320. * Creates a new AssetsManager
  72321. * @param name defines the name of the task
  72322. */
  72323. constructor(
  72324. /**
  72325. * Task name
  72326. */ name: string);
  72327. private _isCompleted;
  72328. private _taskState;
  72329. private _errorObject;
  72330. /**
  72331. * Get if the task is completed
  72332. */
  72333. get isCompleted(): boolean;
  72334. /**
  72335. * Gets the current state of the task
  72336. */
  72337. get taskState(): AssetTaskState;
  72338. /**
  72339. * Gets the current error object (if task is in error)
  72340. */
  72341. get errorObject(): {
  72342. message?: string;
  72343. exception?: any;
  72344. };
  72345. /**
  72346. * Internal only
  72347. * @hidden
  72348. */
  72349. _setErrorObject(message?: string, exception?: any): void;
  72350. /**
  72351. * Execute the current task
  72352. * @param scene defines the scene where you want your assets to be loaded
  72353. * @param onSuccess is a callback called when the task is successfully executed
  72354. * @param onError is a callback called if an error occurs
  72355. */
  72356. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72357. /**
  72358. * Execute the current task
  72359. * @param scene defines the scene where you want your assets to be loaded
  72360. * @param onSuccess is a callback called when the task is successfully executed
  72361. * @param onError is a callback called if an error occurs
  72362. */
  72363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72364. /**
  72365. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72366. * This can be used with failed tasks that have the reason for failure fixed.
  72367. */
  72368. reset(): void;
  72369. private onErrorCallback;
  72370. private onDoneCallback;
  72371. }
  72372. /**
  72373. * Define the interface used by progress events raised during assets loading
  72374. */
  72375. export interface IAssetsProgressEvent {
  72376. /**
  72377. * Defines the number of remaining tasks to process
  72378. */
  72379. remainingCount: number;
  72380. /**
  72381. * Defines the total number of tasks
  72382. */
  72383. totalCount: number;
  72384. /**
  72385. * Defines the task that was just processed
  72386. */
  72387. task: AbstractAssetTask;
  72388. }
  72389. /**
  72390. * Class used to share progress information about assets loading
  72391. */
  72392. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72393. /**
  72394. * Defines the number of remaining tasks to process
  72395. */
  72396. remainingCount: number;
  72397. /**
  72398. * Defines the total number of tasks
  72399. */
  72400. totalCount: number;
  72401. /**
  72402. * Defines the task that was just processed
  72403. */
  72404. task: AbstractAssetTask;
  72405. /**
  72406. * Creates a AssetsProgressEvent
  72407. * @param remainingCount defines the number of remaining tasks to process
  72408. * @param totalCount defines the total number of tasks
  72409. * @param task defines the task that was just processed
  72410. */
  72411. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72412. }
  72413. /**
  72414. * Define a task used by AssetsManager to load assets into a container
  72415. */
  72416. export class ContainerAssetTask extends AbstractAssetTask {
  72417. /**
  72418. * Defines the name of the task
  72419. */
  72420. name: string;
  72421. /**
  72422. * Defines the list of mesh's names you want to load
  72423. */
  72424. meshesNames: any;
  72425. /**
  72426. * Defines the root url to use as a base to load your meshes and associated resources
  72427. */
  72428. rootUrl: string;
  72429. /**
  72430. * Defines the filename or File of the scene to load from
  72431. */
  72432. sceneFilename: string | File;
  72433. /**
  72434. * Get the loaded asset container
  72435. */
  72436. loadedContainer: AssetContainer;
  72437. /**
  72438. * Gets the list of loaded meshes
  72439. */
  72440. loadedMeshes: Array<AbstractMesh>;
  72441. /**
  72442. * Gets the list of loaded particle systems
  72443. */
  72444. loadedParticleSystems: Array<IParticleSystem>;
  72445. /**
  72446. * Gets the list of loaded skeletons
  72447. */
  72448. loadedSkeletons: Array<Skeleton>;
  72449. /**
  72450. * Gets the list of loaded animation groups
  72451. */
  72452. loadedAnimationGroups: Array<AnimationGroup>;
  72453. /**
  72454. * Callback called when the task is successful
  72455. */
  72456. onSuccess: (task: ContainerAssetTask) => void;
  72457. /**
  72458. * Callback called when the task is successful
  72459. */
  72460. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72461. /**
  72462. * Creates a new ContainerAssetTask
  72463. * @param name defines the name of the task
  72464. * @param meshesNames defines the list of mesh's names you want to load
  72465. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72466. * @param sceneFilename defines the filename or File of the scene to load from
  72467. */
  72468. constructor(
  72469. /**
  72470. * Defines the name of the task
  72471. */
  72472. name: string,
  72473. /**
  72474. * Defines the list of mesh's names you want to load
  72475. */
  72476. meshesNames: any,
  72477. /**
  72478. * Defines the root url to use as a base to load your meshes and associated resources
  72479. */
  72480. rootUrl: string,
  72481. /**
  72482. * Defines the filename or File of the scene to load from
  72483. */
  72484. sceneFilename: string | File);
  72485. /**
  72486. * Execute the current task
  72487. * @param scene defines the scene where you want your assets to be loaded
  72488. * @param onSuccess is a callback called when the task is successfully executed
  72489. * @param onError is a callback called if an error occurs
  72490. */
  72491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72492. }
  72493. /**
  72494. * Define a task used by AssetsManager to load meshes
  72495. */
  72496. export class MeshAssetTask extends AbstractAssetTask {
  72497. /**
  72498. * Defines the name of the task
  72499. */
  72500. name: string;
  72501. /**
  72502. * Defines the list of mesh's names you want to load
  72503. */
  72504. meshesNames: any;
  72505. /**
  72506. * Defines the root url to use as a base to load your meshes and associated resources
  72507. */
  72508. rootUrl: string;
  72509. /**
  72510. * Defines the filename or File of the scene to load from
  72511. */
  72512. sceneFilename: string | File;
  72513. /**
  72514. * Gets the list of loaded meshes
  72515. */
  72516. loadedMeshes: Array<AbstractMesh>;
  72517. /**
  72518. * Gets the list of loaded particle systems
  72519. */
  72520. loadedParticleSystems: Array<IParticleSystem>;
  72521. /**
  72522. * Gets the list of loaded skeletons
  72523. */
  72524. loadedSkeletons: Array<Skeleton>;
  72525. /**
  72526. * Gets the list of loaded animation groups
  72527. */
  72528. loadedAnimationGroups: Array<AnimationGroup>;
  72529. /**
  72530. * Callback called when the task is successful
  72531. */
  72532. onSuccess: (task: MeshAssetTask) => void;
  72533. /**
  72534. * Callback called when the task is successful
  72535. */
  72536. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72537. /**
  72538. * Creates a new MeshAssetTask
  72539. * @param name defines the name of the task
  72540. * @param meshesNames defines the list of mesh's names you want to load
  72541. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72542. * @param sceneFilename defines the filename or File of the scene to load from
  72543. */
  72544. constructor(
  72545. /**
  72546. * Defines the name of the task
  72547. */
  72548. name: string,
  72549. /**
  72550. * Defines the list of mesh's names you want to load
  72551. */
  72552. meshesNames: any,
  72553. /**
  72554. * Defines the root url to use as a base to load your meshes and associated resources
  72555. */
  72556. rootUrl: string,
  72557. /**
  72558. * Defines the filename or File of the scene to load from
  72559. */
  72560. sceneFilename: string | File);
  72561. /**
  72562. * Execute the current task
  72563. * @param scene defines the scene where you want your assets to be loaded
  72564. * @param onSuccess is a callback called when the task is successfully executed
  72565. * @param onError is a callback called if an error occurs
  72566. */
  72567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72568. }
  72569. /**
  72570. * Define a task used by AssetsManager to load text content
  72571. */
  72572. export class TextFileAssetTask extends AbstractAssetTask {
  72573. /**
  72574. * Defines the name of the task
  72575. */
  72576. name: string;
  72577. /**
  72578. * Defines the location of the file to load
  72579. */
  72580. url: string;
  72581. /**
  72582. * Gets the loaded text string
  72583. */
  72584. text: string;
  72585. /**
  72586. * Callback called when the task is successful
  72587. */
  72588. onSuccess: (task: TextFileAssetTask) => void;
  72589. /**
  72590. * Callback called when the task is successful
  72591. */
  72592. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72593. /**
  72594. * Creates a new TextFileAssetTask object
  72595. * @param name defines the name of the task
  72596. * @param url defines the location of the file to load
  72597. */
  72598. constructor(
  72599. /**
  72600. * Defines the name of the task
  72601. */
  72602. name: string,
  72603. /**
  72604. * Defines the location of the file to load
  72605. */
  72606. url: string);
  72607. /**
  72608. * Execute the current task
  72609. * @param scene defines the scene where you want your assets to be loaded
  72610. * @param onSuccess is a callback called when the task is successfully executed
  72611. * @param onError is a callback called if an error occurs
  72612. */
  72613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72614. }
  72615. /**
  72616. * Define a task used by AssetsManager to load binary data
  72617. */
  72618. export class BinaryFileAssetTask extends AbstractAssetTask {
  72619. /**
  72620. * Defines the name of the task
  72621. */
  72622. name: string;
  72623. /**
  72624. * Defines the location of the file to load
  72625. */
  72626. url: string;
  72627. /**
  72628. * Gets the lodaded data (as an array buffer)
  72629. */
  72630. data: ArrayBuffer;
  72631. /**
  72632. * Callback called when the task is successful
  72633. */
  72634. onSuccess: (task: BinaryFileAssetTask) => void;
  72635. /**
  72636. * Callback called when the task is successful
  72637. */
  72638. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72639. /**
  72640. * Creates a new BinaryFileAssetTask object
  72641. * @param name defines the name of the new task
  72642. * @param url defines the location of the file to load
  72643. */
  72644. constructor(
  72645. /**
  72646. * Defines the name of the task
  72647. */
  72648. name: string,
  72649. /**
  72650. * Defines the location of the file to load
  72651. */
  72652. url: string);
  72653. /**
  72654. * Execute the current task
  72655. * @param scene defines the scene where you want your assets to be loaded
  72656. * @param onSuccess is a callback called when the task is successfully executed
  72657. * @param onError is a callback called if an error occurs
  72658. */
  72659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72660. }
  72661. /**
  72662. * Define a task used by AssetsManager to load images
  72663. */
  72664. export class ImageAssetTask extends AbstractAssetTask {
  72665. /**
  72666. * Defines the name of the task
  72667. */
  72668. name: string;
  72669. /**
  72670. * Defines the location of the image to load
  72671. */
  72672. url: string;
  72673. /**
  72674. * Gets the loaded images
  72675. */
  72676. image: HTMLImageElement;
  72677. /**
  72678. * Callback called when the task is successful
  72679. */
  72680. onSuccess: (task: ImageAssetTask) => void;
  72681. /**
  72682. * Callback called when the task is successful
  72683. */
  72684. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72685. /**
  72686. * Creates a new ImageAssetTask
  72687. * @param name defines the name of the task
  72688. * @param url defines the location of the image to load
  72689. */
  72690. constructor(
  72691. /**
  72692. * Defines the name of the task
  72693. */
  72694. name: string,
  72695. /**
  72696. * Defines the location of the image to load
  72697. */
  72698. url: string);
  72699. /**
  72700. * Execute the current task
  72701. * @param scene defines the scene where you want your assets to be loaded
  72702. * @param onSuccess is a callback called when the task is successfully executed
  72703. * @param onError is a callback called if an error occurs
  72704. */
  72705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72706. }
  72707. /**
  72708. * Defines the interface used by texture loading tasks
  72709. */
  72710. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72711. /**
  72712. * Gets the loaded texture
  72713. */
  72714. texture: TEX;
  72715. }
  72716. /**
  72717. * Define a task used by AssetsManager to load 2D textures
  72718. */
  72719. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72720. /**
  72721. * Defines the name of the task
  72722. */
  72723. name: string;
  72724. /**
  72725. * Defines the location of the file to load
  72726. */
  72727. url: string;
  72728. /**
  72729. * Defines if mipmap should not be generated (default is false)
  72730. */
  72731. noMipmap?: boolean | undefined;
  72732. /**
  72733. * Defines if texture must be inverted on Y axis (default is true)
  72734. */
  72735. invertY: boolean;
  72736. /**
  72737. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72738. */
  72739. samplingMode: number;
  72740. /**
  72741. * Gets the loaded texture
  72742. */
  72743. texture: Texture;
  72744. /**
  72745. * Callback called when the task is successful
  72746. */
  72747. onSuccess: (task: TextureAssetTask) => void;
  72748. /**
  72749. * Callback called when the task is successful
  72750. */
  72751. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72752. /**
  72753. * Creates a new TextureAssetTask object
  72754. * @param name defines the name of the task
  72755. * @param url defines the location of the file to load
  72756. * @param noMipmap defines if mipmap should not be generated (default is false)
  72757. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72758. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72759. */
  72760. constructor(
  72761. /**
  72762. * Defines the name of the task
  72763. */
  72764. name: string,
  72765. /**
  72766. * Defines the location of the file to load
  72767. */
  72768. url: string,
  72769. /**
  72770. * Defines if mipmap should not be generated (default is false)
  72771. */
  72772. noMipmap?: boolean | undefined,
  72773. /**
  72774. * Defines if texture must be inverted on Y axis (default is true)
  72775. */
  72776. invertY?: boolean,
  72777. /**
  72778. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72779. */
  72780. samplingMode?: number);
  72781. /**
  72782. * Execute the current task
  72783. * @param scene defines the scene where you want your assets to be loaded
  72784. * @param onSuccess is a callback called when the task is successfully executed
  72785. * @param onError is a callback called if an error occurs
  72786. */
  72787. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72788. }
  72789. /**
  72790. * Define a task used by AssetsManager to load cube textures
  72791. */
  72792. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72793. /**
  72794. * Defines the name of the task
  72795. */
  72796. name: string;
  72797. /**
  72798. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72799. */
  72800. url: string;
  72801. /**
  72802. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72803. */
  72804. extensions?: string[] | undefined;
  72805. /**
  72806. * Defines if mipmaps should not be generated (default is false)
  72807. */
  72808. noMipmap?: boolean | undefined;
  72809. /**
  72810. * Defines the explicit list of files (undefined by default)
  72811. */
  72812. files?: string[] | undefined;
  72813. /**
  72814. * Gets the loaded texture
  72815. */
  72816. texture: CubeTexture;
  72817. /**
  72818. * Callback called when the task is successful
  72819. */
  72820. onSuccess: (task: CubeTextureAssetTask) => void;
  72821. /**
  72822. * Callback called when the task is successful
  72823. */
  72824. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72825. /**
  72826. * Creates a new CubeTextureAssetTask
  72827. * @param name defines the name of the task
  72828. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72829. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72830. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72831. * @param files defines the explicit list of files (undefined by default)
  72832. */
  72833. constructor(
  72834. /**
  72835. * Defines the name of the task
  72836. */
  72837. name: string,
  72838. /**
  72839. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72840. */
  72841. url: string,
  72842. /**
  72843. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72844. */
  72845. extensions?: string[] | undefined,
  72846. /**
  72847. * Defines if mipmaps should not be generated (default is false)
  72848. */
  72849. noMipmap?: boolean | undefined,
  72850. /**
  72851. * Defines the explicit list of files (undefined by default)
  72852. */
  72853. files?: string[] | undefined);
  72854. /**
  72855. * Execute the current task
  72856. * @param scene defines the scene where you want your assets to be loaded
  72857. * @param onSuccess is a callback called when the task is successfully executed
  72858. * @param onError is a callback called if an error occurs
  72859. */
  72860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72861. }
  72862. /**
  72863. * Define a task used by AssetsManager to load HDR cube textures
  72864. */
  72865. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72866. /**
  72867. * Defines the name of the task
  72868. */
  72869. name: string;
  72870. /**
  72871. * Defines the location of the file to load
  72872. */
  72873. url: string;
  72874. /**
  72875. * Defines the desired size (the more it increases the longer the generation will be)
  72876. */
  72877. size: number;
  72878. /**
  72879. * Defines if mipmaps should not be generated (default is false)
  72880. */
  72881. noMipmap: boolean;
  72882. /**
  72883. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72884. */
  72885. generateHarmonics: boolean;
  72886. /**
  72887. * 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)
  72888. */
  72889. gammaSpace: boolean;
  72890. /**
  72891. * Internal Use Only
  72892. */
  72893. reserved: boolean;
  72894. /**
  72895. * Gets the loaded texture
  72896. */
  72897. texture: HDRCubeTexture;
  72898. /**
  72899. * Callback called when the task is successful
  72900. */
  72901. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72902. /**
  72903. * Callback called when the task is successful
  72904. */
  72905. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72906. /**
  72907. * Creates a new HDRCubeTextureAssetTask object
  72908. * @param name defines the name of the task
  72909. * @param url defines the location of the file to load
  72910. * @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.
  72911. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72912. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72913. * @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)
  72914. * @param reserved Internal use only
  72915. */
  72916. constructor(
  72917. /**
  72918. * Defines the name of the task
  72919. */
  72920. name: string,
  72921. /**
  72922. * Defines the location of the file to load
  72923. */
  72924. url: string,
  72925. /**
  72926. * Defines the desired size (the more it increases the longer the generation will be)
  72927. */
  72928. size: number,
  72929. /**
  72930. * Defines if mipmaps should not be generated (default is false)
  72931. */
  72932. noMipmap?: boolean,
  72933. /**
  72934. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72935. */
  72936. generateHarmonics?: boolean,
  72937. /**
  72938. * 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)
  72939. */
  72940. gammaSpace?: boolean,
  72941. /**
  72942. * Internal Use Only
  72943. */
  72944. reserved?: boolean);
  72945. /**
  72946. * Execute the current task
  72947. * @param scene defines the scene where you want your assets to be loaded
  72948. * @param onSuccess is a callback called when the task is successfully executed
  72949. * @param onError is a callback called if an error occurs
  72950. */
  72951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72952. }
  72953. /**
  72954. * Define a task used by AssetsManager to load Equirectangular cube textures
  72955. */
  72956. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72957. /**
  72958. * Defines the name of the task
  72959. */
  72960. name: string;
  72961. /**
  72962. * Defines the location of the file to load
  72963. */
  72964. url: string;
  72965. /**
  72966. * Defines the desired size (the more it increases the longer the generation will be)
  72967. */
  72968. size: number;
  72969. /**
  72970. * Defines if mipmaps should not be generated (default is false)
  72971. */
  72972. noMipmap: boolean;
  72973. /**
  72974. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72975. * but the standard material would require them in Gamma space) (default is true)
  72976. */
  72977. gammaSpace: boolean;
  72978. /**
  72979. * Gets the loaded texture
  72980. */
  72981. texture: EquiRectangularCubeTexture;
  72982. /**
  72983. * Callback called when the task is successful
  72984. */
  72985. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72986. /**
  72987. * Callback called when the task is successful
  72988. */
  72989. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72990. /**
  72991. * Creates a new EquiRectangularCubeTextureAssetTask object
  72992. * @param name defines the name of the task
  72993. * @param url defines the location of the file to load
  72994. * @param size defines the desired size (the more it increases the longer the generation will be)
  72995. * If the size is omitted this implies you are using a preprocessed cubemap.
  72996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72997. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72998. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72999. * (default is true)
  73000. */
  73001. constructor(
  73002. /**
  73003. * Defines the name of the task
  73004. */
  73005. name: string,
  73006. /**
  73007. * Defines the location of the file to load
  73008. */
  73009. url: string,
  73010. /**
  73011. * Defines the desired size (the more it increases the longer the generation will be)
  73012. */
  73013. size: number,
  73014. /**
  73015. * Defines if mipmaps should not be generated (default is false)
  73016. */
  73017. noMipmap?: boolean,
  73018. /**
  73019. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73020. * but the standard material would require them in Gamma space) (default is true)
  73021. */
  73022. gammaSpace?: boolean);
  73023. /**
  73024. * Execute the current task
  73025. * @param scene defines the scene where you want your assets to be loaded
  73026. * @param onSuccess is a callback called when the task is successfully executed
  73027. * @param onError is a callback called if an error occurs
  73028. */
  73029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73030. }
  73031. /**
  73032. * This class can be used to easily import assets into a scene
  73033. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73034. */
  73035. export class AssetsManager {
  73036. private _scene;
  73037. private _isLoading;
  73038. protected _tasks: AbstractAssetTask[];
  73039. protected _waitingTasksCount: number;
  73040. protected _totalTasksCount: number;
  73041. /**
  73042. * Callback called when all tasks are processed
  73043. */
  73044. onFinish: (tasks: AbstractAssetTask[]) => void;
  73045. /**
  73046. * Callback called when a task is successful
  73047. */
  73048. onTaskSuccess: (task: AbstractAssetTask) => void;
  73049. /**
  73050. * Callback called when a task had an error
  73051. */
  73052. onTaskError: (task: AbstractAssetTask) => void;
  73053. /**
  73054. * Callback called when a task is done (whatever the result is)
  73055. */
  73056. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73057. /**
  73058. * Observable called when all tasks are processed
  73059. */
  73060. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73061. /**
  73062. * Observable called when a task had an error
  73063. */
  73064. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73065. /**
  73066. * Observable called when all tasks were executed
  73067. */
  73068. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73069. /**
  73070. * Observable called when a task is done (whatever the result is)
  73071. */
  73072. onProgressObservable: Observable<IAssetsProgressEvent>;
  73073. /**
  73074. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73075. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73076. */
  73077. useDefaultLoadingScreen: boolean;
  73078. /**
  73079. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73080. * when all assets have been downloaded.
  73081. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73082. */
  73083. autoHideLoadingUI: boolean;
  73084. /**
  73085. * Creates a new AssetsManager
  73086. * @param scene defines the scene to work on
  73087. */
  73088. constructor(scene: Scene);
  73089. /**
  73090. * Add a ContainerAssetTask to the list of active tasks
  73091. * @param taskName defines the name of the new task
  73092. * @param meshesNames defines the name of meshes to load
  73093. * @param rootUrl defines the root url to use to locate files
  73094. * @param sceneFilename defines the filename of the scene file
  73095. * @returns a new ContainerAssetTask object
  73096. */
  73097. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73098. /**
  73099. * Add a MeshAssetTask to the list of active tasks
  73100. * @param taskName defines the name of the new task
  73101. * @param meshesNames defines the name of meshes to load
  73102. * @param rootUrl defines the root url to use to locate files
  73103. * @param sceneFilename defines the filename of the scene file
  73104. * @returns a new MeshAssetTask object
  73105. */
  73106. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73107. /**
  73108. * Add a TextFileAssetTask to the list of active tasks
  73109. * @param taskName defines the name of the new task
  73110. * @param url defines the url of the file to load
  73111. * @returns a new TextFileAssetTask object
  73112. */
  73113. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73114. /**
  73115. * Add a BinaryFileAssetTask to the list of active tasks
  73116. * @param taskName defines the name of the new task
  73117. * @param url defines the url of the file to load
  73118. * @returns a new BinaryFileAssetTask object
  73119. */
  73120. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73121. /**
  73122. * Add a ImageAssetTask to the list of active tasks
  73123. * @param taskName defines the name of the new task
  73124. * @param url defines the url of the file to load
  73125. * @returns a new ImageAssetTask object
  73126. */
  73127. addImageTask(taskName: string, url: string): ImageAssetTask;
  73128. /**
  73129. * Add a TextureAssetTask to the list of active tasks
  73130. * @param taskName defines the name of the new task
  73131. * @param url defines the url of the file to load
  73132. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73133. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73134. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73135. * @returns a new TextureAssetTask object
  73136. */
  73137. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73138. /**
  73139. * Add a CubeTextureAssetTask to the list of active tasks
  73140. * @param taskName defines the name of the new task
  73141. * @param url defines the url of the file to load
  73142. * @param extensions defines the extension to use to load the cube map (can be null)
  73143. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73144. * @param files defines the list of files to load (can be null)
  73145. * @returns a new CubeTextureAssetTask object
  73146. */
  73147. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73148. /**
  73149. *
  73150. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73151. * @param taskName defines the name of the new task
  73152. * @param url defines the url of the file to load
  73153. * @param size defines the size you want for the cubemap (can be null)
  73154. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73155. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73156. * @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)
  73157. * @param reserved Internal use only
  73158. * @returns a new HDRCubeTextureAssetTask object
  73159. */
  73160. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73161. /**
  73162. *
  73163. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73164. * @param taskName defines the name of the new task
  73165. * @param url defines the url of the file to load
  73166. * @param size defines the size you want for the cubemap (can be null)
  73167. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73168. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73169. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73170. * @returns a new EquiRectangularCubeTextureAssetTask object
  73171. */
  73172. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73173. /**
  73174. * Remove a task from the assets manager.
  73175. * @param task the task to remove
  73176. */
  73177. removeTask(task: AbstractAssetTask): void;
  73178. private _decreaseWaitingTasksCount;
  73179. private _runTask;
  73180. /**
  73181. * Reset the AssetsManager and remove all tasks
  73182. * @return the current instance of the AssetsManager
  73183. */
  73184. reset(): AssetsManager;
  73185. /**
  73186. * Start the loading process
  73187. * @return the current instance of the AssetsManager
  73188. */
  73189. load(): AssetsManager;
  73190. /**
  73191. * Start the loading process as an async operation
  73192. * @return a promise returning the list of failed tasks
  73193. */
  73194. loadAsync(): Promise<void>;
  73195. }
  73196. }
  73197. declare module BABYLON {
  73198. /**
  73199. * Wrapper class for promise with external resolve and reject.
  73200. */
  73201. export class Deferred<T> {
  73202. /**
  73203. * The promise associated with this deferred object.
  73204. */
  73205. readonly promise: Promise<T>;
  73206. private _resolve;
  73207. private _reject;
  73208. /**
  73209. * The resolve method of the promise associated with this deferred object.
  73210. */
  73211. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73212. /**
  73213. * The reject method of the promise associated with this deferred object.
  73214. */
  73215. get reject(): (reason?: any) => void;
  73216. /**
  73217. * Constructor for this deferred object.
  73218. */
  73219. constructor();
  73220. }
  73221. }
  73222. declare module BABYLON {
  73223. /**
  73224. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73225. */
  73226. export class MeshExploder {
  73227. private _centerMesh;
  73228. private _meshes;
  73229. private _meshesOrigins;
  73230. private _toCenterVectors;
  73231. private _scaledDirection;
  73232. private _newPosition;
  73233. private _centerPosition;
  73234. /**
  73235. * Explodes meshes from a center mesh.
  73236. * @param meshes The meshes to explode.
  73237. * @param centerMesh The mesh to be center of explosion.
  73238. */
  73239. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73240. private _setCenterMesh;
  73241. /**
  73242. * Get class name
  73243. * @returns "MeshExploder"
  73244. */
  73245. getClassName(): string;
  73246. /**
  73247. * "Exploded meshes"
  73248. * @returns Array of meshes with the centerMesh at index 0.
  73249. */
  73250. getMeshes(): Array<Mesh>;
  73251. /**
  73252. * Explodes meshes giving a specific direction
  73253. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73254. */
  73255. explode(direction?: number): void;
  73256. }
  73257. }
  73258. declare module BABYLON {
  73259. /**
  73260. * Class used to help managing file picking and drag'n'drop
  73261. */
  73262. export class FilesInput {
  73263. /**
  73264. * List of files ready to be loaded
  73265. */
  73266. static get FilesToLoad(): {
  73267. [key: string]: File;
  73268. };
  73269. /**
  73270. * Callback called when a file is processed
  73271. */
  73272. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73273. private _engine;
  73274. private _currentScene;
  73275. private _sceneLoadedCallback;
  73276. private _progressCallback;
  73277. private _additionalRenderLoopLogicCallback;
  73278. private _textureLoadingCallback;
  73279. private _startingProcessingFilesCallback;
  73280. private _onReloadCallback;
  73281. private _errorCallback;
  73282. private _elementToMonitor;
  73283. private _sceneFileToLoad;
  73284. private _filesToLoad;
  73285. /**
  73286. * Creates a new FilesInput
  73287. * @param engine defines the rendering engine
  73288. * @param scene defines the hosting scene
  73289. * @param sceneLoadedCallback callback called when scene is loaded
  73290. * @param progressCallback callback called to track progress
  73291. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73292. * @param textureLoadingCallback callback called when a texture is loading
  73293. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73294. * @param onReloadCallback callback called when a reload is requested
  73295. * @param errorCallback callback call if an error occurs
  73296. */
  73297. 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>);
  73298. private _dragEnterHandler;
  73299. private _dragOverHandler;
  73300. private _dropHandler;
  73301. /**
  73302. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73303. * @param elementToMonitor defines the DOM element to track
  73304. */
  73305. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73306. /** Gets the current list of files to load */
  73307. get filesToLoad(): File[];
  73308. /**
  73309. * Release all associated resources
  73310. */
  73311. dispose(): void;
  73312. private renderFunction;
  73313. private drag;
  73314. private drop;
  73315. private _traverseFolder;
  73316. private _processFiles;
  73317. /**
  73318. * Load files from a drop event
  73319. * @param event defines the drop event to use as source
  73320. */
  73321. loadFiles(event: any): void;
  73322. private _processReload;
  73323. /**
  73324. * Reload the current scene from the loaded files
  73325. */
  73326. reload(): void;
  73327. }
  73328. }
  73329. declare module BABYLON {
  73330. /**
  73331. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73332. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73333. */
  73334. export class SceneOptimization {
  73335. /**
  73336. * Defines the priority of this optimization (0 by default which means first in the list)
  73337. */
  73338. priority: number;
  73339. /**
  73340. * Gets a string describing the action executed by the current optimization
  73341. * @returns description string
  73342. */
  73343. getDescription(): string;
  73344. /**
  73345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73346. * @param scene defines the current scene where to apply this optimization
  73347. * @param optimizer defines the current optimizer
  73348. * @returns true if everything that can be done was applied
  73349. */
  73350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73351. /**
  73352. * Creates the SceneOptimization object
  73353. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73354. * @param desc defines the description associated with the optimization
  73355. */
  73356. constructor(
  73357. /**
  73358. * Defines the priority of this optimization (0 by default which means first in the list)
  73359. */
  73360. priority?: number);
  73361. }
  73362. /**
  73363. * Defines an optimization used to reduce the size of render target textures
  73364. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73365. */
  73366. export class TextureOptimization extends SceneOptimization {
  73367. /**
  73368. * Defines the priority of this optimization (0 by default which means first in the list)
  73369. */
  73370. priority: number;
  73371. /**
  73372. * 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
  73373. */
  73374. maximumSize: number;
  73375. /**
  73376. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73377. */
  73378. step: number;
  73379. /**
  73380. * Gets a string describing the action executed by the current optimization
  73381. * @returns description string
  73382. */
  73383. getDescription(): string;
  73384. /**
  73385. * Creates the TextureOptimization object
  73386. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73387. * @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
  73388. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73389. */
  73390. constructor(
  73391. /**
  73392. * Defines the priority of this optimization (0 by default which means first in the list)
  73393. */
  73394. priority?: number,
  73395. /**
  73396. * 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
  73397. */
  73398. maximumSize?: number,
  73399. /**
  73400. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73401. */
  73402. step?: number);
  73403. /**
  73404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73405. * @param scene defines the current scene where to apply this optimization
  73406. * @param optimizer defines the current optimizer
  73407. * @returns true if everything that can be done was applied
  73408. */
  73409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73410. }
  73411. /**
  73412. * Defines an optimization used to increase or decrease the rendering resolution
  73413. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73414. */
  73415. export class HardwareScalingOptimization extends SceneOptimization {
  73416. /**
  73417. * Defines the priority of this optimization (0 by default which means first in the list)
  73418. */
  73419. priority: number;
  73420. /**
  73421. * Defines the maximum scale to use (2 by default)
  73422. */
  73423. maximumScale: number;
  73424. /**
  73425. * Defines the step to use between two passes (0.5 by default)
  73426. */
  73427. step: number;
  73428. private _currentScale;
  73429. private _directionOffset;
  73430. /**
  73431. * Gets a string describing the action executed by the current optimization
  73432. * @return description string
  73433. */
  73434. getDescription(): string;
  73435. /**
  73436. * Creates the HardwareScalingOptimization object
  73437. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73438. * @param maximumScale defines the maximum scale to use (2 by default)
  73439. * @param step defines the step to use between two passes (0.5 by default)
  73440. */
  73441. constructor(
  73442. /**
  73443. * Defines the priority of this optimization (0 by default which means first in the list)
  73444. */
  73445. priority?: number,
  73446. /**
  73447. * Defines the maximum scale to use (2 by default)
  73448. */
  73449. maximumScale?: number,
  73450. /**
  73451. * Defines the step to use between two passes (0.5 by default)
  73452. */
  73453. step?: number);
  73454. /**
  73455. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73456. * @param scene defines the current scene where to apply this optimization
  73457. * @param optimizer defines the current optimizer
  73458. * @returns true if everything that can be done was applied
  73459. */
  73460. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73461. }
  73462. /**
  73463. * Defines an optimization used to remove shadows
  73464. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73465. */
  73466. export class ShadowsOptimization extends SceneOptimization {
  73467. /**
  73468. * Gets a string describing the action executed by the current optimization
  73469. * @return description string
  73470. */
  73471. getDescription(): string;
  73472. /**
  73473. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73474. * @param scene defines the current scene where to apply this optimization
  73475. * @param optimizer defines the current optimizer
  73476. * @returns true if everything that can be done was applied
  73477. */
  73478. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73479. }
  73480. /**
  73481. * Defines an optimization used to turn post-processes off
  73482. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73483. */
  73484. export class PostProcessesOptimization extends SceneOptimization {
  73485. /**
  73486. * Gets a string describing the action executed by the current optimization
  73487. * @return description string
  73488. */
  73489. getDescription(): string;
  73490. /**
  73491. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73492. * @param scene defines the current scene where to apply this optimization
  73493. * @param optimizer defines the current optimizer
  73494. * @returns true if everything that can be done was applied
  73495. */
  73496. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73497. }
  73498. /**
  73499. * Defines an optimization used to turn lens flares off
  73500. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73501. */
  73502. export class LensFlaresOptimization extends SceneOptimization {
  73503. /**
  73504. * Gets a string describing the action executed by the current optimization
  73505. * @return description string
  73506. */
  73507. getDescription(): string;
  73508. /**
  73509. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73510. * @param scene defines the current scene where to apply this optimization
  73511. * @param optimizer defines the current optimizer
  73512. * @returns true if everything that can be done was applied
  73513. */
  73514. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73515. }
  73516. /**
  73517. * Defines an optimization based on user defined callback.
  73518. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73519. */
  73520. export class CustomOptimization extends SceneOptimization {
  73521. /**
  73522. * Callback called to apply the custom optimization.
  73523. */
  73524. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73525. /**
  73526. * Callback called to get custom description
  73527. */
  73528. onGetDescription: () => string;
  73529. /**
  73530. * Gets a string describing the action executed by the current optimization
  73531. * @returns description string
  73532. */
  73533. getDescription(): string;
  73534. /**
  73535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73536. * @param scene defines the current scene where to apply this optimization
  73537. * @param optimizer defines the current optimizer
  73538. * @returns true if everything that can be done was applied
  73539. */
  73540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73541. }
  73542. /**
  73543. * Defines an optimization used to turn particles off
  73544. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73545. */
  73546. export class ParticlesOptimization extends SceneOptimization {
  73547. /**
  73548. * Gets a string describing the action executed by the current optimization
  73549. * @return description string
  73550. */
  73551. getDescription(): string;
  73552. /**
  73553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73554. * @param scene defines the current scene where to apply this optimization
  73555. * @param optimizer defines the current optimizer
  73556. * @returns true if everything that can be done was applied
  73557. */
  73558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73559. }
  73560. /**
  73561. * Defines an optimization used to turn render targets off
  73562. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73563. */
  73564. export class RenderTargetsOptimization extends SceneOptimization {
  73565. /**
  73566. * Gets a string describing the action executed by the current optimization
  73567. * @return description string
  73568. */
  73569. getDescription(): string;
  73570. /**
  73571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73572. * @param scene defines the current scene where to apply this optimization
  73573. * @param optimizer defines the current optimizer
  73574. * @returns true if everything that can be done was applied
  73575. */
  73576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73577. }
  73578. /**
  73579. * Defines an optimization used to merge meshes with compatible materials
  73580. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73581. */
  73582. export class MergeMeshesOptimization extends SceneOptimization {
  73583. private static _UpdateSelectionTree;
  73584. /**
  73585. * Gets or sets a boolean which defines if optimization octree has to be updated
  73586. */
  73587. static get UpdateSelectionTree(): boolean;
  73588. /**
  73589. * Gets or sets a boolean which defines if optimization octree has to be updated
  73590. */
  73591. static set UpdateSelectionTree(value: boolean);
  73592. /**
  73593. * Gets a string describing the action executed by the current optimization
  73594. * @return description string
  73595. */
  73596. getDescription(): string;
  73597. private _canBeMerged;
  73598. /**
  73599. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73600. * @param scene defines the current scene where to apply this optimization
  73601. * @param optimizer defines the current optimizer
  73602. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73603. * @returns true if everything that can be done was applied
  73604. */
  73605. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73606. }
  73607. /**
  73608. * Defines a list of options used by SceneOptimizer
  73609. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73610. */
  73611. export class SceneOptimizerOptions {
  73612. /**
  73613. * Defines the target frame rate to reach (60 by default)
  73614. */
  73615. targetFrameRate: number;
  73616. /**
  73617. * Defines the interval between two checkes (2000ms by default)
  73618. */
  73619. trackerDuration: number;
  73620. /**
  73621. * Gets the list of optimizations to apply
  73622. */
  73623. optimizations: SceneOptimization[];
  73624. /**
  73625. * Creates a new list of options used by SceneOptimizer
  73626. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73627. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73628. */
  73629. constructor(
  73630. /**
  73631. * Defines the target frame rate to reach (60 by default)
  73632. */
  73633. targetFrameRate?: number,
  73634. /**
  73635. * Defines the interval between two checkes (2000ms by default)
  73636. */
  73637. trackerDuration?: number);
  73638. /**
  73639. * Add a new optimization
  73640. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73641. * @returns the current SceneOptimizerOptions
  73642. */
  73643. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73644. /**
  73645. * Add a new custom optimization
  73646. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73647. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73648. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73649. * @returns the current SceneOptimizerOptions
  73650. */
  73651. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73652. /**
  73653. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73654. * @param targetFrameRate defines the target frame rate (60 by default)
  73655. * @returns a SceneOptimizerOptions object
  73656. */
  73657. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73658. /**
  73659. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73660. * @param targetFrameRate defines the target frame rate (60 by default)
  73661. * @returns a SceneOptimizerOptions object
  73662. */
  73663. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73664. /**
  73665. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73666. * @param targetFrameRate defines the target frame rate (60 by default)
  73667. * @returns a SceneOptimizerOptions object
  73668. */
  73669. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73670. }
  73671. /**
  73672. * Class used to run optimizations in order to reach a target frame rate
  73673. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73674. */
  73675. export class SceneOptimizer implements IDisposable {
  73676. private _isRunning;
  73677. private _options;
  73678. private _scene;
  73679. private _currentPriorityLevel;
  73680. private _targetFrameRate;
  73681. private _trackerDuration;
  73682. private _currentFrameRate;
  73683. private _sceneDisposeObserver;
  73684. private _improvementMode;
  73685. /**
  73686. * Defines an observable called when the optimizer reaches the target frame rate
  73687. */
  73688. onSuccessObservable: Observable<SceneOptimizer>;
  73689. /**
  73690. * Defines an observable called when the optimizer enables an optimization
  73691. */
  73692. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73693. /**
  73694. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73695. */
  73696. onFailureObservable: Observable<SceneOptimizer>;
  73697. /**
  73698. * Gets a boolean indicating if the optimizer is in improvement mode
  73699. */
  73700. get isInImprovementMode(): boolean;
  73701. /**
  73702. * Gets the current priority level (0 at start)
  73703. */
  73704. get currentPriorityLevel(): number;
  73705. /**
  73706. * Gets the current frame rate checked by the SceneOptimizer
  73707. */
  73708. get currentFrameRate(): number;
  73709. /**
  73710. * Gets or sets the current target frame rate (60 by default)
  73711. */
  73712. get targetFrameRate(): number;
  73713. /**
  73714. * Gets or sets the current target frame rate (60 by default)
  73715. */
  73716. set targetFrameRate(value: number);
  73717. /**
  73718. * Gets or sets the current interval between two checks (every 2000ms by default)
  73719. */
  73720. get trackerDuration(): number;
  73721. /**
  73722. * Gets or sets the current interval between two checks (every 2000ms by default)
  73723. */
  73724. set trackerDuration(value: number);
  73725. /**
  73726. * Gets the list of active optimizations
  73727. */
  73728. get optimizations(): SceneOptimization[];
  73729. /**
  73730. * Creates a new SceneOptimizer
  73731. * @param scene defines the scene to work on
  73732. * @param options defines the options to use with the SceneOptimizer
  73733. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73734. * @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)
  73735. */
  73736. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73737. /**
  73738. * Stops the current optimizer
  73739. */
  73740. stop(): void;
  73741. /**
  73742. * Reset the optimizer to initial step (current priority level = 0)
  73743. */
  73744. reset(): void;
  73745. /**
  73746. * Start the optimizer. By default it will try to reach a specific framerate
  73747. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73748. */
  73749. start(): void;
  73750. private _checkCurrentState;
  73751. /**
  73752. * Release all resources
  73753. */
  73754. dispose(): void;
  73755. /**
  73756. * Helper function to create a SceneOptimizer with one single line of code
  73757. * @param scene defines the scene to work on
  73758. * @param options defines the options to use with the SceneOptimizer
  73759. * @param onSuccess defines a callback to call on success
  73760. * @param onFailure defines a callback to call on failure
  73761. * @returns the new SceneOptimizer object
  73762. */
  73763. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73764. }
  73765. }
  73766. declare module BABYLON {
  73767. /**
  73768. * Class used to serialize a scene into a string
  73769. */
  73770. export class SceneSerializer {
  73771. /**
  73772. * Clear cache used by a previous serialization
  73773. */
  73774. static ClearCache(): void;
  73775. /**
  73776. * Serialize a scene into a JSON compatible object
  73777. * @param scene defines the scene to serialize
  73778. * @returns a JSON compatible object
  73779. */
  73780. static Serialize(scene: Scene): any;
  73781. /**
  73782. * Serialize a mesh into a JSON compatible object
  73783. * @param toSerialize defines the mesh to serialize
  73784. * @param withParents defines if parents must be serialized as well
  73785. * @param withChildren defines if children must be serialized as well
  73786. * @returns a JSON compatible object
  73787. */
  73788. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73789. }
  73790. }
  73791. declare module BABYLON {
  73792. /**
  73793. * Class used to host texture specific utilities
  73794. */
  73795. export class TextureTools {
  73796. /**
  73797. * Uses the GPU to create a copy texture rescaled at a given size
  73798. * @param texture Texture to copy from
  73799. * @param width defines the desired width
  73800. * @param height defines the desired height
  73801. * @param useBilinearMode defines if bilinear mode has to be used
  73802. * @return the generated texture
  73803. */
  73804. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73805. }
  73806. }
  73807. declare module BABYLON {
  73808. /**
  73809. * This represents the different options available for the video capture.
  73810. */
  73811. export interface VideoRecorderOptions {
  73812. /** Defines the mime type of the video. */
  73813. mimeType: string;
  73814. /** Defines the FPS the video should be recorded at. */
  73815. fps: number;
  73816. /** Defines the chunk size for the recording data. */
  73817. recordChunckSize: number;
  73818. /** The audio tracks to attach to the recording. */
  73819. audioTracks?: MediaStreamTrack[];
  73820. }
  73821. /**
  73822. * This can help with recording videos from BabylonJS.
  73823. * This is based on the available WebRTC functionalities of the browser.
  73824. *
  73825. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73826. */
  73827. export class VideoRecorder {
  73828. private static readonly _defaultOptions;
  73829. /**
  73830. * Returns whether or not the VideoRecorder is available in your browser.
  73831. * @param engine Defines the Babylon Engine.
  73832. * @returns true if supported otherwise false.
  73833. */
  73834. static IsSupported(engine: Engine): boolean;
  73835. private readonly _options;
  73836. private _canvas;
  73837. private _mediaRecorder;
  73838. private _recordedChunks;
  73839. private _fileName;
  73840. private _resolve;
  73841. private _reject;
  73842. /**
  73843. * True when a recording is already in progress.
  73844. */
  73845. get isRecording(): boolean;
  73846. /**
  73847. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73848. * @param engine Defines the BabylonJS Engine you wish to record.
  73849. * @param options Defines options that can be used to customize the capture.
  73850. */
  73851. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73852. /**
  73853. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73854. */
  73855. stopRecording(): void;
  73856. /**
  73857. * Starts recording the canvas for a max duration specified in parameters.
  73858. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73859. * If null no automatic download will start and you can rely on the promise to get the data back.
  73860. * @param maxDuration Defines the maximum recording time in seconds.
  73861. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73862. * @return A promise callback at the end of the recording with the video data in Blob.
  73863. */
  73864. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73865. /**
  73866. * Releases internal resources used during the recording.
  73867. */
  73868. dispose(): void;
  73869. private _handleDataAvailable;
  73870. private _handleError;
  73871. private _handleStop;
  73872. }
  73873. }
  73874. declare module BABYLON {
  73875. /**
  73876. * Class containing a set of static utilities functions for screenshots
  73877. */
  73878. export class ScreenshotTools {
  73879. /**
  73880. * Captures a screenshot of the current rendering
  73881. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73882. * @param engine defines the rendering engine
  73883. * @param camera defines the source camera
  73884. * @param size This parameter can be set to a single number or to an object with the
  73885. * following (optional) properties: precision, width, height. If a single number is passed,
  73886. * it will be used for both width and height. If an object is passed, the screenshot size
  73887. * will be derived from the parameters. The precision property is a multiplier allowing
  73888. * rendering at a higher or lower resolution
  73889. * @param successCallback defines the callback receives a single parameter which contains the
  73890. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73891. * src parameter of an <img> to display it
  73892. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73893. * Check your browser for supported MIME types
  73894. */
  73895. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73896. /**
  73897. * Captures a screenshot of the current rendering
  73898. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73899. * @param engine defines the rendering engine
  73900. * @param camera defines the source camera
  73901. * @param size This parameter can be set to a single number or to an object with the
  73902. * following (optional) properties: precision, width, height. If a single number is passed,
  73903. * it will be used for both width and height. If an object is passed, the screenshot size
  73904. * will be derived from the parameters. The precision property is a multiplier allowing
  73905. * rendering at a higher or lower resolution
  73906. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73907. * Check your browser for supported MIME types
  73908. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73909. * to the src parameter of an <img> to display it
  73910. */
  73911. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73912. /**
  73913. * Generates an image screenshot from the specified camera.
  73914. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73915. * @param engine The engine to use for rendering
  73916. * @param camera The camera to use for rendering
  73917. * @param size This parameter can be set to a single number or to an object with the
  73918. * following (optional) properties: precision, width, height. If a single number is passed,
  73919. * it will be used for both width and height. If an object is passed, the screenshot size
  73920. * will be derived from the parameters. The precision property is a multiplier allowing
  73921. * rendering at a higher or lower resolution
  73922. * @param successCallback The callback receives a single parameter which contains the
  73923. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73924. * src parameter of an <img> to display it
  73925. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73926. * Check your browser for supported MIME types
  73927. * @param samples Texture samples (default: 1)
  73928. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73929. * @param fileName A name for for the downloaded file.
  73930. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73931. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  73932. */
  73933. 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;
  73934. /**
  73935. * Generates an image screenshot from the specified camera.
  73936. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73937. * @param engine The engine to use for rendering
  73938. * @param camera The camera to use for rendering
  73939. * @param size This parameter can be set to a single number or to an object with the
  73940. * following (optional) properties: precision, width, height. If a single number is passed,
  73941. * it will be used for both width and height. If an object is passed, the screenshot size
  73942. * will be derived from the parameters. The precision property is a multiplier allowing
  73943. * rendering at a higher or lower resolution
  73944. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73945. * Check your browser for supported MIME types
  73946. * @param samples Texture samples (default: 1)
  73947. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73948. * @param fileName A name for for the downloaded file.
  73949. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73950. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73951. * to the src parameter of an <img> to display it
  73952. */
  73953. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73954. /**
  73955. * Gets height and width for screenshot size
  73956. * @private
  73957. */
  73958. private static _getScreenshotSize;
  73959. }
  73960. }
  73961. declare module BABYLON {
  73962. /**
  73963. * Interface for a data buffer
  73964. */
  73965. export interface IDataBuffer {
  73966. /**
  73967. * Reads bytes from the data buffer.
  73968. * @param byteOffset The byte offset to read
  73969. * @param byteLength The byte length to read
  73970. * @returns A promise that resolves when the bytes are read
  73971. */
  73972. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73973. /**
  73974. * The byte length of the buffer.
  73975. */
  73976. readonly byteLength: number;
  73977. }
  73978. /**
  73979. * Utility class for reading from a data buffer
  73980. */
  73981. export class DataReader {
  73982. /**
  73983. * The data buffer associated with this data reader.
  73984. */
  73985. readonly buffer: IDataBuffer;
  73986. /**
  73987. * The current byte offset from the beginning of the data buffer.
  73988. */
  73989. byteOffset: number;
  73990. private _dataView;
  73991. private _dataByteOffset;
  73992. /**
  73993. * Constructor
  73994. * @param buffer The buffer to read
  73995. */
  73996. constructor(buffer: IDataBuffer);
  73997. /**
  73998. * Loads the given byte length.
  73999. * @param byteLength The byte length to load
  74000. * @returns A promise that resolves when the load is complete
  74001. */
  74002. loadAsync(byteLength: number): Promise<void>;
  74003. /**
  74004. * Read a unsigned 32-bit integer from the currently loaded data range.
  74005. * @returns The 32-bit integer read
  74006. */
  74007. readUint32(): number;
  74008. /**
  74009. * Read a byte array from the currently loaded data range.
  74010. * @param byteLength The byte length to read
  74011. * @returns The byte array read
  74012. */
  74013. readUint8Array(byteLength: number): Uint8Array;
  74014. /**
  74015. * Read a string from the currently loaded data range.
  74016. * @param byteLength The byte length to read
  74017. * @returns The string read
  74018. */
  74019. readString(byteLength: number): string;
  74020. /**
  74021. * Skips the given byte length the currently loaded data range.
  74022. * @param byteLength The byte length to skip
  74023. */
  74024. skipBytes(byteLength: number): void;
  74025. }
  74026. }
  74027. declare module BABYLON {
  74028. /**
  74029. * Class for storing data to local storage if available or in-memory storage otherwise
  74030. */
  74031. export class DataStorage {
  74032. private static _Storage;
  74033. private static _GetStorage;
  74034. /**
  74035. * Reads a string from the data storage
  74036. * @param key The key to read
  74037. * @param defaultValue The value if the key doesn't exist
  74038. * @returns The string value
  74039. */
  74040. static ReadString(key: string, defaultValue: string): string;
  74041. /**
  74042. * Writes a string to the data storage
  74043. * @param key The key to write
  74044. * @param value The value to write
  74045. */
  74046. static WriteString(key: string, value: string): void;
  74047. /**
  74048. * Reads a boolean from the data storage
  74049. * @param key The key to read
  74050. * @param defaultValue The value if the key doesn't exist
  74051. * @returns The boolean value
  74052. */
  74053. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74054. /**
  74055. * Writes a boolean to the data storage
  74056. * @param key The key to write
  74057. * @param value The value to write
  74058. */
  74059. static WriteBoolean(key: string, value: boolean): void;
  74060. /**
  74061. * Reads a number from the data storage
  74062. * @param key The key to read
  74063. * @param defaultValue The value if the key doesn't exist
  74064. * @returns The number value
  74065. */
  74066. static ReadNumber(key: string, defaultValue: number): number;
  74067. /**
  74068. * Writes a number to the data storage
  74069. * @param key The key to write
  74070. * @param value The value to write
  74071. */
  74072. static WriteNumber(key: string, value: number): void;
  74073. }
  74074. }
  74075. declare module BABYLON {
  74076. /**
  74077. * Class used to record delta files between 2 scene states
  74078. */
  74079. export class SceneRecorder {
  74080. private _trackedScene;
  74081. private _savedJSON;
  74082. /**
  74083. * Track a given scene. This means the current scene state will be considered the original state
  74084. * @param scene defines the scene to track
  74085. */
  74086. track(scene: Scene): void;
  74087. /**
  74088. * Get the delta between current state and original state
  74089. * @returns a string containing the delta
  74090. */
  74091. getDelta(): any;
  74092. private _compareArray;
  74093. private _compareObjects;
  74094. private _compareCollections;
  74095. private static GetShadowGeneratorById;
  74096. /**
  74097. * Apply a given delta to a given scene
  74098. * @param deltaJSON defines the JSON containing the delta
  74099. * @param scene defines the scene to apply the delta to
  74100. */
  74101. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74102. private static _ApplyPropertiesToEntity;
  74103. private static _ApplyDeltaForEntity;
  74104. }
  74105. }
  74106. declare module BABYLON {
  74107. /**
  74108. * An interface for all Hit test features
  74109. */
  74110. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74111. /**
  74112. * Triggered when new babylon (transformed) hit test results are available
  74113. */
  74114. onHitTestResultObservable: Observable<T[]>;
  74115. }
  74116. /**
  74117. * Options used for hit testing
  74118. */
  74119. export interface IWebXRLegacyHitTestOptions {
  74120. /**
  74121. * Only test when user interacted with the scene. Default - hit test every frame
  74122. */
  74123. testOnPointerDownOnly?: boolean;
  74124. /**
  74125. * The node to use to transform the local results to world coordinates
  74126. */
  74127. worldParentNode?: TransformNode;
  74128. }
  74129. /**
  74130. * Interface defining the babylon result of raycasting/hit-test
  74131. */
  74132. export interface IWebXRLegacyHitResult {
  74133. /**
  74134. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74135. */
  74136. transformationMatrix: Matrix;
  74137. /**
  74138. * The native hit test result
  74139. */
  74140. xrHitResult: XRHitResult | XRHitTestResult;
  74141. }
  74142. /**
  74143. * The currently-working hit-test module.
  74144. * Hit test (or Ray-casting) is used to interact with the real world.
  74145. * For further information read here - https://github.com/immersive-web/hit-test
  74146. */
  74147. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74148. /**
  74149. * options to use when constructing this feature
  74150. */
  74151. readonly options: IWebXRLegacyHitTestOptions;
  74152. private _direction;
  74153. private _mat;
  74154. private _onSelectEnabled;
  74155. private _origin;
  74156. /**
  74157. * The module's name
  74158. */
  74159. static readonly Name: string;
  74160. /**
  74161. * The (Babylon) version of this module.
  74162. * This is an integer representing the implementation version.
  74163. * This number does not correspond to the WebXR specs version
  74164. */
  74165. static readonly Version: number;
  74166. /**
  74167. * Populated with the last native XR Hit Results
  74168. */
  74169. lastNativeXRHitResults: XRHitResult[];
  74170. /**
  74171. * Triggered when new babylon (transformed) hit test results are available
  74172. */
  74173. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74174. /**
  74175. * Creates a new instance of the (legacy version) hit test feature
  74176. * @param _xrSessionManager an instance of WebXRSessionManager
  74177. * @param options options to use when constructing this feature
  74178. */
  74179. constructor(_xrSessionManager: WebXRSessionManager,
  74180. /**
  74181. * options to use when constructing this feature
  74182. */
  74183. options?: IWebXRLegacyHitTestOptions);
  74184. /**
  74185. * execute a hit test with an XR Ray
  74186. *
  74187. * @param xrSession a native xrSession that will execute this hit test
  74188. * @param xrRay the ray (position and direction) to use for ray-casting
  74189. * @param referenceSpace native XR reference space to use for the hit-test
  74190. * @param filter filter function that will filter the results
  74191. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74192. */
  74193. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74194. /**
  74195. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74196. * @param event the (select) event to use to select with
  74197. * @param referenceSpace the reference space to use for this hit test
  74198. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74199. */
  74200. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74201. /**
  74202. * attach this feature
  74203. * Will usually be called by the features manager
  74204. *
  74205. * @returns true if successful.
  74206. */
  74207. attach(): boolean;
  74208. /**
  74209. * detach this feature.
  74210. * Will usually be called by the features manager
  74211. *
  74212. * @returns true if successful.
  74213. */
  74214. detach(): boolean;
  74215. /**
  74216. * Dispose this feature and all of the resources attached
  74217. */
  74218. dispose(): void;
  74219. protected _onXRFrame(frame: XRFrame): void;
  74220. private _onHitTestResults;
  74221. private _onSelect;
  74222. }
  74223. }
  74224. declare module BABYLON {
  74225. /**
  74226. * Options used for hit testing (version 2)
  74227. */
  74228. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74229. /**
  74230. * Do not create a permanent hit test. Will usually be used when only
  74231. * transient inputs are needed.
  74232. */
  74233. disablePermanentHitTest?: boolean;
  74234. /**
  74235. * Enable transient (for example touch-based) hit test inspections
  74236. */
  74237. enableTransientHitTest?: boolean;
  74238. /**
  74239. * Offset ray for the permanent hit test
  74240. */
  74241. offsetRay?: Vector3;
  74242. /**
  74243. * Offset ray for the transient hit test
  74244. */
  74245. transientOffsetRay?: Vector3;
  74246. /**
  74247. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74248. */
  74249. useReferenceSpace?: boolean;
  74250. /**
  74251. * Override the default entity type(s) of the hit-test result
  74252. */
  74253. entityTypes?: XRHitTestTrackableType[];
  74254. }
  74255. /**
  74256. * Interface defining the babylon result of hit-test
  74257. */
  74258. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74259. /**
  74260. * The input source that generated this hit test (if transient)
  74261. */
  74262. inputSource?: XRInputSource;
  74263. /**
  74264. * Is this a transient hit test
  74265. */
  74266. isTransient?: boolean;
  74267. /**
  74268. * Position of the hit test result
  74269. */
  74270. position: Vector3;
  74271. /**
  74272. * Rotation of the hit test result
  74273. */
  74274. rotationQuaternion: Quaternion;
  74275. /**
  74276. * The native hit test result
  74277. */
  74278. xrHitResult: XRHitTestResult;
  74279. }
  74280. /**
  74281. * The currently-working hit-test module.
  74282. * Hit test (or Ray-casting) is used to interact with the real world.
  74283. * For further information read here - https://github.com/immersive-web/hit-test
  74284. *
  74285. * Tested on chrome (mobile) 80.
  74286. */
  74287. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74288. /**
  74289. * options to use when constructing this feature
  74290. */
  74291. readonly options: IWebXRHitTestOptions;
  74292. private _tmpMat;
  74293. private _tmpPos;
  74294. private _tmpQuat;
  74295. private _transientXrHitTestSource;
  74296. private _xrHitTestSource;
  74297. private initHitTestSource;
  74298. /**
  74299. * The module's name
  74300. */
  74301. static readonly Name: string;
  74302. /**
  74303. * The (Babylon) version of this module.
  74304. * This is an integer representing the implementation version.
  74305. * This number does not correspond to the WebXR specs version
  74306. */
  74307. static readonly Version: number;
  74308. /**
  74309. * When set to true, each hit test will have its own position/rotation objects
  74310. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74311. * the developers will clone them or copy them as they see fit.
  74312. */
  74313. autoCloneTransformation: boolean;
  74314. /**
  74315. * Triggered when new babylon (transformed) hit test results are available
  74316. */
  74317. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74318. /**
  74319. * Use this to temporarily pause hit test checks.
  74320. */
  74321. paused: boolean;
  74322. /**
  74323. * Creates a new instance of the hit test feature
  74324. * @param _xrSessionManager an instance of WebXRSessionManager
  74325. * @param options options to use when constructing this feature
  74326. */
  74327. constructor(_xrSessionManager: WebXRSessionManager,
  74328. /**
  74329. * options to use when constructing this feature
  74330. */
  74331. options?: IWebXRHitTestOptions);
  74332. /**
  74333. * attach this feature
  74334. * Will usually be called by the features manager
  74335. *
  74336. * @returns true if successful.
  74337. */
  74338. attach(): boolean;
  74339. /**
  74340. * detach this feature.
  74341. * Will usually be called by the features manager
  74342. *
  74343. * @returns true if successful.
  74344. */
  74345. detach(): boolean;
  74346. /**
  74347. * Dispose this feature and all of the resources attached
  74348. */
  74349. dispose(): void;
  74350. protected _onXRFrame(frame: XRFrame): void;
  74351. private _processWebXRHitTestResult;
  74352. }
  74353. }
  74354. declare module BABYLON {
  74355. /**
  74356. * Configuration options of the anchor system
  74357. */
  74358. export interface IWebXRAnchorSystemOptions {
  74359. /**
  74360. * a node that will be used to convert local to world coordinates
  74361. */
  74362. worldParentNode?: TransformNode;
  74363. /**
  74364. * If set to true a reference of the created anchors will be kept until the next session starts
  74365. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74366. */
  74367. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74368. }
  74369. /**
  74370. * A babylon container for an XR Anchor
  74371. */
  74372. export interface IWebXRAnchor {
  74373. /**
  74374. * A babylon-assigned ID for this anchor
  74375. */
  74376. id: number;
  74377. /**
  74378. * Transformation matrix to apply to an object attached to this anchor
  74379. */
  74380. transformationMatrix: Matrix;
  74381. /**
  74382. * The native anchor object
  74383. */
  74384. xrAnchor: XRAnchor;
  74385. /**
  74386. * if defined, this object will be constantly updated by the anchor's position and rotation
  74387. */
  74388. attachedNode?: TransformNode;
  74389. }
  74390. /**
  74391. * An implementation of the anchor system for WebXR.
  74392. * For further information see https://github.com/immersive-web/anchors/
  74393. */
  74394. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74395. private _options;
  74396. private _lastFrameDetected;
  74397. private _trackedAnchors;
  74398. private _referenceSpaceForFrameAnchors;
  74399. private _futureAnchors;
  74400. /**
  74401. * The module's name
  74402. */
  74403. static readonly Name: string;
  74404. /**
  74405. * The (Babylon) version of this module.
  74406. * This is an integer representing the implementation version.
  74407. * This number does not correspond to the WebXR specs version
  74408. */
  74409. static readonly Version: number;
  74410. /**
  74411. * Observers registered here will be executed when a new anchor was added to the session
  74412. */
  74413. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74414. /**
  74415. * Observers registered here will be executed when an anchor was removed from the session
  74416. */
  74417. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74418. /**
  74419. * Observers registered here will be executed when an existing anchor updates
  74420. * This can execute N times every frame
  74421. */
  74422. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74423. /**
  74424. * Set the reference space to use for anchor creation, when not using a hit test.
  74425. * Will default to the session's reference space if not defined
  74426. */
  74427. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74428. /**
  74429. * constructs a new anchor system
  74430. * @param _xrSessionManager an instance of WebXRSessionManager
  74431. * @param _options configuration object for this feature
  74432. */
  74433. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74434. private _tmpVector;
  74435. private _tmpQuaternion;
  74436. private _populateTmpTransformation;
  74437. /**
  74438. * Create a new anchor point using a hit test result at a specific point in the scene
  74439. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74440. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74441. *
  74442. * @param hitTestResult The hit test result to use for this anchor creation
  74443. * @param position an optional position offset for this anchor
  74444. * @param rotationQuaternion an optional rotation offset for this anchor
  74445. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74446. */
  74447. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74448. /**
  74449. * Add a new anchor at a specific position and rotation
  74450. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74451. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74452. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74453. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74454. *
  74455. * @param position the position in which to add an anchor
  74456. * @param rotationQuaternion an optional rotation for the anchor transformation
  74457. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74458. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74459. */
  74460. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74461. /**
  74462. * detach this feature.
  74463. * Will usually be called by the features manager
  74464. *
  74465. * @returns true if successful.
  74466. */
  74467. detach(): boolean;
  74468. /**
  74469. * Dispose this feature and all of the resources attached
  74470. */
  74471. dispose(): void;
  74472. protected _onXRFrame(frame: XRFrame): void;
  74473. /**
  74474. * avoiding using Array.find for global support.
  74475. * @param xrAnchor the plane to find in the array
  74476. */
  74477. private _findIndexInAnchorArray;
  74478. private _updateAnchorWithXRFrame;
  74479. private _createAnchorAtTransformation;
  74480. }
  74481. }
  74482. declare module BABYLON {
  74483. /**
  74484. * Options used in the plane detector module
  74485. */
  74486. export interface IWebXRPlaneDetectorOptions {
  74487. /**
  74488. * The node to use to transform the local results to world coordinates
  74489. */
  74490. worldParentNode?: TransformNode;
  74491. /**
  74492. * If set to true a reference of the created planes will be kept until the next session starts
  74493. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74494. */
  74495. doNotRemovePlanesOnSessionEnded?: boolean;
  74496. }
  74497. /**
  74498. * A babylon interface for a WebXR plane.
  74499. * A Plane is actually a polygon, built from N points in space
  74500. *
  74501. * Supported in chrome 79, not supported in canary 81 ATM
  74502. */
  74503. export interface IWebXRPlane {
  74504. /**
  74505. * a babylon-assigned ID for this polygon
  74506. */
  74507. id: number;
  74508. /**
  74509. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74510. */
  74511. polygonDefinition: Array<Vector3>;
  74512. /**
  74513. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74514. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74515. */
  74516. transformationMatrix: Matrix;
  74517. /**
  74518. * the native xr-plane object
  74519. */
  74520. xrPlane: XRPlane;
  74521. }
  74522. /**
  74523. * The plane detector is used to detect planes in the real world when in AR
  74524. * For more information see https://github.com/immersive-web/real-world-geometry/
  74525. */
  74526. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74527. private _options;
  74528. private _detectedPlanes;
  74529. private _enabled;
  74530. private _lastFrameDetected;
  74531. /**
  74532. * The module's name
  74533. */
  74534. static readonly Name: string;
  74535. /**
  74536. * The (Babylon) version of this module.
  74537. * This is an integer representing the implementation version.
  74538. * This number does not correspond to the WebXR specs version
  74539. */
  74540. static readonly Version: number;
  74541. /**
  74542. * Observers registered here will be executed when a new plane was added to the session
  74543. */
  74544. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74545. /**
  74546. * Observers registered here will be executed when a plane is no longer detected in the session
  74547. */
  74548. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74549. /**
  74550. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74551. * This can execute N times every frame
  74552. */
  74553. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74554. /**
  74555. * construct a new Plane Detector
  74556. * @param _xrSessionManager an instance of xr Session manager
  74557. * @param _options configuration to use when constructing this feature
  74558. */
  74559. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74560. /**
  74561. * detach this feature.
  74562. * Will usually be called by the features manager
  74563. *
  74564. * @returns true if successful.
  74565. */
  74566. detach(): boolean;
  74567. /**
  74568. * Dispose this feature and all of the resources attached
  74569. */
  74570. dispose(): void;
  74571. protected _onXRFrame(frame: XRFrame): void;
  74572. private _init;
  74573. private _updatePlaneWithXRPlane;
  74574. /**
  74575. * avoiding using Array.find for global support.
  74576. * @param xrPlane the plane to find in the array
  74577. */
  74578. private findIndexInPlaneArray;
  74579. }
  74580. }
  74581. declare module BABYLON {
  74582. /**
  74583. * Options interface for the background remover plugin
  74584. */
  74585. export interface IWebXRBackgroundRemoverOptions {
  74586. /**
  74587. * Further background meshes to disable when entering AR
  74588. */
  74589. backgroundMeshes?: AbstractMesh[];
  74590. /**
  74591. * flags to configure the removal of the environment helper.
  74592. * If not set, the entire background will be removed. If set, flags should be set as well.
  74593. */
  74594. environmentHelperRemovalFlags?: {
  74595. /**
  74596. * Should the skybox be removed (default false)
  74597. */
  74598. skyBox?: boolean;
  74599. /**
  74600. * Should the ground be removed (default false)
  74601. */
  74602. ground?: boolean;
  74603. };
  74604. /**
  74605. * don't disable the environment helper
  74606. */
  74607. ignoreEnvironmentHelper?: boolean;
  74608. }
  74609. /**
  74610. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74611. */
  74612. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74613. /**
  74614. * read-only options to be used in this module
  74615. */
  74616. readonly options: IWebXRBackgroundRemoverOptions;
  74617. /**
  74618. * The module's name
  74619. */
  74620. static readonly Name: string;
  74621. /**
  74622. * The (Babylon) version of this module.
  74623. * This is an integer representing the implementation version.
  74624. * This number does not correspond to the WebXR specs version
  74625. */
  74626. static readonly Version: number;
  74627. /**
  74628. * registered observers will be triggered when the background state changes
  74629. */
  74630. onBackgroundStateChangedObservable: Observable<boolean>;
  74631. /**
  74632. * constructs a new background remover module
  74633. * @param _xrSessionManager the session manager for this module
  74634. * @param options read-only options to be used in this module
  74635. */
  74636. constructor(_xrSessionManager: WebXRSessionManager,
  74637. /**
  74638. * read-only options to be used in this module
  74639. */
  74640. options?: IWebXRBackgroundRemoverOptions);
  74641. /**
  74642. * attach this feature
  74643. * Will usually be called by the features manager
  74644. *
  74645. * @returns true if successful.
  74646. */
  74647. attach(): boolean;
  74648. /**
  74649. * detach this feature.
  74650. * Will usually be called by the features manager
  74651. *
  74652. * @returns true if successful.
  74653. */
  74654. detach(): boolean;
  74655. /**
  74656. * Dispose this feature and all of the resources attached
  74657. */
  74658. dispose(): void;
  74659. protected _onXRFrame(_xrFrame: XRFrame): void;
  74660. private _setBackgroundState;
  74661. }
  74662. }
  74663. declare module BABYLON {
  74664. /**
  74665. * Options for the controller physics feature
  74666. */
  74667. export class IWebXRControllerPhysicsOptions {
  74668. /**
  74669. * Should the headset get its own impostor
  74670. */
  74671. enableHeadsetImpostor?: boolean;
  74672. /**
  74673. * Optional parameters for the headset impostor
  74674. */
  74675. headsetImpostorParams?: {
  74676. /**
  74677. * The type of impostor to create. Default is sphere
  74678. */
  74679. impostorType: number;
  74680. /**
  74681. * the size of the impostor. Defaults to 10cm
  74682. */
  74683. impostorSize?: number | {
  74684. width: number;
  74685. height: number;
  74686. depth: number;
  74687. };
  74688. /**
  74689. * Friction definitions
  74690. */
  74691. friction?: number;
  74692. /**
  74693. * Restitution
  74694. */
  74695. restitution?: number;
  74696. };
  74697. /**
  74698. * The physics properties of the future impostors
  74699. */
  74700. physicsProperties?: {
  74701. /**
  74702. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74703. * Note that this requires a physics engine that supports mesh impostors!
  74704. */
  74705. useControllerMesh?: boolean;
  74706. /**
  74707. * The type of impostor to create. Default is sphere
  74708. */
  74709. impostorType?: number;
  74710. /**
  74711. * the size of the impostor. Defaults to 10cm
  74712. */
  74713. impostorSize?: number | {
  74714. width: number;
  74715. height: number;
  74716. depth: number;
  74717. };
  74718. /**
  74719. * Friction definitions
  74720. */
  74721. friction?: number;
  74722. /**
  74723. * Restitution
  74724. */
  74725. restitution?: number;
  74726. };
  74727. /**
  74728. * the xr input to use with this pointer selection
  74729. */
  74730. xrInput: WebXRInput;
  74731. }
  74732. /**
  74733. * Add physics impostor to your webxr controllers,
  74734. * including naive calculation of their linear and angular velocity
  74735. */
  74736. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74737. private readonly _options;
  74738. private _attachController;
  74739. private _controllers;
  74740. private _debugMode;
  74741. private _delta;
  74742. private _headsetImpostor?;
  74743. private _headsetMesh?;
  74744. private _lastTimestamp;
  74745. private _tmpQuaternion;
  74746. private _tmpVector;
  74747. /**
  74748. * The module's name
  74749. */
  74750. static readonly Name: string;
  74751. /**
  74752. * The (Babylon) version of this module.
  74753. * This is an integer representing the implementation version.
  74754. * This number does not correspond to the webxr specs version
  74755. */
  74756. static readonly Version: number;
  74757. /**
  74758. * Construct a new Controller Physics Feature
  74759. * @param _xrSessionManager the corresponding xr session manager
  74760. * @param _options options to create this feature with
  74761. */
  74762. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74763. /**
  74764. * @hidden
  74765. * enable debugging - will show console outputs and the impostor mesh
  74766. */
  74767. _enablePhysicsDebug(): void;
  74768. /**
  74769. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74770. * @param xrController the controller to add
  74771. */
  74772. addController(xrController: WebXRInputSource): void;
  74773. /**
  74774. * attach this feature
  74775. * Will usually be called by the features manager
  74776. *
  74777. * @returns true if successful.
  74778. */
  74779. attach(): boolean;
  74780. /**
  74781. * detach this feature.
  74782. * Will usually be called by the features manager
  74783. *
  74784. * @returns true if successful.
  74785. */
  74786. detach(): boolean;
  74787. /**
  74788. * Get the headset impostor, if enabled
  74789. * @returns the impostor
  74790. */
  74791. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74792. /**
  74793. * Get the physics impostor of a specific controller.
  74794. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74795. * @param controller the controller or the controller id of which to get the impostor
  74796. * @returns the impostor or null
  74797. */
  74798. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74799. /**
  74800. * Update the physics properties provided in the constructor
  74801. * @param newProperties the new properties object
  74802. */
  74803. setPhysicsProperties(newProperties: {
  74804. impostorType?: number;
  74805. impostorSize?: number | {
  74806. width: number;
  74807. height: number;
  74808. depth: number;
  74809. };
  74810. friction?: number;
  74811. restitution?: number;
  74812. }): void;
  74813. protected _onXRFrame(_xrFrame: any): void;
  74814. private _detachController;
  74815. }
  74816. }
  74817. declare module BABYLON {
  74818. /**
  74819. * A babylon interface for a "WebXR" feature point.
  74820. * Represents the position and confidence value of a given feature point.
  74821. */
  74822. export interface IWebXRFeaturePoint {
  74823. /**
  74824. * Represents the position of the feature point in world space.
  74825. */
  74826. position: Vector3;
  74827. /**
  74828. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  74829. */
  74830. confidenceValue: number;
  74831. }
  74832. /**
  74833. * The feature point system is used to detect feature points from real world geometry.
  74834. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  74835. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  74836. */
  74837. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  74838. private _enabled;
  74839. private _featurePointCloud;
  74840. /**
  74841. * The module's name
  74842. */
  74843. static readonly Name: string;
  74844. /**
  74845. * The (Babylon) version of this module.
  74846. * This is an integer representing the implementation version.
  74847. * This number does not correspond to the WebXR specs version
  74848. */
  74849. static readonly Version: number;
  74850. /**
  74851. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  74852. * Will notify the observers about which feature points have been added.
  74853. */
  74854. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  74855. /**
  74856. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  74857. * Will notify the observers about which feature points have been updated.
  74858. */
  74859. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  74860. /**
  74861. * The current feature point cloud maintained across frames.
  74862. */
  74863. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  74864. /**
  74865. * construct the feature point system
  74866. * @param _xrSessionManager an instance of xr Session manager
  74867. */
  74868. constructor(_xrSessionManager: WebXRSessionManager);
  74869. /**
  74870. * Detach this feature.
  74871. * Will usually be called by the features manager
  74872. *
  74873. * @returns true if successful.
  74874. */
  74875. detach(): boolean;
  74876. /**
  74877. * Dispose this feature and all of the resources attached
  74878. */
  74879. dispose(): void;
  74880. /**
  74881. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  74882. */
  74883. protected _onXRFrame(frame: XRFrame): void;
  74884. /**
  74885. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  74886. */
  74887. private _init;
  74888. }
  74889. }
  74890. declare module BABYLON {
  74891. /**
  74892. * Configuration interface for the hand tracking feature
  74893. */
  74894. export interface IWebXRHandTrackingOptions {
  74895. /**
  74896. * The xrInput that will be used as source for new hands
  74897. */
  74898. xrInput: WebXRInput;
  74899. /**
  74900. * Configuration object for the joint meshes
  74901. */
  74902. jointMeshes?: {
  74903. /**
  74904. * Should the meshes created be invisible (defaults to false)
  74905. */
  74906. invisible?: boolean;
  74907. /**
  74908. * A source mesh to be used to create instances. Defaults to a sphere.
  74909. * This mesh will be the source for all other (25) meshes.
  74910. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  74911. */
  74912. sourceMesh?: Mesh;
  74913. /**
  74914. * Should the source mesh stay visible. Defaults to false
  74915. */
  74916. keepOriginalVisible?: boolean;
  74917. /**
  74918. * Scale factor for all instances (defaults to 2)
  74919. */
  74920. scaleFactor?: number;
  74921. /**
  74922. * Should each instance have its own physics impostor
  74923. */
  74924. enablePhysics?: boolean;
  74925. /**
  74926. * If enabled, override default physics properties
  74927. */
  74928. physicsProps?: {
  74929. friction?: number;
  74930. restitution?: number;
  74931. impostorType?: number;
  74932. };
  74933. /**
  74934. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  74935. */
  74936. handMesh?: AbstractMesh;
  74937. };
  74938. }
  74939. /**
  74940. * Parts of the hands divided to writs and finger names
  74941. */
  74942. export const enum HandPart {
  74943. /**
  74944. * HandPart - Wrist
  74945. */
  74946. WRIST = "wrist",
  74947. /**
  74948. * HandPart - The THumb
  74949. */
  74950. THUMB = "thumb",
  74951. /**
  74952. * HandPart - Index finger
  74953. */
  74954. INDEX = "index",
  74955. /**
  74956. * HandPart - Middle finger
  74957. */
  74958. MIDDLE = "middle",
  74959. /**
  74960. * HandPart - Ring finger
  74961. */
  74962. RING = "ring",
  74963. /**
  74964. * HandPart - Little finger
  74965. */
  74966. LITTLE = "little"
  74967. }
  74968. /**
  74969. * Representing a single hand (with its corresponding native XRHand object)
  74970. */
  74971. export class WebXRHand implements IDisposable {
  74972. /** the controller to which the hand correlates */
  74973. readonly xrController: WebXRInputSource;
  74974. /** the meshes to be used to track the hand joints */
  74975. readonly trackedMeshes: AbstractMesh[];
  74976. /**
  74977. * Hand-parts definition (key is HandPart)
  74978. */
  74979. static HandPartsDefinition: {
  74980. [key: string]: number[];
  74981. };
  74982. /**
  74983. * Populate the HandPartsDefinition object.
  74984. * This is called as a side effect since certain browsers don't have XRHand defined.
  74985. */
  74986. static _PopulateHandPartsDefinition(): void;
  74987. /**
  74988. * Construct a new hand object
  74989. * @param xrController the controller to which the hand correlates
  74990. * @param trackedMeshes the meshes to be used to track the hand joints
  74991. */
  74992. constructor(
  74993. /** the controller to which the hand correlates */
  74994. xrController: WebXRInputSource,
  74995. /** the meshes to be used to track the hand joints */
  74996. trackedMeshes: AbstractMesh[]);
  74997. /**
  74998. * Update this hand from the latest xr frame
  74999. * @param xrFrame xrFrame to update from
  75000. * @param referenceSpace The current viewer reference space
  75001. * @param scaleFactor optional scale factor for the meshes
  75002. */
  75003. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75004. /**
  75005. * Get meshes of part of the hand
  75006. * @param part the part of hand to get
  75007. * @returns An array of meshes that correlate to the hand part requested
  75008. */
  75009. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75010. /**
  75011. * Dispose this Hand object
  75012. */
  75013. dispose(): void;
  75014. }
  75015. /**
  75016. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75017. */
  75018. export class WebXRHandTracking extends WebXRAbstractFeature {
  75019. /**
  75020. * options to use when constructing this feature
  75021. */
  75022. readonly options: IWebXRHandTrackingOptions;
  75023. private static _idCounter;
  75024. /**
  75025. * The module's name
  75026. */
  75027. static readonly Name: string;
  75028. /**
  75029. * The (Babylon) version of this module.
  75030. * This is an integer representing the implementation version.
  75031. * This number does not correspond to the WebXR specs version
  75032. */
  75033. static readonly Version: number;
  75034. /**
  75035. * This observable will notify registered observers when a new hand object was added and initialized
  75036. */
  75037. onHandAddedObservable: Observable<WebXRHand>;
  75038. /**
  75039. * This observable will notify its observers right before the hand object is disposed
  75040. */
  75041. onHandRemovedObservable: Observable<WebXRHand>;
  75042. private _hands;
  75043. /**
  75044. * Creates a new instance of the hit test feature
  75045. * @param _xrSessionManager an instance of WebXRSessionManager
  75046. * @param options options to use when constructing this feature
  75047. */
  75048. constructor(_xrSessionManager: WebXRSessionManager,
  75049. /**
  75050. * options to use when constructing this feature
  75051. */
  75052. options: IWebXRHandTrackingOptions);
  75053. /**
  75054. * Check if the needed objects are defined.
  75055. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75056. */
  75057. isCompatible(): boolean;
  75058. /**
  75059. * attach this feature
  75060. * Will usually be called by the features manager
  75061. *
  75062. * @returns true if successful.
  75063. */
  75064. attach(): boolean;
  75065. /**
  75066. * detach this feature.
  75067. * Will usually be called by the features manager
  75068. *
  75069. * @returns true if successful.
  75070. */
  75071. detach(): boolean;
  75072. /**
  75073. * Dispose this feature and all of the resources attached
  75074. */
  75075. dispose(): void;
  75076. /**
  75077. * Get the hand object according to the controller id
  75078. * @param controllerId the controller id to which we want to get the hand
  75079. * @returns null if not found or the WebXRHand object if found
  75080. */
  75081. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75082. /**
  75083. * Get a hand object according to the requested handedness
  75084. * @param handedness the handedness to request
  75085. * @returns null if not found or the WebXRHand object if found
  75086. */
  75087. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75088. protected _onXRFrame(_xrFrame: XRFrame): void;
  75089. private _attachHand;
  75090. private _detachHand;
  75091. }
  75092. }
  75093. declare module BABYLON {
  75094. /**
  75095. * The motion controller class for all microsoft mixed reality controllers
  75096. */
  75097. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75098. protected readonly _mapping: {
  75099. defaultButton: {
  75100. valueNodeName: string;
  75101. unpressedNodeName: string;
  75102. pressedNodeName: string;
  75103. };
  75104. defaultAxis: {
  75105. valueNodeName: string;
  75106. minNodeName: string;
  75107. maxNodeName: string;
  75108. };
  75109. buttons: {
  75110. "xr-standard-trigger": {
  75111. rootNodeName: string;
  75112. componentProperty: string;
  75113. states: string[];
  75114. };
  75115. "xr-standard-squeeze": {
  75116. rootNodeName: string;
  75117. componentProperty: string;
  75118. states: string[];
  75119. };
  75120. "xr-standard-touchpad": {
  75121. rootNodeName: string;
  75122. labelAnchorNodeName: string;
  75123. touchPointNodeName: string;
  75124. };
  75125. "xr-standard-thumbstick": {
  75126. rootNodeName: string;
  75127. componentProperty: string;
  75128. states: string[];
  75129. };
  75130. };
  75131. axes: {
  75132. "xr-standard-touchpad": {
  75133. "x-axis": {
  75134. rootNodeName: string;
  75135. };
  75136. "y-axis": {
  75137. rootNodeName: string;
  75138. };
  75139. };
  75140. "xr-standard-thumbstick": {
  75141. "x-axis": {
  75142. rootNodeName: string;
  75143. };
  75144. "y-axis": {
  75145. rootNodeName: string;
  75146. };
  75147. };
  75148. };
  75149. };
  75150. /**
  75151. * The base url used to load the left and right controller models
  75152. */
  75153. static MODEL_BASE_URL: string;
  75154. /**
  75155. * The name of the left controller model file
  75156. */
  75157. static MODEL_LEFT_FILENAME: string;
  75158. /**
  75159. * The name of the right controller model file
  75160. */
  75161. static MODEL_RIGHT_FILENAME: string;
  75162. profileId: string;
  75163. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75164. protected _getFilenameAndPath(): {
  75165. filename: string;
  75166. path: string;
  75167. };
  75168. protected _getModelLoadingConstraints(): boolean;
  75169. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75170. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75171. protected _updateModel(): void;
  75172. }
  75173. }
  75174. declare module BABYLON {
  75175. /**
  75176. * The motion controller class for oculus touch (quest, rift).
  75177. * This class supports legacy mapping as well the standard xr mapping
  75178. */
  75179. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75180. private _forceLegacyControllers;
  75181. private _modelRootNode;
  75182. /**
  75183. * The base url used to load the left and right controller models
  75184. */
  75185. static MODEL_BASE_URL: string;
  75186. /**
  75187. * The name of the left controller model file
  75188. */
  75189. static MODEL_LEFT_FILENAME: string;
  75190. /**
  75191. * The name of the right controller model file
  75192. */
  75193. static MODEL_RIGHT_FILENAME: string;
  75194. /**
  75195. * Base Url for the Quest controller model.
  75196. */
  75197. static QUEST_MODEL_BASE_URL: string;
  75198. profileId: string;
  75199. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75200. protected _getFilenameAndPath(): {
  75201. filename: string;
  75202. path: string;
  75203. };
  75204. protected _getModelLoadingConstraints(): boolean;
  75205. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75206. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75207. protected _updateModel(): void;
  75208. /**
  75209. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75210. * between the touch and touch 2.
  75211. */
  75212. private _isQuest;
  75213. }
  75214. }
  75215. declare module BABYLON {
  75216. /**
  75217. * The motion controller class for the standard HTC-Vive controllers
  75218. */
  75219. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75220. private _modelRootNode;
  75221. /**
  75222. * The base url used to load the left and right controller models
  75223. */
  75224. static MODEL_BASE_URL: string;
  75225. /**
  75226. * File name for the controller model.
  75227. */
  75228. static MODEL_FILENAME: string;
  75229. profileId: string;
  75230. /**
  75231. * Create a new Vive motion controller object
  75232. * @param scene the scene to use to create this controller
  75233. * @param gamepadObject the corresponding gamepad object
  75234. * @param handedness the handedness of the controller
  75235. */
  75236. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75237. protected _getFilenameAndPath(): {
  75238. filename: string;
  75239. path: string;
  75240. };
  75241. protected _getModelLoadingConstraints(): boolean;
  75242. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75243. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75244. protected _updateModel(): void;
  75245. }
  75246. }
  75247. declare module BABYLON {
  75248. /**
  75249. * A cursor which tracks a point on a path
  75250. */
  75251. export class PathCursor {
  75252. private path;
  75253. /**
  75254. * Stores path cursor callbacks for when an onchange event is triggered
  75255. */
  75256. private _onchange;
  75257. /**
  75258. * The value of the path cursor
  75259. */
  75260. value: number;
  75261. /**
  75262. * The animation array of the path cursor
  75263. */
  75264. animations: Animation[];
  75265. /**
  75266. * Initializes the path cursor
  75267. * @param path The path to track
  75268. */
  75269. constructor(path: Path2);
  75270. /**
  75271. * Gets the cursor point on the path
  75272. * @returns A point on the path cursor at the cursor location
  75273. */
  75274. getPoint(): Vector3;
  75275. /**
  75276. * Moves the cursor ahead by the step amount
  75277. * @param step The amount to move the cursor forward
  75278. * @returns This path cursor
  75279. */
  75280. moveAhead(step?: number): PathCursor;
  75281. /**
  75282. * Moves the cursor behind by the step amount
  75283. * @param step The amount to move the cursor back
  75284. * @returns This path cursor
  75285. */
  75286. moveBack(step?: number): PathCursor;
  75287. /**
  75288. * Moves the cursor by the step amount
  75289. * If the step amount is greater than one, an exception is thrown
  75290. * @param step The amount to move the cursor
  75291. * @returns This path cursor
  75292. */
  75293. move(step: number): PathCursor;
  75294. /**
  75295. * Ensures that the value is limited between zero and one
  75296. * @returns This path cursor
  75297. */
  75298. private ensureLimits;
  75299. /**
  75300. * Runs onchange callbacks on change (used by the animation engine)
  75301. * @returns This path cursor
  75302. */
  75303. private raiseOnChange;
  75304. /**
  75305. * Executes a function on change
  75306. * @param f A path cursor onchange callback
  75307. * @returns This path cursor
  75308. */
  75309. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75310. }
  75311. }
  75312. declare module BABYLON {
  75313. /** @hidden */
  75314. export var blurPixelShader: {
  75315. name: string;
  75316. shader: string;
  75317. };
  75318. }
  75319. declare module BABYLON {
  75320. /** @hidden */
  75321. export var pointCloudVertexDeclaration: {
  75322. name: string;
  75323. shader: string;
  75324. };
  75325. }
  75326. // Mixins
  75327. interface Window {
  75328. mozIndexedDB: IDBFactory;
  75329. webkitIndexedDB: IDBFactory;
  75330. msIndexedDB: IDBFactory;
  75331. webkitURL: typeof URL;
  75332. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75333. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75334. WebGLRenderingContext: WebGLRenderingContext;
  75335. MSGesture: MSGesture;
  75336. CANNON: any;
  75337. AudioContext: AudioContext;
  75338. webkitAudioContext: AudioContext;
  75339. PointerEvent: any;
  75340. Math: Math;
  75341. Uint8Array: Uint8ArrayConstructor;
  75342. Float32Array: Float32ArrayConstructor;
  75343. mozURL: typeof URL;
  75344. msURL: typeof URL;
  75345. VRFrameData: any; // WebVR, from specs 1.1
  75346. DracoDecoderModule: any;
  75347. setImmediate(handler: (...args: any[]) => void): number;
  75348. }
  75349. interface HTMLCanvasElement {
  75350. requestPointerLock(): void;
  75351. msRequestPointerLock?(): void;
  75352. mozRequestPointerLock?(): void;
  75353. webkitRequestPointerLock?(): void;
  75354. /** Track wether a record is in progress */
  75355. isRecording: boolean;
  75356. /** Capture Stream method defined by some browsers */
  75357. captureStream(fps?: number): MediaStream;
  75358. }
  75359. interface CanvasRenderingContext2D {
  75360. msImageSmoothingEnabled: boolean;
  75361. }
  75362. interface MouseEvent {
  75363. mozMovementX: number;
  75364. mozMovementY: number;
  75365. webkitMovementX: number;
  75366. webkitMovementY: number;
  75367. msMovementX: number;
  75368. msMovementY: number;
  75369. }
  75370. interface Navigator {
  75371. mozGetVRDevices: (any: any) => any;
  75372. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75373. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75374. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75375. webkitGetGamepads(): Gamepad[];
  75376. msGetGamepads(): Gamepad[];
  75377. webkitGamepads(): Gamepad[];
  75378. }
  75379. interface HTMLVideoElement {
  75380. mozSrcObject: any;
  75381. }
  75382. interface Math {
  75383. fround(x: number): number;
  75384. imul(a: number, b: number): number;
  75385. }
  75386. interface WebGLRenderingContext {
  75387. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75388. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75389. vertexAttribDivisor(index: number, divisor: number): void;
  75390. createVertexArray(): any;
  75391. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75392. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75393. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75394. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75395. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75396. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75397. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75398. // Queries
  75399. createQuery(): WebGLQuery;
  75400. deleteQuery(query: WebGLQuery): void;
  75401. beginQuery(target: number, query: WebGLQuery): void;
  75402. endQuery(target: number): void;
  75403. getQueryParameter(query: WebGLQuery, pname: number): any;
  75404. getQuery(target: number, pname: number): any;
  75405. MAX_SAMPLES: number;
  75406. RGBA8: number;
  75407. READ_FRAMEBUFFER: number;
  75408. DRAW_FRAMEBUFFER: number;
  75409. UNIFORM_BUFFER: number;
  75410. HALF_FLOAT_OES: number;
  75411. RGBA16F: number;
  75412. RGBA32F: number;
  75413. R32F: number;
  75414. RG32F: number;
  75415. RGB32F: number;
  75416. R16F: number;
  75417. RG16F: number;
  75418. RGB16F: number;
  75419. RED: number;
  75420. RG: number;
  75421. R8: number;
  75422. RG8: number;
  75423. UNSIGNED_INT_24_8: number;
  75424. DEPTH24_STENCIL8: number;
  75425. MIN: number;
  75426. MAX: number;
  75427. /* Multiple Render Targets */
  75428. drawBuffers(buffers: number[]): void;
  75429. readBuffer(src: number): void;
  75430. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75431. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75432. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75433. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75434. // Occlusion Query
  75435. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75436. ANY_SAMPLES_PASSED: number;
  75437. QUERY_RESULT_AVAILABLE: number;
  75438. QUERY_RESULT: number;
  75439. }
  75440. interface WebGLProgram {
  75441. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75442. }
  75443. interface EXT_disjoint_timer_query {
  75444. QUERY_COUNTER_BITS_EXT: number;
  75445. TIME_ELAPSED_EXT: number;
  75446. TIMESTAMP_EXT: number;
  75447. GPU_DISJOINT_EXT: number;
  75448. QUERY_RESULT_EXT: number;
  75449. QUERY_RESULT_AVAILABLE_EXT: number;
  75450. queryCounterEXT(query: WebGLQuery, target: number): void;
  75451. createQueryEXT(): WebGLQuery;
  75452. beginQueryEXT(target: number, query: WebGLQuery): void;
  75453. endQueryEXT(target: number): void;
  75454. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75455. deleteQueryEXT(query: WebGLQuery): void;
  75456. }
  75457. interface WebGLUniformLocation {
  75458. _currentState: any;
  75459. }
  75460. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75461. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75462. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75463. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75464. interface WebGLRenderingContext {
  75465. readonly RASTERIZER_DISCARD: number;
  75466. readonly DEPTH_COMPONENT24: number;
  75467. readonly TEXTURE_3D: number;
  75468. readonly TEXTURE_2D_ARRAY: number;
  75469. readonly TEXTURE_COMPARE_FUNC: number;
  75470. readonly TEXTURE_COMPARE_MODE: number;
  75471. readonly COMPARE_REF_TO_TEXTURE: number;
  75472. readonly TEXTURE_WRAP_R: number;
  75473. readonly HALF_FLOAT: number;
  75474. readonly RGB8: number;
  75475. readonly RED_INTEGER: number;
  75476. readonly RG_INTEGER: number;
  75477. readonly RGB_INTEGER: number;
  75478. readonly RGBA_INTEGER: number;
  75479. readonly R8_SNORM: number;
  75480. readonly RG8_SNORM: number;
  75481. readonly RGB8_SNORM: number;
  75482. readonly RGBA8_SNORM: number;
  75483. readonly R8I: number;
  75484. readonly RG8I: number;
  75485. readonly RGB8I: number;
  75486. readonly RGBA8I: number;
  75487. readonly R8UI: number;
  75488. readonly RG8UI: number;
  75489. readonly RGB8UI: number;
  75490. readonly RGBA8UI: number;
  75491. readonly R16I: number;
  75492. readonly RG16I: number;
  75493. readonly RGB16I: number;
  75494. readonly RGBA16I: number;
  75495. readonly R16UI: number;
  75496. readonly RG16UI: number;
  75497. readonly RGB16UI: number;
  75498. readonly RGBA16UI: number;
  75499. readonly R32I: number;
  75500. readonly RG32I: number;
  75501. readonly RGB32I: number;
  75502. readonly RGBA32I: number;
  75503. readonly R32UI: number;
  75504. readonly RG32UI: number;
  75505. readonly RGB32UI: number;
  75506. readonly RGBA32UI: number;
  75507. readonly RGB10_A2UI: number;
  75508. readonly R11F_G11F_B10F: number;
  75509. readonly RGB9_E5: number;
  75510. readonly RGB10_A2: number;
  75511. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75512. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75513. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75514. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75515. readonly DEPTH_COMPONENT32F: number;
  75516. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75517. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75518. 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;
  75519. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75520. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75521. readonly TRANSFORM_FEEDBACK: number;
  75522. readonly INTERLEAVED_ATTRIBS: number;
  75523. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75524. createTransformFeedback(): WebGLTransformFeedback;
  75525. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75526. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75527. beginTransformFeedback(primitiveMode: number): void;
  75528. endTransformFeedback(): void;
  75529. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75530. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75531. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75532. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75533. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75534. }
  75535. interface ImageBitmap {
  75536. readonly width: number;
  75537. readonly height: number;
  75538. close(): void;
  75539. }
  75540. interface WebGLQuery extends WebGLObject {
  75541. }
  75542. declare var WebGLQuery: {
  75543. prototype: WebGLQuery;
  75544. new(): WebGLQuery;
  75545. };
  75546. interface WebGLSampler extends WebGLObject {
  75547. }
  75548. declare var WebGLSampler: {
  75549. prototype: WebGLSampler;
  75550. new(): WebGLSampler;
  75551. };
  75552. interface WebGLSync extends WebGLObject {
  75553. }
  75554. declare var WebGLSync: {
  75555. prototype: WebGLSync;
  75556. new(): WebGLSync;
  75557. };
  75558. interface WebGLTransformFeedback extends WebGLObject {
  75559. }
  75560. declare var WebGLTransformFeedback: {
  75561. prototype: WebGLTransformFeedback;
  75562. new(): WebGLTransformFeedback;
  75563. };
  75564. interface WebGLVertexArrayObject extends WebGLObject {
  75565. }
  75566. declare var WebGLVertexArrayObject: {
  75567. prototype: WebGLVertexArrayObject;
  75568. new(): WebGLVertexArrayObject;
  75569. };
  75570. // Type definitions for WebVR API
  75571. // Project: https://w3c.github.io/webvr/
  75572. // Definitions by: six a <https://github.com/lostfictions>
  75573. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75574. interface VRDisplay extends EventTarget {
  75575. /**
  75576. * Dictionary of capabilities describing the VRDisplay.
  75577. */
  75578. readonly capabilities: VRDisplayCapabilities;
  75579. /**
  75580. * z-depth defining the far plane of the eye view frustum
  75581. * enables mapping of values in the render target depth
  75582. * attachment to scene coordinates. Initially set to 10000.0.
  75583. */
  75584. depthFar: number;
  75585. /**
  75586. * z-depth defining the near plane of the eye view frustum
  75587. * enables mapping of values in the render target depth
  75588. * attachment to scene coordinates. Initially set to 0.01.
  75589. */
  75590. depthNear: number;
  75591. /**
  75592. * An identifier for this distinct VRDisplay. Used as an
  75593. * association point in the Gamepad API.
  75594. */
  75595. readonly displayId: number;
  75596. /**
  75597. * A display name, a user-readable name identifying it.
  75598. */
  75599. readonly displayName: string;
  75600. readonly isConnected: boolean;
  75601. readonly isPresenting: boolean;
  75602. /**
  75603. * If this VRDisplay supports room-scale experiences, the optional
  75604. * stage attribute contains details on the room-scale parameters.
  75605. */
  75606. readonly stageParameters: VRStageParameters | null;
  75607. /**
  75608. * Passing the value returned by `requestAnimationFrame` to
  75609. * `cancelAnimationFrame` will unregister the callback.
  75610. * @param handle Define the hanle of the request to cancel
  75611. */
  75612. cancelAnimationFrame(handle: number): void;
  75613. /**
  75614. * Stops presenting to the VRDisplay.
  75615. * @returns a promise to know when it stopped
  75616. */
  75617. exitPresent(): Promise<void>;
  75618. /**
  75619. * Return the current VREyeParameters for the given eye.
  75620. * @param whichEye Define the eye we want the parameter for
  75621. * @returns the eye parameters
  75622. */
  75623. getEyeParameters(whichEye: string): VREyeParameters;
  75624. /**
  75625. * Populates the passed VRFrameData with the information required to render
  75626. * the current frame.
  75627. * @param frameData Define the data structure to populate
  75628. * @returns true if ok otherwise false
  75629. */
  75630. getFrameData(frameData: VRFrameData): boolean;
  75631. /**
  75632. * Get the layers currently being presented.
  75633. * @returns the list of VR layers
  75634. */
  75635. getLayers(): VRLayer[];
  75636. /**
  75637. * Return a VRPose containing the future predicted pose of the VRDisplay
  75638. * when the current frame will be presented. The value returned will not
  75639. * change until JavaScript has returned control to the browser.
  75640. *
  75641. * The VRPose will contain the position, orientation, velocity,
  75642. * and acceleration of each of these properties.
  75643. * @returns the pose object
  75644. */
  75645. getPose(): VRPose;
  75646. /**
  75647. * Return the current instantaneous pose of the VRDisplay, with no
  75648. * prediction applied.
  75649. * @returns the current instantaneous pose
  75650. */
  75651. getImmediatePose(): VRPose;
  75652. /**
  75653. * The callback passed to `requestAnimationFrame` will be called
  75654. * any time a new frame should be rendered. When the VRDisplay is
  75655. * presenting the callback will be called at the native refresh
  75656. * rate of the HMD. When not presenting this function acts
  75657. * identically to how window.requestAnimationFrame acts. Content should
  75658. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75659. * asynchronously from other displays and at differing refresh rates.
  75660. * @param callback Define the eaction to run next frame
  75661. * @returns the request handle it
  75662. */
  75663. requestAnimationFrame(callback: FrameRequestCallback): number;
  75664. /**
  75665. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75666. * Repeat calls while already presenting will update the VRLayers being displayed.
  75667. * @param layers Define the list of layer to present
  75668. * @returns a promise to know when the request has been fulfilled
  75669. */
  75670. requestPresent(layers: VRLayer[]): Promise<void>;
  75671. /**
  75672. * Reset the pose for this display, treating its current position and
  75673. * orientation as the "origin/zero" values. VRPose.position,
  75674. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75675. * updated when calling resetPose(). This should be called in only
  75676. * sitting-space experiences.
  75677. */
  75678. resetPose(): void;
  75679. /**
  75680. * The VRLayer provided to the VRDisplay will be captured and presented
  75681. * in the HMD. Calling this function has the same effect on the source
  75682. * canvas as any other operation that uses its source image, and canvases
  75683. * created without preserveDrawingBuffer set to true will be cleared.
  75684. * @param pose Define the pose to submit
  75685. */
  75686. submitFrame(pose?: VRPose): void;
  75687. }
  75688. declare var VRDisplay: {
  75689. prototype: VRDisplay;
  75690. new(): VRDisplay;
  75691. };
  75692. interface VRLayer {
  75693. leftBounds?: number[] | Float32Array | null;
  75694. rightBounds?: number[] | Float32Array | null;
  75695. source?: HTMLCanvasElement | null;
  75696. }
  75697. interface VRDisplayCapabilities {
  75698. readonly canPresent: boolean;
  75699. readonly hasExternalDisplay: boolean;
  75700. readonly hasOrientation: boolean;
  75701. readonly hasPosition: boolean;
  75702. readonly maxLayers: number;
  75703. }
  75704. interface VREyeParameters {
  75705. /** @deprecated */
  75706. readonly fieldOfView: VRFieldOfView;
  75707. readonly offset: Float32Array;
  75708. readonly renderHeight: number;
  75709. readonly renderWidth: number;
  75710. }
  75711. interface VRFieldOfView {
  75712. readonly downDegrees: number;
  75713. readonly leftDegrees: number;
  75714. readonly rightDegrees: number;
  75715. readonly upDegrees: number;
  75716. }
  75717. interface VRFrameData {
  75718. readonly leftProjectionMatrix: Float32Array;
  75719. readonly leftViewMatrix: Float32Array;
  75720. readonly pose: VRPose;
  75721. readonly rightProjectionMatrix: Float32Array;
  75722. readonly rightViewMatrix: Float32Array;
  75723. readonly timestamp: number;
  75724. }
  75725. interface VRPose {
  75726. readonly angularAcceleration: Float32Array | null;
  75727. readonly angularVelocity: Float32Array | null;
  75728. readonly linearAcceleration: Float32Array | null;
  75729. readonly linearVelocity: Float32Array | null;
  75730. readonly orientation: Float32Array | null;
  75731. readonly position: Float32Array | null;
  75732. readonly timestamp: number;
  75733. }
  75734. interface VRStageParameters {
  75735. sittingToStandingTransform?: Float32Array;
  75736. sizeX?: number;
  75737. sizeY?: number;
  75738. }
  75739. interface Navigator {
  75740. getVRDisplays(): Promise<VRDisplay[]>;
  75741. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75742. }
  75743. interface Window {
  75744. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75745. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75746. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75747. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75748. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75749. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75750. }
  75751. interface Gamepad {
  75752. readonly displayId: number;
  75753. }
  75754. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75755. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75756. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75757. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75758. type XRHandedness = "none" | "left" | "right";
  75759. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75760. type XREye = "none" | "left" | "right";
  75761. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75762. interface XRSpace extends EventTarget {}
  75763. interface XRRenderState {
  75764. depthNear?: number;
  75765. depthFar?: number;
  75766. inlineVerticalFieldOfView?: number;
  75767. baseLayer?: XRWebGLLayer;
  75768. }
  75769. interface XRInputSource {
  75770. handedness: XRHandedness;
  75771. targetRayMode: XRTargetRayMode;
  75772. targetRaySpace: XRSpace;
  75773. gripSpace: XRSpace | undefined;
  75774. gamepad: Gamepad | undefined;
  75775. profiles: Array<string>;
  75776. hand: XRHand | undefined;
  75777. }
  75778. interface XRSessionInit {
  75779. optionalFeatures?: string[];
  75780. requiredFeatures?: string[];
  75781. }
  75782. interface XRSession {
  75783. addEventListener: Function;
  75784. removeEventListener: Function;
  75785. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75786. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75787. requestAnimationFrame: Function;
  75788. end(): Promise<void>;
  75789. renderState: XRRenderState;
  75790. inputSources: Array<XRInputSource>;
  75791. // hit test
  75792. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75793. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75794. // legacy AR hit test
  75795. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75796. // legacy plane detection
  75797. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  75798. }
  75799. interface XRReferenceSpace extends XRSpace {
  75800. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75801. onreset: any;
  75802. }
  75803. type XRPlaneSet = Set<XRPlane>;
  75804. type XRAnchorSet = Set<XRAnchor>;
  75805. interface XRFrame {
  75806. session: XRSession;
  75807. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75808. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75809. // AR
  75810. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  75811. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75812. // Anchors
  75813. trackedAnchors?: XRAnchorSet;
  75814. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75815. // Planes
  75816. worldInformation: {
  75817. detectedPlanes?: XRPlaneSet;
  75818. };
  75819. // Hand tracking
  75820. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  75821. }
  75822. interface XRViewerPose extends XRPose {
  75823. views: Array<XRView>;
  75824. }
  75825. interface XRPose {
  75826. transform: XRRigidTransform;
  75827. emulatedPosition: boolean;
  75828. }
  75829. interface XRWebGLLayerOptions {
  75830. antialias?: boolean;
  75831. depth?: boolean;
  75832. stencil?: boolean;
  75833. alpha?: boolean;
  75834. multiview?: boolean;
  75835. framebufferScaleFactor?: number;
  75836. }
  75837. declare var XRWebGLLayer: {
  75838. prototype: XRWebGLLayer;
  75839. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75840. };
  75841. interface XRWebGLLayer {
  75842. framebuffer: WebGLFramebuffer;
  75843. framebufferWidth: number;
  75844. framebufferHeight: number;
  75845. getViewport: Function;
  75846. }
  75847. declare class XRRigidTransform {
  75848. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75849. position: DOMPointReadOnly;
  75850. orientation: DOMPointReadOnly;
  75851. matrix: Float32Array;
  75852. inverse: XRRigidTransform;
  75853. }
  75854. interface XRView {
  75855. eye: XREye;
  75856. projectionMatrix: Float32Array;
  75857. transform: XRRigidTransform;
  75858. }
  75859. interface XRInputSourceChangeEvent {
  75860. session: XRSession;
  75861. removed: Array<XRInputSource>;
  75862. added: Array<XRInputSource>;
  75863. }
  75864. interface XRInputSourceEvent extends Event {
  75865. readonly frame: XRFrame;
  75866. readonly inputSource: XRInputSource;
  75867. }
  75868. // Experimental(er) features
  75869. declare class XRRay {
  75870. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75871. origin: DOMPointReadOnly;
  75872. direction: DOMPointReadOnly;
  75873. matrix: Float32Array;
  75874. }
  75875. declare enum XRHitTestTrackableType {
  75876. "point",
  75877. "plane",
  75878. "mesh",
  75879. }
  75880. interface XRHitResult {
  75881. hitMatrix: Float32Array;
  75882. }
  75883. interface XRTransientInputHitTestResult {
  75884. readonly inputSource: XRInputSource;
  75885. readonly results: Array<XRHitTestResult>;
  75886. }
  75887. interface XRHitTestResult {
  75888. getPose(baseSpace: XRSpace): XRPose | undefined;
  75889. // When anchor system is enabled
  75890. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75891. }
  75892. interface XRHitTestSource {
  75893. cancel(): void;
  75894. }
  75895. interface XRTransientInputHitTestSource {
  75896. cancel(): void;
  75897. }
  75898. interface XRHitTestOptionsInit {
  75899. space: XRSpace;
  75900. entityTypes?: Array<XRHitTestTrackableType>;
  75901. offsetRay?: XRRay;
  75902. }
  75903. interface XRTransientInputHitTestOptionsInit {
  75904. profile: string;
  75905. entityTypes?: Array<XRHitTestTrackableType>;
  75906. offsetRay?: XRRay;
  75907. }
  75908. interface XRAnchor {
  75909. anchorSpace: XRSpace;
  75910. delete(): void;
  75911. }
  75912. interface XRPlane {
  75913. orientation: "Horizontal" | "Vertical";
  75914. planeSpace: XRSpace;
  75915. polygon: Array<DOMPointReadOnly>;
  75916. lastChangedTime: number;
  75917. }
  75918. interface XRJointSpace extends XRSpace {}
  75919. interface XRJointPose extends XRPose {
  75920. radius: number | undefined;
  75921. }
  75922. declare class XRHand extends Array<XRJointSpace> {
  75923. readonly length: number;
  75924. static readonly WRIST = 0;
  75925. static readonly THUMB_METACARPAL = 1;
  75926. static readonly THUMB_PHALANX_PROXIMAL = 2;
  75927. static readonly THUMB_PHALANX_DISTAL = 3;
  75928. static readonly THUMB_PHALANX_TIP = 4;
  75929. static readonly INDEX_METACARPAL = 5;
  75930. static readonly INDEX_PHALANX_PROXIMAL = 6;
  75931. static readonly INDEX_PHALANX_INTERMEDIATE = 7;
  75932. static readonly INDEX_PHALANX_DISTAL = 8;
  75933. static readonly INDEX_PHALANX_TIP = 9;
  75934. static readonly MIDDLE_METACARPAL = 10;
  75935. static readonly MIDDLE_PHALANX_PROXIMAL = 11;
  75936. static readonly MIDDLE_PHALANX_INTERMEDIATE = 12;
  75937. static readonly MIDDLE_PHALANX_DISTAL = 13;
  75938. static readonly MIDDLE_PHALANX_TIP = 14;
  75939. static readonly RING_METACARPAL = 15;
  75940. static readonly RING_PHALANX_PROXIMAL = 16;
  75941. static readonly RING_PHALANX_INTERMEDIATE = 17;
  75942. static readonly RING_PHALANX_DISTAL = 18;
  75943. static readonly RING_PHALANX_TIP = 19;
  75944. static readonly LITTLE_METACARPAL = 20;
  75945. static readonly LITTLE_PHALANX_PROXIMAL = 21;
  75946. static readonly LITTLE_PHALANX_INTERMEDIATE = 22;
  75947. static readonly LITTLE_PHALANX_DISTAL = 23;
  75948. static readonly LITTLE_PHALANX_TIP = 24;
  75949. }
  75950. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  75951. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  75952. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  75953. interface XRSession {
  75954. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  75955. }
  75956. interface XRFrame {
  75957. featurePointCloud? : Array<number>;
  75958. }
  75959. /**
  75960. * @ignore
  75961. */
  75962. declare module BABYLON.GLTF2.Exporter {
  75963. }
  75964. /**
  75965. * @ignore
  75966. */
  75967. declare module BABYLON.GLTF1 {
  75968. }
  75969. declare module BABYLON.GUI {
  75970. /**
  75971. * Class used to specific a value and its associated unit
  75972. */
  75973. export class ValueAndUnit {
  75974. /** defines the unit to store */
  75975. unit: number;
  75976. /** defines a boolean indicating if the value can be negative */
  75977. negativeValueAllowed: boolean;
  75978. private _value;
  75979. private _originalUnit;
  75980. /**
  75981. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75982. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75983. */
  75984. ignoreAdaptiveScaling: boolean;
  75985. /**
  75986. * Creates a new ValueAndUnit
  75987. * @param value defines the value to store
  75988. * @param unit defines the unit to store
  75989. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75990. */
  75991. constructor(value: number,
  75992. /** defines the unit to store */
  75993. unit?: number,
  75994. /** defines a boolean indicating if the value can be negative */
  75995. negativeValueAllowed?: boolean);
  75996. /** Gets a boolean indicating if the value is a percentage */
  75997. get isPercentage(): boolean;
  75998. /** Gets a boolean indicating if the value is store as pixel */
  75999. get isPixel(): boolean;
  76000. /** Gets direct internal value */
  76001. get internalValue(): number;
  76002. /**
  76003. * Gets value as pixel
  76004. * @param host defines the root host
  76005. * @param refValue defines the reference value for percentages
  76006. * @returns the value as pixel
  76007. */
  76008. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76009. /**
  76010. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76011. * @param value defines the value to store
  76012. * @param unit defines the unit to store
  76013. * @returns the current ValueAndUnit
  76014. */
  76015. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76016. /**
  76017. * Gets the value accordingly to its unit
  76018. * @param host defines the root host
  76019. * @returns the value
  76020. */
  76021. getValue(host: AdvancedDynamicTexture): number;
  76022. /**
  76023. * Gets a string representation of the value
  76024. * @param host defines the root host
  76025. * @param decimals defines an optional number of decimals to display
  76026. * @returns a string
  76027. */
  76028. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76029. /**
  76030. * Store a value parsed from a string
  76031. * @param source defines the source string
  76032. * @returns true if the value was successfully parsed
  76033. */
  76034. fromString(source: string | number): boolean;
  76035. private static _Regex;
  76036. private static _UNITMODE_PERCENTAGE;
  76037. private static _UNITMODE_PIXEL;
  76038. /** UNITMODE_PERCENTAGE */
  76039. static get UNITMODE_PERCENTAGE(): number;
  76040. /** UNITMODE_PIXEL */
  76041. static get UNITMODE_PIXEL(): number;
  76042. }
  76043. }
  76044. declare module BABYLON.GUI {
  76045. /**
  76046. * Define a style used by control to automatically setup properties based on a template.
  76047. * Only support font related properties so far
  76048. */
  76049. export class Style implements BABYLON.IDisposable {
  76050. private _fontFamily;
  76051. private _fontStyle;
  76052. private _fontWeight;
  76053. /** @hidden */
  76054. _host: AdvancedDynamicTexture;
  76055. /** @hidden */
  76056. _fontSize: ValueAndUnit;
  76057. /**
  76058. * BABYLON.Observable raised when the style values are changed
  76059. */
  76060. onChangedObservable: BABYLON.Observable<Style>;
  76061. /**
  76062. * Creates a new style object
  76063. * @param host defines the AdvancedDynamicTexture which hosts this style
  76064. */
  76065. constructor(host: AdvancedDynamicTexture);
  76066. /**
  76067. * Gets or sets the font size
  76068. */
  76069. get fontSize(): string | number;
  76070. set fontSize(value: string | number);
  76071. /**
  76072. * Gets or sets the font family
  76073. */
  76074. get fontFamily(): string;
  76075. set fontFamily(value: string);
  76076. /**
  76077. * Gets or sets the font style
  76078. */
  76079. get fontStyle(): string;
  76080. set fontStyle(value: string);
  76081. /** Gets or sets font weight */
  76082. get fontWeight(): string;
  76083. set fontWeight(value: string);
  76084. /** Dispose all associated resources */
  76085. dispose(): void;
  76086. }
  76087. }
  76088. declare module BABYLON.GUI {
  76089. /**
  76090. * Class used to transport BABYLON.Vector2 information for pointer events
  76091. */
  76092. export class Vector2WithInfo extends BABYLON.Vector2 {
  76093. /** defines the current mouse button index */
  76094. buttonIndex: number;
  76095. /**
  76096. * Creates a new Vector2WithInfo
  76097. * @param source defines the vector2 data to transport
  76098. * @param buttonIndex defines the current mouse button index
  76099. */
  76100. constructor(source: BABYLON.Vector2,
  76101. /** defines the current mouse button index */
  76102. buttonIndex?: number);
  76103. }
  76104. /** Class used to provide 2D matrix features */
  76105. export class Matrix2D {
  76106. /** Gets the internal array of 6 floats used to store matrix data */
  76107. m: Float32Array;
  76108. /**
  76109. * Creates a new matrix
  76110. * @param m00 defines value for (0, 0)
  76111. * @param m01 defines value for (0, 1)
  76112. * @param m10 defines value for (1, 0)
  76113. * @param m11 defines value for (1, 1)
  76114. * @param m20 defines value for (2, 0)
  76115. * @param m21 defines value for (2, 1)
  76116. */
  76117. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76118. /**
  76119. * Fills the matrix from direct values
  76120. * @param m00 defines value for (0, 0)
  76121. * @param m01 defines value for (0, 1)
  76122. * @param m10 defines value for (1, 0)
  76123. * @param m11 defines value for (1, 1)
  76124. * @param m20 defines value for (2, 0)
  76125. * @param m21 defines value for (2, 1)
  76126. * @returns the current modified matrix
  76127. */
  76128. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76129. /**
  76130. * Gets matrix determinant
  76131. * @returns the determinant
  76132. */
  76133. determinant(): number;
  76134. /**
  76135. * Inverses the matrix and stores it in a target matrix
  76136. * @param result defines the target matrix
  76137. * @returns the current matrix
  76138. */
  76139. invertToRef(result: Matrix2D): Matrix2D;
  76140. /**
  76141. * Multiplies the current matrix with another one
  76142. * @param other defines the second operand
  76143. * @param result defines the target matrix
  76144. * @returns the current matrix
  76145. */
  76146. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76147. /**
  76148. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76149. * @param x defines the x coordinate to transform
  76150. * @param y defines the x coordinate to transform
  76151. * @param result defines the target vector2
  76152. * @returns the current matrix
  76153. */
  76154. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76155. /**
  76156. * Creates an identity matrix
  76157. * @returns a new matrix
  76158. */
  76159. static Identity(): Matrix2D;
  76160. /**
  76161. * Creates a translation matrix and stores it in a target matrix
  76162. * @param x defines the x coordinate of the translation
  76163. * @param y defines the y coordinate of the translation
  76164. * @param result defines the target matrix
  76165. */
  76166. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76167. /**
  76168. * Creates a scaling matrix and stores it in a target matrix
  76169. * @param x defines the x coordinate of the scaling
  76170. * @param y defines the y coordinate of the scaling
  76171. * @param result defines the target matrix
  76172. */
  76173. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76174. /**
  76175. * Creates a rotation matrix and stores it in a target matrix
  76176. * @param angle defines the rotation angle
  76177. * @param result defines the target matrix
  76178. */
  76179. static RotationToRef(angle: number, result: Matrix2D): void;
  76180. private static _TempPreTranslationMatrix;
  76181. private static _TempPostTranslationMatrix;
  76182. private static _TempRotationMatrix;
  76183. private static _TempScalingMatrix;
  76184. private static _TempCompose0;
  76185. private static _TempCompose1;
  76186. private static _TempCompose2;
  76187. /**
  76188. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76189. * @param tx defines the x coordinate of the translation
  76190. * @param ty defines the y coordinate of the translation
  76191. * @param angle defines the rotation angle
  76192. * @param scaleX defines the x coordinate of the scaling
  76193. * @param scaleY defines the y coordinate of the scaling
  76194. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76195. * @param result defines the target matrix
  76196. */
  76197. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76198. }
  76199. }
  76200. declare module BABYLON.GUI {
  76201. /**
  76202. * Class used to store 2D control sizes
  76203. */
  76204. export class Measure {
  76205. /** defines left coordinate */
  76206. left: number;
  76207. /** defines top coordinate */
  76208. top: number;
  76209. /** defines width dimension */
  76210. width: number;
  76211. /** defines height dimension */
  76212. height: number;
  76213. /**
  76214. * Creates a new measure
  76215. * @param left defines left coordinate
  76216. * @param top defines top coordinate
  76217. * @param width defines width dimension
  76218. * @param height defines height dimension
  76219. */
  76220. constructor(
  76221. /** defines left coordinate */
  76222. left: number,
  76223. /** defines top coordinate */
  76224. top: number,
  76225. /** defines width dimension */
  76226. width: number,
  76227. /** defines height dimension */
  76228. height: number);
  76229. /**
  76230. * Copy from another measure
  76231. * @param other defines the other measure to copy from
  76232. */
  76233. copyFrom(other: Measure): void;
  76234. /**
  76235. * Copy from a group of 4 floats
  76236. * @param left defines left coordinate
  76237. * @param top defines top coordinate
  76238. * @param width defines width dimension
  76239. * @param height defines height dimension
  76240. */
  76241. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76242. /**
  76243. * Computes the axis aligned bounding box measure for two given measures
  76244. * @param a Input measure
  76245. * @param b Input measure
  76246. * @param result the resulting bounding measure
  76247. */
  76248. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76249. /**
  76250. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76251. * @param transform the matrix to transform the measure before computing the AABB
  76252. * @param addX number to add to left
  76253. * @param addY number to add to top
  76254. * @param addWidth number to add to width
  76255. * @param addHeight number to add to height
  76256. * @param result the resulting AABB
  76257. */
  76258. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76259. /**
  76260. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76261. * @param transform the matrix to transform the measure before computing the AABB
  76262. * @param result the resulting AABB
  76263. */
  76264. transformToRef(transform: Matrix2D, result: Measure): void;
  76265. /**
  76266. * Check equality between this measure and another one
  76267. * @param other defines the other measures
  76268. * @returns true if both measures are equals
  76269. */
  76270. isEqualsTo(other: Measure): boolean;
  76271. /**
  76272. * Creates an empty measure
  76273. * @returns a new measure
  76274. */
  76275. static Empty(): Measure;
  76276. }
  76277. }
  76278. declare module BABYLON.GUI {
  76279. /**
  76280. * Interface used to define a control that can receive focus
  76281. */
  76282. export interface IFocusableControl {
  76283. /**
  76284. * Function called when the control receives the focus
  76285. */
  76286. onFocus(): void;
  76287. /**
  76288. * Function called when the control loses the focus
  76289. */
  76290. onBlur(): void;
  76291. /**
  76292. * Function called to let the control handle keyboard events
  76293. * @param evt defines the current keyboard event
  76294. */
  76295. processKeyboard(evt: KeyboardEvent): void;
  76296. /**
  76297. * Function called to get the list of controls that should not steal the focus from this control
  76298. * @returns an array of controls
  76299. */
  76300. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76301. }
  76302. /**
  76303. * Class used to create texture to support 2D GUI elements
  76304. * @see https://doc.babylonjs.com/how_to/gui
  76305. */
  76306. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76307. private _isDirty;
  76308. private _renderObserver;
  76309. private _resizeObserver;
  76310. private _preKeyboardObserver;
  76311. private _pointerMoveObserver;
  76312. private _pointerObserver;
  76313. private _canvasPointerOutObserver;
  76314. private _canvasBlurObserver;
  76315. private _background;
  76316. /** @hidden */
  76317. _rootContainer: Container;
  76318. /** @hidden */
  76319. _lastPickedControl: Control;
  76320. /** @hidden */
  76321. _lastControlOver: {
  76322. [pointerId: number]: Control;
  76323. };
  76324. /** @hidden */
  76325. _lastControlDown: {
  76326. [pointerId: number]: Control;
  76327. };
  76328. /** @hidden */
  76329. _capturingControl: {
  76330. [pointerId: number]: Control;
  76331. };
  76332. /** @hidden */
  76333. _shouldBlockPointer: boolean;
  76334. /** @hidden */
  76335. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76336. /** @hidden */
  76337. _linkedControls: Control[];
  76338. private _isFullscreen;
  76339. private _fullscreenViewport;
  76340. private _idealWidth;
  76341. private _idealHeight;
  76342. private _useSmallestIdeal;
  76343. private _renderAtIdealSize;
  76344. private _focusedControl;
  76345. private _blockNextFocusCheck;
  76346. private _renderScale;
  76347. private _rootElement;
  76348. private _cursorChanged;
  76349. private _defaultMousePointerId;
  76350. /** @hidden */
  76351. _numLayoutCalls: number;
  76352. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76353. get numLayoutCalls(): number;
  76354. /** @hidden */
  76355. _numRenderCalls: number;
  76356. /** Gets the number of render calls made the last time the ADT has been rendered */
  76357. get numRenderCalls(): number;
  76358. /**
  76359. * Define type to string to ensure compatibility across browsers
  76360. * Safari doesn't support DataTransfer constructor
  76361. */
  76362. private _clipboardData;
  76363. /**
  76364. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76365. */
  76366. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76367. /**
  76368. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76369. */
  76370. onControlPickedObservable: BABYLON.Observable<Control>;
  76371. /**
  76372. * BABYLON.Observable event triggered before layout is evaluated
  76373. */
  76374. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76375. /**
  76376. * BABYLON.Observable event triggered after the layout was evaluated
  76377. */
  76378. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76379. /**
  76380. * BABYLON.Observable event triggered before the texture is rendered
  76381. */
  76382. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76383. /**
  76384. * BABYLON.Observable event triggered after the texture was rendered
  76385. */
  76386. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76387. /**
  76388. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76389. */
  76390. premulAlpha: boolean;
  76391. /**
  76392. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76393. * Useful when you want more antialiasing
  76394. */
  76395. get renderScale(): number;
  76396. set renderScale(value: number);
  76397. /** Gets or sets the background color */
  76398. get background(): string;
  76399. set background(value: string);
  76400. /**
  76401. * Gets or sets the ideal width used to design controls.
  76402. * The GUI will then rescale everything accordingly
  76403. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76404. */
  76405. get idealWidth(): number;
  76406. set idealWidth(value: number);
  76407. /**
  76408. * Gets or sets the ideal height used to design controls.
  76409. * The GUI will then rescale everything accordingly
  76410. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76411. */
  76412. get idealHeight(): number;
  76413. set idealHeight(value: number);
  76414. /**
  76415. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76416. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76417. */
  76418. get useSmallestIdeal(): boolean;
  76419. set useSmallestIdeal(value: boolean);
  76420. /**
  76421. * Gets or sets a boolean indicating if adaptive scaling must be used
  76422. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76423. */
  76424. get renderAtIdealSize(): boolean;
  76425. set renderAtIdealSize(value: boolean);
  76426. /**
  76427. * Gets the ratio used when in "ideal mode"
  76428. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76429. * */
  76430. get idealRatio(): number;
  76431. /**
  76432. * Gets the underlying layer used to render the texture when in fullscreen mode
  76433. */
  76434. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76435. /**
  76436. * Gets the root container control
  76437. */
  76438. get rootContainer(): Container;
  76439. /**
  76440. * Returns an array containing the root container.
  76441. * This is mostly used to let the Inspector introspects the ADT
  76442. * @returns an array containing the rootContainer
  76443. */
  76444. getChildren(): Array<Container>;
  76445. /**
  76446. * Will return all controls that are inside this texture
  76447. * @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
  76448. * @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
  76449. * @return all child controls
  76450. */
  76451. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76452. /**
  76453. * Gets or sets the current focused control
  76454. */
  76455. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76456. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76457. /**
  76458. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76459. */
  76460. get isForeground(): boolean;
  76461. set isForeground(value: boolean);
  76462. /**
  76463. * Gets or set information about clipboardData
  76464. */
  76465. get clipboardData(): string;
  76466. set clipboardData(value: string);
  76467. /**
  76468. * Creates a new AdvancedDynamicTexture
  76469. * @param name defines the name of the texture
  76470. * @param width defines the width of the texture
  76471. * @param height defines the height of the texture
  76472. * @param scene defines the hosting scene
  76473. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76474. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76475. */
  76476. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76477. /**
  76478. * Get the current class name of the texture useful for serialization or dynamic coding.
  76479. * @returns "AdvancedDynamicTexture"
  76480. */
  76481. getClassName(): string;
  76482. /**
  76483. * Function used to execute a function on all controls
  76484. * @param func defines the function to execute
  76485. * @param container defines the container where controls belong. If null the root container will be used
  76486. */
  76487. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76488. private _useInvalidateRectOptimization;
  76489. /**
  76490. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76491. */
  76492. get useInvalidateRectOptimization(): boolean;
  76493. set useInvalidateRectOptimization(value: boolean);
  76494. private _invalidatedRectangle;
  76495. /**
  76496. * Invalidates a rectangle area on the gui texture
  76497. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76498. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76499. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76500. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76501. */
  76502. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76503. /**
  76504. * Marks the texture as dirty forcing a complete update
  76505. */
  76506. markAsDirty(): void;
  76507. /**
  76508. * Helper function used to create a new style
  76509. * @returns a new style
  76510. * @see https://doc.babylonjs.com/how_to/gui#styles
  76511. */
  76512. createStyle(): Style;
  76513. /**
  76514. * Adds a new control to the root container
  76515. * @param control defines the control to add
  76516. * @returns the current texture
  76517. */
  76518. addControl(control: Control): AdvancedDynamicTexture;
  76519. /**
  76520. * Removes a control from the root container
  76521. * @param control defines the control to remove
  76522. * @returns the current texture
  76523. */
  76524. removeControl(control: Control): AdvancedDynamicTexture;
  76525. /**
  76526. * Release all resources
  76527. */
  76528. dispose(): void;
  76529. private _onResize;
  76530. /** @hidden */
  76531. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76532. /**
  76533. * Get screen coordinates for a vector3
  76534. * @param position defines the position to project
  76535. * @param worldMatrix defines the world matrix to use
  76536. * @returns the projected position
  76537. */
  76538. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76539. private _checkUpdate;
  76540. private _clearMeasure;
  76541. private _render;
  76542. /** @hidden */
  76543. _changeCursor(cursor: string): void;
  76544. /** @hidden */
  76545. _registerLastControlDown(control: Control, pointerId: number): void;
  76546. private _doPicking;
  76547. /** @hidden */
  76548. _cleanControlAfterRemovalFromList(list: {
  76549. [pointerId: number]: Control;
  76550. }, control: Control): void;
  76551. /** @hidden */
  76552. _cleanControlAfterRemoval(control: Control): void;
  76553. /** Attach to all scene events required to support pointer events */
  76554. attach(): void;
  76555. /** @hidden */
  76556. private onClipboardCopy;
  76557. /** @hidden */
  76558. private onClipboardCut;
  76559. /** @hidden */
  76560. private onClipboardPaste;
  76561. /**
  76562. * Register the clipboard Events onto the canvas
  76563. */
  76564. registerClipboardEvents(): void;
  76565. /**
  76566. * Unregister the clipboard Events from the canvas
  76567. */
  76568. unRegisterClipboardEvents(): void;
  76569. /**
  76570. * Connect the texture to a hosting mesh to enable interactions
  76571. * @param mesh defines the mesh to attach to
  76572. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76573. */
  76574. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76575. /**
  76576. * Move the focus to a specific control
  76577. * @param control defines the control which will receive the focus
  76578. */
  76579. moveFocusToControl(control: IFocusableControl): void;
  76580. private _manageFocus;
  76581. private _attachToOnPointerOut;
  76582. private _attachToOnBlur;
  76583. /**
  76584. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76585. * @param mesh defines the mesh which will receive the texture
  76586. * @param width defines the texture width (1024 by default)
  76587. * @param height defines the texture height (1024 by default)
  76588. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76589. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76590. * @returns a new AdvancedDynamicTexture
  76591. */
  76592. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76593. /**
  76594. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76595. * In this mode the texture will rely on a layer for its rendering.
  76596. * This allows it to be treated like any other layer.
  76597. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76598. * LayerMask is set through advancedTexture.layer.layerMask
  76599. * @param name defines name for the texture
  76600. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76601. * @param scene defines the hsoting scene
  76602. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76603. * @returns a new AdvancedDynamicTexture
  76604. */
  76605. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76606. }
  76607. }
  76608. declare module BABYLON.GUI {
  76609. /**
  76610. * Root class used for all 2D controls
  76611. * @see https://doc.babylonjs.com/how_to/gui#controls
  76612. */
  76613. export class Control {
  76614. /** defines the name of the control */
  76615. name?: string | undefined;
  76616. /**
  76617. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76618. */
  76619. static AllowAlphaInheritance: boolean;
  76620. private _alpha;
  76621. private _alphaSet;
  76622. private _zIndex;
  76623. /** @hidden */
  76624. _host: AdvancedDynamicTexture;
  76625. /** Gets or sets the control parent */
  76626. parent: BABYLON.Nullable<Container>;
  76627. /** @hidden */
  76628. _currentMeasure: Measure;
  76629. private _fontFamily;
  76630. private _fontStyle;
  76631. private _fontWeight;
  76632. private _fontSize;
  76633. private _font;
  76634. /** @hidden */
  76635. _width: ValueAndUnit;
  76636. /** @hidden */
  76637. _height: ValueAndUnit;
  76638. /** @hidden */
  76639. protected _fontOffset: {
  76640. ascent: number;
  76641. height: number;
  76642. descent: number;
  76643. };
  76644. private _color;
  76645. private _style;
  76646. private _styleObserver;
  76647. /** @hidden */
  76648. protected _horizontalAlignment: number;
  76649. /** @hidden */
  76650. protected _verticalAlignment: number;
  76651. /** @hidden */
  76652. protected _isDirty: boolean;
  76653. /** @hidden */
  76654. protected _wasDirty: boolean;
  76655. /** @hidden */
  76656. _tempParentMeasure: Measure;
  76657. /** @hidden */
  76658. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76659. /** @hidden */
  76660. protected _cachedParentMeasure: Measure;
  76661. private _paddingLeft;
  76662. private _paddingRight;
  76663. private _paddingTop;
  76664. private _paddingBottom;
  76665. /** @hidden */
  76666. _left: ValueAndUnit;
  76667. /** @hidden */
  76668. _top: ValueAndUnit;
  76669. private _scaleX;
  76670. private _scaleY;
  76671. private _rotation;
  76672. private _transformCenterX;
  76673. private _transformCenterY;
  76674. /** @hidden */
  76675. _transformMatrix: Matrix2D;
  76676. /** @hidden */
  76677. protected _invertTransformMatrix: Matrix2D;
  76678. /** @hidden */
  76679. protected _transformedPosition: BABYLON.Vector2;
  76680. private _isMatrixDirty;
  76681. private _cachedOffsetX;
  76682. private _cachedOffsetY;
  76683. private _isVisible;
  76684. private _isHighlighted;
  76685. /** @hidden */
  76686. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76687. private _fontSet;
  76688. private _dummyVector2;
  76689. private _downCount;
  76690. private _enterCount;
  76691. private _doNotRender;
  76692. private _downPointerIds;
  76693. protected _isEnabled: boolean;
  76694. protected _disabledColor: string;
  76695. protected _disabledColorItem: string;
  76696. /** @hidden */
  76697. protected _rebuildLayout: boolean;
  76698. /** @hidden */
  76699. _customData: any;
  76700. /** @hidden */
  76701. _isClipped: boolean;
  76702. /** @hidden */
  76703. _automaticSize: boolean;
  76704. /** @hidden */
  76705. _tag: any;
  76706. /**
  76707. * 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
  76708. */
  76709. uniqueId: number;
  76710. /**
  76711. * Gets or sets an object used to store user defined information for the node
  76712. */
  76713. metadata: any;
  76714. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76715. isHitTestVisible: boolean;
  76716. /** Gets or sets a boolean indicating if the control can block pointer events */
  76717. isPointerBlocker: boolean;
  76718. /** Gets or sets a boolean indicating if the control can be focusable */
  76719. isFocusInvisible: boolean;
  76720. /**
  76721. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76722. * 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
  76723. */
  76724. clipChildren: boolean;
  76725. /**
  76726. * Gets or sets a boolean indicating that control content must be clipped
  76727. * 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
  76728. */
  76729. clipContent: boolean;
  76730. /**
  76731. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76732. */
  76733. useBitmapCache: boolean;
  76734. private _cacheData;
  76735. private _shadowOffsetX;
  76736. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76737. get shadowOffsetX(): number;
  76738. set shadowOffsetX(value: number);
  76739. private _shadowOffsetY;
  76740. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76741. get shadowOffsetY(): number;
  76742. set shadowOffsetY(value: number);
  76743. private _shadowBlur;
  76744. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76745. get shadowBlur(): number;
  76746. set shadowBlur(value: number);
  76747. private _shadowColor;
  76748. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76749. get shadowColor(): string;
  76750. set shadowColor(value: string);
  76751. /** Gets or sets the cursor to use when the control is hovered */
  76752. hoverCursor: string;
  76753. /** @hidden */
  76754. protected _linkOffsetX: ValueAndUnit;
  76755. /** @hidden */
  76756. protected _linkOffsetY: ValueAndUnit;
  76757. /** Gets the control type name */
  76758. get typeName(): string;
  76759. /**
  76760. * Get the current class name of the control.
  76761. * @returns current class name
  76762. */
  76763. getClassName(): string;
  76764. /**
  76765. * An event triggered when pointer wheel is scrolled
  76766. */
  76767. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76768. /**
  76769. * An event triggered when the pointer move over the control.
  76770. */
  76771. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76772. /**
  76773. * An event triggered when the pointer move out of the control.
  76774. */
  76775. onPointerOutObservable: BABYLON.Observable<Control>;
  76776. /**
  76777. * An event triggered when the pointer taps the control
  76778. */
  76779. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76780. /**
  76781. * An event triggered when pointer up
  76782. */
  76783. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76784. /**
  76785. * An event triggered when a control is clicked on
  76786. */
  76787. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76788. /**
  76789. * An event triggered when pointer enters the control
  76790. */
  76791. onPointerEnterObservable: BABYLON.Observable<Control>;
  76792. /**
  76793. * An event triggered when the control is marked as dirty
  76794. */
  76795. onDirtyObservable: BABYLON.Observable<Control>;
  76796. /**
  76797. * An event triggered before drawing the control
  76798. */
  76799. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76800. /**
  76801. * An event triggered after the control was drawn
  76802. */
  76803. onAfterDrawObservable: BABYLON.Observable<Control>;
  76804. /**
  76805. * An event triggered when the control has been disposed
  76806. */
  76807. onDisposeObservable: BABYLON.Observable<Control>;
  76808. /**
  76809. * Get the hosting AdvancedDynamicTexture
  76810. */
  76811. get host(): AdvancedDynamicTexture;
  76812. /** Gets or set information about font offsets (used to render and align text) */
  76813. get fontOffset(): {
  76814. ascent: number;
  76815. height: number;
  76816. descent: number;
  76817. };
  76818. set fontOffset(offset: {
  76819. ascent: number;
  76820. height: number;
  76821. descent: number;
  76822. });
  76823. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76824. get alpha(): number;
  76825. set alpha(value: number);
  76826. /**
  76827. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76828. */
  76829. get isHighlighted(): boolean;
  76830. set isHighlighted(value: boolean);
  76831. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76832. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76833. */
  76834. get scaleX(): number;
  76835. set scaleX(value: number);
  76836. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76837. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76838. */
  76839. get scaleY(): number;
  76840. set scaleY(value: number);
  76841. /** Gets or sets the rotation angle (0 by default)
  76842. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76843. */
  76844. get rotation(): number;
  76845. set rotation(value: number);
  76846. /** Gets or sets the transformation center on Y axis (0 by default)
  76847. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76848. */
  76849. get transformCenterY(): number;
  76850. set transformCenterY(value: number);
  76851. /** Gets or sets the transformation center on X axis (0 by default)
  76852. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76853. */
  76854. get transformCenterX(): number;
  76855. set transformCenterX(value: number);
  76856. /**
  76857. * Gets or sets the horizontal alignment
  76858. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76859. */
  76860. get horizontalAlignment(): number;
  76861. set horizontalAlignment(value: number);
  76862. /**
  76863. * Gets or sets the vertical alignment
  76864. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76865. */
  76866. get verticalAlignment(): number;
  76867. set verticalAlignment(value: number);
  76868. /**
  76869. * Gets or sets a fixed ratio for this control.
  76870. * When different from 0, the ratio is used to compute the "second" dimension.
  76871. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76872. * second dimension is computed as first dimension * fixedRatio
  76873. */
  76874. fixedRatio: number;
  76875. private _fixedRatioMasterIsWidth;
  76876. /**
  76877. * Gets or sets control width
  76878. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76879. */
  76880. get width(): string | number;
  76881. set width(value: string | number);
  76882. /**
  76883. * Gets or sets the control width in pixel
  76884. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76885. */
  76886. get widthInPixels(): number;
  76887. set widthInPixels(value: number);
  76888. /**
  76889. * Gets or sets control height
  76890. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76891. */
  76892. get height(): string | number;
  76893. set height(value: string | number);
  76894. /**
  76895. * Gets or sets control height in pixel
  76896. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76897. */
  76898. get heightInPixels(): number;
  76899. set heightInPixels(value: number);
  76900. /** Gets or set font family */
  76901. get fontFamily(): string;
  76902. set fontFamily(value: string);
  76903. /** Gets or sets font style */
  76904. get fontStyle(): string;
  76905. set fontStyle(value: string);
  76906. /** Gets or sets font weight */
  76907. get fontWeight(): string;
  76908. set fontWeight(value: string);
  76909. /**
  76910. * Gets or sets style
  76911. * @see https://doc.babylonjs.com/how_to/gui#styles
  76912. */
  76913. get style(): BABYLON.Nullable<Style>;
  76914. set style(value: BABYLON.Nullable<Style>);
  76915. /** @hidden */
  76916. get _isFontSizeInPercentage(): boolean;
  76917. /** Gets or sets font size in pixels */
  76918. get fontSizeInPixels(): number;
  76919. set fontSizeInPixels(value: number);
  76920. /** Gets or sets font size */
  76921. get fontSize(): string | number;
  76922. set fontSize(value: string | number);
  76923. /** Gets or sets foreground color */
  76924. get color(): string;
  76925. set color(value: string);
  76926. /** Gets or sets z index which is used to reorder controls on the z axis */
  76927. get zIndex(): number;
  76928. set zIndex(value: number);
  76929. /** Gets or sets a boolean indicating if the control can be rendered */
  76930. get notRenderable(): boolean;
  76931. set notRenderable(value: boolean);
  76932. /** Gets or sets a boolean indicating if the control is visible */
  76933. get isVisible(): boolean;
  76934. set isVisible(value: boolean);
  76935. /** Gets a boolean indicating that the control needs to update its rendering */
  76936. get isDirty(): boolean;
  76937. /**
  76938. * Gets the current linked mesh (or null if none)
  76939. */
  76940. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76941. /**
  76942. * Gets or sets a value indicating the padding to use on the left of the control
  76943. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76944. */
  76945. get paddingLeft(): string | number;
  76946. set paddingLeft(value: string | number);
  76947. /**
  76948. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76949. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76950. */
  76951. get paddingLeftInPixels(): number;
  76952. set paddingLeftInPixels(value: number);
  76953. /**
  76954. * Gets or sets a value indicating the padding to use on the right of the control
  76955. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76956. */
  76957. get paddingRight(): string | number;
  76958. set paddingRight(value: string | number);
  76959. /**
  76960. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76961. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76962. */
  76963. get paddingRightInPixels(): number;
  76964. set paddingRightInPixels(value: number);
  76965. /**
  76966. * Gets or sets a value indicating the padding to use on the top of the control
  76967. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76968. */
  76969. get paddingTop(): string | number;
  76970. set paddingTop(value: string | number);
  76971. /**
  76972. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76973. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76974. */
  76975. get paddingTopInPixels(): number;
  76976. set paddingTopInPixels(value: number);
  76977. /**
  76978. * Gets or sets a value indicating the padding to use on the bottom of the control
  76979. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76980. */
  76981. get paddingBottom(): string | number;
  76982. set paddingBottom(value: string | number);
  76983. /**
  76984. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76985. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76986. */
  76987. get paddingBottomInPixels(): number;
  76988. set paddingBottomInPixels(value: number);
  76989. /**
  76990. * Gets or sets a value indicating the left coordinate of the control
  76991. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76992. */
  76993. get left(): string | number;
  76994. set left(value: string | number);
  76995. /**
  76996. * Gets or sets a value indicating the left coordinate in pixels of the control
  76997. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76998. */
  76999. get leftInPixels(): number;
  77000. set leftInPixels(value: number);
  77001. /**
  77002. * Gets or sets a value indicating the top coordinate of the control
  77003. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77004. */
  77005. get top(): string | number;
  77006. set top(value: string | number);
  77007. /**
  77008. * Gets or sets a value indicating the top coordinate in pixels of the control
  77009. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77010. */
  77011. get topInPixels(): number;
  77012. set topInPixels(value: number);
  77013. /**
  77014. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77015. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77016. */
  77017. get linkOffsetX(): string | number;
  77018. set linkOffsetX(value: string | number);
  77019. /**
  77020. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77021. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77022. */
  77023. get linkOffsetXInPixels(): number;
  77024. set linkOffsetXInPixels(value: number);
  77025. /**
  77026. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77027. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77028. */
  77029. get linkOffsetY(): string | number;
  77030. set linkOffsetY(value: string | number);
  77031. /**
  77032. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77033. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77034. */
  77035. get linkOffsetYInPixels(): number;
  77036. set linkOffsetYInPixels(value: number);
  77037. /** Gets the center coordinate on X axis */
  77038. get centerX(): number;
  77039. /** Gets the center coordinate on Y axis */
  77040. get centerY(): number;
  77041. /** Gets or sets if control is Enabled*/
  77042. get isEnabled(): boolean;
  77043. set isEnabled(value: boolean);
  77044. /** Gets or sets background color of control if it's disabled*/
  77045. get disabledColor(): string;
  77046. set disabledColor(value: string);
  77047. /** Gets or sets front color of control if it's disabled*/
  77048. get disabledColorItem(): string;
  77049. set disabledColorItem(value: string);
  77050. /**
  77051. * Creates a new control
  77052. * @param name defines the name of the control
  77053. */
  77054. constructor(
  77055. /** defines the name of the control */
  77056. name?: string | undefined);
  77057. /** @hidden */
  77058. protected _getTypeName(): string;
  77059. /**
  77060. * Gets the first ascendant in the hierarchy of the given type
  77061. * @param className defines the required type
  77062. * @returns the ascendant or null if not found
  77063. */
  77064. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77065. /** @hidden */
  77066. _resetFontCache(): void;
  77067. /**
  77068. * Determines if a container is an ascendant of the current control
  77069. * @param container defines the container to look for
  77070. * @returns true if the container is one of the ascendant of the control
  77071. */
  77072. isAscendant(container: Control): boolean;
  77073. /**
  77074. * Gets coordinates in local control space
  77075. * @param globalCoordinates defines the coordinates to transform
  77076. * @returns the new coordinates in local space
  77077. */
  77078. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77079. /**
  77080. * Gets coordinates in local control space
  77081. * @param globalCoordinates defines the coordinates to transform
  77082. * @param result defines the target vector2 where to store the result
  77083. * @returns the current control
  77084. */
  77085. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77086. /**
  77087. * Gets coordinates in parent local control space
  77088. * @param globalCoordinates defines the coordinates to transform
  77089. * @returns the new coordinates in parent local space
  77090. */
  77091. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77092. /**
  77093. * Move the current control to a vector3 position projected onto the screen.
  77094. * @param position defines the target position
  77095. * @param scene defines the hosting scene
  77096. */
  77097. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77098. /**
  77099. * Will store all controls that have this control as ascendant in a given array
  77100. * @param results defines the array where to store the descendants
  77101. * @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
  77102. * @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
  77103. */
  77104. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77105. /**
  77106. * Will return all controls that have this control as ascendant
  77107. * @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
  77108. * @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
  77109. * @return all child controls
  77110. */
  77111. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77112. /**
  77113. * Link current control with a target mesh
  77114. * @param mesh defines the mesh to link with
  77115. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77116. */
  77117. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77118. /** @hidden */
  77119. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77120. /** @hidden */
  77121. _offsetLeft(offset: number): void;
  77122. /** @hidden */
  77123. _offsetTop(offset: number): void;
  77124. /** @hidden */
  77125. _markMatrixAsDirty(): void;
  77126. /** @hidden */
  77127. _flagDescendantsAsMatrixDirty(): void;
  77128. /** @hidden */
  77129. _intersectsRect(rect: Measure): boolean;
  77130. /** @hidden */
  77131. protected invalidateRect(): void;
  77132. /** @hidden */
  77133. _markAsDirty(force?: boolean): void;
  77134. /** @hidden */
  77135. _markAllAsDirty(): void;
  77136. /** @hidden */
  77137. _link(host: AdvancedDynamicTexture): void;
  77138. /** @hidden */
  77139. protected _transform(context?: CanvasRenderingContext2D): void;
  77140. /** @hidden */
  77141. _renderHighlight(context: CanvasRenderingContext2D): void;
  77142. /** @hidden */
  77143. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77144. /** @hidden */
  77145. protected _applyStates(context: CanvasRenderingContext2D): void;
  77146. /** @hidden */
  77147. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77148. /** @hidden */
  77149. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77150. protected _evaluateClippingState(parentMeasure: Measure): void;
  77151. /** @hidden */
  77152. _measure(): void;
  77153. /** @hidden */
  77154. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77155. /** @hidden */
  77156. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77157. /** @hidden */
  77158. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77159. /** @hidden */
  77160. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77161. private static _ClipMeasure;
  77162. private _tmpMeasureA;
  77163. private _clip;
  77164. /** @hidden */
  77165. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77166. /** @hidden */
  77167. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77168. /**
  77169. * Tests if a given coordinates belong to the current control
  77170. * @param x defines x coordinate to test
  77171. * @param y defines y coordinate to test
  77172. * @returns true if the coordinates are inside the control
  77173. */
  77174. contains(x: number, y: number): boolean;
  77175. /** @hidden */
  77176. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77177. /** @hidden */
  77178. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77179. /** @hidden */
  77180. _onPointerEnter(target: Control): boolean;
  77181. /** @hidden */
  77182. _onPointerOut(target: Control, force?: boolean): void;
  77183. /** @hidden */
  77184. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77185. /** @hidden */
  77186. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77187. /** @hidden */
  77188. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77189. /** @hidden */
  77190. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77191. /** @hidden */
  77192. _onCanvasBlur(): void;
  77193. /** @hidden */
  77194. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77195. private _prepareFont;
  77196. /** Releases associated resources */
  77197. dispose(): void;
  77198. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77199. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77200. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77201. private static _VERTICAL_ALIGNMENT_TOP;
  77202. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77203. private static _VERTICAL_ALIGNMENT_CENTER;
  77204. /** HORIZONTAL_ALIGNMENT_LEFT */
  77205. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77206. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77207. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77208. /** HORIZONTAL_ALIGNMENT_CENTER */
  77209. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77210. /** VERTICAL_ALIGNMENT_TOP */
  77211. static get VERTICAL_ALIGNMENT_TOP(): number;
  77212. /** VERTICAL_ALIGNMENT_BOTTOM */
  77213. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77214. /** VERTICAL_ALIGNMENT_CENTER */
  77215. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77216. private static _FontHeightSizes;
  77217. /** @hidden */
  77218. static _GetFontOffset(font: string): {
  77219. ascent: number;
  77220. height: number;
  77221. descent: number;
  77222. };
  77223. /**
  77224. * Creates a stack panel that can be used to render headers
  77225. * @param control defines the control to associate with the header
  77226. * @param text defines the text of the header
  77227. * @param size defines the size of the header
  77228. * @param options defines options used to configure the header
  77229. * @returns a new StackPanel
  77230. * @ignore
  77231. * @hidden
  77232. */
  77233. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77234. isHorizontal: boolean;
  77235. controlFirst: boolean;
  77236. }) => any;
  77237. /** @hidden */
  77238. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77239. }
  77240. }
  77241. declare module BABYLON.GUI {
  77242. /**
  77243. * Root class for 2D containers
  77244. * @see https://doc.babylonjs.com/how_to/gui#containers
  77245. */
  77246. export class Container extends Control {
  77247. name?: string | undefined;
  77248. /** @hidden */
  77249. _children: Control[];
  77250. /** @hidden */
  77251. protected _measureForChildren: Measure;
  77252. /** @hidden */
  77253. protected _background: string;
  77254. /** @hidden */
  77255. protected _adaptWidthToChildren: boolean;
  77256. /** @hidden */
  77257. protected _adaptHeightToChildren: boolean;
  77258. /**
  77259. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77260. */
  77261. logLayoutCycleErrors: boolean;
  77262. /**
  77263. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77264. */
  77265. maxLayoutCycle: number;
  77266. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77267. get adaptHeightToChildren(): boolean;
  77268. set adaptHeightToChildren(value: boolean);
  77269. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77270. get adaptWidthToChildren(): boolean;
  77271. set adaptWidthToChildren(value: boolean);
  77272. /** Gets or sets background color */
  77273. get background(): string;
  77274. set background(value: string);
  77275. /** Gets the list of children */
  77276. get children(): Control[];
  77277. /**
  77278. * Creates a new Container
  77279. * @param name defines the name of the container
  77280. */
  77281. constructor(name?: string | undefined);
  77282. protected _getTypeName(): string;
  77283. _flagDescendantsAsMatrixDirty(): void;
  77284. /**
  77285. * Gets a child using its name
  77286. * @param name defines the child name to look for
  77287. * @returns the child control if found
  77288. */
  77289. getChildByName(name: string): BABYLON.Nullable<Control>;
  77290. /**
  77291. * Gets a child using its type and its name
  77292. * @param name defines the child name to look for
  77293. * @param type defines the child type to look for
  77294. * @returns the child control if found
  77295. */
  77296. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77297. /**
  77298. * Search for a specific control in children
  77299. * @param control defines the control to look for
  77300. * @returns true if the control is in child list
  77301. */
  77302. containsControl(control: Control): boolean;
  77303. /**
  77304. * Adds a new control to the current container
  77305. * @param control defines the control to add
  77306. * @returns the current container
  77307. */
  77308. addControl(control: BABYLON.Nullable<Control>): Container;
  77309. /**
  77310. * Removes all controls from the current container
  77311. * @returns the current container
  77312. */
  77313. clearControls(): Container;
  77314. /**
  77315. * Removes a control from the current container
  77316. * @param control defines the control to remove
  77317. * @returns the current container
  77318. */
  77319. removeControl(control: Control): Container;
  77320. /** @hidden */
  77321. _reOrderControl(control: Control): void;
  77322. /** @hidden */
  77323. _offsetLeft(offset: number): void;
  77324. /** @hidden */
  77325. _offsetTop(offset: number): void;
  77326. /** @hidden */
  77327. _markAllAsDirty(): void;
  77328. /** @hidden */
  77329. protected _localDraw(context: CanvasRenderingContext2D): void;
  77330. /** @hidden */
  77331. _link(host: AdvancedDynamicTexture): void;
  77332. /** @hidden */
  77333. protected _beforeLayout(): void;
  77334. /** @hidden */
  77335. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77336. /** @hidden */
  77337. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77338. protected _postMeasure(): void;
  77339. /** @hidden */
  77340. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77341. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77342. /** @hidden */
  77343. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77344. /** @hidden */
  77345. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77346. /** Releases associated resources */
  77347. dispose(): void;
  77348. }
  77349. }
  77350. declare module BABYLON.GUI {
  77351. /** Class used to create rectangle container */
  77352. export class Rectangle extends Container {
  77353. name?: string | undefined;
  77354. private _thickness;
  77355. private _cornerRadius;
  77356. /** Gets or sets border thickness */
  77357. get thickness(): number;
  77358. set thickness(value: number);
  77359. /** Gets or sets the corner radius angle */
  77360. get cornerRadius(): number;
  77361. set cornerRadius(value: number);
  77362. /**
  77363. * Creates a new Rectangle
  77364. * @param name defines the control name
  77365. */
  77366. constructor(name?: string | undefined);
  77367. protected _getTypeName(): string;
  77368. protected _localDraw(context: CanvasRenderingContext2D): void;
  77369. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77370. private _drawRoundedRect;
  77371. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77372. }
  77373. }
  77374. declare module BABYLON.GUI {
  77375. /**
  77376. * Enum that determines the text-wrapping mode to use.
  77377. */
  77378. export enum TextWrapping {
  77379. /**
  77380. * Clip the text when it's larger than Control.width; this is the default mode.
  77381. */
  77382. Clip = 0,
  77383. /**
  77384. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77385. */
  77386. WordWrap = 1,
  77387. /**
  77388. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77389. */
  77390. Ellipsis = 2
  77391. }
  77392. /**
  77393. * Class used to create text block control
  77394. */
  77395. export class TextBlock extends Control {
  77396. /**
  77397. * Defines the name of the control
  77398. */
  77399. name?: string | undefined;
  77400. private _text;
  77401. private _textWrapping;
  77402. private _textHorizontalAlignment;
  77403. private _textVerticalAlignment;
  77404. private _lines;
  77405. private _resizeToFit;
  77406. private _lineSpacing;
  77407. private _outlineWidth;
  77408. private _outlineColor;
  77409. /**
  77410. * An event triggered after the text is changed
  77411. */
  77412. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77413. /**
  77414. * An event triggered after the text was broken up into lines
  77415. */
  77416. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77417. /**
  77418. * Function used to split a string into words. By default, a string is split at each space character found
  77419. */
  77420. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77421. /**
  77422. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77423. */
  77424. get lines(): any[];
  77425. /**
  77426. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77427. */
  77428. get resizeToFit(): boolean;
  77429. /**
  77430. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77431. */
  77432. set resizeToFit(value: boolean);
  77433. /**
  77434. * Gets or sets a boolean indicating if text must be wrapped
  77435. */
  77436. get textWrapping(): TextWrapping | boolean;
  77437. /**
  77438. * Gets or sets a boolean indicating if text must be wrapped
  77439. */
  77440. set textWrapping(value: TextWrapping | boolean);
  77441. /**
  77442. * Gets or sets text to display
  77443. */
  77444. get text(): string;
  77445. /**
  77446. * Gets or sets text to display
  77447. */
  77448. set text(value: string);
  77449. /**
  77450. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77451. */
  77452. get textHorizontalAlignment(): number;
  77453. /**
  77454. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77455. */
  77456. set textHorizontalAlignment(value: number);
  77457. /**
  77458. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77459. */
  77460. get textVerticalAlignment(): number;
  77461. /**
  77462. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77463. */
  77464. set textVerticalAlignment(value: number);
  77465. /**
  77466. * Gets or sets line spacing value
  77467. */
  77468. set lineSpacing(value: string | number);
  77469. /**
  77470. * Gets or sets line spacing value
  77471. */
  77472. get lineSpacing(): string | number;
  77473. /**
  77474. * Gets or sets outlineWidth of the text to display
  77475. */
  77476. get outlineWidth(): number;
  77477. /**
  77478. * Gets or sets outlineWidth of the text to display
  77479. */
  77480. set outlineWidth(value: number);
  77481. /**
  77482. * Gets or sets outlineColor of the text to display
  77483. */
  77484. get outlineColor(): string;
  77485. /**
  77486. * Gets or sets outlineColor of the text to display
  77487. */
  77488. set outlineColor(value: string);
  77489. /**
  77490. * Creates a new TextBlock object
  77491. * @param name defines the name of the control
  77492. * @param text defines the text to display (emptry string by default)
  77493. */
  77494. constructor(
  77495. /**
  77496. * Defines the name of the control
  77497. */
  77498. name?: string | undefined, text?: string);
  77499. protected _getTypeName(): string;
  77500. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77501. private _drawText;
  77502. /** @hidden */
  77503. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77504. protected _applyStates(context: CanvasRenderingContext2D): void;
  77505. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77506. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77507. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77508. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77509. protected _renderLines(context: CanvasRenderingContext2D): void;
  77510. /**
  77511. * Given a width constraint applied on the text block, find the expected height
  77512. * @returns expected height
  77513. */
  77514. computeExpectedHeight(): number;
  77515. dispose(): void;
  77516. }
  77517. }
  77518. declare module BABYLON.GUI {
  77519. /**
  77520. * Class used to create 2D images
  77521. */
  77522. export class Image extends Control {
  77523. name?: string | undefined;
  77524. private _workingCanvas;
  77525. private _domImage;
  77526. private _imageWidth;
  77527. private _imageHeight;
  77528. private _loaded;
  77529. private _stretch;
  77530. private _source;
  77531. private _autoScale;
  77532. private _sourceLeft;
  77533. private _sourceTop;
  77534. private _sourceWidth;
  77535. private _sourceHeight;
  77536. private _svgAttributesComputationCompleted;
  77537. private _isSVG;
  77538. private _cellWidth;
  77539. private _cellHeight;
  77540. private _cellId;
  77541. private _populateNinePatchSlicesFromImage;
  77542. private _sliceLeft;
  77543. private _sliceRight;
  77544. private _sliceTop;
  77545. private _sliceBottom;
  77546. private _detectPointerOnOpaqueOnly;
  77547. private _imageDataCache;
  77548. /**
  77549. * BABYLON.Observable notified when the content is loaded
  77550. */
  77551. onImageLoadedObservable: BABYLON.Observable<Image>;
  77552. /**
  77553. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77554. */
  77555. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77556. /**
  77557. * Gets a boolean indicating that the content is loaded
  77558. */
  77559. get isLoaded(): boolean;
  77560. /**
  77561. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77562. */
  77563. get populateNinePatchSlicesFromImage(): boolean;
  77564. set populateNinePatchSlicesFromImage(value: boolean);
  77565. /**
  77566. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77567. * Beware using this as this will comsume more memory as the image has to be stored twice
  77568. */
  77569. get detectPointerOnOpaqueOnly(): boolean;
  77570. set detectPointerOnOpaqueOnly(value: boolean);
  77571. /**
  77572. * Gets or sets the left value for slicing (9-patch)
  77573. */
  77574. get sliceLeft(): number;
  77575. set sliceLeft(value: number);
  77576. /**
  77577. * Gets or sets the right value for slicing (9-patch)
  77578. */
  77579. get sliceRight(): number;
  77580. set sliceRight(value: number);
  77581. /**
  77582. * Gets or sets the top value for slicing (9-patch)
  77583. */
  77584. get sliceTop(): number;
  77585. set sliceTop(value: number);
  77586. /**
  77587. * Gets or sets the bottom value for slicing (9-patch)
  77588. */
  77589. get sliceBottom(): number;
  77590. set sliceBottom(value: number);
  77591. /**
  77592. * Gets or sets the left coordinate in the source image
  77593. */
  77594. get sourceLeft(): number;
  77595. set sourceLeft(value: number);
  77596. /**
  77597. * Gets or sets the top coordinate in the source image
  77598. */
  77599. get sourceTop(): number;
  77600. set sourceTop(value: number);
  77601. /**
  77602. * Gets or sets the width to capture in the source image
  77603. */
  77604. get sourceWidth(): number;
  77605. set sourceWidth(value: number);
  77606. /**
  77607. * Gets or sets the height to capture in the source image
  77608. */
  77609. get sourceHeight(): number;
  77610. set sourceHeight(value: number);
  77611. /** Indicates if the format of the image is SVG */
  77612. get isSVG(): boolean;
  77613. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77614. get svgAttributesComputationCompleted(): boolean;
  77615. /**
  77616. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77617. * @see https://doc.babylonjs.com/how_to/gui#image
  77618. */
  77619. get autoScale(): boolean;
  77620. set autoScale(value: boolean);
  77621. /** Gets or sets the streching mode used by the image */
  77622. get stretch(): number;
  77623. set stretch(value: number);
  77624. /** @hidden */
  77625. _rotate90(n: number, preserveProperties?: boolean): Image;
  77626. private _handleRotationForSVGImage;
  77627. private _rotate90SourceProperties;
  77628. /**
  77629. * Gets or sets the internal DOM image used to render the control
  77630. */
  77631. set domImage(value: HTMLImageElement);
  77632. get domImage(): HTMLImageElement;
  77633. private _onImageLoaded;
  77634. private _extractNinePatchSliceDataFromImage;
  77635. /**
  77636. * Gets or sets image source url
  77637. */
  77638. set source(value: BABYLON.Nullable<string>);
  77639. /**
  77640. * Checks for svg document with icon id present
  77641. */
  77642. private _svgCheck;
  77643. /**
  77644. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77645. * given external svg file and icon id
  77646. */
  77647. private _getSVGAttribs;
  77648. /**
  77649. * Gets or sets the cell width to use when animation sheet is enabled
  77650. * @see https://doc.babylonjs.com/how_to/gui#image
  77651. */
  77652. get cellWidth(): number;
  77653. set cellWidth(value: number);
  77654. /**
  77655. * Gets or sets the cell height to use when animation sheet is enabled
  77656. * @see https://doc.babylonjs.com/how_to/gui#image
  77657. */
  77658. get cellHeight(): number;
  77659. set cellHeight(value: number);
  77660. /**
  77661. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77662. * @see https://doc.babylonjs.com/how_to/gui#image
  77663. */
  77664. get cellId(): number;
  77665. set cellId(value: number);
  77666. /**
  77667. * Creates a new Image
  77668. * @param name defines the control name
  77669. * @param url defines the image url
  77670. */
  77671. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77672. /**
  77673. * Tests if a given coordinates belong to the current control
  77674. * @param x defines x coordinate to test
  77675. * @param y defines y coordinate to test
  77676. * @returns true if the coordinates are inside the control
  77677. */
  77678. contains(x: number, y: number): boolean;
  77679. protected _getTypeName(): string;
  77680. /** Force the control to synchronize with its content */
  77681. synchronizeSizeWithContent(): void;
  77682. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77683. private _prepareWorkingCanvasForOpaqueDetection;
  77684. private _drawImage;
  77685. _draw(context: CanvasRenderingContext2D): void;
  77686. private _renderCornerPatch;
  77687. private _renderNinePatch;
  77688. dispose(): void;
  77689. /** STRETCH_NONE */
  77690. static readonly STRETCH_NONE: number;
  77691. /** STRETCH_FILL */
  77692. static readonly STRETCH_FILL: number;
  77693. /** STRETCH_UNIFORM */
  77694. static readonly STRETCH_UNIFORM: number;
  77695. /** STRETCH_EXTEND */
  77696. static readonly STRETCH_EXTEND: number;
  77697. /** NINE_PATCH */
  77698. static readonly STRETCH_NINE_PATCH: number;
  77699. }
  77700. }
  77701. declare module BABYLON.GUI {
  77702. /**
  77703. * Class used to create 2D buttons
  77704. */
  77705. export class Button extends Rectangle {
  77706. name?: string | undefined;
  77707. /**
  77708. * Function called to generate a pointer enter animation
  77709. */
  77710. pointerEnterAnimation: () => void;
  77711. /**
  77712. * Function called to generate a pointer out animation
  77713. */
  77714. pointerOutAnimation: () => void;
  77715. /**
  77716. * Function called to generate a pointer down animation
  77717. */
  77718. pointerDownAnimation: () => void;
  77719. /**
  77720. * Function called to generate a pointer up animation
  77721. */
  77722. pointerUpAnimation: () => void;
  77723. /**
  77724. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77725. */
  77726. delegatePickingToChildren: boolean;
  77727. private _image;
  77728. /**
  77729. * Returns the image part of the button (if any)
  77730. */
  77731. get image(): BABYLON.Nullable<Image>;
  77732. private _textBlock;
  77733. /**
  77734. * Returns the image part of the button (if any)
  77735. */
  77736. get textBlock(): BABYLON.Nullable<TextBlock>;
  77737. /**
  77738. * Creates a new Button
  77739. * @param name defines the name of the button
  77740. */
  77741. constructor(name?: string | undefined);
  77742. protected _getTypeName(): string;
  77743. /** @hidden */
  77744. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77745. /** @hidden */
  77746. _onPointerEnter(target: Control): boolean;
  77747. /** @hidden */
  77748. _onPointerOut(target: Control, force?: boolean): void;
  77749. /** @hidden */
  77750. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77751. /** @hidden */
  77752. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77753. /**
  77754. * Creates a new button made with an image and a text
  77755. * @param name defines the name of the button
  77756. * @param text defines the text of the button
  77757. * @param imageUrl defines the url of the image
  77758. * @returns a new Button
  77759. */
  77760. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77761. /**
  77762. * Creates a new button made with an image
  77763. * @param name defines the name of the button
  77764. * @param imageUrl defines the url of the image
  77765. * @returns a new Button
  77766. */
  77767. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77768. /**
  77769. * Creates a new button made with a text
  77770. * @param name defines the name of the button
  77771. * @param text defines the text of the button
  77772. * @returns a new Button
  77773. */
  77774. static CreateSimpleButton(name: string, text: string): Button;
  77775. /**
  77776. * Creates a new button made with an image and a centered text
  77777. * @param name defines the name of the button
  77778. * @param text defines the text of the button
  77779. * @param imageUrl defines the url of the image
  77780. * @returns a new Button
  77781. */
  77782. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77783. }
  77784. }
  77785. declare module BABYLON.GUI {
  77786. /**
  77787. * Class used to create a 2D stack panel container
  77788. */
  77789. export class StackPanel extends Container {
  77790. name?: string | undefined;
  77791. private _isVertical;
  77792. private _manualWidth;
  77793. private _manualHeight;
  77794. private _doNotTrackManualChanges;
  77795. /**
  77796. * Gets or sets a boolean indicating that layou warnings should be ignored
  77797. */
  77798. ignoreLayoutWarnings: boolean;
  77799. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77800. get isVertical(): boolean;
  77801. set isVertical(value: boolean);
  77802. /**
  77803. * Gets or sets panel width.
  77804. * This value should not be set when in horizontal mode as it will be computed automatically
  77805. */
  77806. set width(value: string | number);
  77807. get width(): string | number;
  77808. /**
  77809. * Gets or sets panel height.
  77810. * This value should not be set when in vertical mode as it will be computed automatically
  77811. */
  77812. set height(value: string | number);
  77813. get height(): string | number;
  77814. /**
  77815. * Creates a new StackPanel
  77816. * @param name defines control name
  77817. */
  77818. constructor(name?: string | undefined);
  77819. protected _getTypeName(): string;
  77820. /** @hidden */
  77821. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77822. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77823. protected _postMeasure(): void;
  77824. }
  77825. }
  77826. declare module BABYLON.GUI {
  77827. /**
  77828. * Class used to represent a 2D checkbox
  77829. */
  77830. export class Checkbox extends Control {
  77831. name?: string | undefined;
  77832. private _isChecked;
  77833. private _background;
  77834. private _checkSizeRatio;
  77835. private _thickness;
  77836. /** Gets or sets border thickness */
  77837. get thickness(): number;
  77838. set thickness(value: number);
  77839. /**
  77840. * BABYLON.Observable raised when isChecked property changes
  77841. */
  77842. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77843. /** Gets or sets a value indicating the ratio between overall size and check size */
  77844. get checkSizeRatio(): number;
  77845. set checkSizeRatio(value: number);
  77846. /** Gets or sets background color */
  77847. get background(): string;
  77848. set background(value: string);
  77849. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77850. get isChecked(): boolean;
  77851. set isChecked(value: boolean);
  77852. /**
  77853. * Creates a new CheckBox
  77854. * @param name defines the control name
  77855. */
  77856. constructor(name?: string | undefined);
  77857. protected _getTypeName(): string;
  77858. /** @hidden */
  77859. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77860. /** @hidden */
  77861. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77862. /**
  77863. * Utility function to easily create a checkbox with a header
  77864. * @param title defines the label to use for the header
  77865. * @param onValueChanged defines the callback to call when value changes
  77866. * @returns a StackPanel containing the checkbox and a textBlock
  77867. */
  77868. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77869. }
  77870. }
  77871. declare module BABYLON.GUI {
  77872. /**
  77873. * Class used to store key control properties
  77874. */
  77875. export class KeyPropertySet {
  77876. /** Width */
  77877. width?: string;
  77878. /** Height */
  77879. height?: string;
  77880. /** Left padding */
  77881. paddingLeft?: string;
  77882. /** Right padding */
  77883. paddingRight?: string;
  77884. /** Top padding */
  77885. paddingTop?: string;
  77886. /** Bottom padding */
  77887. paddingBottom?: string;
  77888. /** Foreground color */
  77889. color?: string;
  77890. /** Background color */
  77891. background?: string;
  77892. }
  77893. /**
  77894. * Class used to create virtual keyboard
  77895. */
  77896. export class VirtualKeyboard extends StackPanel {
  77897. /** BABYLON.Observable raised when a key is pressed */
  77898. onKeyPressObservable: BABYLON.Observable<string>;
  77899. /** Gets or sets default key button width */
  77900. defaultButtonWidth: string;
  77901. /** Gets or sets default key button height */
  77902. defaultButtonHeight: string;
  77903. /** Gets or sets default key button left padding */
  77904. defaultButtonPaddingLeft: string;
  77905. /** Gets or sets default key button right padding */
  77906. defaultButtonPaddingRight: string;
  77907. /** Gets or sets default key button top padding */
  77908. defaultButtonPaddingTop: string;
  77909. /** Gets or sets default key button bottom padding */
  77910. defaultButtonPaddingBottom: string;
  77911. /** Gets or sets default key button foreground color */
  77912. defaultButtonColor: string;
  77913. /** Gets or sets default key button background color */
  77914. defaultButtonBackground: string;
  77915. /** Gets or sets shift button foreground color */
  77916. shiftButtonColor: string;
  77917. /** Gets or sets shift button thickness*/
  77918. selectedShiftThickness: number;
  77919. /** Gets shift key state */
  77920. shiftState: number;
  77921. protected _getTypeName(): string;
  77922. private _createKey;
  77923. /**
  77924. * Adds a new row of keys
  77925. * @param keys defines the list of keys to add
  77926. * @param propertySets defines the associated property sets
  77927. */
  77928. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77929. /**
  77930. * Set the shift key to a specific state
  77931. * @param shiftState defines the new shift state
  77932. */
  77933. applyShiftState(shiftState: number): void;
  77934. private _currentlyConnectedInputText;
  77935. private _connectedInputTexts;
  77936. private _onKeyPressObserver;
  77937. /** Gets the input text control currently attached to the keyboard */
  77938. get connectedInputText(): BABYLON.Nullable<InputText>;
  77939. /**
  77940. * Connects the keyboard with an input text control
  77941. *
  77942. * @param input defines the target control
  77943. */
  77944. connect(input: InputText): void;
  77945. /**
  77946. * Disconnects the keyboard from connected InputText controls
  77947. *
  77948. * @param input optionally defines a target control, otherwise all are disconnected
  77949. */
  77950. disconnect(input?: InputText): void;
  77951. private _removeConnectedInputObservables;
  77952. /**
  77953. * Release all resources
  77954. */
  77955. dispose(): void;
  77956. /**
  77957. * Creates a new keyboard using a default layout
  77958. *
  77959. * @param name defines control name
  77960. * @returns a new VirtualKeyboard
  77961. */
  77962. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77963. }
  77964. }
  77965. declare module BABYLON.GUI {
  77966. /**
  77967. * Class used to create input text control
  77968. */
  77969. export class InputText extends Control implements IFocusableControl {
  77970. name?: string | undefined;
  77971. private _text;
  77972. private _placeholderText;
  77973. private _background;
  77974. private _focusedBackground;
  77975. private _focusedColor;
  77976. private _placeholderColor;
  77977. private _thickness;
  77978. private _margin;
  77979. private _autoStretchWidth;
  77980. private _maxWidth;
  77981. private _isFocused;
  77982. private _blinkTimeout;
  77983. private _blinkIsEven;
  77984. private _cursorOffset;
  77985. private _scrollLeft;
  77986. private _textWidth;
  77987. private _clickedCoordinate;
  77988. private _deadKey;
  77989. private _addKey;
  77990. private _currentKey;
  77991. private _isTextHighlightOn;
  77992. private _textHighlightColor;
  77993. private _highligherOpacity;
  77994. private _highlightedText;
  77995. private _startHighlightIndex;
  77996. private _endHighlightIndex;
  77997. private _cursorIndex;
  77998. private _onFocusSelectAll;
  77999. private _isPointerDown;
  78000. private _onClipboardObserver;
  78001. private _onPointerDblTapObserver;
  78002. /** @hidden */
  78003. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78004. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78005. promptMessage: string;
  78006. /** Force disable prompt on mobile device */
  78007. disableMobilePrompt: boolean;
  78008. /** BABYLON.Observable raised when the text changes */
  78009. onTextChangedObservable: BABYLON.Observable<InputText>;
  78010. /** BABYLON.Observable raised just before an entered character is to be added */
  78011. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78012. /** BABYLON.Observable raised when the control gets the focus */
  78013. onFocusObservable: BABYLON.Observable<InputText>;
  78014. /** BABYLON.Observable raised when the control loses the focus */
  78015. onBlurObservable: BABYLON.Observable<InputText>;
  78016. /**Observable raised when the text is highlighted */
  78017. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78018. /**Observable raised when copy event is triggered */
  78019. onTextCopyObservable: BABYLON.Observable<InputText>;
  78020. /** BABYLON.Observable raised when cut event is triggered */
  78021. onTextCutObservable: BABYLON.Observable<InputText>;
  78022. /** BABYLON.Observable raised when paste event is triggered */
  78023. onTextPasteObservable: BABYLON.Observable<InputText>;
  78024. /** BABYLON.Observable raised when a key event was processed */
  78025. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78026. /** Gets or sets the maximum width allowed by the control */
  78027. get maxWidth(): string | number;
  78028. /** Gets the maximum width allowed by the control in pixels */
  78029. get maxWidthInPixels(): number;
  78030. set maxWidth(value: string | number);
  78031. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78032. get highligherOpacity(): number;
  78033. set highligherOpacity(value: number);
  78034. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78035. get onFocusSelectAll(): boolean;
  78036. set onFocusSelectAll(value: boolean);
  78037. /** Gets or sets the text hightlight color */
  78038. get textHighlightColor(): string;
  78039. set textHighlightColor(value: string);
  78040. /** Gets or sets control margin */
  78041. get margin(): string;
  78042. /** Gets control margin in pixels */
  78043. get marginInPixels(): number;
  78044. set margin(value: string);
  78045. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78046. get autoStretchWidth(): boolean;
  78047. set autoStretchWidth(value: boolean);
  78048. /** Gets or sets border thickness */
  78049. get thickness(): number;
  78050. set thickness(value: number);
  78051. /** Gets or sets the background color when focused */
  78052. get focusedBackground(): string;
  78053. set focusedBackground(value: string);
  78054. /** Gets or sets the background color when focused */
  78055. get focusedColor(): string;
  78056. set focusedColor(value: string);
  78057. /** Gets or sets the background color */
  78058. get background(): string;
  78059. set background(value: string);
  78060. /** Gets or sets the placeholder color */
  78061. get placeholderColor(): string;
  78062. set placeholderColor(value: string);
  78063. /** Gets or sets the text displayed when the control is empty */
  78064. get placeholderText(): string;
  78065. set placeholderText(value: string);
  78066. /** Gets or sets the dead key flag */
  78067. get deadKey(): boolean;
  78068. set deadKey(flag: boolean);
  78069. /** Gets or sets the highlight text */
  78070. get highlightedText(): string;
  78071. set highlightedText(text: string);
  78072. /** Gets or sets if the current key should be added */
  78073. get addKey(): boolean;
  78074. set addKey(flag: boolean);
  78075. /** Gets or sets the value of the current key being entered */
  78076. get currentKey(): string;
  78077. set currentKey(key: string);
  78078. /** Gets or sets the text displayed in the control */
  78079. get text(): string;
  78080. set text(value: string);
  78081. /** Gets or sets control width */
  78082. get width(): string | number;
  78083. set width(value: string | number);
  78084. /**
  78085. * Creates a new InputText
  78086. * @param name defines the control name
  78087. * @param text defines the text of the control
  78088. */
  78089. constructor(name?: string | undefined, text?: string);
  78090. /** @hidden */
  78091. onBlur(): void;
  78092. /** @hidden */
  78093. onFocus(): void;
  78094. protected _getTypeName(): string;
  78095. /**
  78096. * Function called to get the list of controls that should not steal the focus from this control
  78097. * @returns an array of controls
  78098. */
  78099. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78100. /** @hidden */
  78101. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78102. /** @hidden */
  78103. private _updateValueFromCursorIndex;
  78104. /** @hidden */
  78105. private _processDblClick;
  78106. /** @hidden */
  78107. private _selectAllText;
  78108. /**
  78109. * Handles the keyboard event
  78110. * @param evt Defines the KeyboardEvent
  78111. */
  78112. processKeyboard(evt: KeyboardEvent): void;
  78113. /** @hidden */
  78114. private _onCopyText;
  78115. /** @hidden */
  78116. private _onCutText;
  78117. /** @hidden */
  78118. private _onPasteText;
  78119. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78120. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78121. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78122. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78123. protected _beforeRenderText(text: string): string;
  78124. dispose(): void;
  78125. }
  78126. }
  78127. declare module BABYLON.GUI {
  78128. /**
  78129. * Class used to create a 2D grid container
  78130. */
  78131. export class Grid extends Container {
  78132. name?: string | undefined;
  78133. private _rowDefinitions;
  78134. private _columnDefinitions;
  78135. private _cells;
  78136. private _childControls;
  78137. /**
  78138. * Gets the number of columns
  78139. */
  78140. get columnCount(): number;
  78141. /**
  78142. * Gets the number of rows
  78143. */
  78144. get rowCount(): number;
  78145. /** Gets the list of children */
  78146. get children(): Control[];
  78147. /** Gets the list of cells (e.g. the containers) */
  78148. get cells(): {
  78149. [key: string]: Container;
  78150. };
  78151. /**
  78152. * Gets the definition of a specific row
  78153. * @param index defines the index of the row
  78154. * @returns the row definition
  78155. */
  78156. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78157. /**
  78158. * Gets the definition of a specific column
  78159. * @param index defines the index of the column
  78160. * @returns the column definition
  78161. */
  78162. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78163. /**
  78164. * Adds a new row to the grid
  78165. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78166. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78167. * @returns the current grid
  78168. */
  78169. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78170. /**
  78171. * Adds a new column to the grid
  78172. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78173. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78174. * @returns the current grid
  78175. */
  78176. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78177. /**
  78178. * Update a row definition
  78179. * @param index defines the index of the row to update
  78180. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78181. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78182. * @returns the current grid
  78183. */
  78184. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78185. /**
  78186. * Update a column definition
  78187. * @param index defines the index of the column to update
  78188. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78189. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78190. * @returns the current grid
  78191. */
  78192. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78193. /**
  78194. * Gets the list of children stored in a specific cell
  78195. * @param row defines the row to check
  78196. * @param column defines the column to check
  78197. * @returns the list of controls
  78198. */
  78199. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78200. /**
  78201. * Gets a string representing the child cell info (row x column)
  78202. * @param child defines the control to get info from
  78203. * @returns a string containing the child cell info (row x column)
  78204. */
  78205. getChildCellInfo(child: Control): string;
  78206. private _removeCell;
  78207. private _offsetCell;
  78208. /**
  78209. * Remove a column definition at specified index
  78210. * @param index defines the index of the column to remove
  78211. * @returns the current grid
  78212. */
  78213. removeColumnDefinition(index: number): Grid;
  78214. /**
  78215. * Remove a row definition at specified index
  78216. * @param index defines the index of the row to remove
  78217. * @returns the current grid
  78218. */
  78219. removeRowDefinition(index: number): Grid;
  78220. /**
  78221. * Adds a new control to the current grid
  78222. * @param control defines the control to add
  78223. * @param row defines the row where to add the control (0 by default)
  78224. * @param column defines the column where to add the control (0 by default)
  78225. * @returns the current grid
  78226. */
  78227. addControl(control: Control, row?: number, column?: number): Grid;
  78228. /**
  78229. * Removes a control from the current container
  78230. * @param control defines the control to remove
  78231. * @returns the current container
  78232. */
  78233. removeControl(control: Control): Container;
  78234. /**
  78235. * Creates a new Grid
  78236. * @param name defines control name
  78237. */
  78238. constructor(name?: string | undefined);
  78239. protected _getTypeName(): string;
  78240. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78241. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78242. _flagDescendantsAsMatrixDirty(): void;
  78243. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78244. /** Releases associated resources */
  78245. dispose(): void;
  78246. }
  78247. }
  78248. declare module BABYLON.GUI {
  78249. /** Class used to create color pickers */
  78250. export class ColorPicker extends Control {
  78251. name?: string | undefined;
  78252. private static _Epsilon;
  78253. private _colorWheelCanvas;
  78254. private _value;
  78255. private _tmpColor;
  78256. private _pointerStartedOnSquare;
  78257. private _pointerStartedOnWheel;
  78258. private _squareLeft;
  78259. private _squareTop;
  78260. private _squareSize;
  78261. private _h;
  78262. private _s;
  78263. private _v;
  78264. private _lastPointerDownID;
  78265. /**
  78266. * BABYLON.Observable raised when the value changes
  78267. */
  78268. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78269. /** Gets or sets the color of the color picker */
  78270. get value(): BABYLON.Color3;
  78271. set value(value: BABYLON.Color3);
  78272. /**
  78273. * Gets or sets control width
  78274. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78275. */
  78276. get width(): string | number;
  78277. set width(value: string | number);
  78278. /**
  78279. * Gets or sets control height
  78280. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78281. */
  78282. get height(): string | number;
  78283. /** Gets or sets control height */
  78284. set height(value: string | number);
  78285. /** Gets or sets control size */
  78286. get size(): string | number;
  78287. set size(value: string | number);
  78288. /**
  78289. * Creates a new ColorPicker
  78290. * @param name defines the control name
  78291. */
  78292. constructor(name?: string | undefined);
  78293. protected _getTypeName(): string;
  78294. /** @hidden */
  78295. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78296. private _updateSquareProps;
  78297. private _drawGradientSquare;
  78298. private _drawCircle;
  78299. private _createColorWheelCanvas;
  78300. /** @hidden */
  78301. _draw(context: CanvasRenderingContext2D): void;
  78302. private _pointerIsDown;
  78303. private _updateValueFromPointer;
  78304. private _isPointOnSquare;
  78305. private _isPointOnWheel;
  78306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78307. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78308. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78309. _onCanvasBlur(): void;
  78310. /**
  78311. * This function expands the color picker by creating a color picker dialog with manual
  78312. * color value input and the ability to save colors into an array to be used later in
  78313. * subsequent launches of the dialogue.
  78314. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78315. * @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.
  78316. * @returns picked color as a hex string and the saved colors array as hex strings.
  78317. */
  78318. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78319. pickerWidth?: string;
  78320. pickerHeight?: string;
  78321. headerHeight?: string;
  78322. lastColor?: string;
  78323. swatchLimit?: number;
  78324. numSwatchesPerLine?: number;
  78325. savedColors?: Array<string>;
  78326. }): Promise<{
  78327. savedColors?: string[];
  78328. pickedColor: string;
  78329. }>;
  78330. }
  78331. }
  78332. declare module BABYLON.GUI {
  78333. /** Class used to create 2D ellipse containers */
  78334. export class Ellipse extends Container {
  78335. name?: string | undefined;
  78336. private _thickness;
  78337. /** Gets or sets border thickness */
  78338. get thickness(): number;
  78339. set thickness(value: number);
  78340. /**
  78341. * Creates a new Ellipse
  78342. * @param name defines the control name
  78343. */
  78344. constructor(name?: string | undefined);
  78345. protected _getTypeName(): string;
  78346. protected _localDraw(context: CanvasRenderingContext2D): void;
  78347. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78348. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78349. }
  78350. }
  78351. declare module BABYLON.GUI {
  78352. /**
  78353. * Class used to create a password control
  78354. */
  78355. export class InputPassword extends InputText {
  78356. protected _beforeRenderText(text: string): string;
  78357. }
  78358. }
  78359. declare module BABYLON.GUI {
  78360. /** Class used to render 2D lines */
  78361. export class Line extends Control {
  78362. name?: string | undefined;
  78363. private _lineWidth;
  78364. private _x1;
  78365. private _y1;
  78366. private _x2;
  78367. private _y2;
  78368. private _dash;
  78369. private _connectedControl;
  78370. private _connectedControlDirtyObserver;
  78371. /** Gets or sets the dash pattern */
  78372. get dash(): Array<number>;
  78373. set dash(value: Array<number>);
  78374. /** Gets or sets the control connected with the line end */
  78375. get connectedControl(): Control;
  78376. set connectedControl(value: Control);
  78377. /** Gets or sets start coordinates on X axis */
  78378. get x1(): string | number;
  78379. set x1(value: string | number);
  78380. /** Gets or sets start coordinates on Y axis */
  78381. get y1(): string | number;
  78382. set y1(value: string | number);
  78383. /** Gets or sets end coordinates on X axis */
  78384. get x2(): string | number;
  78385. set x2(value: string | number);
  78386. /** Gets or sets end coordinates on Y axis */
  78387. get y2(): string | number;
  78388. set y2(value: string | number);
  78389. /** Gets or sets line width */
  78390. get lineWidth(): number;
  78391. set lineWidth(value: number);
  78392. /** Gets or sets horizontal alignment */
  78393. set horizontalAlignment(value: number);
  78394. /** Gets or sets vertical alignment */
  78395. set verticalAlignment(value: number);
  78396. private get _effectiveX2();
  78397. private get _effectiveY2();
  78398. /**
  78399. * Creates a new Line
  78400. * @param name defines the control name
  78401. */
  78402. constructor(name?: string | undefined);
  78403. protected _getTypeName(): string;
  78404. _draw(context: CanvasRenderingContext2D): void;
  78405. _measure(): void;
  78406. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78407. /**
  78408. * Move one end of the line given 3D cartesian coordinates.
  78409. * @param position Targeted world position
  78410. * @param scene BABYLON.Scene
  78411. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78412. */
  78413. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78414. /**
  78415. * Move one end of the line to a position in screen absolute space.
  78416. * @param projectedPosition Position in screen absolute space (X, Y)
  78417. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78418. */
  78419. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78420. }
  78421. }
  78422. declare module BABYLON.GUI {
  78423. /**
  78424. * Class used to store a point for a MultiLine object.
  78425. * The point can be pure 2D coordinates, a mesh or a control
  78426. */
  78427. export class MultiLinePoint {
  78428. private _multiLine;
  78429. private _x;
  78430. private _y;
  78431. private _control;
  78432. private _mesh;
  78433. private _controlObserver;
  78434. private _meshObserver;
  78435. /** @hidden */
  78436. _point: BABYLON.Vector2;
  78437. /**
  78438. * Creates a new MultiLinePoint
  78439. * @param multiLine defines the source MultiLine object
  78440. */
  78441. constructor(multiLine: MultiLine);
  78442. /** Gets or sets x coordinate */
  78443. get x(): string | number;
  78444. set x(value: string | number);
  78445. /** Gets or sets y coordinate */
  78446. get y(): string | number;
  78447. set y(value: string | number);
  78448. /** Gets or sets the control associated with this point */
  78449. get control(): BABYLON.Nullable<Control>;
  78450. set control(value: BABYLON.Nullable<Control>);
  78451. /** Gets or sets the mesh associated with this point */
  78452. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78453. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78454. /** Resets links */
  78455. resetLinks(): void;
  78456. /**
  78457. * Gets a translation vector
  78458. * @returns the translation vector
  78459. */
  78460. translate(): BABYLON.Vector2;
  78461. private _translatePoint;
  78462. /** Release associated resources */
  78463. dispose(): void;
  78464. }
  78465. }
  78466. declare module BABYLON.GUI {
  78467. /**
  78468. * Class used to create multi line control
  78469. */
  78470. export class MultiLine extends Control {
  78471. name?: string | undefined;
  78472. private _lineWidth;
  78473. private _dash;
  78474. private _points;
  78475. private _minX;
  78476. private _minY;
  78477. private _maxX;
  78478. private _maxY;
  78479. /**
  78480. * Creates a new MultiLine
  78481. * @param name defines the control name
  78482. */
  78483. constructor(name?: string | undefined);
  78484. /** Gets or sets dash pattern */
  78485. get dash(): Array<number>;
  78486. set dash(value: Array<number>);
  78487. /**
  78488. * Gets point stored at specified index
  78489. * @param index defines the index to look for
  78490. * @returns the requested point if found
  78491. */
  78492. getAt(index: number): MultiLinePoint;
  78493. /** Function called when a point is updated */
  78494. onPointUpdate: () => void;
  78495. /**
  78496. * Adds new points to the point collection
  78497. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78498. * @returns the list of created MultiLinePoint
  78499. */
  78500. add(...items: (AbstractMesh | Control | {
  78501. x: string | number;
  78502. y: string | number;
  78503. })[]): MultiLinePoint[];
  78504. /**
  78505. * Adds a new point to the point collection
  78506. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78507. * @returns the created MultiLinePoint
  78508. */
  78509. push(item?: (AbstractMesh | Control | {
  78510. x: string | number;
  78511. y: string | number;
  78512. })): MultiLinePoint;
  78513. /**
  78514. * Remove a specific value or point from the active point collection
  78515. * @param value defines the value or point to remove
  78516. */
  78517. remove(value: number | MultiLinePoint): void;
  78518. /**
  78519. * Resets this object to initial state (no point)
  78520. */
  78521. reset(): void;
  78522. /**
  78523. * Resets all links
  78524. */
  78525. resetLinks(): void;
  78526. /** Gets or sets line width */
  78527. get lineWidth(): number;
  78528. set lineWidth(value: number);
  78529. set horizontalAlignment(value: number);
  78530. set verticalAlignment(value: number);
  78531. protected _getTypeName(): string;
  78532. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78533. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78534. _measure(): void;
  78535. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78536. dispose(): void;
  78537. }
  78538. }
  78539. declare module BABYLON.GUI {
  78540. /**
  78541. * Class used to create radio button controls
  78542. */
  78543. export class RadioButton extends Control {
  78544. name?: string | undefined;
  78545. private _isChecked;
  78546. private _background;
  78547. private _checkSizeRatio;
  78548. private _thickness;
  78549. /** Gets or sets border thickness */
  78550. get thickness(): number;
  78551. set thickness(value: number);
  78552. /** Gets or sets group name */
  78553. group: string;
  78554. /** BABYLON.Observable raised when isChecked is changed */
  78555. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78556. /** Gets or sets a value indicating the ratio between overall size and check size */
  78557. get checkSizeRatio(): number;
  78558. set checkSizeRatio(value: number);
  78559. /** Gets or sets background color */
  78560. get background(): string;
  78561. set background(value: string);
  78562. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78563. get isChecked(): boolean;
  78564. set isChecked(value: boolean);
  78565. /**
  78566. * Creates a new RadioButton
  78567. * @param name defines the control name
  78568. */
  78569. constructor(name?: string | undefined);
  78570. protected _getTypeName(): string;
  78571. _draw(context: CanvasRenderingContext2D): void;
  78572. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78573. /**
  78574. * Utility function to easily create a radio button with a header
  78575. * @param title defines the label to use for the header
  78576. * @param group defines the group to use for the radio button
  78577. * @param isChecked defines the initial state of the radio button
  78578. * @param onValueChanged defines the callback to call when value changes
  78579. * @returns a StackPanel containing the radio button and a textBlock
  78580. */
  78581. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78582. }
  78583. }
  78584. declare module BABYLON.GUI {
  78585. /**
  78586. * Class used to create slider controls
  78587. */
  78588. export class BaseSlider extends Control {
  78589. name?: string | undefined;
  78590. protected _thumbWidth: ValueAndUnit;
  78591. private _minimum;
  78592. private _maximum;
  78593. private _value;
  78594. private _isVertical;
  78595. protected _barOffset: ValueAndUnit;
  78596. private _isThumbClamped;
  78597. protected _displayThumb: boolean;
  78598. private _step;
  78599. private _lastPointerDownID;
  78600. protected _effectiveBarOffset: number;
  78601. protected _renderLeft: number;
  78602. protected _renderTop: number;
  78603. protected _renderWidth: number;
  78604. protected _renderHeight: number;
  78605. protected _backgroundBoxLength: number;
  78606. protected _backgroundBoxThickness: number;
  78607. protected _effectiveThumbThickness: number;
  78608. /** BABYLON.Observable raised when the sldier value changes */
  78609. onValueChangedObservable: BABYLON.Observable<number>;
  78610. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78611. get displayThumb(): boolean;
  78612. set displayThumb(value: boolean);
  78613. /** Gets or sets a step to apply to values (0 by default) */
  78614. get step(): number;
  78615. set step(value: number);
  78616. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78617. get barOffset(): string | number;
  78618. /** Gets main bar offset in pixels*/
  78619. get barOffsetInPixels(): number;
  78620. set barOffset(value: string | number);
  78621. /** Gets or sets thumb width */
  78622. get thumbWidth(): string | number;
  78623. /** Gets thumb width in pixels */
  78624. get thumbWidthInPixels(): number;
  78625. set thumbWidth(value: string | number);
  78626. /** Gets or sets minimum value */
  78627. get minimum(): number;
  78628. set minimum(value: number);
  78629. /** Gets or sets maximum value */
  78630. get maximum(): number;
  78631. set maximum(value: number);
  78632. /** Gets or sets current value */
  78633. get value(): number;
  78634. set value(value: number);
  78635. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78636. get isVertical(): boolean;
  78637. set isVertical(value: boolean);
  78638. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78639. get isThumbClamped(): boolean;
  78640. set isThumbClamped(value: boolean);
  78641. /**
  78642. * Creates a new BaseSlider
  78643. * @param name defines the control name
  78644. */
  78645. constructor(name?: string | undefined);
  78646. protected _getTypeName(): string;
  78647. protected _getThumbPosition(): number;
  78648. protected _getThumbThickness(type: string): number;
  78649. protected _prepareRenderingData(type: string): void;
  78650. private _pointerIsDown;
  78651. /** @hidden */
  78652. protected _updateValueFromPointer(x: number, y: number): void;
  78653. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78654. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78655. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78656. _onCanvasBlur(): void;
  78657. }
  78658. }
  78659. declare module BABYLON.GUI {
  78660. /**
  78661. * Class used to create slider controls
  78662. */
  78663. export class Slider extends BaseSlider {
  78664. name?: string | undefined;
  78665. private _background;
  78666. private _borderColor;
  78667. private _isThumbCircle;
  78668. protected _displayValueBar: boolean;
  78669. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78670. get displayValueBar(): boolean;
  78671. set displayValueBar(value: boolean);
  78672. /** Gets or sets border color */
  78673. get borderColor(): string;
  78674. set borderColor(value: string);
  78675. /** Gets or sets background color */
  78676. get background(): string;
  78677. set background(value: string);
  78678. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78679. get isThumbCircle(): boolean;
  78680. set isThumbCircle(value: boolean);
  78681. /**
  78682. * Creates a new Slider
  78683. * @param name defines the control name
  78684. */
  78685. constructor(name?: string | undefined);
  78686. protected _getTypeName(): string;
  78687. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78688. }
  78689. }
  78690. declare module BABYLON.GUI {
  78691. /** Class used to create a RadioGroup
  78692. * which contains groups of radio buttons
  78693. */
  78694. export class SelectorGroup {
  78695. /** name of SelectorGroup */
  78696. name: string;
  78697. private _groupPanel;
  78698. private _selectors;
  78699. private _groupHeader;
  78700. /**
  78701. * Creates a new SelectorGroup
  78702. * @param name of group, used as a group heading
  78703. */
  78704. constructor(
  78705. /** name of SelectorGroup */
  78706. name: string);
  78707. /** Gets the groupPanel of the SelectorGroup */
  78708. get groupPanel(): StackPanel;
  78709. /** Gets the selectors array */
  78710. get selectors(): StackPanel[];
  78711. /** Gets and sets the group header */
  78712. get header(): string;
  78713. set header(label: string);
  78714. /** @hidden */
  78715. private _addGroupHeader;
  78716. /** @hidden*/
  78717. _getSelector(selectorNb: number): StackPanel | undefined;
  78718. /** Removes the selector at the given position
  78719. * @param selectorNb the position of the selector within the group
  78720. */
  78721. removeSelector(selectorNb: number): void;
  78722. }
  78723. /** Class used to create a CheckboxGroup
  78724. * which contains groups of checkbox buttons
  78725. */
  78726. export class CheckboxGroup extends SelectorGroup {
  78727. /** Adds a checkbox as a control
  78728. * @param text is the label for the selector
  78729. * @param func is the function called when the Selector is checked
  78730. * @param checked is true when Selector is checked
  78731. */
  78732. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78733. /** @hidden */
  78734. _setSelectorLabel(selectorNb: number, label: string): void;
  78735. /** @hidden */
  78736. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78737. /** @hidden */
  78738. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78739. /** @hidden */
  78740. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78741. }
  78742. /** Class used to create a RadioGroup
  78743. * which contains groups of radio buttons
  78744. */
  78745. export class RadioGroup extends SelectorGroup {
  78746. private _selectNb;
  78747. /** Adds a radio button as a control
  78748. * @param label is the label for the selector
  78749. * @param func is the function called when the Selector is checked
  78750. * @param checked is true when Selector is checked
  78751. */
  78752. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78753. /** @hidden */
  78754. _setSelectorLabel(selectorNb: number, label: string): void;
  78755. /** @hidden */
  78756. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78757. /** @hidden */
  78758. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78759. /** @hidden */
  78760. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78761. }
  78762. /** Class used to create a SliderGroup
  78763. * which contains groups of slider buttons
  78764. */
  78765. export class SliderGroup extends SelectorGroup {
  78766. /**
  78767. * Adds a slider to the SelectorGroup
  78768. * @param label is the label for the SliderBar
  78769. * @param func is the function called when the Slider moves
  78770. * @param unit is a string describing the units used, eg degrees or metres
  78771. * @param min is the minimum value for the Slider
  78772. * @param max is the maximum value for the Slider
  78773. * @param value is the start value for the Slider between min and max
  78774. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78775. */
  78776. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78777. /** @hidden */
  78778. _setSelectorLabel(selectorNb: number, label: string): void;
  78779. /** @hidden */
  78780. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78781. /** @hidden */
  78782. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78783. /** @hidden */
  78784. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78785. }
  78786. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78787. * @see https://doc.babylonjs.com/how_to/selector
  78788. */
  78789. export class SelectionPanel extends Rectangle {
  78790. /** name of SelectionPanel */
  78791. name: string;
  78792. /** an array of SelectionGroups */
  78793. groups: SelectorGroup[];
  78794. private _panel;
  78795. private _buttonColor;
  78796. private _buttonBackground;
  78797. private _headerColor;
  78798. private _barColor;
  78799. private _barHeight;
  78800. private _spacerHeight;
  78801. private _labelColor;
  78802. private _groups;
  78803. private _bars;
  78804. /**
  78805. * Creates a new SelectionPanel
  78806. * @param name of SelectionPanel
  78807. * @param groups is an array of SelectionGroups
  78808. */
  78809. constructor(
  78810. /** name of SelectionPanel */
  78811. name: string,
  78812. /** an array of SelectionGroups */
  78813. groups?: SelectorGroup[]);
  78814. protected _getTypeName(): string;
  78815. /** Gets or sets the headerColor */
  78816. get headerColor(): string;
  78817. set headerColor(color: string);
  78818. private _setHeaderColor;
  78819. /** Gets or sets the button color */
  78820. get buttonColor(): string;
  78821. set buttonColor(color: string);
  78822. private _setbuttonColor;
  78823. /** Gets or sets the label color */
  78824. get labelColor(): string;
  78825. set labelColor(color: string);
  78826. private _setLabelColor;
  78827. /** Gets or sets the button background */
  78828. get buttonBackground(): string;
  78829. set buttonBackground(color: string);
  78830. private _setButtonBackground;
  78831. /** Gets or sets the color of separator bar */
  78832. get barColor(): string;
  78833. set barColor(color: string);
  78834. private _setBarColor;
  78835. /** Gets or sets the height of separator bar */
  78836. get barHeight(): string;
  78837. set barHeight(value: string);
  78838. private _setBarHeight;
  78839. /** Gets or sets the height of spacers*/
  78840. get spacerHeight(): string;
  78841. set spacerHeight(value: string);
  78842. private _setSpacerHeight;
  78843. /** Adds a bar between groups */
  78844. private _addSpacer;
  78845. /** Add a group to the selection panel
  78846. * @param group is the selector group to add
  78847. */
  78848. addGroup(group: SelectorGroup): void;
  78849. /** Remove the group from the given position
  78850. * @param groupNb is the position of the group in the list
  78851. */
  78852. removeGroup(groupNb: number): void;
  78853. /** Change a group header label
  78854. * @param label is the new group header label
  78855. * @param groupNb is the number of the group to relabel
  78856. * */
  78857. setHeaderName(label: string, groupNb: number): void;
  78858. /** Change selector label to the one given
  78859. * @param label is the new selector label
  78860. * @param groupNb is the number of the groupcontaining the selector
  78861. * @param selectorNb is the number of the selector within a group to relabel
  78862. * */
  78863. relabel(label: string, groupNb: number, selectorNb: number): void;
  78864. /** For a given group position remove the selector at the given position
  78865. * @param groupNb is the number of the group to remove the selector from
  78866. * @param selectorNb is the number of the selector within the group
  78867. */
  78868. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78869. /** For a given group position of correct type add a checkbox button
  78870. * @param groupNb is the number of the group to remove the selector from
  78871. * @param label is the label for the selector
  78872. * @param func is the function called when the Selector is checked
  78873. * @param checked is true when Selector is checked
  78874. */
  78875. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78876. /** For a given group position of correct type add a radio button
  78877. * @param groupNb is the number of the group to remove the selector from
  78878. * @param label is the label for the selector
  78879. * @param func is the function called when the Selector is checked
  78880. * @param checked is true when Selector is checked
  78881. */
  78882. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78883. /**
  78884. * For a given slider group add a slider
  78885. * @param groupNb is the number of the group to add the slider to
  78886. * @param label is the label for the Slider
  78887. * @param func is the function called when the Slider moves
  78888. * @param unit is a string describing the units used, eg degrees or metres
  78889. * @param min is the minimum value for the Slider
  78890. * @param max is the maximum value for the Slider
  78891. * @param value is the start value for the Slider between min and max
  78892. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78893. */
  78894. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78895. }
  78896. }
  78897. declare module BABYLON.GUI {
  78898. /**
  78899. * Class used to hold a the container for ScrollViewer
  78900. * @hidden
  78901. */
  78902. export class _ScrollViewerWindow extends Container {
  78903. parentClientWidth: number;
  78904. parentClientHeight: number;
  78905. private _freezeControls;
  78906. private _parentMeasure;
  78907. private _oldLeft;
  78908. private _oldTop;
  78909. get freezeControls(): boolean;
  78910. set freezeControls(value: boolean);
  78911. private _bucketWidth;
  78912. private _bucketHeight;
  78913. private _buckets;
  78914. private _bucketLen;
  78915. get bucketWidth(): number;
  78916. get bucketHeight(): number;
  78917. setBucketSizes(width: number, height: number): void;
  78918. private _useBuckets;
  78919. private _makeBuckets;
  78920. private _dispatchInBuckets;
  78921. private _updateMeasures;
  78922. private _updateChildrenMeasures;
  78923. private _restoreMeasures;
  78924. /**
  78925. * Creates a new ScrollViewerWindow
  78926. * @param name of ScrollViewerWindow
  78927. */
  78928. constructor(name?: string);
  78929. protected _getTypeName(): string;
  78930. /** @hidden */
  78931. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78932. /** @hidden */
  78933. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78934. private _scrollChildren;
  78935. private _scrollChildrenWithBuckets;
  78936. /** @hidden */
  78937. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78938. protected _postMeasure(): void;
  78939. }
  78940. }
  78941. declare module BABYLON.GUI {
  78942. /**
  78943. * Class used to create slider controls
  78944. */
  78945. export class ScrollBar extends BaseSlider {
  78946. name?: string | undefined;
  78947. private _background;
  78948. private _borderColor;
  78949. private _tempMeasure;
  78950. /** Gets or sets border color */
  78951. get borderColor(): string;
  78952. set borderColor(value: string);
  78953. /** Gets or sets background color */
  78954. get background(): string;
  78955. set background(value: string);
  78956. /**
  78957. * Creates a new Slider
  78958. * @param name defines the control name
  78959. */
  78960. constructor(name?: string | undefined);
  78961. protected _getTypeName(): string;
  78962. protected _getThumbThickness(): number;
  78963. _draw(context: CanvasRenderingContext2D): void;
  78964. private _first;
  78965. private _originX;
  78966. private _originY;
  78967. /** @hidden */
  78968. protected _updateValueFromPointer(x: number, y: number): void;
  78969. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78970. }
  78971. }
  78972. declare module BABYLON.GUI {
  78973. /**
  78974. * Class used to create slider controls
  78975. */
  78976. export class ImageScrollBar extends BaseSlider {
  78977. name?: string | undefined;
  78978. private _backgroundBaseImage;
  78979. private _backgroundImage;
  78980. private _thumbImage;
  78981. private _thumbBaseImage;
  78982. private _thumbLength;
  78983. private _thumbHeight;
  78984. private _barImageHeight;
  78985. private _tempMeasure;
  78986. /** Number of 90° rotation to apply on the images when in vertical mode */
  78987. num90RotationInVerticalMode: number;
  78988. /**
  78989. * Gets or sets the image used to render the background for horizontal bar
  78990. */
  78991. get backgroundImage(): Image;
  78992. set backgroundImage(value: Image);
  78993. /**
  78994. * Gets or sets the image used to render the thumb
  78995. */
  78996. get thumbImage(): Image;
  78997. set thumbImage(value: Image);
  78998. /**
  78999. * Gets or sets the length of the thumb
  79000. */
  79001. get thumbLength(): number;
  79002. set thumbLength(value: number);
  79003. /**
  79004. * Gets or sets the height of the thumb
  79005. */
  79006. get thumbHeight(): number;
  79007. set thumbHeight(value: number);
  79008. /**
  79009. * Gets or sets the height of the bar image
  79010. */
  79011. get barImageHeight(): number;
  79012. set barImageHeight(value: number);
  79013. /**
  79014. * Creates a new ImageScrollBar
  79015. * @param name defines the control name
  79016. */
  79017. constructor(name?: string | undefined);
  79018. protected _getTypeName(): string;
  79019. protected _getThumbThickness(): number;
  79020. _draw(context: CanvasRenderingContext2D): void;
  79021. private _first;
  79022. private _originX;
  79023. private _originY;
  79024. /** @hidden */
  79025. protected _updateValueFromPointer(x: number, y: number): void;
  79026. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79027. }
  79028. }
  79029. declare module BABYLON.GUI {
  79030. /**
  79031. * Class used to hold a viewer window and sliders in a grid
  79032. */
  79033. export class ScrollViewer extends Rectangle {
  79034. private _grid;
  79035. private _horizontalBarSpace;
  79036. private _verticalBarSpace;
  79037. private _dragSpace;
  79038. private _horizontalBar;
  79039. private _verticalBar;
  79040. private _barColor;
  79041. private _barBackground;
  79042. private _barImage;
  79043. private _horizontalBarImage;
  79044. private _verticalBarImage;
  79045. private _barBackgroundImage;
  79046. private _horizontalBarBackgroundImage;
  79047. private _verticalBarBackgroundImage;
  79048. private _barSize;
  79049. private _window;
  79050. private _pointerIsOver;
  79051. private _wheelPrecision;
  79052. private _onWheelObserver;
  79053. private _clientWidth;
  79054. private _clientHeight;
  79055. private _useImageBar;
  79056. private _thumbLength;
  79057. private _thumbHeight;
  79058. private _barImageHeight;
  79059. private _horizontalBarImageHeight;
  79060. private _verticalBarImageHeight;
  79061. private _oldWindowContentsWidth;
  79062. private _oldWindowContentsHeight;
  79063. /**
  79064. * Gets the horizontal scrollbar
  79065. */
  79066. get horizontalBar(): ScrollBar | ImageScrollBar;
  79067. /**
  79068. * Gets the vertical scrollbar
  79069. */
  79070. get verticalBar(): ScrollBar | ImageScrollBar;
  79071. /**
  79072. * Adds a new control to the current container
  79073. * @param control defines the control to add
  79074. * @returns the current container
  79075. */
  79076. addControl(control: BABYLON.Nullable<Control>): Container;
  79077. /**
  79078. * Removes a control from the current container
  79079. * @param control defines the control to remove
  79080. * @returns the current container
  79081. */
  79082. removeControl(control: Control): Container;
  79083. /** Gets the list of children */
  79084. get children(): Control[];
  79085. _flagDescendantsAsMatrixDirty(): void;
  79086. /**
  79087. * Freezes or unfreezes the controls in the window.
  79088. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79089. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79090. */
  79091. get freezeControls(): boolean;
  79092. set freezeControls(value: boolean);
  79093. /** Gets the bucket width */
  79094. get bucketWidth(): number;
  79095. /** Gets the bucket height */
  79096. get bucketHeight(): number;
  79097. /**
  79098. * Sets the bucket sizes.
  79099. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79100. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79101. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79102. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79103. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79104. * used), that's why it is not enabled by default.
  79105. * @param width width of the bucket
  79106. * @param height height of the bucket
  79107. */
  79108. setBucketSizes(width: number, height: number): void;
  79109. private _forceHorizontalBar;
  79110. private _forceVerticalBar;
  79111. /**
  79112. * Forces the horizontal scroll bar to be displayed
  79113. */
  79114. get forceHorizontalBar(): boolean;
  79115. set forceHorizontalBar(value: boolean);
  79116. /**
  79117. * Forces the vertical scroll bar to be displayed
  79118. */
  79119. get forceVerticalBar(): boolean;
  79120. set forceVerticalBar(value: boolean);
  79121. /**
  79122. * Creates a new ScrollViewer
  79123. * @param name of ScrollViewer
  79124. */
  79125. constructor(name?: string, isImageBased?: boolean);
  79126. /** Reset the scroll viewer window to initial size */
  79127. resetWindow(): void;
  79128. protected _getTypeName(): string;
  79129. private _buildClientSizes;
  79130. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79131. protected _postMeasure(): void;
  79132. /**
  79133. * Gets or sets the mouse wheel precision
  79134. * from 0 to 1 with a default value of 0.05
  79135. * */
  79136. get wheelPrecision(): number;
  79137. set wheelPrecision(value: number);
  79138. /** Gets or sets the scroll bar container background color */
  79139. get scrollBackground(): string;
  79140. set scrollBackground(color: string);
  79141. /** Gets or sets the bar color */
  79142. get barColor(): string;
  79143. set barColor(color: string);
  79144. /** Gets or sets the bar image */
  79145. get thumbImage(): Image;
  79146. set thumbImage(value: Image);
  79147. /** Gets or sets the horizontal bar image */
  79148. get horizontalThumbImage(): Image;
  79149. set horizontalThumbImage(value: Image);
  79150. /** Gets or sets the vertical bar image */
  79151. get verticalThumbImage(): Image;
  79152. set verticalThumbImage(value: Image);
  79153. /** Gets or sets the size of the bar */
  79154. get barSize(): number;
  79155. set barSize(value: number);
  79156. /** Gets or sets the length of the thumb */
  79157. get thumbLength(): number;
  79158. set thumbLength(value: number);
  79159. /** Gets or sets the height of the thumb */
  79160. get thumbHeight(): number;
  79161. set thumbHeight(value: number);
  79162. /** Gets or sets the height of the bar image */
  79163. get barImageHeight(): number;
  79164. set barImageHeight(value: number);
  79165. /** Gets or sets the height of the horizontal bar image */
  79166. get horizontalBarImageHeight(): number;
  79167. set horizontalBarImageHeight(value: number);
  79168. /** Gets or sets the height of the vertical bar image */
  79169. get verticalBarImageHeight(): number;
  79170. set verticalBarImageHeight(value: number);
  79171. /** Gets or sets the bar background */
  79172. get barBackground(): string;
  79173. set barBackground(color: string);
  79174. /** Gets or sets the bar background image */
  79175. get barImage(): Image;
  79176. set barImage(value: Image);
  79177. /** Gets or sets the horizontal bar background image */
  79178. get horizontalBarImage(): Image;
  79179. set horizontalBarImage(value: Image);
  79180. /** Gets or sets the vertical bar background image */
  79181. get verticalBarImage(): Image;
  79182. set verticalBarImage(value: Image);
  79183. private _setWindowPosition;
  79184. /** @hidden */
  79185. private _updateScroller;
  79186. _link(host: AdvancedDynamicTexture): void;
  79187. /** @hidden */
  79188. private _addBar;
  79189. /** @hidden */
  79190. private _attachWheel;
  79191. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79192. /** Releases associated resources */
  79193. dispose(): void;
  79194. }
  79195. }
  79196. declare module BABYLON.GUI {
  79197. /** Class used to render a grid */
  79198. export class DisplayGrid extends Control {
  79199. name?: string | undefined;
  79200. private _cellWidth;
  79201. private _cellHeight;
  79202. private _minorLineTickness;
  79203. private _minorLineColor;
  79204. private _majorLineTickness;
  79205. private _majorLineColor;
  79206. private _majorLineFrequency;
  79207. private _background;
  79208. private _displayMajorLines;
  79209. private _displayMinorLines;
  79210. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79211. get displayMinorLines(): boolean;
  79212. set displayMinorLines(value: boolean);
  79213. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79214. get displayMajorLines(): boolean;
  79215. set displayMajorLines(value: boolean);
  79216. /** Gets or sets background color (Black by default) */
  79217. get background(): string;
  79218. set background(value: string);
  79219. /** Gets or sets the width of each cell (20 by default) */
  79220. get cellWidth(): number;
  79221. set cellWidth(value: number);
  79222. /** Gets or sets the height of each cell (20 by default) */
  79223. get cellHeight(): number;
  79224. set cellHeight(value: number);
  79225. /** Gets or sets the tickness of minor lines (1 by default) */
  79226. get minorLineTickness(): number;
  79227. set minorLineTickness(value: number);
  79228. /** Gets or sets the color of minor lines (DarkGray by default) */
  79229. get minorLineColor(): string;
  79230. set minorLineColor(value: string);
  79231. /** Gets or sets the tickness of major lines (2 by default) */
  79232. get majorLineTickness(): number;
  79233. set majorLineTickness(value: number);
  79234. /** Gets or sets the color of major lines (White by default) */
  79235. get majorLineColor(): string;
  79236. set majorLineColor(value: string);
  79237. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79238. get majorLineFrequency(): number;
  79239. set majorLineFrequency(value: number);
  79240. /**
  79241. * Creates a new GridDisplayRectangle
  79242. * @param name defines the control name
  79243. */
  79244. constructor(name?: string | undefined);
  79245. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79246. protected _getTypeName(): string;
  79247. }
  79248. }
  79249. declare module BABYLON.GUI {
  79250. /**
  79251. * Class used to create slider controls based on images
  79252. */
  79253. export class ImageBasedSlider extends BaseSlider {
  79254. name?: string | undefined;
  79255. private _backgroundImage;
  79256. private _thumbImage;
  79257. private _valueBarImage;
  79258. private _tempMeasure;
  79259. get displayThumb(): boolean;
  79260. set displayThumb(value: boolean);
  79261. /**
  79262. * Gets or sets the image used to render the background
  79263. */
  79264. get backgroundImage(): Image;
  79265. set backgroundImage(value: Image);
  79266. /**
  79267. * Gets or sets the image used to render the value bar
  79268. */
  79269. get valueBarImage(): Image;
  79270. set valueBarImage(value: Image);
  79271. /**
  79272. * Gets or sets the image used to render the thumb
  79273. */
  79274. get thumbImage(): Image;
  79275. set thumbImage(value: Image);
  79276. /**
  79277. * Creates a new ImageBasedSlider
  79278. * @param name defines the control name
  79279. */
  79280. constructor(name?: string | undefined);
  79281. protected _getTypeName(): string;
  79282. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79283. }
  79284. }
  79285. declare module BABYLON.GUI {
  79286. /**
  79287. * Forcing an export so that this code will execute
  79288. * @hidden
  79289. */
  79290. const name = "Statics";
  79291. }
  79292. declare module BABYLON.GUI {
  79293. /**
  79294. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79295. */
  79296. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79297. /**
  79298. * Define the instrumented AdvancedDynamicTexture.
  79299. */
  79300. texture: AdvancedDynamicTexture;
  79301. private _captureRenderTime;
  79302. private _renderTime;
  79303. private _captureLayoutTime;
  79304. private _layoutTime;
  79305. private _onBeginRenderObserver;
  79306. private _onEndRenderObserver;
  79307. private _onBeginLayoutObserver;
  79308. private _onEndLayoutObserver;
  79309. /**
  79310. * Gets the perf counter used to capture render time
  79311. */
  79312. get renderTimeCounter(): BABYLON.PerfCounter;
  79313. /**
  79314. * Gets the perf counter used to capture layout time
  79315. */
  79316. get layoutTimeCounter(): BABYLON.PerfCounter;
  79317. /**
  79318. * Enable or disable the render time capture
  79319. */
  79320. get captureRenderTime(): boolean;
  79321. set captureRenderTime(value: boolean);
  79322. /**
  79323. * Enable or disable the layout time capture
  79324. */
  79325. get captureLayoutTime(): boolean;
  79326. set captureLayoutTime(value: boolean);
  79327. /**
  79328. * Instantiates a new advanced dynamic texture instrumentation.
  79329. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79330. * @param texture Defines the AdvancedDynamicTexture to instrument
  79331. */
  79332. constructor(
  79333. /**
  79334. * Define the instrumented AdvancedDynamicTexture.
  79335. */
  79336. texture: AdvancedDynamicTexture);
  79337. /**
  79338. * Dispose and release associated resources.
  79339. */
  79340. dispose(): void;
  79341. }
  79342. }
  79343. declare module BABYLON.GUI {
  79344. /**
  79345. * Class used to load GUI via XML.
  79346. */
  79347. export class XmlLoader {
  79348. private _nodes;
  79349. private _nodeTypes;
  79350. private _isLoaded;
  79351. private _objectAttributes;
  79352. private _parentClass;
  79353. /**
  79354. * Create a new xml loader
  79355. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79356. */
  79357. constructor(parentClass?: null);
  79358. private _getChainElement;
  79359. private _getClassAttribute;
  79360. private _createGuiElement;
  79361. private _parseGrid;
  79362. private _parseElement;
  79363. private _prepareSourceElement;
  79364. private _parseElementsFromSource;
  79365. private _parseXml;
  79366. /**
  79367. * Gets if the loading has finished.
  79368. * @returns whether the loading has finished or not
  79369. */
  79370. isLoaded(): boolean;
  79371. /**
  79372. * Gets a loaded node / control by id.
  79373. * @param id the Controls id set in the xml
  79374. * @returns element of type Control
  79375. */
  79376. getNodeById(id: string): any;
  79377. /**
  79378. * Gets all loaded nodes / controls
  79379. * @returns Array of controls
  79380. */
  79381. getNodes(): any;
  79382. /**
  79383. * Initiates the xml layout loading
  79384. * @param xmlFile defines the xml layout to load
  79385. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79386. * @param callback defines the callback called on layout load.
  79387. */
  79388. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79389. }
  79390. }
  79391. declare module BABYLON.GUI {
  79392. /**
  79393. * Class used to create containers for controls
  79394. */
  79395. export class Container3D extends Control3D {
  79396. private _blockLayout;
  79397. /**
  79398. * Gets the list of child controls
  79399. */
  79400. protected _children: Control3D[];
  79401. /**
  79402. * Gets the list of child controls
  79403. */
  79404. get children(): Array<Control3D>;
  79405. /**
  79406. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79407. * This is helpful to optimize layout operation when adding multiple children in a row
  79408. */
  79409. get blockLayout(): boolean;
  79410. set blockLayout(value: boolean);
  79411. /**
  79412. * Creates a new container
  79413. * @param name defines the container name
  79414. */
  79415. constructor(name?: string);
  79416. /**
  79417. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79418. * @returns the current container
  79419. */
  79420. updateLayout(): Container3D;
  79421. /**
  79422. * Gets a boolean indicating if the given control is in the children of this control
  79423. * @param control defines the control to check
  79424. * @returns true if the control is in the child list
  79425. */
  79426. containsControl(control: Control3D): boolean;
  79427. /**
  79428. * Adds a control to the children of this control
  79429. * @param control defines the control to add
  79430. * @returns the current container
  79431. */
  79432. addControl(control: Control3D): Container3D;
  79433. /**
  79434. * This function will be called everytime a new control is added
  79435. */
  79436. protected _arrangeChildren(): void;
  79437. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79438. /**
  79439. * Removes a control from the children of this control
  79440. * @param control defines the control to remove
  79441. * @returns the current container
  79442. */
  79443. removeControl(control: Control3D): Container3D;
  79444. protected _getTypeName(): string;
  79445. /**
  79446. * Releases all associated resources
  79447. */
  79448. dispose(): void;
  79449. /** Control rotation will remain unchanged */
  79450. static readonly UNSET_ORIENTATION: number;
  79451. /** Control will rotate to make it look at sphere central axis */
  79452. static readonly FACEORIGIN_ORIENTATION: number;
  79453. /** Control will rotate to make it look back at sphere central axis */
  79454. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79455. /** Control will rotate to look at z axis (0, 0, 1) */
  79456. static readonly FACEFORWARD_ORIENTATION: number;
  79457. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79458. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79459. }
  79460. }
  79461. declare module BABYLON.GUI {
  79462. /**
  79463. * Class used to manage 3D user interface
  79464. * @see https://doc.babylonjs.com/how_to/gui3d
  79465. */
  79466. export class GUI3DManager implements BABYLON.IDisposable {
  79467. private _scene;
  79468. private _sceneDisposeObserver;
  79469. private _utilityLayer;
  79470. private _rootContainer;
  79471. private _pointerObserver;
  79472. private _pointerOutObserver;
  79473. /** @hidden */
  79474. _lastPickedControl: Control3D;
  79475. /** @hidden */
  79476. _lastControlOver: {
  79477. [pointerId: number]: Control3D;
  79478. };
  79479. /** @hidden */
  79480. _lastControlDown: {
  79481. [pointerId: number]: Control3D;
  79482. };
  79483. /**
  79484. * BABYLON.Observable raised when the point picked by the pointer events changed
  79485. */
  79486. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79487. /** @hidden */
  79488. _sharedMaterials: {
  79489. [key: string]: BABYLON.Material;
  79490. };
  79491. /** Gets the hosting scene */
  79492. get scene(): BABYLON.Scene;
  79493. /** Gets associated utility layer */
  79494. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79495. /**
  79496. * Creates a new GUI3DManager
  79497. * @param scene
  79498. */
  79499. constructor(scene?: BABYLON.Scene);
  79500. private _handlePointerOut;
  79501. private _doPicking;
  79502. /**
  79503. * Gets the root container
  79504. */
  79505. get rootContainer(): Container3D;
  79506. /**
  79507. * Gets a boolean indicating if the given control is in the root child list
  79508. * @param control defines the control to check
  79509. * @returns true if the control is in the root child list
  79510. */
  79511. containsControl(control: Control3D): boolean;
  79512. /**
  79513. * Adds a control to the root child list
  79514. * @param control defines the control to add
  79515. * @returns the current manager
  79516. */
  79517. addControl(control: Control3D): GUI3DManager;
  79518. /**
  79519. * Removes a control from the root child list
  79520. * @param control defines the control to remove
  79521. * @returns the current container
  79522. */
  79523. removeControl(control: Control3D): GUI3DManager;
  79524. /**
  79525. * Releases all associated resources
  79526. */
  79527. dispose(): void;
  79528. }
  79529. }
  79530. declare module BABYLON.GUI {
  79531. /**
  79532. * Class used to transport BABYLON.Vector3 information for pointer events
  79533. */
  79534. export class Vector3WithInfo extends BABYLON.Vector3 {
  79535. /** defines the current mouse button index */
  79536. buttonIndex: number;
  79537. /**
  79538. * Creates a new Vector3WithInfo
  79539. * @param source defines the vector3 data to transport
  79540. * @param buttonIndex defines the current mouse button index
  79541. */
  79542. constructor(source: BABYLON.Vector3,
  79543. /** defines the current mouse button index */
  79544. buttonIndex?: number);
  79545. }
  79546. }
  79547. declare module BABYLON.GUI {
  79548. /**
  79549. * Class used as base class for controls
  79550. */
  79551. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79552. /** Defines the control name */
  79553. name?: string | undefined;
  79554. /** @hidden */
  79555. _host: GUI3DManager;
  79556. private _node;
  79557. private _downCount;
  79558. private _enterCount;
  79559. private _downPointerIds;
  79560. private _isVisible;
  79561. /** Gets or sets the control position in world space */
  79562. get position(): BABYLON.Vector3;
  79563. set position(value: BABYLON.Vector3);
  79564. /** Gets or sets the control scaling in world space */
  79565. get scaling(): BABYLON.Vector3;
  79566. set scaling(value: BABYLON.Vector3);
  79567. /** Callback used to start pointer enter animation */
  79568. pointerEnterAnimation: () => void;
  79569. /** Callback used to start pointer out animation */
  79570. pointerOutAnimation: () => void;
  79571. /** Callback used to start pointer down animation */
  79572. pointerDownAnimation: () => void;
  79573. /** Callback used to start pointer up animation */
  79574. pointerUpAnimation: () => void;
  79575. /**
  79576. * An event triggered when the pointer move over the control
  79577. */
  79578. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79579. /**
  79580. * An event triggered when the pointer move out of the control
  79581. */
  79582. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79583. /**
  79584. * An event triggered when the pointer taps the control
  79585. */
  79586. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79587. /**
  79588. * An event triggered when pointer is up
  79589. */
  79590. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79591. /**
  79592. * An event triggered when a control is clicked on (with a mouse)
  79593. */
  79594. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79595. /**
  79596. * An event triggered when pointer enters the control
  79597. */
  79598. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79599. /**
  79600. * Gets or sets the parent container
  79601. */
  79602. parent: BABYLON.Nullable<Container3D>;
  79603. private _behaviors;
  79604. /**
  79605. * Gets the list of attached behaviors
  79606. * @see https://doc.babylonjs.com/features/behaviour
  79607. */
  79608. get behaviors(): BABYLON.Behavior<Control3D>[];
  79609. /**
  79610. * Attach a behavior to the control
  79611. * @see https://doc.babylonjs.com/features/behaviour
  79612. * @param behavior defines the behavior to attach
  79613. * @returns the current control
  79614. */
  79615. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79616. /**
  79617. * Remove an attached behavior
  79618. * @see https://doc.babylonjs.com/features/behaviour
  79619. * @param behavior defines the behavior to attach
  79620. * @returns the current control
  79621. */
  79622. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79623. /**
  79624. * Gets an attached behavior by name
  79625. * @param name defines the name of the behavior to look for
  79626. * @see https://doc.babylonjs.com/features/behaviour
  79627. * @returns null if behavior was not found else the requested behavior
  79628. */
  79629. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79630. /** Gets or sets a boolean indicating if the control is visible */
  79631. get isVisible(): boolean;
  79632. set isVisible(value: boolean);
  79633. /**
  79634. * Creates a new control
  79635. * @param name defines the control name
  79636. */
  79637. constructor(
  79638. /** Defines the control name */
  79639. name?: string | undefined);
  79640. /**
  79641. * Gets a string representing the class name
  79642. */
  79643. get typeName(): string;
  79644. /**
  79645. * Get the current class name of the control.
  79646. * @returns current class name
  79647. */
  79648. getClassName(): string;
  79649. protected _getTypeName(): string;
  79650. /**
  79651. * Gets the transform node used by this control
  79652. */
  79653. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79654. /**
  79655. * Gets the mesh used to render this control
  79656. */
  79657. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79658. /**
  79659. * Link the control as child of the given node
  79660. * @param node defines the node to link to. Use null to unlink the control
  79661. * @returns the current control
  79662. */
  79663. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79664. /** @hidden **/
  79665. _prepareNode(scene: BABYLON.Scene): void;
  79666. /**
  79667. * Node creation.
  79668. * Can be overriden by children
  79669. * @param scene defines the scene where the node must be attached
  79670. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79671. */
  79672. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79673. /**
  79674. * Affect a material to the given mesh
  79675. * @param mesh defines the mesh which will represent the control
  79676. */
  79677. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79678. /** @hidden */
  79679. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79680. /** @hidden */
  79681. _onPointerEnter(target: Control3D): boolean;
  79682. /** @hidden */
  79683. _onPointerOut(target: Control3D): void;
  79684. /** @hidden */
  79685. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79686. /** @hidden */
  79687. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79688. /** @hidden */
  79689. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79690. /** @hidden */
  79691. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79692. /** @hidden */
  79693. _disposeNode(): void;
  79694. /**
  79695. * Releases all associated resources
  79696. */
  79697. dispose(): void;
  79698. }
  79699. }
  79700. declare module BABYLON.GUI {
  79701. /**
  79702. * Class used as a root to all buttons
  79703. */
  79704. export class AbstractButton3D extends Control3D {
  79705. /**
  79706. * Creates a new button
  79707. * @param name defines the control name
  79708. */
  79709. constructor(name?: string);
  79710. protected _getTypeName(): string;
  79711. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79712. }
  79713. }
  79714. declare module BABYLON.GUI {
  79715. /**
  79716. * Class used to create a button in 3D
  79717. */
  79718. export class Button3D extends AbstractButton3D {
  79719. /** @hidden */
  79720. protected _currentMaterial: BABYLON.Material;
  79721. private _facadeTexture;
  79722. private _content;
  79723. private _contentResolution;
  79724. private _contentScaleRatio;
  79725. /**
  79726. * Gets or sets the texture resolution used to render content (512 by default)
  79727. */
  79728. get contentResolution(): BABYLON.int;
  79729. set contentResolution(value: BABYLON.int);
  79730. /**
  79731. * Gets or sets the texture scale ratio used to render content (2 by default)
  79732. */
  79733. get contentScaleRatio(): number;
  79734. set contentScaleRatio(value: number);
  79735. protected _disposeFacadeTexture(): void;
  79736. protected _resetContent(): void;
  79737. /**
  79738. * Creates a new button
  79739. * @param name defines the control name
  79740. */
  79741. constructor(name?: string);
  79742. /**
  79743. * Gets or sets the GUI 2D content used to display the button's facade
  79744. */
  79745. get content(): Control;
  79746. set content(value: Control);
  79747. /**
  79748. * Apply the facade texture (created from the content property).
  79749. * This function can be overloaded by child classes
  79750. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79751. */
  79752. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79753. protected _getTypeName(): string;
  79754. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79755. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79756. /**
  79757. * Releases all associated resources
  79758. */
  79759. dispose(): void;
  79760. }
  79761. }
  79762. declare module BABYLON.GUI {
  79763. /**
  79764. * Abstract class used to create a container panel deployed on the surface of a volume
  79765. */
  79766. export abstract class VolumeBasedPanel extends Container3D {
  79767. private _columns;
  79768. private _rows;
  79769. private _rowThenColum;
  79770. private _orientation;
  79771. protected _cellWidth: number;
  79772. protected _cellHeight: number;
  79773. /**
  79774. * Gets or sets the distance between elements
  79775. */
  79776. margin: number;
  79777. /**
  79778. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79779. * | Value | Type | Description |
  79780. * | ----- | ----------------------------------- | ----------- |
  79781. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79782. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79783. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79784. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79785. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79786. */
  79787. get orientation(): number;
  79788. set orientation(value: number);
  79789. /**
  79790. * Gets or sets the number of columns requested (10 by default).
  79791. * The panel will automatically compute the number of rows based on number of child controls.
  79792. */
  79793. get columns(): BABYLON.int;
  79794. set columns(value: BABYLON.int);
  79795. /**
  79796. * Gets or sets a the number of rows requested.
  79797. * The panel will automatically compute the number of columns based on number of child controls.
  79798. */
  79799. get rows(): BABYLON.int;
  79800. set rows(value: BABYLON.int);
  79801. /**
  79802. * Creates new VolumeBasedPanel
  79803. */
  79804. constructor();
  79805. protected _arrangeChildren(): void;
  79806. /** Child classes must implement this function to provide correct control positioning */
  79807. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79808. /** Child classes can implement this function to provide additional processing */
  79809. protected _finalProcessing(): void;
  79810. }
  79811. }
  79812. declare module BABYLON.GUI {
  79813. /**
  79814. * Class used to create a container panel deployed on the surface of a cylinder
  79815. */
  79816. export class CylinderPanel extends VolumeBasedPanel {
  79817. private _radius;
  79818. /**
  79819. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79820. */
  79821. get radius(): BABYLON.float;
  79822. set radius(value: BABYLON.float);
  79823. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79824. private _cylindricalMapping;
  79825. }
  79826. }
  79827. declare module BABYLON.GUI {
  79828. /** @hidden */
  79829. export var fluentVertexShader: {
  79830. name: string;
  79831. shader: string;
  79832. };
  79833. }
  79834. declare module BABYLON.GUI {
  79835. /** @hidden */
  79836. export var fluentPixelShader: {
  79837. name: string;
  79838. shader: string;
  79839. };
  79840. }
  79841. declare module BABYLON.GUI {
  79842. /** @hidden */
  79843. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79844. INNERGLOW: boolean;
  79845. BORDER: boolean;
  79846. HOVERLIGHT: boolean;
  79847. TEXTURE: boolean;
  79848. constructor();
  79849. }
  79850. /**
  79851. * Class used to render controls with fluent desgin
  79852. */
  79853. export class FluentMaterial extends BABYLON.PushMaterial {
  79854. /**
  79855. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79856. */
  79857. innerGlowColorIntensity: number;
  79858. /**
  79859. * Gets or sets the inner glow color (white by default)
  79860. */
  79861. innerGlowColor: BABYLON.Color3;
  79862. /**
  79863. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79864. */
  79865. albedoColor: BABYLON.Color3;
  79866. /**
  79867. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79868. */
  79869. renderBorders: boolean;
  79870. /**
  79871. * Gets or sets border width (default is 0.5)
  79872. */
  79873. borderWidth: number;
  79874. /**
  79875. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79876. */
  79877. edgeSmoothingValue: number;
  79878. /**
  79879. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79880. */
  79881. borderMinValue: number;
  79882. /**
  79883. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79884. */
  79885. renderHoverLight: boolean;
  79886. /**
  79887. * Gets or sets the radius used to render the hover light (default is 1.0)
  79888. */
  79889. hoverRadius: number;
  79890. /**
  79891. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79892. */
  79893. hoverColor: BABYLON.Color4;
  79894. /**
  79895. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79896. */
  79897. hoverPosition: BABYLON.Vector3;
  79898. private _albedoTexture;
  79899. /** Gets or sets the texture to use for albedo color */
  79900. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79901. /**
  79902. * Creates a new Fluent material
  79903. * @param name defines the name of the material
  79904. * @param scene defines the hosting scene
  79905. */
  79906. constructor(name: string, scene: BABYLON.Scene);
  79907. needAlphaBlending(): boolean;
  79908. needAlphaTesting(): boolean;
  79909. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79911. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79912. getActiveTextures(): BABYLON.BaseTexture[];
  79913. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79914. dispose(forceDisposeEffect?: boolean): void;
  79915. clone(name: string): FluentMaterial;
  79916. serialize(): any;
  79917. getClassName(): string;
  79918. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79919. }
  79920. }
  79921. declare module BABYLON.GUI {
  79922. /**
  79923. * Class used to create a holographic button in 3D
  79924. */
  79925. export class HolographicButton extends Button3D {
  79926. private _backPlate;
  79927. private _textPlate;
  79928. private _frontPlate;
  79929. private _text;
  79930. private _imageUrl;
  79931. private _shareMaterials;
  79932. private _frontMaterial;
  79933. private _backMaterial;
  79934. private _plateMaterial;
  79935. private _pickedPointObserver;
  79936. private _tooltipFade;
  79937. private _tooltipTextBlock;
  79938. private _tooltipTexture;
  79939. private _tooltipMesh;
  79940. private _tooltipHoverObserver;
  79941. private _tooltipOutObserver;
  79942. private _disposeTooltip;
  79943. /**
  79944. * Rendering ground id of all the mesh in the button
  79945. */
  79946. set renderingGroupId(id: number);
  79947. get renderingGroupId(): number;
  79948. /**
  79949. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79950. */
  79951. set tooltipText(text: BABYLON.Nullable<string>);
  79952. get tooltipText(): BABYLON.Nullable<string>;
  79953. /**
  79954. * Gets or sets text for the button
  79955. */
  79956. get text(): string;
  79957. set text(value: string);
  79958. /**
  79959. * Gets or sets the image url for the button
  79960. */
  79961. get imageUrl(): string;
  79962. set imageUrl(value: string);
  79963. /**
  79964. * Gets the back material used by this button
  79965. */
  79966. get backMaterial(): FluentMaterial;
  79967. /**
  79968. * Gets the front material used by this button
  79969. */
  79970. get frontMaterial(): FluentMaterial;
  79971. /**
  79972. * Gets the plate material used by this button
  79973. */
  79974. get plateMaterial(): BABYLON.StandardMaterial;
  79975. /**
  79976. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79977. */
  79978. get shareMaterials(): boolean;
  79979. /**
  79980. * Creates a new button
  79981. * @param name defines the control name
  79982. */
  79983. constructor(name?: string, shareMaterials?: boolean);
  79984. protected _getTypeName(): string;
  79985. private _rebuildContent;
  79986. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79987. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79988. private _createBackMaterial;
  79989. private _createFrontMaterial;
  79990. private _createPlateMaterial;
  79991. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79992. /**
  79993. * Releases all associated resources
  79994. */
  79995. dispose(): void;
  79996. }
  79997. }
  79998. declare module BABYLON.GUI {
  79999. /**
  80000. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80001. */
  80002. export class MeshButton3D extends Button3D {
  80003. /** @hidden */
  80004. protected _currentMesh: BABYLON.Mesh;
  80005. /**
  80006. * Creates a new 3D button based on a mesh
  80007. * @param mesh mesh to become a 3D button
  80008. * @param name defines the control name
  80009. */
  80010. constructor(mesh: BABYLON.Mesh, name?: string);
  80011. protected _getTypeName(): string;
  80012. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80013. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80014. }
  80015. }
  80016. declare module BABYLON.GUI {
  80017. /**
  80018. * Class used to create a container panel deployed on the surface of a plane
  80019. */
  80020. export class PlanePanel extends VolumeBasedPanel {
  80021. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80022. }
  80023. }
  80024. declare module BABYLON.GUI {
  80025. /**
  80026. * Class used to create a container panel where items get randomized planar mapping
  80027. */
  80028. export class ScatterPanel extends VolumeBasedPanel {
  80029. private _iteration;
  80030. /**
  80031. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80032. */
  80033. get iteration(): BABYLON.float;
  80034. set iteration(value: BABYLON.float);
  80035. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80036. private _scatterMapping;
  80037. protected _finalProcessing(): void;
  80038. }
  80039. }
  80040. declare module BABYLON.GUI {
  80041. /**
  80042. * Class used to create a container panel deployed on the surface of a sphere
  80043. */
  80044. export class SpherePanel extends VolumeBasedPanel {
  80045. private _radius;
  80046. /**
  80047. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80048. */
  80049. get radius(): BABYLON.float;
  80050. set radius(value: BABYLON.float);
  80051. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80052. private _sphericalMapping;
  80053. }
  80054. }
  80055. declare module BABYLON.GUI {
  80056. /**
  80057. * Class used to create a stack panel in 3D on XY plane
  80058. */
  80059. export class StackPanel3D extends Container3D {
  80060. private _isVertical;
  80061. /**
  80062. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80063. */
  80064. get isVertical(): boolean;
  80065. set isVertical(value: boolean);
  80066. /**
  80067. * Gets or sets the distance between elements
  80068. */
  80069. margin: number;
  80070. /**
  80071. * Creates new StackPanel
  80072. * @param isVertical
  80073. */
  80074. constructor(isVertical?: boolean);
  80075. protected _arrangeChildren(): void;
  80076. }
  80077. }
  80078. declare module BABYLON {
  80079. /**
  80080. * Configuration for glTF validation
  80081. */
  80082. export interface IGLTFValidationConfiguration {
  80083. /**
  80084. * The url of the glTF validator.
  80085. */
  80086. url: string;
  80087. }
  80088. /**
  80089. * glTF validation
  80090. */
  80091. export class GLTFValidation {
  80092. /**
  80093. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80094. */
  80095. static Configuration: IGLTFValidationConfiguration;
  80096. private static _LoadScriptPromise;
  80097. /**
  80098. * Validate a glTF asset using the glTF-Validator.
  80099. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80100. * @param rootUrl The root url for the glTF
  80101. * @param fileName The file name for the glTF
  80102. * @param getExternalResource The callback to get external resources for the glTF validator
  80103. * @returns A promise that resolves with the glTF validation results once complete
  80104. */
  80105. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80106. }
  80107. }
  80108. declare module BABYLON {
  80109. /**
  80110. * Mode that determines the coordinate system to use.
  80111. */
  80112. export enum GLTFLoaderCoordinateSystemMode {
  80113. /**
  80114. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80115. */
  80116. AUTO = 0,
  80117. /**
  80118. * Sets the useRightHandedSystem flag on the scene.
  80119. */
  80120. FORCE_RIGHT_HANDED = 1
  80121. }
  80122. /**
  80123. * Mode that determines what animations will start.
  80124. */
  80125. export enum GLTFLoaderAnimationStartMode {
  80126. /**
  80127. * No animation will start.
  80128. */
  80129. NONE = 0,
  80130. /**
  80131. * The first animation will start.
  80132. */
  80133. FIRST = 1,
  80134. /**
  80135. * All animations will start.
  80136. */
  80137. ALL = 2
  80138. }
  80139. /**
  80140. * Interface that contains the data for the glTF asset.
  80141. */
  80142. export interface IGLTFLoaderData {
  80143. /**
  80144. * The object that represents the glTF JSON.
  80145. */
  80146. json: Object;
  80147. /**
  80148. * The BIN chunk of a binary glTF.
  80149. */
  80150. bin: Nullable<IDataBuffer>;
  80151. }
  80152. /**
  80153. * Interface for extending the loader.
  80154. */
  80155. export interface IGLTFLoaderExtension {
  80156. /**
  80157. * The name of this extension.
  80158. */
  80159. readonly name: string;
  80160. /**
  80161. * Defines whether this extension is enabled.
  80162. */
  80163. enabled: boolean;
  80164. /**
  80165. * Defines the order of this extension.
  80166. * The loader sorts the extensions using these values when loading.
  80167. */
  80168. order?: number;
  80169. }
  80170. /**
  80171. * Loader state.
  80172. */
  80173. export enum GLTFLoaderState {
  80174. /**
  80175. * The asset is loading.
  80176. */
  80177. LOADING = 0,
  80178. /**
  80179. * The asset is ready for rendering.
  80180. */
  80181. READY = 1,
  80182. /**
  80183. * The asset is completely loaded.
  80184. */
  80185. COMPLETE = 2
  80186. }
  80187. /** @hidden */
  80188. export interface IImportMeshAsyncOutput {
  80189. meshes: AbstractMesh[];
  80190. particleSystems: IParticleSystem[];
  80191. skeletons: Skeleton[];
  80192. animationGroups: AnimationGroup[];
  80193. lights: Light[];
  80194. transformNodes: TransformNode[];
  80195. }
  80196. /** @hidden */
  80197. export interface IGLTFLoader extends IDisposable {
  80198. readonly state: Nullable<GLTFLoaderState>;
  80199. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80200. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80201. }
  80202. /**
  80203. * File loader for loading glTF files into a scene.
  80204. */
  80205. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80206. /** @hidden */
  80207. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80208. /** @hidden */
  80209. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80210. /**
  80211. * Raised when the asset has been parsed
  80212. */
  80213. onParsedObservable: Observable<IGLTFLoaderData>;
  80214. private _onParsedObserver;
  80215. /**
  80216. * Raised when the asset has been parsed
  80217. */
  80218. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80219. /**
  80220. * 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.
  80221. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80222. * Defaults to true.
  80223. * @hidden
  80224. */
  80225. static IncrementalLoading: boolean;
  80226. /**
  80227. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80228. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80229. * @hidden
  80230. */
  80231. static HomogeneousCoordinates: boolean;
  80232. /**
  80233. * The coordinate system mode. Defaults to AUTO.
  80234. */
  80235. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80236. /**
  80237. * The animation start mode. Defaults to FIRST.
  80238. */
  80239. animationStartMode: GLTFLoaderAnimationStartMode;
  80240. /**
  80241. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80242. */
  80243. compileMaterials: boolean;
  80244. /**
  80245. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80246. */
  80247. useClipPlane: boolean;
  80248. /**
  80249. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80250. */
  80251. compileShadowGenerators: boolean;
  80252. /**
  80253. * Defines if the Alpha blended materials are only applied as coverage.
  80254. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80255. * If true, no extra effects are applied to transparent pixels.
  80256. */
  80257. transparencyAsCoverage: boolean;
  80258. /**
  80259. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80260. * Enabling will disable offline support and glTF validator.
  80261. * Defaults to false.
  80262. */
  80263. useRangeRequests: boolean;
  80264. /**
  80265. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80266. */
  80267. createInstances: boolean;
  80268. /**
  80269. * 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.
  80270. */
  80271. alwaysComputeBoundingBox: boolean;
  80272. /**
  80273. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80274. */
  80275. loadAllMaterials: boolean;
  80276. /**
  80277. * Function called before loading a url referenced by the asset.
  80278. */
  80279. preprocessUrlAsync: (url: string) => Promise<string>;
  80280. /**
  80281. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80282. * 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, ...)
  80283. */
  80284. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80285. private _onMeshLoadedObserver;
  80286. /**
  80287. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80288. * 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, ...)
  80289. */
  80290. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80291. /**
  80292. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80293. */
  80294. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80295. private _onTextureLoadedObserver;
  80296. /**
  80297. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80298. */
  80299. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80300. /**
  80301. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80302. */
  80303. readonly onMaterialLoadedObservable: Observable<Material>;
  80304. private _onMaterialLoadedObserver;
  80305. /**
  80306. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80307. */
  80308. set onMaterialLoaded(callback: (material: Material) => void);
  80309. /**
  80310. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80311. */
  80312. readonly onCameraLoadedObservable: Observable<Camera>;
  80313. private _onCameraLoadedObserver;
  80314. /**
  80315. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80316. */
  80317. set onCameraLoaded(callback: (camera: Camera) => void);
  80318. /**
  80319. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80320. * For assets with LODs, raised when all of the LODs are complete.
  80321. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80322. */
  80323. readonly onCompleteObservable: Observable<void>;
  80324. private _onCompleteObserver;
  80325. /**
  80326. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80327. * For assets with LODs, raised when all of the LODs are complete.
  80328. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80329. */
  80330. set onComplete(callback: () => void);
  80331. /**
  80332. * Observable raised when an error occurs.
  80333. */
  80334. readonly onErrorObservable: Observable<any>;
  80335. private _onErrorObserver;
  80336. /**
  80337. * Callback raised when an error occurs.
  80338. */
  80339. set onError(callback: (reason: any) => void);
  80340. /**
  80341. * Observable raised after the loader is disposed.
  80342. */
  80343. readonly onDisposeObservable: Observable<void>;
  80344. private _onDisposeObserver;
  80345. /**
  80346. * Callback raised after the loader is disposed.
  80347. */
  80348. set onDispose(callback: () => void);
  80349. /**
  80350. * Observable raised after a loader extension is created.
  80351. * Set additional options for a loader extension in this event.
  80352. */
  80353. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80354. private _onExtensionLoadedObserver;
  80355. /**
  80356. * Callback raised after a loader extension is created.
  80357. */
  80358. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80359. /**
  80360. * Defines if the loader logging is enabled.
  80361. */
  80362. get loggingEnabled(): boolean;
  80363. set loggingEnabled(value: boolean);
  80364. /**
  80365. * Defines if the loader should capture performance counters.
  80366. */
  80367. get capturePerformanceCounters(): boolean;
  80368. set capturePerformanceCounters(value: boolean);
  80369. /**
  80370. * Defines if the loader should validate the asset.
  80371. */
  80372. validate: boolean;
  80373. /**
  80374. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80375. */
  80376. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80377. private _onValidatedObserver;
  80378. /**
  80379. * Callback raised after a loader extension is created.
  80380. */
  80381. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80382. private _loader;
  80383. private _progressCallback?;
  80384. private _requests;
  80385. private static magicBase64Encoded;
  80386. /**
  80387. * Name of the loader ("gltf")
  80388. */
  80389. name: string;
  80390. /** @hidden */
  80391. extensions: ISceneLoaderPluginExtensions;
  80392. /**
  80393. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80394. */
  80395. dispose(): void;
  80396. /** @hidden */
  80397. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80398. /** @hidden */
  80399. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80400. /** @hidden */
  80401. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80402. meshes: AbstractMesh[];
  80403. particleSystems: IParticleSystem[];
  80404. skeletons: Skeleton[];
  80405. animationGroups: AnimationGroup[];
  80406. }>;
  80407. /** @hidden */
  80408. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80409. /** @hidden */
  80410. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80411. /** @hidden */
  80412. canDirectLoad(data: string): boolean;
  80413. /** @hidden */
  80414. directLoad(scene: Scene, data: string): Promise<any>;
  80415. /**
  80416. * The callback that allows custom handling of the root url based on the response url.
  80417. * @param rootUrl the original root url
  80418. * @param responseURL the response url if available
  80419. * @returns the new root url
  80420. */
  80421. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80422. /** @hidden */
  80423. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80424. /**
  80425. * The loader state or null if the loader is not active.
  80426. */
  80427. get loaderState(): Nullable<GLTFLoaderState>;
  80428. /**
  80429. * Returns a promise that resolves when the asset is completely loaded.
  80430. * @returns a promise that resolves when the asset is completely loaded.
  80431. */
  80432. whenCompleteAsync(): Promise<void>;
  80433. /** @hidden */
  80434. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80435. /** @hidden */
  80436. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80437. private _onProgress;
  80438. private _validate;
  80439. private _getLoader;
  80440. private _parseJson;
  80441. private _unpackBinaryAsync;
  80442. private _unpackBinaryV1Async;
  80443. private _unpackBinaryV2Async;
  80444. private static _parseVersion;
  80445. private static _compareVersion;
  80446. private static readonly _logSpaces;
  80447. private _logIndentLevel;
  80448. private _loggingEnabled;
  80449. /** @hidden */
  80450. _log: (message: string) => void;
  80451. /** @hidden */
  80452. _logOpen(message: string): void;
  80453. /** @hidden */
  80454. _logClose(): void;
  80455. private _logEnabled;
  80456. private _logDisabled;
  80457. private _capturePerformanceCounters;
  80458. /** @hidden */
  80459. _startPerformanceCounter: (counterName: string) => void;
  80460. /** @hidden */
  80461. _endPerformanceCounter: (counterName: string) => void;
  80462. private _startPerformanceCounterEnabled;
  80463. private _startPerformanceCounterDisabled;
  80464. private _endPerformanceCounterEnabled;
  80465. private _endPerformanceCounterDisabled;
  80466. }
  80467. }
  80468. declare module BABYLON.GLTF1 {
  80469. /**
  80470. * Enums
  80471. * @hidden
  80472. */
  80473. export enum EComponentType {
  80474. BYTE = 5120,
  80475. UNSIGNED_BYTE = 5121,
  80476. SHORT = 5122,
  80477. UNSIGNED_SHORT = 5123,
  80478. FLOAT = 5126
  80479. }
  80480. /** @hidden */
  80481. export enum EShaderType {
  80482. FRAGMENT = 35632,
  80483. VERTEX = 35633
  80484. }
  80485. /** @hidden */
  80486. export enum EParameterType {
  80487. BYTE = 5120,
  80488. UNSIGNED_BYTE = 5121,
  80489. SHORT = 5122,
  80490. UNSIGNED_SHORT = 5123,
  80491. INT = 5124,
  80492. UNSIGNED_INT = 5125,
  80493. FLOAT = 5126,
  80494. FLOAT_VEC2 = 35664,
  80495. FLOAT_VEC3 = 35665,
  80496. FLOAT_VEC4 = 35666,
  80497. INT_VEC2 = 35667,
  80498. INT_VEC3 = 35668,
  80499. INT_VEC4 = 35669,
  80500. BOOL = 35670,
  80501. BOOL_VEC2 = 35671,
  80502. BOOL_VEC3 = 35672,
  80503. BOOL_VEC4 = 35673,
  80504. FLOAT_MAT2 = 35674,
  80505. FLOAT_MAT3 = 35675,
  80506. FLOAT_MAT4 = 35676,
  80507. SAMPLER_2D = 35678
  80508. }
  80509. /** @hidden */
  80510. export enum ETextureWrapMode {
  80511. CLAMP_TO_EDGE = 33071,
  80512. MIRRORED_REPEAT = 33648,
  80513. REPEAT = 10497
  80514. }
  80515. /** @hidden */
  80516. export enum ETextureFilterType {
  80517. NEAREST = 9728,
  80518. LINEAR = 9728,
  80519. NEAREST_MIPMAP_NEAREST = 9984,
  80520. LINEAR_MIPMAP_NEAREST = 9985,
  80521. NEAREST_MIPMAP_LINEAR = 9986,
  80522. LINEAR_MIPMAP_LINEAR = 9987
  80523. }
  80524. /** @hidden */
  80525. export enum ETextureFormat {
  80526. ALPHA = 6406,
  80527. RGB = 6407,
  80528. RGBA = 6408,
  80529. LUMINANCE = 6409,
  80530. LUMINANCE_ALPHA = 6410
  80531. }
  80532. /** @hidden */
  80533. export enum ECullingType {
  80534. FRONT = 1028,
  80535. BACK = 1029,
  80536. FRONT_AND_BACK = 1032
  80537. }
  80538. /** @hidden */
  80539. export enum EBlendingFunction {
  80540. ZERO = 0,
  80541. ONE = 1,
  80542. SRC_COLOR = 768,
  80543. ONE_MINUS_SRC_COLOR = 769,
  80544. DST_COLOR = 774,
  80545. ONE_MINUS_DST_COLOR = 775,
  80546. SRC_ALPHA = 770,
  80547. ONE_MINUS_SRC_ALPHA = 771,
  80548. DST_ALPHA = 772,
  80549. ONE_MINUS_DST_ALPHA = 773,
  80550. CONSTANT_COLOR = 32769,
  80551. ONE_MINUS_CONSTANT_COLOR = 32770,
  80552. CONSTANT_ALPHA = 32771,
  80553. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80554. SRC_ALPHA_SATURATE = 776
  80555. }
  80556. /** @hidden */
  80557. export interface IGLTFProperty {
  80558. extensions?: {
  80559. [key: string]: any;
  80560. };
  80561. extras?: Object;
  80562. }
  80563. /** @hidden */
  80564. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80565. name?: string;
  80566. }
  80567. /** @hidden */
  80568. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80569. bufferView: string;
  80570. byteOffset: number;
  80571. byteStride: number;
  80572. count: number;
  80573. type: string;
  80574. componentType: EComponentType;
  80575. max?: number[];
  80576. min?: number[];
  80577. name?: string;
  80578. }
  80579. /** @hidden */
  80580. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80581. buffer: string;
  80582. byteOffset: number;
  80583. byteLength: number;
  80584. byteStride: number;
  80585. target?: number;
  80586. }
  80587. /** @hidden */
  80588. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80589. uri: string;
  80590. byteLength?: number;
  80591. type?: string;
  80592. }
  80593. /** @hidden */
  80594. export interface IGLTFShader extends IGLTFChildRootProperty {
  80595. uri: string;
  80596. type: EShaderType;
  80597. }
  80598. /** @hidden */
  80599. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80600. attributes: string[];
  80601. fragmentShader: string;
  80602. vertexShader: string;
  80603. }
  80604. /** @hidden */
  80605. export interface IGLTFTechniqueParameter {
  80606. type: number;
  80607. count?: number;
  80608. semantic?: string;
  80609. node?: string;
  80610. value?: number | boolean | string | Array<any>;
  80611. source?: string;
  80612. babylonValue?: any;
  80613. }
  80614. /** @hidden */
  80615. export interface IGLTFTechniqueCommonProfile {
  80616. lightingModel: string;
  80617. texcoordBindings: Object;
  80618. parameters?: Array<any>;
  80619. }
  80620. /** @hidden */
  80621. export interface IGLTFTechniqueStatesFunctions {
  80622. blendColor?: number[];
  80623. blendEquationSeparate?: number[];
  80624. blendFuncSeparate?: number[];
  80625. colorMask: boolean[];
  80626. cullFace: number[];
  80627. }
  80628. /** @hidden */
  80629. export interface IGLTFTechniqueStates {
  80630. enable: number[];
  80631. functions: IGLTFTechniqueStatesFunctions;
  80632. }
  80633. /** @hidden */
  80634. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80635. parameters: {
  80636. [key: string]: IGLTFTechniqueParameter;
  80637. };
  80638. program: string;
  80639. attributes: {
  80640. [key: string]: string;
  80641. };
  80642. uniforms: {
  80643. [key: string]: string;
  80644. };
  80645. states: IGLTFTechniqueStates;
  80646. }
  80647. /** @hidden */
  80648. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80649. technique?: string;
  80650. values: string[];
  80651. }
  80652. /** @hidden */
  80653. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80654. attributes: {
  80655. [key: string]: string;
  80656. };
  80657. indices: string;
  80658. material: string;
  80659. mode?: number;
  80660. }
  80661. /** @hidden */
  80662. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80663. primitives: IGLTFMeshPrimitive[];
  80664. }
  80665. /** @hidden */
  80666. export interface IGLTFImage extends IGLTFChildRootProperty {
  80667. uri: string;
  80668. }
  80669. /** @hidden */
  80670. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80671. magFilter?: number;
  80672. minFilter?: number;
  80673. wrapS?: number;
  80674. wrapT?: number;
  80675. }
  80676. /** @hidden */
  80677. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80678. sampler: string;
  80679. source: string;
  80680. format?: ETextureFormat;
  80681. internalFormat?: ETextureFormat;
  80682. target?: number;
  80683. type?: number;
  80684. babylonTexture?: Texture;
  80685. }
  80686. /** @hidden */
  80687. export interface IGLTFAmbienLight {
  80688. color?: number[];
  80689. }
  80690. /** @hidden */
  80691. export interface IGLTFDirectionalLight {
  80692. color?: number[];
  80693. }
  80694. /** @hidden */
  80695. export interface IGLTFPointLight {
  80696. color?: number[];
  80697. constantAttenuation?: number;
  80698. linearAttenuation?: number;
  80699. quadraticAttenuation?: number;
  80700. }
  80701. /** @hidden */
  80702. export interface IGLTFSpotLight {
  80703. color?: number[];
  80704. constantAttenuation?: number;
  80705. fallOfAngle?: number;
  80706. fallOffExponent?: number;
  80707. linearAttenuation?: number;
  80708. quadraticAttenuation?: number;
  80709. }
  80710. /** @hidden */
  80711. export interface IGLTFLight extends IGLTFChildRootProperty {
  80712. type: string;
  80713. }
  80714. /** @hidden */
  80715. export interface IGLTFCameraOrthographic {
  80716. xmag: number;
  80717. ymag: number;
  80718. zfar: number;
  80719. znear: number;
  80720. }
  80721. /** @hidden */
  80722. export interface IGLTFCameraPerspective {
  80723. aspectRatio: number;
  80724. yfov: number;
  80725. zfar: number;
  80726. znear: number;
  80727. }
  80728. /** @hidden */
  80729. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80730. type: string;
  80731. }
  80732. /** @hidden */
  80733. export interface IGLTFAnimationChannelTarget {
  80734. id: string;
  80735. path: string;
  80736. }
  80737. /** @hidden */
  80738. export interface IGLTFAnimationChannel {
  80739. sampler: string;
  80740. target: IGLTFAnimationChannelTarget;
  80741. }
  80742. /** @hidden */
  80743. export interface IGLTFAnimationSampler {
  80744. input: string;
  80745. output: string;
  80746. interpolation?: string;
  80747. }
  80748. /** @hidden */
  80749. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80750. channels?: IGLTFAnimationChannel[];
  80751. parameters?: {
  80752. [key: string]: string;
  80753. };
  80754. samplers?: {
  80755. [key: string]: IGLTFAnimationSampler;
  80756. };
  80757. }
  80758. /** @hidden */
  80759. export interface IGLTFNodeInstanceSkin {
  80760. skeletons: string[];
  80761. skin: string;
  80762. meshes: string[];
  80763. }
  80764. /** @hidden */
  80765. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80766. bindShapeMatrix: number[];
  80767. inverseBindMatrices: string;
  80768. jointNames: string[];
  80769. babylonSkeleton?: Skeleton;
  80770. }
  80771. /** @hidden */
  80772. export interface IGLTFNode extends IGLTFChildRootProperty {
  80773. camera?: string;
  80774. children: string[];
  80775. skin?: string;
  80776. jointName?: string;
  80777. light?: string;
  80778. matrix: number[];
  80779. mesh?: string;
  80780. meshes?: string[];
  80781. rotation?: number[];
  80782. scale?: number[];
  80783. translation?: number[];
  80784. babylonNode?: Node;
  80785. }
  80786. /** @hidden */
  80787. export interface IGLTFScene extends IGLTFChildRootProperty {
  80788. nodes: string[];
  80789. }
  80790. /** @hidden */
  80791. export interface IGLTFRuntime {
  80792. extensions: {
  80793. [key: string]: any;
  80794. };
  80795. accessors: {
  80796. [key: string]: IGLTFAccessor;
  80797. };
  80798. buffers: {
  80799. [key: string]: IGLTFBuffer;
  80800. };
  80801. bufferViews: {
  80802. [key: string]: IGLTFBufferView;
  80803. };
  80804. meshes: {
  80805. [key: string]: IGLTFMesh;
  80806. };
  80807. lights: {
  80808. [key: string]: IGLTFLight;
  80809. };
  80810. cameras: {
  80811. [key: string]: IGLTFCamera;
  80812. };
  80813. nodes: {
  80814. [key: string]: IGLTFNode;
  80815. };
  80816. images: {
  80817. [key: string]: IGLTFImage;
  80818. };
  80819. textures: {
  80820. [key: string]: IGLTFTexture;
  80821. };
  80822. shaders: {
  80823. [key: string]: IGLTFShader;
  80824. };
  80825. programs: {
  80826. [key: string]: IGLTFProgram;
  80827. };
  80828. samplers: {
  80829. [key: string]: IGLTFSampler;
  80830. };
  80831. techniques: {
  80832. [key: string]: IGLTFTechnique;
  80833. };
  80834. materials: {
  80835. [key: string]: IGLTFMaterial;
  80836. };
  80837. animations: {
  80838. [key: string]: IGLTFAnimation;
  80839. };
  80840. skins: {
  80841. [key: string]: IGLTFSkins;
  80842. };
  80843. currentScene?: Object;
  80844. scenes: {
  80845. [key: string]: IGLTFScene;
  80846. };
  80847. extensionsUsed: string[];
  80848. extensionsRequired?: string[];
  80849. buffersCount: number;
  80850. shaderscount: number;
  80851. scene: Scene;
  80852. rootUrl: string;
  80853. loadedBufferCount: number;
  80854. loadedBufferViews: {
  80855. [name: string]: ArrayBufferView;
  80856. };
  80857. loadedShaderCount: number;
  80858. importOnlyMeshes: boolean;
  80859. importMeshesNames?: string[];
  80860. dummyNodes: Node[];
  80861. forAssetContainer: boolean;
  80862. }
  80863. /** @hidden */
  80864. export interface INodeToRoot {
  80865. bone: Bone;
  80866. node: IGLTFNode;
  80867. id: string;
  80868. }
  80869. /** @hidden */
  80870. export interface IJointNode {
  80871. node: IGLTFNode;
  80872. id: string;
  80873. }
  80874. }
  80875. declare module BABYLON.GLTF1 {
  80876. /**
  80877. * Utils functions for GLTF
  80878. * @hidden
  80879. */
  80880. export class GLTFUtils {
  80881. /**
  80882. * Sets the given "parameter" matrix
  80883. * @param scene: the Scene object
  80884. * @param source: the source node where to pick the matrix
  80885. * @param parameter: the GLTF technique parameter
  80886. * @param uniformName: the name of the shader's uniform
  80887. * @param shaderMaterial: the shader material
  80888. */
  80889. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80890. /**
  80891. * Sets the given "parameter" matrix
  80892. * @param shaderMaterial: the shader material
  80893. * @param uniform: the name of the shader's uniform
  80894. * @param value: the value of the uniform
  80895. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80896. */
  80897. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80898. /**
  80899. * Returns the wrap mode of the texture
  80900. * @param mode: the mode value
  80901. */
  80902. static GetWrapMode(mode: number): number;
  80903. /**
  80904. * Returns the byte stride giving an accessor
  80905. * @param accessor: the GLTF accessor objet
  80906. */
  80907. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80908. /**
  80909. * Returns the texture filter mode giving a mode value
  80910. * @param mode: the filter mode value
  80911. */
  80912. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80913. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80914. /**
  80915. * Returns a buffer from its accessor
  80916. * @param gltfRuntime: the GLTF runtime
  80917. * @param accessor: the GLTF accessor
  80918. */
  80919. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80920. /**
  80921. * Decodes a buffer view into a string
  80922. * @param view: the buffer view
  80923. */
  80924. static DecodeBufferToText(view: ArrayBufferView): string;
  80925. /**
  80926. * Returns the default material of gltf. Related to
  80927. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80928. * @param scene: the Babylon.js scene
  80929. */
  80930. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80931. private static _DefaultMaterial;
  80932. }
  80933. }
  80934. declare module BABYLON.GLTF1 {
  80935. /**
  80936. * Implementation of the base glTF spec
  80937. * @hidden
  80938. */
  80939. export class GLTFLoaderBase {
  80940. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80941. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80942. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80943. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80944. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80945. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80946. }
  80947. /**
  80948. * glTF V1 Loader
  80949. * @hidden
  80950. */
  80951. export class GLTFLoader implements IGLTFLoader {
  80952. static Extensions: {
  80953. [name: string]: GLTFLoaderExtension;
  80954. };
  80955. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80956. state: Nullable<GLTFLoaderState>;
  80957. dispose(): void;
  80958. private _importMeshAsync;
  80959. /**
  80960. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80961. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80962. * @param scene the scene the meshes should be added to
  80963. * @param forAssetContainer defines if the entities must be stored in the scene
  80964. * @param data gltf data containing information of the meshes in a loaded file
  80965. * @param rootUrl root url to load from
  80966. * @param onProgress event that fires when loading progress has occured
  80967. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80968. */
  80969. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80970. private _loadAsync;
  80971. /**
  80972. * Imports all objects from a loaded gltf file and adds them to the scene
  80973. * @param scene the scene the objects should be added to
  80974. * @param data gltf data containing information of the meshes in a loaded file
  80975. * @param rootUrl root url to load from
  80976. * @param onProgress event that fires when loading progress has occured
  80977. * @returns a promise which completes when objects have been loaded to the scene
  80978. */
  80979. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80980. private _loadShadersAsync;
  80981. private _loadBuffersAsync;
  80982. private _createNodes;
  80983. }
  80984. /** @hidden */
  80985. export abstract class GLTFLoaderExtension {
  80986. private _name;
  80987. constructor(name: string);
  80988. get name(): string;
  80989. /**
  80990. * Defines an override for loading the runtime
  80991. * Return true to stop further extensions from loading the runtime
  80992. */
  80993. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80994. /**
  80995. * Defines an onverride for creating gltf runtime
  80996. * Return true to stop further extensions from creating the runtime
  80997. */
  80998. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80999. /**
  81000. * Defines an override for loading buffers
  81001. * Return true to stop further extensions from loading this buffer
  81002. */
  81003. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81004. /**
  81005. * Defines an override for loading texture buffers
  81006. * Return true to stop further extensions from loading this texture data
  81007. */
  81008. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81009. /**
  81010. * Defines an override for creating textures
  81011. * Return true to stop further extensions from loading this texture
  81012. */
  81013. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81014. /**
  81015. * Defines an override for loading shader strings
  81016. * Return true to stop further extensions from loading this shader data
  81017. */
  81018. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81019. /**
  81020. * Defines an override for loading materials
  81021. * Return true to stop further extensions from loading this material
  81022. */
  81023. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81024. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81025. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81026. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81027. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81028. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81029. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81030. private static LoadTextureBufferAsync;
  81031. private static CreateTextureAsync;
  81032. private static ApplyExtensions;
  81033. }
  81034. }
  81035. declare module BABYLON.GLTF1 {
  81036. /** @hidden */
  81037. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81038. private _bin;
  81039. constructor();
  81040. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81041. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81042. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81043. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81044. }
  81045. }
  81046. declare module BABYLON.GLTF1 {
  81047. /** @hidden */
  81048. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81049. constructor();
  81050. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81051. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81052. private _loadTexture;
  81053. }
  81054. }
  81055. declare module BABYLON.GLTF2.Loader {
  81056. /**
  81057. * Loader interface with an index field.
  81058. */
  81059. export interface IArrayItem {
  81060. /**
  81061. * The index of this item in the array.
  81062. */
  81063. index: number;
  81064. }
  81065. /**
  81066. * Loader interface with additional members.
  81067. */
  81068. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81069. /** @hidden */
  81070. _data?: Promise<ArrayBufferView>;
  81071. /** @hidden */
  81072. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81073. }
  81074. /**
  81075. * Loader interface with additional members.
  81076. */
  81077. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81078. }
  81079. /** @hidden */
  81080. export interface _IAnimationSamplerData {
  81081. input: Float32Array;
  81082. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81083. output: Float32Array;
  81084. }
  81085. /**
  81086. * Loader interface with additional members.
  81087. */
  81088. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81089. /** @hidden */
  81090. _data?: Promise<_IAnimationSamplerData>;
  81091. }
  81092. /**
  81093. * Loader interface with additional members.
  81094. */
  81095. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81096. channels: IAnimationChannel[];
  81097. samplers: IAnimationSampler[];
  81098. /** @hidden */
  81099. _babylonAnimationGroup?: AnimationGroup;
  81100. }
  81101. /**
  81102. * Loader interface with additional members.
  81103. */
  81104. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81105. /** @hidden */
  81106. _data?: Promise<ArrayBufferView>;
  81107. }
  81108. /**
  81109. * Loader interface with additional members.
  81110. */
  81111. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81112. /** @hidden */
  81113. _data?: Promise<ArrayBufferView>;
  81114. /** @hidden */
  81115. _babylonBuffer?: Promise<Buffer>;
  81116. }
  81117. /**
  81118. * Loader interface with additional members.
  81119. */
  81120. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81121. }
  81122. /**
  81123. * Loader interface with additional members.
  81124. */
  81125. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81126. /** @hidden */
  81127. _data?: Promise<ArrayBufferView>;
  81128. }
  81129. /**
  81130. * Loader interface with additional members.
  81131. */
  81132. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81133. }
  81134. /**
  81135. * Loader interface with additional members.
  81136. */
  81137. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81138. }
  81139. /**
  81140. * Loader interface with additional members.
  81141. */
  81142. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81143. baseColorTexture?: ITextureInfo;
  81144. metallicRoughnessTexture?: ITextureInfo;
  81145. }
  81146. /**
  81147. * Loader interface with additional members.
  81148. */
  81149. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81150. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81151. normalTexture?: IMaterialNormalTextureInfo;
  81152. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81153. emissiveTexture?: ITextureInfo;
  81154. /** @hidden */
  81155. _data?: {
  81156. [babylonDrawMode: number]: {
  81157. babylonMaterial: Material;
  81158. babylonMeshes: AbstractMesh[];
  81159. promise: Promise<void>;
  81160. };
  81161. };
  81162. }
  81163. /**
  81164. * Loader interface with additional members.
  81165. */
  81166. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81167. primitives: IMeshPrimitive[];
  81168. }
  81169. /**
  81170. * Loader interface with additional members.
  81171. */
  81172. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81173. /** @hidden */
  81174. _instanceData?: {
  81175. babylonSourceMesh: Mesh;
  81176. promise: Promise<any>;
  81177. };
  81178. }
  81179. /**
  81180. * Loader interface with additional members.
  81181. */
  81182. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81183. /**
  81184. * The parent glTF node.
  81185. */
  81186. parent?: INode;
  81187. /** @hidden */
  81188. _babylonTransformNode?: TransformNode;
  81189. /** @hidden */
  81190. _primitiveBabylonMeshes?: AbstractMesh[];
  81191. /** @hidden */
  81192. _babylonBones?: Bone[];
  81193. /** @hidden */
  81194. _numMorphTargets?: number;
  81195. }
  81196. /** @hidden */
  81197. export interface _ISamplerData {
  81198. noMipMaps: boolean;
  81199. samplingMode: number;
  81200. wrapU: number;
  81201. wrapV: number;
  81202. }
  81203. /**
  81204. * Loader interface with additional members.
  81205. */
  81206. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81207. /** @hidden */
  81208. _data?: _ISamplerData;
  81209. }
  81210. /**
  81211. * Loader interface with additional members.
  81212. */
  81213. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81214. }
  81215. /**
  81216. * Loader interface with additional members.
  81217. */
  81218. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81219. /** @hidden */
  81220. _data?: {
  81221. babylonSkeleton: Skeleton;
  81222. promise: Promise<void>;
  81223. };
  81224. }
  81225. /**
  81226. * Loader interface with additional members.
  81227. */
  81228. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81229. }
  81230. /**
  81231. * Loader interface with additional members.
  81232. */
  81233. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81234. }
  81235. /**
  81236. * Loader interface with additional members.
  81237. */
  81238. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81239. accessors?: IAccessor[];
  81240. animations?: IAnimation[];
  81241. buffers?: IBuffer[];
  81242. bufferViews?: IBufferView[];
  81243. cameras?: ICamera[];
  81244. images?: IImage[];
  81245. materials?: IMaterial[];
  81246. meshes?: IMesh[];
  81247. nodes?: INode[];
  81248. samplers?: ISampler[];
  81249. scenes?: IScene[];
  81250. skins?: ISkin[];
  81251. textures?: ITexture[];
  81252. }
  81253. }
  81254. declare module BABYLON.GLTF2 {
  81255. /**
  81256. * Interface for a glTF loader extension.
  81257. */
  81258. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81259. /**
  81260. * Called after the loader state changes to LOADING.
  81261. */
  81262. onLoading?(): void;
  81263. /**
  81264. * Called after the loader state changes to READY.
  81265. */
  81266. onReady?(): void;
  81267. /**
  81268. * Define this method to modify the default behavior when loading scenes.
  81269. * @param context The context when loading the asset
  81270. * @param scene The glTF scene property
  81271. * @returns A promise that resolves when the load is complete or null if not handled
  81272. */
  81273. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81274. /**
  81275. * Define this method to modify the default behavior when loading nodes.
  81276. * @param context The context when loading the asset
  81277. * @param node The glTF node property
  81278. * @param assign A function called synchronously after parsing the glTF properties
  81279. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81280. */
  81281. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81282. /**
  81283. * Define this method to modify the default behavior when loading cameras.
  81284. * @param context The context when loading the asset
  81285. * @param camera The glTF camera property
  81286. * @param assign A function called synchronously after parsing the glTF properties
  81287. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81288. */
  81289. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81290. /**
  81291. * @hidden
  81292. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81293. * @param context The context when loading the asset
  81294. * @param primitive The glTF mesh primitive property
  81295. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81296. */
  81297. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81298. /**
  81299. * @hidden
  81300. * Define this method to modify the default behavior when loading data for mesh primitives.
  81301. * @param context The context when loading the asset
  81302. * @param name The mesh name when loading the asset
  81303. * @param node The glTF node when loading the asset
  81304. * @param mesh The glTF mesh when loading the asset
  81305. * @param primitive The glTF mesh primitive property
  81306. * @param assign A function called synchronously after parsing the glTF properties
  81307. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81308. */
  81309. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81310. /**
  81311. * @hidden
  81312. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81313. * @param context The context when loading the asset
  81314. * @param material The glTF material property
  81315. * @param assign A function called synchronously after parsing the glTF properties
  81316. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81317. */
  81318. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81319. /**
  81320. * Define this method to modify the default behavior when creating materials.
  81321. * @param context The context when loading the asset
  81322. * @param material The glTF material property
  81323. * @param babylonDrawMode The draw mode for the Babylon material
  81324. * @returns The Babylon material or null if not handled
  81325. */
  81326. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81327. /**
  81328. * Define this method to modify the default behavior when loading material properties.
  81329. * @param context The context when loading the asset
  81330. * @param material The glTF material property
  81331. * @param babylonMaterial The Babylon material
  81332. * @returns A promise that resolves when the load is complete or null if not handled
  81333. */
  81334. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81335. /**
  81336. * Define this method to modify the default behavior when loading texture infos.
  81337. * @param context The context when loading the asset
  81338. * @param textureInfo The glTF texture info property
  81339. * @param assign A function called synchronously after parsing the glTF properties
  81340. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81341. */
  81342. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81343. /**
  81344. * @hidden
  81345. * Define this method to modify the default behavior when loading textures.
  81346. * @param context The context when loading the asset
  81347. * @param texture The glTF texture property
  81348. * @param assign A function called synchronously after parsing the glTF properties
  81349. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81350. */
  81351. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81352. /**
  81353. * Define this method to modify the default behavior when loading animations.
  81354. * @param context The context when loading the asset
  81355. * @param animation The glTF animation property
  81356. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81357. */
  81358. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81359. /**
  81360. * @hidden
  81361. * Define this method to modify the default behavior when loading skins.
  81362. * @param context The context when loading the asset
  81363. * @param node The glTF node property
  81364. * @param skin The glTF skin property
  81365. * @returns A promise that resolves when the load is complete or null if not handled
  81366. */
  81367. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81368. /**
  81369. * @hidden
  81370. * Define this method to modify the default behavior when loading uris.
  81371. * @param context The context when loading the asset
  81372. * @param property The glTF property associated with the uri
  81373. * @param uri The uri to load
  81374. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81375. */
  81376. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81377. /**
  81378. * Define this method to modify the default behavior when loading buffer views.
  81379. * @param context The context when loading the asset
  81380. * @param bufferView The glTF buffer view property
  81381. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81382. */
  81383. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81384. /**
  81385. * Define this method to modify the default behavior when loading buffers.
  81386. * @param context The context when loading the asset
  81387. * @param buffer The glTF buffer property
  81388. * @param byteOffset The byte offset to load
  81389. * @param byteLength The byte length to load
  81390. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81391. */
  81392. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81393. }
  81394. }
  81395. declare module BABYLON.GLTF2 {
  81396. /**
  81397. * Helper class for working with arrays when loading the glTF asset
  81398. */
  81399. export class ArrayItem {
  81400. /**
  81401. * Gets an item from the given array.
  81402. * @param context The context when loading the asset
  81403. * @param array The array to get the item from
  81404. * @param index The index to the array
  81405. * @returns The array item
  81406. */
  81407. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81408. /**
  81409. * Assign an `index` field to each item of the given array.
  81410. * @param array The array of items
  81411. */
  81412. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81413. }
  81414. /**
  81415. * The glTF 2.0 loader
  81416. */
  81417. export class GLTFLoader implements IGLTFLoader {
  81418. /** @hidden */
  81419. _completePromises: Promise<any>[];
  81420. /** @hidden */
  81421. _forAssetContainer: boolean;
  81422. /** Storage */
  81423. _babylonLights: Light[];
  81424. /** @hidden */
  81425. _disableInstancedMesh: number;
  81426. private _disposed;
  81427. private _parent;
  81428. private _state;
  81429. private _extensions;
  81430. private _rootUrl;
  81431. private _fileName;
  81432. private _uniqueRootUrl;
  81433. private _gltf;
  81434. private _bin;
  81435. private _babylonScene;
  81436. private _rootBabylonMesh;
  81437. private _defaultBabylonMaterialData;
  81438. private static _RegisteredExtensions;
  81439. /**
  81440. * The default glTF sampler.
  81441. */
  81442. static readonly DefaultSampler: ISampler;
  81443. /**
  81444. * Registers a loader extension.
  81445. * @param name The name of the loader extension.
  81446. * @param factory The factory function that creates the loader extension.
  81447. */
  81448. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81449. /**
  81450. * Unregisters a loader extension.
  81451. * @param name The name of the loader extension.
  81452. * @returns A boolean indicating whether the extension has been unregistered
  81453. */
  81454. static UnregisterExtension(name: string): boolean;
  81455. /**
  81456. * The loader state.
  81457. */
  81458. get state(): Nullable<GLTFLoaderState>;
  81459. /**
  81460. * The object that represents the glTF JSON.
  81461. */
  81462. get gltf(): IGLTF;
  81463. /**
  81464. * The BIN chunk of a binary glTF.
  81465. */
  81466. get bin(): Nullable<IDataBuffer>;
  81467. /**
  81468. * The parent file loader.
  81469. */
  81470. get parent(): GLTFFileLoader;
  81471. /**
  81472. * The Babylon scene when loading the asset.
  81473. */
  81474. get babylonScene(): Scene;
  81475. /**
  81476. * The root Babylon mesh when loading the asset.
  81477. */
  81478. get rootBabylonMesh(): Mesh;
  81479. /** @hidden */
  81480. constructor(parent: GLTFFileLoader);
  81481. /** @hidden */
  81482. dispose(): void;
  81483. /** @hidden */
  81484. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81485. /** @hidden */
  81486. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81487. private _loadAsync;
  81488. private _loadData;
  81489. private _setupData;
  81490. private _loadExtensions;
  81491. private _checkExtensions;
  81492. private _setState;
  81493. private _createRootNode;
  81494. /**
  81495. * Loads a glTF scene.
  81496. * @param context The context when loading the asset
  81497. * @param scene The glTF scene property
  81498. * @returns A promise that resolves when the load is complete
  81499. */
  81500. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81501. private _forEachPrimitive;
  81502. private _getMeshes;
  81503. private _getTransformNodes;
  81504. private _getSkeletons;
  81505. private _getAnimationGroups;
  81506. private _startAnimations;
  81507. /**
  81508. * Loads a glTF node.
  81509. * @param context The context when loading the asset
  81510. * @param node The glTF node property
  81511. * @param assign A function called synchronously after parsing the glTF properties
  81512. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81513. */
  81514. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81515. private _loadMeshAsync;
  81516. /**
  81517. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81518. * @param context The context when loading the asset
  81519. * @param name The mesh name when loading the asset
  81520. * @param node The glTF node when loading the asset
  81521. * @param mesh The glTF mesh when loading the asset
  81522. * @param primitive The glTF mesh primitive property
  81523. * @param assign A function called synchronously after parsing the glTF properties
  81524. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81525. */
  81526. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81527. private _loadVertexDataAsync;
  81528. private _createMorphTargets;
  81529. private _loadMorphTargetsAsync;
  81530. private _loadMorphTargetVertexDataAsync;
  81531. private static _LoadTransform;
  81532. private _loadSkinAsync;
  81533. private _loadBones;
  81534. private _loadBone;
  81535. private _loadSkinInverseBindMatricesDataAsync;
  81536. private _updateBoneMatrices;
  81537. private _getNodeMatrix;
  81538. /**
  81539. * Loads a glTF camera.
  81540. * @param context The context when loading the asset
  81541. * @param camera The glTF camera property
  81542. * @param assign A function called synchronously after parsing the glTF properties
  81543. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81544. */
  81545. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81546. private _loadAnimationsAsync;
  81547. /**
  81548. * Loads a glTF animation.
  81549. * @param context The context when loading the asset
  81550. * @param animation The glTF animation property
  81551. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81552. */
  81553. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81554. /**
  81555. * @hidden Loads a glTF animation channel.
  81556. * @param context The context when loading the asset
  81557. * @param animationContext The context of the animation when loading the asset
  81558. * @param animation The glTF animation property
  81559. * @param channel The glTF animation channel property
  81560. * @param babylonAnimationGroup The babylon animation group property
  81561. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81562. * @returns A void promise when the channel load is complete
  81563. */
  81564. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81565. private _loadAnimationSamplerAsync;
  81566. private _loadBufferAsync;
  81567. /**
  81568. * Loads a glTF buffer view.
  81569. * @param context The context when loading the asset
  81570. * @param bufferView The glTF buffer view property
  81571. * @returns A promise that resolves with the loaded data when the load is complete
  81572. */
  81573. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81574. private _loadAccessorAsync;
  81575. /** @hidden */
  81576. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81577. private _loadIndicesAccessorAsync;
  81578. private _loadVertexBufferViewAsync;
  81579. private _loadVertexAccessorAsync;
  81580. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81581. /** @hidden */
  81582. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81583. private _createDefaultMaterial;
  81584. /**
  81585. * Creates a Babylon material from a glTF material.
  81586. * @param context The context when loading the asset
  81587. * @param material The glTF material property
  81588. * @param babylonDrawMode The draw mode for the Babylon material
  81589. * @returns The Babylon material
  81590. */
  81591. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81592. /**
  81593. * Loads properties from a glTF material into a Babylon material.
  81594. * @param context The context when loading the asset
  81595. * @param material The glTF material property
  81596. * @param babylonMaterial The Babylon material
  81597. * @returns A promise that resolves when the load is complete
  81598. */
  81599. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81600. /**
  81601. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81602. * @param context The context when loading the asset
  81603. * @param material The glTF material property
  81604. * @param babylonMaterial The Babylon material
  81605. * @returns A promise that resolves when the load is complete
  81606. */
  81607. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81608. /**
  81609. * Loads the alpha properties from a glTF material into a Babylon material.
  81610. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81611. * @param context The context when loading the asset
  81612. * @param material The glTF material property
  81613. * @param babylonMaterial The Babylon material
  81614. */
  81615. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81616. /**
  81617. * Loads a glTF texture info.
  81618. * @param context The context when loading the asset
  81619. * @param textureInfo The glTF texture info property
  81620. * @param assign A function called synchronously after parsing the glTF properties
  81621. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81622. */
  81623. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81624. /** @hidden */
  81625. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81626. /** @hidden */
  81627. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81628. private _loadSampler;
  81629. /**
  81630. * Loads a glTF image.
  81631. * @param context The context when loading the asset
  81632. * @param image The glTF image property
  81633. * @returns A promise that resolves with the loaded data when the load is complete
  81634. */
  81635. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81636. /**
  81637. * Loads a glTF uri.
  81638. * @param context The context when loading the asset
  81639. * @param property The glTF property associated with the uri
  81640. * @param uri The base64 or relative uri
  81641. * @returns A promise that resolves with the loaded data when the load is complete
  81642. */
  81643. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81644. /**
  81645. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81646. * @param babylonObject the Babylon object with metadata
  81647. * @param pointer the JSON pointer
  81648. */
  81649. static AddPointerMetadata(babylonObject: {
  81650. metadata: any;
  81651. }, pointer: string): void;
  81652. private static _GetTextureWrapMode;
  81653. private static _GetTextureSamplingMode;
  81654. private static _GetTypedArrayConstructor;
  81655. private static _GetTypedArray;
  81656. private static _GetNumComponents;
  81657. private static _ValidateUri;
  81658. /** @hidden */
  81659. static _GetDrawMode(context: string, mode: number | undefined): number;
  81660. private _compileMaterialsAsync;
  81661. private _compileShadowGeneratorsAsync;
  81662. private _forEachExtensions;
  81663. private _applyExtensions;
  81664. private _extensionsOnLoading;
  81665. private _extensionsOnReady;
  81666. private _extensionsLoadSceneAsync;
  81667. private _extensionsLoadNodeAsync;
  81668. private _extensionsLoadCameraAsync;
  81669. private _extensionsLoadVertexDataAsync;
  81670. private _extensionsLoadMeshPrimitiveAsync;
  81671. private _extensionsLoadMaterialAsync;
  81672. private _extensionsCreateMaterial;
  81673. private _extensionsLoadMaterialPropertiesAsync;
  81674. private _extensionsLoadTextureInfoAsync;
  81675. private _extensionsLoadTextureAsync;
  81676. private _extensionsLoadAnimationAsync;
  81677. private _extensionsLoadSkinAsync;
  81678. private _extensionsLoadUriAsync;
  81679. private _extensionsLoadBufferViewAsync;
  81680. private _extensionsLoadBufferAsync;
  81681. /**
  81682. * Helper method called by a loader extension to load an glTF extension.
  81683. * @param context The context when loading the asset
  81684. * @param property The glTF property to load the extension from
  81685. * @param extensionName The name of the extension to load
  81686. * @param actionAsync The action to run
  81687. * @returns The promise returned by actionAsync or null if the extension does not exist
  81688. */
  81689. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81690. /**
  81691. * Helper method called by a loader extension to load a glTF extra.
  81692. * @param context The context when loading the asset
  81693. * @param property The glTF property to load the extra from
  81694. * @param extensionName The name of the extension to load
  81695. * @param actionAsync The action to run
  81696. * @returns The promise returned by actionAsync or null if the extra does not exist
  81697. */
  81698. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81699. /**
  81700. * Checks for presence of an extension.
  81701. * @param name The name of the extension to check
  81702. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81703. */
  81704. isExtensionUsed(name: string): boolean;
  81705. /**
  81706. * Increments the indentation level and logs a message.
  81707. * @param message The message to log
  81708. */
  81709. logOpen(message: string): void;
  81710. /**
  81711. * Decrements the indentation level.
  81712. */
  81713. logClose(): void;
  81714. /**
  81715. * Logs a message
  81716. * @param message The message to log
  81717. */
  81718. log(message: string): void;
  81719. /**
  81720. * Starts a performance counter.
  81721. * @param counterName The name of the performance counter
  81722. */
  81723. startPerformanceCounter(counterName: string): void;
  81724. /**
  81725. * Ends a performance counter.
  81726. * @param counterName The name of the performance counter
  81727. */
  81728. endPerformanceCounter(counterName: string): void;
  81729. }
  81730. }
  81731. declare module BABYLON.GLTF2.Loader.Extensions {
  81732. /** @hidden */
  81733. interface IEXTLightsImageBased_LightImageBased {
  81734. _babylonTexture?: BaseTexture;
  81735. _loaded?: Promise<void>;
  81736. }
  81737. /**
  81738. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81739. */
  81740. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81741. /**
  81742. * The name of this extension.
  81743. */
  81744. readonly name: string;
  81745. /**
  81746. * Defines whether this extension is enabled.
  81747. */
  81748. enabled: boolean;
  81749. private _loader;
  81750. private _lights?;
  81751. /** @hidden */
  81752. constructor(loader: GLTFLoader);
  81753. /** @hidden */
  81754. dispose(): void;
  81755. /** @hidden */
  81756. onLoading(): void;
  81757. /** @hidden */
  81758. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81759. private _loadLightAsync;
  81760. }
  81761. }
  81762. declare module BABYLON.GLTF2.Loader.Extensions {
  81763. /**
  81764. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81765. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81766. * !!! Experimental Extension Subject to Changes !!!
  81767. */
  81768. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81769. /**
  81770. * The name of this extension.
  81771. */
  81772. readonly name: string;
  81773. /**
  81774. * Defines whether this extension is enabled.
  81775. */
  81776. enabled: boolean;
  81777. private _loader;
  81778. /** @hidden */
  81779. constructor(loader: GLTFLoader);
  81780. /** @hidden */
  81781. dispose(): void;
  81782. /** @hidden */
  81783. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81784. }
  81785. }
  81786. declare module BABYLON.GLTF2.Loader.Extensions {
  81787. /**
  81788. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81789. */
  81790. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81791. /** The name of this extension. */
  81792. readonly name: string;
  81793. /** Defines whether this extension is enabled. */
  81794. enabled: boolean;
  81795. private _loader;
  81796. /** @hidden */
  81797. constructor(loader: GLTFLoader);
  81798. /** @hidden */
  81799. dispose(): void;
  81800. /** @hidden */
  81801. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81802. }
  81803. }
  81804. declare module BABYLON.GLTF2.Loader.Extensions {
  81805. /**
  81806. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81807. */
  81808. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81809. /**
  81810. * The name of this extension.
  81811. */
  81812. readonly name: string;
  81813. /**
  81814. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81815. */
  81816. dracoCompression?: DracoCompression;
  81817. /**
  81818. * Defines whether this extension is enabled.
  81819. */
  81820. enabled: boolean;
  81821. private _loader;
  81822. /** @hidden */
  81823. constructor(loader: GLTFLoader);
  81824. /** @hidden */
  81825. dispose(): void;
  81826. /** @hidden */
  81827. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81828. }
  81829. }
  81830. declare module BABYLON.GLTF2.Loader.Extensions {
  81831. /**
  81832. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81833. */
  81834. export class KHR_lights implements IGLTFLoaderExtension {
  81835. /**
  81836. * The name of this extension.
  81837. */
  81838. readonly name: string;
  81839. /**
  81840. * Defines whether this extension is enabled.
  81841. */
  81842. enabled: boolean;
  81843. private _loader;
  81844. private _lights?;
  81845. /** @hidden */
  81846. constructor(loader: GLTFLoader);
  81847. /** @hidden */
  81848. dispose(): void;
  81849. /** @hidden */
  81850. onLoading(): void;
  81851. /** @hidden */
  81852. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81853. }
  81854. }
  81855. declare module BABYLON.GLTF2.Loader.Extensions {
  81856. /**
  81857. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81858. */
  81859. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81860. /**
  81861. * The name of this extension.
  81862. */
  81863. readonly name: string;
  81864. /**
  81865. * Defines whether this extension is enabled.
  81866. */
  81867. enabled: boolean;
  81868. /**
  81869. * Defines a number that determines the order the extensions are applied.
  81870. */
  81871. order: number;
  81872. private _loader;
  81873. /** @hidden */
  81874. constructor(loader: GLTFLoader);
  81875. /** @hidden */
  81876. dispose(): void;
  81877. /** @hidden */
  81878. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81879. private _loadSpecularGlossinessPropertiesAsync;
  81880. }
  81881. }
  81882. declare module BABYLON.GLTF2.Loader.Extensions {
  81883. /**
  81884. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81885. */
  81886. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81887. /**
  81888. * The name of this extension.
  81889. */
  81890. readonly name: string;
  81891. /**
  81892. * Defines whether this extension is enabled.
  81893. */
  81894. enabled: boolean;
  81895. /**
  81896. * Defines a number that determines the order the extensions are applied.
  81897. */
  81898. order: number;
  81899. private _loader;
  81900. /** @hidden */
  81901. constructor(loader: GLTFLoader);
  81902. /** @hidden */
  81903. dispose(): void;
  81904. /** @hidden */
  81905. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81906. private _loadUnlitPropertiesAsync;
  81907. }
  81908. }
  81909. declare module BABYLON.GLTF2.Loader.Extensions {
  81910. /**
  81911. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81912. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81913. * !!! Experimental Extension Subject to Changes !!!
  81914. */
  81915. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81916. /**
  81917. * The name of this extension.
  81918. */
  81919. readonly name: string;
  81920. /**
  81921. * Defines whether this extension is enabled.
  81922. */
  81923. enabled: boolean;
  81924. /**
  81925. * Defines a number that determines the order the extensions are applied.
  81926. */
  81927. order: number;
  81928. private _loader;
  81929. /** @hidden */
  81930. constructor(loader: GLTFLoader);
  81931. /** @hidden */
  81932. dispose(): void;
  81933. /** @hidden */
  81934. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81935. private _loadClearCoatPropertiesAsync;
  81936. }
  81937. }
  81938. declare module BABYLON.GLTF2.Loader.Extensions {
  81939. /**
  81940. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81941. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81942. * !!! Experimental Extension Subject to Changes !!!
  81943. */
  81944. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81945. /**
  81946. * The name of this extension.
  81947. */
  81948. readonly name: string;
  81949. /**
  81950. * Defines whether this extension is enabled.
  81951. */
  81952. enabled: boolean;
  81953. /**
  81954. * Defines a number that determines the order the extensions are applied.
  81955. */
  81956. order: number;
  81957. private _loader;
  81958. /** @hidden */
  81959. constructor(loader: GLTFLoader);
  81960. /** @hidden */
  81961. dispose(): void;
  81962. /** @hidden */
  81963. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81964. private _loadSheenPropertiesAsync;
  81965. }
  81966. }
  81967. declare module BABYLON.GLTF2.Loader.Extensions {
  81968. /**
  81969. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81970. * !!! Experimental Extension Subject to Changes !!!
  81971. */
  81972. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81973. /**
  81974. * The name of this extension.
  81975. */
  81976. readonly name: string;
  81977. /**
  81978. * Defines whether this extension is enabled.
  81979. */
  81980. enabled: boolean;
  81981. /**
  81982. * Defines a number that determines the order the extensions are applied.
  81983. */
  81984. order: number;
  81985. private _loader;
  81986. /** @hidden */
  81987. constructor(loader: GLTFLoader);
  81988. /** @hidden */
  81989. dispose(): void;
  81990. /** @hidden */
  81991. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81992. private _loadSpecularPropertiesAsync;
  81993. }
  81994. }
  81995. declare module BABYLON.GLTF2.Loader.Extensions {
  81996. /**
  81997. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81998. * !!! Experimental Extension Subject to Changes !!!
  81999. */
  82000. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82001. /**
  82002. * Default ior Value from the spec.
  82003. */
  82004. private static readonly _DEFAULT_IOR;
  82005. /**
  82006. * The name of this extension.
  82007. */
  82008. readonly name: string;
  82009. /**
  82010. * Defines whether this extension is enabled.
  82011. */
  82012. enabled: boolean;
  82013. /**
  82014. * Defines a number that determines the order the extensions are applied.
  82015. */
  82016. order: number;
  82017. private _loader;
  82018. /** @hidden */
  82019. constructor(loader: GLTFLoader);
  82020. /** @hidden */
  82021. dispose(): void;
  82022. /** @hidden */
  82023. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82024. private _loadIorPropertiesAsync;
  82025. }
  82026. }
  82027. declare module BABYLON.GLTF2.Loader.Extensions {
  82028. /**
  82029. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82030. * !!! Experimental Extension Subject to Changes !!!
  82031. */
  82032. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82033. /**
  82034. * The name of this extension.
  82035. */
  82036. readonly name: string;
  82037. /**
  82038. * Defines whether this extension is enabled.
  82039. */
  82040. enabled: boolean;
  82041. private _loader;
  82042. private _variants?;
  82043. /** @hidden */
  82044. constructor(loader: GLTFLoader);
  82045. /** @hidden */
  82046. dispose(): void;
  82047. /**
  82048. * Gets the list of available variant names for this asset.
  82049. * @param rootMesh The glTF root mesh
  82050. * @returns the list of all the variant names for this model
  82051. */
  82052. static GetAvailableVariants(rootMesh: Mesh): string[];
  82053. /**
  82054. * Gets the list of available variant names for this asset.
  82055. * @param rootMesh The glTF root mesh
  82056. * @returns the list of all the variant names for this model
  82057. */
  82058. getAvailableVariants(rootMesh: Mesh): string[];
  82059. /**
  82060. * Select a variant given a variant name or a list of variant names.
  82061. * @param rootMesh The glTF root mesh
  82062. * @param variantName The variant name(s) to select.
  82063. */
  82064. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82065. /**
  82066. * Select a variant given a variant name or a list of variant names.
  82067. * @param rootMesh The glTF root mesh
  82068. * @param variantName The variant name(s) to select.
  82069. */
  82070. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82071. /**
  82072. * Reset back to the original before selecting a variant.
  82073. * @param rootMesh The glTF root mesh
  82074. */
  82075. static Reset(rootMesh: Mesh): void;
  82076. /**
  82077. * Reset back to the original before selecting a variant.
  82078. * @param rootMesh The glTF root mesh
  82079. */
  82080. reset(rootMesh: Mesh): void;
  82081. /**
  82082. * Gets the last selected variant name(s) or null if original.
  82083. * @param rootMesh The glTF root mesh
  82084. * @returns The selected variant name(s).
  82085. */
  82086. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82087. /**
  82088. * Gets the last selected variant name(s) or null if original.
  82089. * @param rootMesh The glTF root mesh
  82090. * @returns The selected variant name(s).
  82091. */
  82092. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82093. private static _GetExtensionMetadata;
  82094. /** @hidden */
  82095. onLoading(): void;
  82096. /** @hidden */
  82097. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82098. }
  82099. }
  82100. declare module BABYLON.GLTF2.Loader.Extensions {
  82101. /**
  82102. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82103. * !!! Experimental Extension Subject to Changes !!!
  82104. */
  82105. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82106. /**
  82107. * The name of this extension.
  82108. */
  82109. readonly name: string;
  82110. /**
  82111. * Defines whether this extension is enabled.
  82112. */
  82113. enabled: boolean;
  82114. /**
  82115. * Defines a number that determines the order the extensions are applied.
  82116. */
  82117. order: number;
  82118. private _loader;
  82119. /** @hidden */
  82120. constructor(loader: GLTFLoader);
  82121. /** @hidden */
  82122. dispose(): void;
  82123. /** @hidden */
  82124. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82125. private _loadTransparentPropertiesAsync;
  82126. }
  82127. }
  82128. declare module BABYLON.GLTF2.Loader.Extensions {
  82129. /**
  82130. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82131. */
  82132. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82133. /**
  82134. * The name of this extension.
  82135. */
  82136. readonly name: string;
  82137. /**
  82138. * Defines whether this extension is enabled.
  82139. */
  82140. enabled: boolean;
  82141. /** @hidden */
  82142. constructor(loader: GLTFLoader);
  82143. /** @hidden */
  82144. dispose(): void;
  82145. }
  82146. }
  82147. declare module BABYLON.GLTF2.Loader.Extensions {
  82148. /**
  82149. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82150. * !!! Experimental Extension Subject to Changes !!!
  82151. */
  82152. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82153. /** The name of this extension. */
  82154. readonly name: string;
  82155. /** Defines whether this extension is enabled. */
  82156. enabled: boolean;
  82157. private _loader;
  82158. /** @hidden */
  82159. constructor(loader: GLTFLoader);
  82160. /** @hidden */
  82161. dispose(): void;
  82162. /** @hidden */
  82163. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82164. }
  82165. }
  82166. declare module BABYLON.GLTF2.Loader.Extensions {
  82167. /**
  82168. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82169. */
  82170. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82171. /**
  82172. * The name of this extension.
  82173. */
  82174. readonly name: string;
  82175. /**
  82176. * Defines whether this extension is enabled.
  82177. */
  82178. enabled: boolean;
  82179. private _loader;
  82180. /** @hidden */
  82181. constructor(loader: GLTFLoader);
  82182. /** @hidden */
  82183. dispose(): void;
  82184. /** @hidden */
  82185. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82186. }
  82187. }
  82188. declare module BABYLON.GLTF2.Loader.Extensions {
  82189. /**
  82190. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82191. * !!! Experimental Extension Subject to Changes !!!
  82192. */
  82193. export class KHR_xmp implements IGLTFLoaderExtension {
  82194. /**
  82195. * The name of this extension.
  82196. */
  82197. readonly name: string;
  82198. /**
  82199. * Defines whether this extension is enabled.
  82200. */
  82201. enabled: boolean;
  82202. /**
  82203. * Defines a number that determines the order the extensions are applied.
  82204. */
  82205. order: number;
  82206. private _loader;
  82207. /** @hidden */
  82208. constructor(loader: GLTFLoader);
  82209. /** @hidden */
  82210. dispose(): void;
  82211. /**
  82212. * Called after the loader state changes to LOADING.
  82213. */
  82214. onLoading(): void;
  82215. }
  82216. }
  82217. declare module BABYLON.GLTF2.Loader.Extensions {
  82218. /**
  82219. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82220. */
  82221. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82222. /**
  82223. * The name of this extension.
  82224. */
  82225. readonly name: string;
  82226. /**
  82227. * Defines whether this extension is enabled.
  82228. */
  82229. enabled: boolean;
  82230. private _loader;
  82231. private _clips;
  82232. private _emitters;
  82233. /** @hidden */
  82234. constructor(loader: GLTFLoader);
  82235. /** @hidden */
  82236. dispose(): void;
  82237. /** @hidden */
  82238. onLoading(): void;
  82239. /** @hidden */
  82240. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82241. /** @hidden */
  82242. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82243. /** @hidden */
  82244. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82245. private _loadClipAsync;
  82246. private _loadEmitterAsync;
  82247. private _getEventAction;
  82248. private _loadAnimationEventAsync;
  82249. }
  82250. }
  82251. declare module BABYLON.GLTF2.Loader.Extensions {
  82252. /**
  82253. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82254. */
  82255. export class MSFT_lod implements IGLTFLoaderExtension {
  82256. /**
  82257. * The name of this extension.
  82258. */
  82259. readonly name: string;
  82260. /**
  82261. * Defines whether this extension is enabled.
  82262. */
  82263. enabled: boolean;
  82264. /**
  82265. * Defines a number that determines the order the extensions are applied.
  82266. */
  82267. order: number;
  82268. /**
  82269. * Maximum number of LODs to load, starting from the lowest LOD.
  82270. */
  82271. maxLODsToLoad: number;
  82272. /**
  82273. * Observable raised when all node LODs of one level are loaded.
  82274. * The event data is the index of the loaded LOD starting from zero.
  82275. * Dispose the loader to cancel the loading of the next level of LODs.
  82276. */
  82277. onNodeLODsLoadedObservable: Observable<number>;
  82278. /**
  82279. * Observable raised when all material LODs of one level are loaded.
  82280. * The event data is the index of the loaded LOD starting from zero.
  82281. * Dispose the loader to cancel the loading of the next level of LODs.
  82282. */
  82283. onMaterialLODsLoadedObservable: Observable<number>;
  82284. private _loader;
  82285. private _bufferLODs;
  82286. private _nodeIndexLOD;
  82287. private _nodeSignalLODs;
  82288. private _nodePromiseLODs;
  82289. private _nodeBufferLODs;
  82290. private _materialIndexLOD;
  82291. private _materialSignalLODs;
  82292. private _materialPromiseLODs;
  82293. private _materialBufferLODs;
  82294. /** @hidden */
  82295. constructor(loader: GLTFLoader);
  82296. /** @hidden */
  82297. dispose(): void;
  82298. /** @hidden */
  82299. onReady(): void;
  82300. /** @hidden */
  82301. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82302. /** @hidden */
  82303. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82304. /** @hidden */
  82305. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82306. /** @hidden */
  82307. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82308. /** @hidden */
  82309. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82310. private _loadBufferLOD;
  82311. /**
  82312. * Gets an array of LOD properties from lowest to highest.
  82313. */
  82314. private _getLODs;
  82315. private _disposeTransformNode;
  82316. private _disposeMaterials;
  82317. }
  82318. }
  82319. declare module BABYLON.GLTF2.Loader.Extensions {
  82320. /** @hidden */
  82321. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82322. readonly name: string;
  82323. enabled: boolean;
  82324. private _loader;
  82325. constructor(loader: GLTFLoader);
  82326. dispose(): void;
  82327. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82328. }
  82329. }
  82330. declare module BABYLON.GLTF2.Loader.Extensions {
  82331. /** @hidden */
  82332. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82333. readonly name: string;
  82334. enabled: boolean;
  82335. private _loader;
  82336. constructor(loader: GLTFLoader);
  82337. dispose(): void;
  82338. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82339. }
  82340. }
  82341. declare module BABYLON.GLTF2.Loader.Extensions {
  82342. /**
  82343. * Store glTF extras (if present) in BJS objects' metadata
  82344. */
  82345. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82346. /**
  82347. * The name of this extension.
  82348. */
  82349. readonly name: string;
  82350. /**
  82351. * Defines whether this extension is enabled.
  82352. */
  82353. enabled: boolean;
  82354. private _loader;
  82355. private _assignExtras;
  82356. /** @hidden */
  82357. constructor(loader: GLTFLoader);
  82358. /** @hidden */
  82359. dispose(): void;
  82360. /** @hidden */
  82361. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82362. /** @hidden */
  82363. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82364. /** @hidden */
  82365. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82366. }
  82367. }
  82368. declare module BABYLON {
  82369. /**
  82370. * Class reading and parsing the MTL file bundled with the obj file.
  82371. */
  82372. export class MTLFileLoader {
  82373. /**
  82374. * Invert Y-Axis of referenced textures on load
  82375. */
  82376. static INVERT_TEXTURE_Y: boolean;
  82377. /**
  82378. * All material loaded from the mtl will be set here
  82379. */
  82380. materials: StandardMaterial[];
  82381. /**
  82382. * This function will read the mtl file and create each material described inside
  82383. * This function could be improve by adding :
  82384. * -some component missing (Ni, Tf...)
  82385. * -including the specific options available
  82386. *
  82387. * @param scene defines the scene the material will be created in
  82388. * @param data defines the mtl data to parse
  82389. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82390. * @param forAssetContainer defines if the material should be registered in the scene
  82391. */
  82392. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82393. /**
  82394. * Gets the texture for the material.
  82395. *
  82396. * If the material is imported from input file,
  82397. * We sanitize the url to ensure it takes the textre from aside the material.
  82398. *
  82399. * @param rootUrl The root url to load from
  82400. * @param value The value stored in the mtl
  82401. * @return The Texture
  82402. */
  82403. private static _getTexture;
  82404. }
  82405. }
  82406. declare module BABYLON {
  82407. /**
  82408. * Options for loading OBJ/MTL files
  82409. */
  82410. type MeshLoadOptions = {
  82411. /**
  82412. * Defines if UVs are optimized by default during load.
  82413. */
  82414. OptimizeWithUV: boolean;
  82415. /**
  82416. * Defines custom scaling of UV coordinates of loaded meshes.
  82417. */
  82418. UVScaling: Vector2;
  82419. /**
  82420. * Invert model on y-axis (does a model scaling inversion)
  82421. */
  82422. InvertY: boolean;
  82423. /**
  82424. * Invert Y-Axis of referenced textures on load
  82425. */
  82426. InvertTextureY: boolean;
  82427. /**
  82428. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82429. */
  82430. ImportVertexColors: boolean;
  82431. /**
  82432. * Compute the normals for the model, even if normals are present in the file.
  82433. */
  82434. ComputeNormals: boolean;
  82435. /**
  82436. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82437. */
  82438. SkipMaterials: boolean;
  82439. /**
  82440. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82441. */
  82442. MaterialLoadingFailsSilently: boolean;
  82443. };
  82444. /**
  82445. * OBJ file type loader.
  82446. * This is a babylon scene loader plugin.
  82447. */
  82448. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82449. /**
  82450. * Defines if UVs are optimized by default during load.
  82451. */
  82452. static OPTIMIZE_WITH_UV: boolean;
  82453. /**
  82454. * Invert model on y-axis (does a model scaling inversion)
  82455. */
  82456. static INVERT_Y: boolean;
  82457. /**
  82458. * Invert Y-Axis of referenced textures on load
  82459. */
  82460. static get INVERT_TEXTURE_Y(): boolean;
  82461. static set INVERT_TEXTURE_Y(value: boolean);
  82462. /**
  82463. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82464. */
  82465. static IMPORT_VERTEX_COLORS: boolean;
  82466. /**
  82467. * Compute the normals for the model, even if normals are present in the file.
  82468. */
  82469. static COMPUTE_NORMALS: boolean;
  82470. /**
  82471. * Defines custom scaling of UV coordinates of loaded meshes.
  82472. */
  82473. static UV_SCALING: Vector2;
  82474. /**
  82475. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82476. */
  82477. static SKIP_MATERIALS: boolean;
  82478. /**
  82479. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82480. *
  82481. * Defaults to true for backwards compatibility.
  82482. */
  82483. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82484. /**
  82485. * Defines the name of the plugin.
  82486. */
  82487. name: string;
  82488. /**
  82489. * Defines the extension the plugin is able to load.
  82490. */
  82491. extensions: string;
  82492. /** @hidden */
  82493. obj: RegExp;
  82494. /** @hidden */
  82495. group: RegExp;
  82496. /** @hidden */
  82497. mtllib: RegExp;
  82498. /** @hidden */
  82499. usemtl: RegExp;
  82500. /** @hidden */
  82501. smooth: RegExp;
  82502. /** @hidden */
  82503. vertexPattern: RegExp;
  82504. /** @hidden */
  82505. normalPattern: RegExp;
  82506. /** @hidden */
  82507. uvPattern: RegExp;
  82508. /** @hidden */
  82509. facePattern1: RegExp;
  82510. /** @hidden */
  82511. facePattern2: RegExp;
  82512. /** @hidden */
  82513. facePattern3: RegExp;
  82514. /** @hidden */
  82515. facePattern4: RegExp;
  82516. /** @hidden */
  82517. facePattern5: RegExp;
  82518. private _forAssetContainer;
  82519. private _meshLoadOptions;
  82520. /**
  82521. * Creates loader for .OBJ files
  82522. *
  82523. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82524. */
  82525. constructor(meshLoadOptions?: MeshLoadOptions);
  82526. private static get currentMeshLoadOptions();
  82527. /**
  82528. * Calls synchronously the MTL file attached to this obj.
  82529. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82530. * Without this function materials are not displayed in the first frame (but displayed after).
  82531. * In consequence it is impossible to get material information in your HTML file
  82532. *
  82533. * @param url The URL of the MTL file
  82534. * @param rootUrl
  82535. * @param onSuccess Callback function to be called when the MTL file is loaded
  82536. * @private
  82537. */
  82538. private _loadMTL;
  82539. /**
  82540. * Instantiates a OBJ file loader plugin.
  82541. * @returns the created plugin
  82542. */
  82543. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82544. /**
  82545. * If the data string can be loaded directly.
  82546. *
  82547. * @param data string containing the file data
  82548. * @returns if the data can be loaded directly
  82549. */
  82550. canDirectLoad(data: string): boolean;
  82551. /**
  82552. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82553. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82554. * @param scene the scene the meshes should be added to
  82555. * @param data the OBJ data to load
  82556. * @param rootUrl root url to load from
  82557. * @param onProgress event that fires when loading progress has occured
  82558. * @param fileName Defines the name of the file to load
  82559. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82560. */
  82561. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82562. meshes: AbstractMesh[];
  82563. particleSystems: IParticleSystem[];
  82564. skeletons: Skeleton[];
  82565. animationGroups: AnimationGroup[];
  82566. }>;
  82567. /**
  82568. * Imports all objects from the loaded OBJ data and adds them to the scene
  82569. * @param scene the scene the objects should be added to
  82570. * @param data the OBJ data to load
  82571. * @param rootUrl root url to load from
  82572. * @param onProgress event that fires when loading progress has occured
  82573. * @param fileName Defines the name of the file to load
  82574. * @returns a promise which completes when objects have been loaded to the scene
  82575. */
  82576. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82577. /**
  82578. * Load into an asset container.
  82579. * @param scene The scene to load into
  82580. * @param data The data to import
  82581. * @param rootUrl The root url for scene and resources
  82582. * @param onProgress The callback when the load progresses
  82583. * @param fileName Defines the name of the file to load
  82584. * @returns The loaded asset container
  82585. */
  82586. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82587. /**
  82588. * Read the OBJ file and create an Array of meshes.
  82589. * Each mesh contains all information given by the OBJ and the MTL file.
  82590. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82591. *
  82592. * @param meshesNames
  82593. * @param scene Scene The scene where are displayed the data
  82594. * @param data String The content of the obj file
  82595. * @param rootUrl String The path to the folder
  82596. * @returns Array<AbstractMesh>
  82597. * @private
  82598. */
  82599. private _parseSolid;
  82600. }
  82601. }
  82602. declare module BABYLON {
  82603. /**
  82604. * STL file type loader.
  82605. * This is a babylon scene loader plugin.
  82606. */
  82607. export class STLFileLoader implements ISceneLoaderPlugin {
  82608. /** @hidden */
  82609. solidPattern: RegExp;
  82610. /** @hidden */
  82611. facetsPattern: RegExp;
  82612. /** @hidden */
  82613. normalPattern: RegExp;
  82614. /** @hidden */
  82615. vertexPattern: RegExp;
  82616. /**
  82617. * Defines the name of the plugin.
  82618. */
  82619. name: string;
  82620. /**
  82621. * Defines the extensions the stl loader is able to load.
  82622. * force data to come in as an ArrayBuffer
  82623. * we'll convert to string if it looks like it's an ASCII .stl
  82624. */
  82625. extensions: ISceneLoaderPluginExtensions;
  82626. /**
  82627. * Import meshes into a scene.
  82628. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82629. * @param scene The scene to import into
  82630. * @param data The data to import
  82631. * @param rootUrl The root url for scene and resources
  82632. * @param meshes The meshes array to import into
  82633. * @param particleSystems The particle systems array to import into
  82634. * @param skeletons The skeletons array to import into
  82635. * @param onError The callback when import fails
  82636. * @returns True if successful or false otherwise
  82637. */
  82638. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82639. /**
  82640. * Load into a scene.
  82641. * @param scene The scene to load into
  82642. * @param data The data to import
  82643. * @param rootUrl The root url for scene and resources
  82644. * @param onError The callback when import fails
  82645. * @returns true if successful or false otherwise
  82646. */
  82647. load(scene: Scene, data: any, rootUrl: string): boolean;
  82648. /**
  82649. * Load into an asset container.
  82650. * @param scene The scene to load into
  82651. * @param data The data to import
  82652. * @param rootUrl The root url for scene and resources
  82653. * @param onError The callback when import fails
  82654. * @returns The loaded asset container
  82655. */
  82656. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82657. private _isBinary;
  82658. private _parseBinary;
  82659. private _parseASCII;
  82660. }
  82661. }
  82662. declare module BABYLON {
  82663. /**
  82664. * Class for generating OBJ data from a Babylon scene.
  82665. */
  82666. export class OBJExport {
  82667. /**
  82668. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82669. * @param mesh defines the list of meshes to serialize
  82670. * @param materials defines if materials should be exported
  82671. * @param matlibname defines the name of the associated mtl file
  82672. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82673. * @returns the OBJ content
  82674. */
  82675. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82676. /**
  82677. * Exports the material(s) of a mesh in .MTL file format (text)
  82678. * @param mesh defines the mesh to extract the material from
  82679. * @returns the mtl content
  82680. */
  82681. static MTL(mesh: Mesh): string;
  82682. }
  82683. }
  82684. declare module BABYLON {
  82685. /** @hidden */
  82686. export var __IGLTFExporterExtension: number;
  82687. /**
  82688. * Interface for extending the exporter
  82689. * @hidden
  82690. */
  82691. export interface IGLTFExporterExtension {
  82692. /**
  82693. * The name of this extension
  82694. */
  82695. readonly name: string;
  82696. /**
  82697. * Defines whether this extension is enabled
  82698. */
  82699. enabled: boolean;
  82700. /**
  82701. * Defines whether this extension is required
  82702. */
  82703. required: boolean;
  82704. }
  82705. }
  82706. declare module BABYLON.GLTF2.Exporter {
  82707. /** @hidden */
  82708. export var __IGLTFExporterExtensionV2: number;
  82709. /**
  82710. * Interface for a glTF exporter extension
  82711. * @hidden
  82712. */
  82713. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82714. /**
  82715. * Define this method to modify the default behavior before exporting a texture
  82716. * @param context The context when loading the asset
  82717. * @param babylonTexture The Babylon.js texture
  82718. * @param mimeType The mime-type of the generated image
  82719. * @returns A promise that resolves with the exported texture
  82720. */
  82721. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82722. /**
  82723. * Define this method to get notified when a texture info is created
  82724. * @param context The context when loading the asset
  82725. * @param textureInfo The glTF texture info
  82726. * @param babylonTexture The Babylon.js texture
  82727. */
  82728. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82729. /**
  82730. * Define this method to modify the default behavior when exporting texture info
  82731. * @param context The context when loading the asset
  82732. * @param meshPrimitive glTF mesh primitive
  82733. * @param babylonSubMesh Babylon submesh
  82734. * @param binaryWriter glTF serializer binary writer instance
  82735. * @returns nullable IMeshPrimitive promise
  82736. */
  82737. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82738. /**
  82739. * Define this method to modify the default behavior when exporting a node
  82740. * @param context The context when exporting the node
  82741. * @param node glTF node
  82742. * @param babylonNode BabylonJS node
  82743. * @returns nullable INode promise
  82744. */
  82745. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82746. [key: number]: number;
  82747. }): Promise<Nullable<INode>>;
  82748. /**
  82749. * Define this method to modify the default behavior when exporting a material
  82750. * @param material glTF material
  82751. * @param babylonMaterial BabylonJS material
  82752. * @returns nullable IMaterial promise
  82753. */
  82754. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82755. /**
  82756. * Define this method to return additional textures to export from a material
  82757. * @param material glTF material
  82758. * @param babylonMaterial BabylonJS material
  82759. * @returns List of textures
  82760. */
  82761. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82762. /** Gets a boolean indicating that this extension was used */
  82763. wasUsed: boolean;
  82764. /** Gets a boolean indicating that this extension is required for the file to work */
  82765. required: boolean;
  82766. /**
  82767. * Called after the exporter state changes to EXPORTING
  82768. */
  82769. onExporting?(): void;
  82770. }
  82771. }
  82772. declare module BABYLON.GLTF2.Exporter {
  82773. /**
  82774. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82775. * @hidden
  82776. */
  82777. export class _GLTFMaterialExporter {
  82778. /**
  82779. * Represents the dielectric specular values for R, G and B
  82780. */
  82781. private static readonly _DielectricSpecular;
  82782. /**
  82783. * Allows the maximum specular power to be defined for material calculations
  82784. */
  82785. private static readonly _MaxSpecularPower;
  82786. /**
  82787. * Mapping to store textures
  82788. */
  82789. private _textureMap;
  82790. /**
  82791. * Numeric tolerance value
  82792. */
  82793. private static readonly _Epsilon;
  82794. /**
  82795. * Reference to the glTF Exporter
  82796. */
  82797. private _exporter;
  82798. constructor(exporter: _Exporter);
  82799. /**
  82800. * Specifies if two colors are approximately equal in value
  82801. * @param color1 first color to compare to
  82802. * @param color2 second color to compare to
  82803. * @param epsilon threshold value
  82804. */
  82805. private static FuzzyEquals;
  82806. /**
  82807. * Gets the materials from a Babylon scene and converts them to glTF materials
  82808. * @param scene babylonjs scene
  82809. * @param mimeType texture mime type
  82810. * @param images array of images
  82811. * @param textures array of textures
  82812. * @param materials array of materials
  82813. * @param imageData mapping of texture names to base64 textures
  82814. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82815. */
  82816. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82817. /**
  82818. * Makes a copy of the glTF material without the texture parameters
  82819. * @param originalMaterial original glTF material
  82820. * @returns glTF material without texture parameters
  82821. */
  82822. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82823. /**
  82824. * Specifies if the material has any texture parameters present
  82825. * @param material glTF Material
  82826. * @returns boolean specifying if texture parameters are present
  82827. */
  82828. _hasTexturesPresent(material: IMaterial): boolean;
  82829. /**
  82830. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82831. * @param babylonStandardMaterial
  82832. * @returns glTF Metallic Roughness Material representation
  82833. */
  82834. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82835. /**
  82836. * Computes the metallic factor
  82837. * @param diffuse diffused value
  82838. * @param specular specular value
  82839. * @param oneMinusSpecularStrength one minus the specular strength
  82840. * @returns metallic value
  82841. */
  82842. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82843. /**
  82844. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82845. * @param glTFMaterial glTF material
  82846. * @param babylonMaterial Babylon material
  82847. */
  82848. private static _SetAlphaMode;
  82849. /**
  82850. * Converts a Babylon Standard Material to a glTF Material
  82851. * @param babylonStandardMaterial BJS Standard Material
  82852. * @param mimeType mime type to use for the textures
  82853. * @param images array of glTF image interfaces
  82854. * @param textures array of glTF texture interfaces
  82855. * @param materials array of glTF material interfaces
  82856. * @param imageData map of image file name to data
  82857. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82858. */
  82859. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82860. private _finishMaterial;
  82861. /**
  82862. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82863. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82864. * @param mimeType mime type to use for the textures
  82865. * @param images array of glTF image interfaces
  82866. * @param textures array of glTF texture interfaces
  82867. * @param materials array of glTF material interfaces
  82868. * @param imageData map of image file name to data
  82869. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82870. */
  82871. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82872. /**
  82873. * Converts an image typed array buffer to a base64 image
  82874. * @param buffer typed array buffer
  82875. * @param width width of the image
  82876. * @param height height of the image
  82877. * @param mimeType mimetype of the image
  82878. * @returns base64 image string
  82879. */
  82880. private _createBase64FromCanvasAsync;
  82881. /**
  82882. * Generates a white texture based on the specified width and height
  82883. * @param width width of the texture in pixels
  82884. * @param height height of the texture in pixels
  82885. * @param scene babylonjs scene
  82886. * @returns white texture
  82887. */
  82888. private _createWhiteTexture;
  82889. /**
  82890. * 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
  82891. * @param texture1 first texture to resize
  82892. * @param texture2 second texture to resize
  82893. * @param scene babylonjs scene
  82894. * @returns resized textures or null
  82895. */
  82896. private _resizeTexturesToSameDimensions;
  82897. /**
  82898. * Converts an array of pixels to a Float32Array
  82899. * Throws an error if the pixel format is not supported
  82900. * @param pixels - array buffer containing pixel values
  82901. * @returns Float32 of pixels
  82902. */
  82903. private _convertPixelArrayToFloat32;
  82904. /**
  82905. * Convert Specular Glossiness Textures to Metallic Roughness
  82906. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82907. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82908. * @param diffuseTexture texture used to store diffuse information
  82909. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82910. * @param factors specular glossiness material factors
  82911. * @param mimeType the mime type to use for the texture
  82912. * @returns pbr metallic roughness interface or null
  82913. */
  82914. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82915. /**
  82916. * Converts specular glossiness material properties to metallic roughness
  82917. * @param specularGlossiness interface with specular glossiness material properties
  82918. * @returns interface with metallic roughness material properties
  82919. */
  82920. private _convertSpecularGlossinessToMetallicRoughness;
  82921. /**
  82922. * Calculates the surface reflectance, independent of lighting conditions
  82923. * @param color Color source to calculate brightness from
  82924. * @returns number representing the perceived brightness, or zero if color is undefined
  82925. */
  82926. private _getPerceivedBrightness;
  82927. /**
  82928. * Returns the maximum color component value
  82929. * @param color
  82930. * @returns maximum color component value, or zero if color is null or undefined
  82931. */
  82932. private _getMaxComponent;
  82933. /**
  82934. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82935. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82936. * @param mimeType mime type to use for the textures
  82937. * @param images array of glTF image interfaces
  82938. * @param textures array of glTF texture interfaces
  82939. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82940. * @param imageData map of image file name to data
  82941. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82942. * @returns glTF PBR Metallic Roughness factors
  82943. */
  82944. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82945. private _getGLTFTextureSampler;
  82946. private _getGLTFTextureWrapMode;
  82947. private _getGLTFTextureWrapModesSampler;
  82948. /**
  82949. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82950. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82951. * @param mimeType mime type to use for the textures
  82952. * @param images array of glTF image interfaces
  82953. * @param textures array of glTF texture interfaces
  82954. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82955. * @param imageData map of image file name to data
  82956. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82957. * @returns glTF PBR Metallic Roughness factors
  82958. */
  82959. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82960. /**
  82961. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82962. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82963. * @param mimeType mime type to use for the textures
  82964. * @param images array of glTF image interfaces
  82965. * @param textures array of glTF texture interfaces
  82966. * @param materials array of glTF material interfaces
  82967. * @param imageData map of image file name to data
  82968. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82969. */
  82970. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82971. private setMetallicRoughnessPbrMaterial;
  82972. private getPixelsFromTexture;
  82973. /**
  82974. * Extracts a texture from a Babylon texture into file data and glTF data
  82975. * @param babylonTexture Babylon texture to extract
  82976. * @param mimeType Mime Type of the babylonTexture
  82977. * @return glTF texture info, or null if the texture format is not supported
  82978. */
  82979. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82980. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82981. /**
  82982. * Builds a texture from base64 string
  82983. * @param base64Texture base64 texture string
  82984. * @param baseTextureName Name to use for the texture
  82985. * @param mimeType image mime type for the texture
  82986. * @param images array of images
  82987. * @param textures array of textures
  82988. * @param imageData map of image data
  82989. * @returns glTF texture info, or null if the texture format is not supported
  82990. */
  82991. private _getTextureInfoFromBase64;
  82992. }
  82993. }
  82994. declare module BABYLON {
  82995. /**
  82996. * Class for holding and downloading glTF file data
  82997. */
  82998. export class GLTFData {
  82999. /**
  83000. * Object which contains the file name as the key and its data as the value
  83001. */
  83002. glTFFiles: {
  83003. [fileName: string]: string | Blob;
  83004. };
  83005. /**
  83006. * Initializes the glTF file object
  83007. */
  83008. constructor();
  83009. /**
  83010. * Downloads the glTF data as files based on their names and data
  83011. */
  83012. downloadFiles(): void;
  83013. }
  83014. }
  83015. declare module BABYLON {
  83016. /**
  83017. * Holds a collection of exporter options and parameters
  83018. */
  83019. export interface IExportOptions {
  83020. /**
  83021. * Function which indicates whether a babylon node should be exported or not
  83022. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83023. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83024. */
  83025. shouldExportNode?(node: Node): boolean;
  83026. /**
  83027. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83028. * @param metadata source metadata to read from
  83029. * @returns the data to store to glTF node extras
  83030. */
  83031. metadataSelector?(metadata: any): any;
  83032. /**
  83033. * The sample rate to bake animation curves
  83034. */
  83035. animationSampleRate?: number;
  83036. /**
  83037. * Begin serialization without waiting for the scene to be ready
  83038. */
  83039. exportWithoutWaitingForScene?: boolean;
  83040. /**
  83041. * Indicates if coordinate system swapping root nodes should be included in export
  83042. */
  83043. includeCoordinateSystemConversionNodes?: boolean;
  83044. }
  83045. /**
  83046. * Class for generating glTF data from a Babylon scene.
  83047. */
  83048. export class GLTF2Export {
  83049. /**
  83050. * Exports the geometry of the scene to .gltf file format asynchronously
  83051. * @param scene Babylon scene with scene hierarchy information
  83052. * @param filePrefix File prefix to use when generating the glTF file
  83053. * @param options Exporter options
  83054. * @returns Returns an object with a .gltf file and associates texture names
  83055. * as keys and their data and paths as values
  83056. */
  83057. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83058. private static _PreExportAsync;
  83059. private static _PostExportAsync;
  83060. /**
  83061. * Exports the geometry of the scene to .glb file format asychronously
  83062. * @param scene Babylon scene with scene hierarchy information
  83063. * @param filePrefix File prefix to use when generating glb file
  83064. * @param options Exporter options
  83065. * @returns Returns an object with a .glb filename as key and data as value
  83066. */
  83067. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83068. }
  83069. }
  83070. declare module BABYLON.GLTF2.Exporter {
  83071. /**
  83072. * @hidden
  83073. */
  83074. export class _GLTFUtilities {
  83075. /**
  83076. * Creates a buffer view based on the supplied arguments
  83077. * @param bufferIndex index value of the specified buffer
  83078. * @param byteOffset byte offset value
  83079. * @param byteLength byte length of the bufferView
  83080. * @param byteStride byte distance between conequential elements
  83081. * @param name name of the buffer view
  83082. * @returns bufferView for glTF
  83083. */
  83084. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83085. /**
  83086. * Creates an accessor based on the supplied arguments
  83087. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83088. * @param name The name of the accessor
  83089. * @param type The type of the accessor
  83090. * @param componentType The datatype of components in the attribute
  83091. * @param count The number of attributes referenced by this accessor
  83092. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83093. * @param min Minimum value of each component in this attribute
  83094. * @param max Maximum value of each component in this attribute
  83095. * @returns accessor for glTF
  83096. */
  83097. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83098. /**
  83099. * Calculates the minimum and maximum values of an array of position floats
  83100. * @param positions Positions array of a mesh
  83101. * @param vertexStart Starting vertex offset to calculate min and max values
  83102. * @param vertexCount Number of vertices to check for min and max values
  83103. * @returns min number array and max number array
  83104. */
  83105. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83106. min: number[];
  83107. max: number[];
  83108. };
  83109. /**
  83110. * Converts a new right-handed Vector3
  83111. * @param vector vector3 array
  83112. * @returns right-handed Vector3
  83113. */
  83114. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83115. /**
  83116. * Converts a Vector3 to right-handed
  83117. * @param vector Vector3 to convert to right-handed
  83118. */
  83119. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83120. /**
  83121. * Converts a three element number array to right-handed
  83122. * @param vector number array to convert to right-handed
  83123. */
  83124. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83125. /**
  83126. * Converts a new right-handed Vector3
  83127. * @param vector vector3 array
  83128. * @returns right-handed Vector3
  83129. */
  83130. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83131. /**
  83132. * Converts a Vector3 to right-handed
  83133. * @param vector Vector3 to convert to right-handed
  83134. */
  83135. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83136. /**
  83137. * Converts a three element number array to right-handed
  83138. * @param vector number array to convert to right-handed
  83139. */
  83140. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83141. /**
  83142. * Converts a Vector4 to right-handed
  83143. * @param vector Vector4 to convert to right-handed
  83144. */
  83145. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83146. /**
  83147. * Converts a Vector4 to right-handed
  83148. * @param vector Vector4 to convert to right-handed
  83149. */
  83150. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83151. /**
  83152. * Converts a Quaternion to right-handed
  83153. * @param quaternion Source quaternion to convert to right-handed
  83154. */
  83155. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83156. /**
  83157. * Converts a Quaternion to right-handed
  83158. * @param quaternion Source quaternion to convert to right-handed
  83159. */
  83160. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83161. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83162. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83163. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83164. }
  83165. }
  83166. declare module BABYLON.GLTF2.Exporter {
  83167. /**
  83168. * Converts Babylon Scene into glTF 2.0.
  83169. * @hidden
  83170. */
  83171. export class _Exporter {
  83172. /**
  83173. * Stores the glTF to export
  83174. */
  83175. _glTF: IGLTF;
  83176. /**
  83177. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83178. */
  83179. _bufferViews: IBufferView[];
  83180. /**
  83181. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83182. */
  83183. _accessors: IAccessor[];
  83184. /**
  83185. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83186. */
  83187. _nodes: INode[];
  83188. /**
  83189. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83190. */
  83191. private _scenes;
  83192. /**
  83193. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83194. */
  83195. private _meshes;
  83196. /**
  83197. * Stores all the generated material information, which represents the appearance of each primitive
  83198. */
  83199. _materials: IMaterial[];
  83200. _materialMap: {
  83201. [materialID: number]: number;
  83202. };
  83203. /**
  83204. * Stores all the generated texture information, which is referenced by glTF materials
  83205. */
  83206. _textures: ITexture[];
  83207. /**
  83208. * Stores all the generated image information, which is referenced by glTF textures
  83209. */
  83210. _images: IImage[];
  83211. /**
  83212. * Stores all the texture samplers
  83213. */
  83214. _samplers: ISampler[];
  83215. /**
  83216. * Stores all the generated glTF skins
  83217. */
  83218. _skins: ISkin[];
  83219. /**
  83220. * Stores all the generated animation samplers, which is referenced by glTF animations
  83221. */
  83222. /**
  83223. * Stores the animations for glTF models
  83224. */
  83225. private _animations;
  83226. /**
  83227. * Stores the total amount of bytes stored in the glTF buffer
  83228. */
  83229. private _totalByteLength;
  83230. /**
  83231. * Stores a reference to the Babylon scene containing the source geometry and material information
  83232. */
  83233. _babylonScene: Scene;
  83234. /**
  83235. * Stores a map of the image data, where the key is the file name and the value
  83236. * is the image data
  83237. */
  83238. _imageData: {
  83239. [fileName: string]: {
  83240. data: Uint8Array;
  83241. mimeType: ImageMimeType;
  83242. };
  83243. };
  83244. /**
  83245. * Stores a map of the unique id of a node to its index in the node array
  83246. */
  83247. _nodeMap: {
  83248. [key: number]: number;
  83249. };
  83250. /**
  83251. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83252. */
  83253. _convertToRightHandedSystem: boolean;
  83254. /**
  83255. * Specifies if a Babylon node should be converted to right-handed on export
  83256. */
  83257. _convertToRightHandedSystemMap: {
  83258. [nodeId: number]: boolean;
  83259. };
  83260. _includeCoordinateSystemConversionNodes: boolean;
  83261. /**
  83262. * Baked animation sample rate
  83263. */
  83264. private _animationSampleRate;
  83265. private _options;
  83266. private _localEngine;
  83267. _glTFMaterialExporter: _GLTFMaterialExporter;
  83268. private _extensions;
  83269. private static _ExtensionNames;
  83270. private static _ExtensionFactories;
  83271. private _applyExtension;
  83272. private _applyExtensions;
  83273. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83274. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83275. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83276. [key: number]: number;
  83277. }): Promise<Nullable<INode>>;
  83278. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83279. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83280. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83281. private _forEachExtensions;
  83282. private _extensionsOnExporting;
  83283. /**
  83284. * Load glTF serializer extensions
  83285. */
  83286. private _loadExtensions;
  83287. /**
  83288. * Creates a glTF Exporter instance, which can accept optional exporter options
  83289. * @param babylonScene Babylon scene object
  83290. * @param options Options to modify the behavior of the exporter
  83291. */
  83292. constructor(babylonScene: Scene, options?: IExportOptions);
  83293. dispose(): void;
  83294. /**
  83295. * Registers a glTF exporter extension
  83296. * @param name Name of the extension to export
  83297. * @param factory The factory function that creates the exporter extension
  83298. */
  83299. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83300. /**
  83301. * Un-registers an exporter extension
  83302. * @param name The name fo the exporter extension
  83303. * @returns A boolean indicating whether the extension has been un-registered
  83304. */
  83305. static UnregisterExtension(name: string): boolean;
  83306. /**
  83307. * Lazy load a local engine
  83308. */
  83309. _getLocalEngine(): Engine;
  83310. private reorderIndicesBasedOnPrimitiveMode;
  83311. /**
  83312. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83313. * clock-wise during export to glTF
  83314. * @param submesh BabylonJS submesh
  83315. * @param primitiveMode Primitive mode of the mesh
  83316. * @param sideOrientation the winding order of the submesh
  83317. * @param vertexBufferKind The type of vertex attribute
  83318. * @param meshAttributeArray The vertex attribute data
  83319. * @param byteOffset The offset to the binary data
  83320. * @param binaryWriter The binary data for the glTF file
  83321. * @param convertToRightHandedSystem Converts the values to right-handed
  83322. */
  83323. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83324. /**
  83325. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83326. * clock-wise during export to glTF
  83327. * @param submesh BabylonJS submesh
  83328. * @param primitiveMode Primitive mode of the mesh
  83329. * @param sideOrientation the winding order of the submesh
  83330. * @param vertexBufferKind The type of vertex attribute
  83331. * @param meshAttributeArray The vertex attribute data
  83332. * @param byteOffset The offset to the binary data
  83333. * @param binaryWriter The binary data for the glTF file
  83334. * @param convertToRightHandedSystem Converts the values to right-handed
  83335. */
  83336. private reorderTriangleFillMode;
  83337. /**
  83338. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83339. * clock-wise during export to glTF
  83340. * @param submesh BabylonJS submesh
  83341. * @param primitiveMode Primitive mode of the mesh
  83342. * @param sideOrientation the winding order of the submesh
  83343. * @param vertexBufferKind The type of vertex attribute
  83344. * @param meshAttributeArray The vertex attribute data
  83345. * @param byteOffset The offset to the binary data
  83346. * @param binaryWriter The binary data for the glTF file
  83347. * @param convertToRightHandedSystem Converts the values to right-handed
  83348. */
  83349. private reorderTriangleStripDrawMode;
  83350. /**
  83351. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83352. * clock-wise during export to glTF
  83353. * @param submesh BabylonJS submesh
  83354. * @param primitiveMode Primitive mode of the mesh
  83355. * @param sideOrientation the winding order of the submesh
  83356. * @param vertexBufferKind The type of vertex attribute
  83357. * @param meshAttributeArray The vertex attribute data
  83358. * @param byteOffset The offset to the binary data
  83359. * @param binaryWriter The binary data for the glTF file
  83360. * @param convertToRightHandedSystem Converts the values to right-handed
  83361. */
  83362. private reorderTriangleFanMode;
  83363. /**
  83364. * Writes the vertex attribute data to binary
  83365. * @param vertices The vertices to write to the binary writer
  83366. * @param byteOffset The offset into the binary writer to overwrite binary data
  83367. * @param vertexAttributeKind The vertex attribute type
  83368. * @param meshAttributeArray The vertex attribute data
  83369. * @param binaryWriter The writer containing the binary data
  83370. * @param convertToRightHandedSystem Converts the values to right-handed
  83371. */
  83372. private writeVertexAttributeData;
  83373. /**
  83374. * Writes mesh attribute data to a data buffer
  83375. * Returns the bytelength of the data
  83376. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83377. * @param meshAttributeArray Array containing the attribute data
  83378. * @param byteStride Specifies the space between data
  83379. * @param binaryWriter The buffer to write the binary data to
  83380. * @param convertToRightHandedSystem Converts the values to right-handed
  83381. */
  83382. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83383. /**
  83384. * Writes mesh attribute data to a data buffer
  83385. * Returns the bytelength of the data
  83386. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83387. * @param meshAttributeArray Array containing the attribute data
  83388. * @param byteStride Specifies the space between data
  83389. * @param binaryWriter The buffer to write the binary data to
  83390. * @param convertToRightHandedSystem Converts the values to right-handed
  83391. */
  83392. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  83393. /**
  83394. * Generates glTF json data
  83395. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83396. * @param glTFPrefix Text to use when prefixing a glTF file
  83397. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83398. * @returns json data as string
  83399. */
  83400. private generateJSON;
  83401. /**
  83402. * Generates data for .gltf and .bin files based on the glTF prefix string
  83403. * @param glTFPrefix Text to use when prefixing a glTF file
  83404. * @param dispose Dispose the exporter
  83405. * @returns GLTFData with glTF file data
  83406. */
  83407. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83408. /**
  83409. * Creates a binary buffer for glTF
  83410. * @returns array buffer for binary data
  83411. */
  83412. private _generateBinaryAsync;
  83413. /**
  83414. * Pads the number to a multiple of 4
  83415. * @param num number to pad
  83416. * @returns padded number
  83417. */
  83418. private _getPadding;
  83419. /**
  83420. * @hidden
  83421. */
  83422. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83423. /**
  83424. * Sets the TRS for each node
  83425. * @param node glTF Node for storing the transformation data
  83426. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83427. * @param convertToRightHandedSystem Converts the values to right-handed
  83428. */
  83429. private setNodeTransformation;
  83430. private getVertexBufferFromMesh;
  83431. /**
  83432. * Creates a bufferview based on the vertices type for the Babylon mesh
  83433. * @param kind Indicates the type of vertices data
  83434. * @param componentType Indicates the numerical type used to store the data
  83435. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83436. * @param binaryWriter The buffer to write the bufferview data to
  83437. * @param convertToRightHandedSystem Converts the values to right-handed
  83438. */
  83439. private createBufferViewKind;
  83440. /**
  83441. * Creates a bufferview based on the vertices type for the Babylon mesh
  83442. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  83443. * @param babylonMorphTarget the morph target to be exported
  83444. * @param binaryWriter The buffer to write the bufferview data to
  83445. * @param convertToRightHandedSystem Converts the values to right-handed
  83446. */
  83447. private setMorphTargetAttributes;
  83448. /**
  83449. * The primitive mode of the Babylon mesh
  83450. * @param babylonMesh The BabylonJS mesh
  83451. */
  83452. private getMeshPrimitiveMode;
  83453. /**
  83454. * Sets the primitive mode of the glTF mesh primitive
  83455. * @param meshPrimitive glTF mesh primitive
  83456. * @param primitiveMode The primitive mode
  83457. */
  83458. private setPrimitiveMode;
  83459. /**
  83460. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83461. * @param meshPrimitive glTF mesh primitive
  83462. * @param attributeKind vertex attribute
  83463. * @returns boolean specifying if uv coordinates are present
  83464. */
  83465. private setAttributeKind;
  83466. /**
  83467. * Sets data for the primitive attributes of each submesh
  83468. * @param mesh glTF Mesh object to store the primitive attribute information
  83469. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83470. * @param binaryWriter Buffer to write the attribute data to
  83471. * @param convertToRightHandedSystem Converts the values to right-handed
  83472. */
  83473. private setPrimitiveAttributesAsync;
  83474. /**
  83475. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83476. * @param node The node to check
  83477. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83478. */
  83479. private isBabylonCoordinateSystemConvertingNode;
  83480. /**
  83481. * Creates a glTF scene based on the array of meshes
  83482. * Returns the the total byte offset
  83483. * @param babylonScene Babylon scene to get the mesh data from
  83484. * @param binaryWriter Buffer to write binary data to
  83485. */
  83486. private createSceneAsync;
  83487. /**
  83488. * Creates a mapping of Node unique id to node index and handles animations
  83489. * @param babylonScene Babylon Scene
  83490. * @param nodes Babylon transform nodes
  83491. * @param binaryWriter Buffer to write binary data to
  83492. * @returns Node mapping of unique id to index
  83493. */
  83494. private createNodeMapAndAnimationsAsync;
  83495. /**
  83496. * Creates a glTF node from a Babylon mesh
  83497. * @param babylonMesh Source Babylon mesh
  83498. * @param binaryWriter Buffer for storing geometry data
  83499. * @param convertToRightHandedSystem Converts the values to right-handed
  83500. * @param nodeMap Node mapping of unique id to glTF node index
  83501. * @returns glTF node
  83502. */
  83503. private createNodeAsync;
  83504. /**
  83505. * Creates a glTF skin from a Babylon skeleton
  83506. * @param babylonScene Babylon Scene
  83507. * @param nodes Babylon transform nodes
  83508. * @param binaryWriter Buffer to write binary data to
  83509. * @returns Node mapping of unique id to index
  83510. */
  83511. private createSkinsAsync;
  83512. }
  83513. /**
  83514. * @hidden
  83515. *
  83516. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83517. */
  83518. export class _BinaryWriter {
  83519. /**
  83520. * Array buffer which stores all binary data
  83521. */
  83522. private _arrayBuffer;
  83523. /**
  83524. * View of the array buffer
  83525. */
  83526. private _dataView;
  83527. /**
  83528. * byte offset of data in array buffer
  83529. */
  83530. private _byteOffset;
  83531. /**
  83532. * Initialize binary writer with an initial byte length
  83533. * @param byteLength Initial byte length of the array buffer
  83534. */
  83535. constructor(byteLength: number);
  83536. /**
  83537. * Resize the array buffer to the specified byte length
  83538. * @param byteLength
  83539. */
  83540. private resizeBuffer;
  83541. /**
  83542. * Get an array buffer with the length of the byte offset
  83543. * @returns ArrayBuffer resized to the byte offset
  83544. */
  83545. getArrayBuffer(): ArrayBuffer;
  83546. /**
  83547. * Get the byte offset of the array buffer
  83548. * @returns byte offset
  83549. */
  83550. getByteOffset(): number;
  83551. /**
  83552. * Stores an UInt8 in the array buffer
  83553. * @param entry
  83554. * @param byteOffset If defined, specifies where to set the value as an offset.
  83555. */
  83556. setUInt8(entry: number, byteOffset?: number): void;
  83557. /**
  83558. * Stores an UInt16 in the array buffer
  83559. * @param entry
  83560. * @param byteOffset If defined, specifies where to set the value as an offset.
  83561. */
  83562. setUInt16(entry: number, byteOffset?: number): void;
  83563. /**
  83564. * Gets an UInt32 in the array buffer
  83565. * @param entry
  83566. * @param byteOffset If defined, specifies where to set the value as an offset.
  83567. */
  83568. getUInt32(byteOffset: number): number;
  83569. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83570. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83571. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83572. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83573. /**
  83574. * Stores a Float32 in the array buffer
  83575. * @param entry
  83576. */
  83577. setFloat32(entry: number, byteOffset?: number): void;
  83578. /**
  83579. * Stores an UInt32 in the array buffer
  83580. * @param entry
  83581. * @param byteOffset If defined, specifies where to set the value as an offset.
  83582. */
  83583. setUInt32(entry: number, byteOffset?: number): void;
  83584. }
  83585. }
  83586. declare module BABYLON.GLTF2.Exporter {
  83587. /**
  83588. * @hidden
  83589. * Interface to store animation data.
  83590. */
  83591. export interface _IAnimationData {
  83592. /**
  83593. * Keyframe data.
  83594. */
  83595. inputs: number[];
  83596. /**
  83597. * Value data.
  83598. */
  83599. outputs: number[][];
  83600. /**
  83601. * Animation interpolation data.
  83602. */
  83603. samplerInterpolation: AnimationSamplerInterpolation;
  83604. /**
  83605. * Minimum keyframe value.
  83606. */
  83607. inputsMin: number;
  83608. /**
  83609. * Maximum keyframe value.
  83610. */
  83611. inputsMax: number;
  83612. }
  83613. /**
  83614. * @hidden
  83615. */
  83616. export interface _IAnimationInfo {
  83617. /**
  83618. * The target channel for the animation
  83619. */
  83620. animationChannelTargetPath: AnimationChannelTargetPath;
  83621. /**
  83622. * The glTF accessor type for the data.
  83623. */
  83624. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  83625. /**
  83626. * Specifies if quaternions should be used.
  83627. */
  83628. useQuaternion: boolean;
  83629. }
  83630. /**
  83631. * @hidden
  83632. * Utility class for generating glTF animation data from BabylonJS.
  83633. */
  83634. export class _GLTFAnimation {
  83635. /**
  83636. * @ignore
  83637. *
  83638. * Creates glTF channel animation from BabylonJS animation.
  83639. * @param babylonTransformNode - BabylonJS mesh.
  83640. * @param animation - animation.
  83641. * @param animationChannelTargetPath - The target animation channel.
  83642. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83643. * @param useQuaternion - Specifies if quaternions are used.
  83644. * @returns nullable IAnimationData
  83645. */
  83646. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83647. private static _DeduceAnimationInfo;
  83648. /**
  83649. * @ignore
  83650. * Create node animations from the transform node animations
  83651. * @param babylonNode
  83652. * @param runtimeGLTFAnimation
  83653. * @param idleGLTFAnimations
  83654. * @param nodeMap
  83655. * @param nodes
  83656. * @param binaryWriter
  83657. * @param bufferViews
  83658. * @param accessors
  83659. * @param convertToRightHandedSystem
  83660. * @param animationSampleRate
  83661. */
  83662. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83663. [key: number]: number;
  83664. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83665. /**
  83666. * @ignore
  83667. * Create individual morph animations from the mesh's morph target animation tracks
  83668. * @param babylonNode
  83669. * @param runtimeGLTFAnimation
  83670. * @param idleGLTFAnimations
  83671. * @param nodeMap
  83672. * @param nodes
  83673. * @param binaryWriter
  83674. * @param bufferViews
  83675. * @param accessors
  83676. * @param convertToRightHandedSystem
  83677. * @param animationSampleRate
  83678. */
  83679. static _CreateMorphTargetAnimationFromMorphTargets(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83680. [key: number]: number;
  83681. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83682. /**
  83683. * @ignore
  83684. * Create node and morph animations from the animation groups
  83685. * @param babylonScene
  83686. * @param glTFAnimations
  83687. * @param nodeMap
  83688. * @param nodes
  83689. * @param binaryWriter
  83690. * @param bufferViews
  83691. * @param accessors
  83692. * @param convertToRightHandedSystemMap
  83693. * @param animationSampleRate
  83694. */
  83695. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83696. [key: number]: number;
  83697. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83698. [nodeId: number]: boolean;
  83699. }, animationSampleRate: number): void;
  83700. private static AddAnimation;
  83701. /**
  83702. * Create a baked animation
  83703. * @param babylonTransformNode BabylonJS mesh
  83704. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83705. * @param animationChannelTargetPath animation target channel
  83706. * @param minFrame minimum animation frame
  83707. * @param maxFrame maximum animation frame
  83708. * @param fps frames per second of the animation
  83709. * @param inputs input key frames of the animation
  83710. * @param outputs output key frame data of the animation
  83711. * @param convertToRightHandedSystem converts the values to right-handed
  83712. * @param useQuaternion specifies if quaternions should be used
  83713. */
  83714. private static _CreateBakedAnimation;
  83715. private static _ConvertFactorToVector3OrQuaternion;
  83716. private static _SetInterpolatedValue;
  83717. /**
  83718. * Creates linear animation from the animation key frames
  83719. * @param babylonTransformNode BabylonJS mesh
  83720. * @param animation BabylonJS animation
  83721. * @param animationChannelTargetPath The target animation channel
  83722. * @param frameDelta The difference between the last and first frame of the animation
  83723. * @param inputs Array to store the key frame times
  83724. * @param outputs Array to store the key frame data
  83725. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83726. * @param useQuaternion Specifies if quaternions are used in the animation
  83727. */
  83728. private static _CreateLinearOrStepAnimation;
  83729. /**
  83730. * Creates cubic spline animation from the animation key frames
  83731. * @param babylonTransformNode BabylonJS mesh
  83732. * @param animation BabylonJS animation
  83733. * @param animationChannelTargetPath The target animation channel
  83734. * @param frameDelta The difference between the last and first frame of the animation
  83735. * @param inputs Array to store the key frame times
  83736. * @param outputs Array to store the key frame data
  83737. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83738. * @param useQuaternion Specifies if quaternions are used in the animation
  83739. */
  83740. private static _CreateCubicSplineAnimation;
  83741. private static _GetBasePositionRotationOrScale;
  83742. /**
  83743. * Adds a key frame value
  83744. * @param keyFrame
  83745. * @param animation
  83746. * @param outputs
  83747. * @param animationChannelTargetPath
  83748. * @param basePositionRotationOrScale
  83749. * @param convertToRightHandedSystem
  83750. * @param useQuaternion
  83751. */
  83752. private static _AddKeyframeValue;
  83753. /**
  83754. * Determine the interpolation based on the key frames
  83755. * @param keyFrames
  83756. * @param animationChannelTargetPath
  83757. * @param useQuaternion
  83758. */
  83759. private static _DeduceInterpolation;
  83760. /**
  83761. * Adds an input tangent or output tangent to the output data
  83762. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83763. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83764. * @param outputs The animation data by keyframe
  83765. * @param animationChannelTargetPath The target animation channel
  83766. * @param interpolation The interpolation type
  83767. * @param keyFrame The key frame with the animation data
  83768. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83769. * @param useQuaternion Specifies if quaternions are used
  83770. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83771. */
  83772. private static AddSplineTangent;
  83773. /**
  83774. * Get the minimum and maximum key frames' frame values
  83775. * @param keyFrames animation key frames
  83776. * @returns the minimum and maximum key frame value
  83777. */
  83778. private static calculateMinMaxKeyFrames;
  83779. }
  83780. }
  83781. declare module BABYLON.GLTF2.Exporter {
  83782. /** @hidden */
  83783. export var textureTransformPixelShader: {
  83784. name: string;
  83785. shader: string;
  83786. };
  83787. }
  83788. declare module BABYLON.GLTF2.Exporter.Extensions {
  83789. /**
  83790. * @hidden
  83791. */
  83792. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83793. private _recordedTextures;
  83794. /** Name of this extension */
  83795. readonly name: string;
  83796. /** Defines whether this extension is enabled */
  83797. enabled: boolean;
  83798. /** Defines whether this extension is required */
  83799. required: boolean;
  83800. /** Reference to the glTF exporter */
  83801. private _wasUsed;
  83802. constructor(exporter: _Exporter);
  83803. dispose(): void;
  83804. /** @hidden */
  83805. get wasUsed(): boolean;
  83806. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83807. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83808. /**
  83809. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83810. * @param babylonTexture
  83811. * @param offset
  83812. * @param rotation
  83813. * @param scale
  83814. * @param scene
  83815. */
  83816. private _textureTransformTextureAsync;
  83817. }
  83818. }
  83819. declare module BABYLON.GLTF2.Exporter.Extensions {
  83820. /**
  83821. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83822. */
  83823. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83824. /** The name of this extension. */
  83825. readonly name: string;
  83826. /** Defines whether this extension is enabled. */
  83827. enabled: boolean;
  83828. /** Defines whether this extension is required */
  83829. required: boolean;
  83830. /** Reference to the glTF exporter */
  83831. private _exporter;
  83832. private _lights;
  83833. /** @hidden */
  83834. constructor(exporter: _Exporter);
  83835. /** @hidden */
  83836. dispose(): void;
  83837. /** @hidden */
  83838. get wasUsed(): boolean;
  83839. /** @hidden */
  83840. onExporting(): void;
  83841. /**
  83842. * Define this method to modify the default behavior when exporting a node
  83843. * @param context The context when exporting the node
  83844. * @param node glTF node
  83845. * @param babylonNode BabylonJS node
  83846. * @param nodeMap Node mapping of unique id to glTF node index
  83847. * @returns nullable INode promise
  83848. */
  83849. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83850. [key: number]: number;
  83851. }): Promise<Nullable<INode>>;
  83852. }
  83853. }
  83854. declare module BABYLON.GLTF2.Exporter.Extensions {
  83855. /**
  83856. * @hidden
  83857. */
  83858. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83859. /** Name of this extension */
  83860. readonly name: string;
  83861. /** Defines whether this extension is enabled */
  83862. enabled: boolean;
  83863. /** Defines whether this extension is required */
  83864. required: boolean;
  83865. /** Reference to the glTF exporter */
  83866. private _textureInfos;
  83867. private _exportedTextures;
  83868. private _wasUsed;
  83869. constructor(exporter: _Exporter);
  83870. dispose(): void;
  83871. /** @hidden */
  83872. get wasUsed(): boolean;
  83873. private _getTextureIndex;
  83874. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83875. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83876. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83877. }
  83878. }
  83879. declare module BABYLON.GLTF2.Exporter.Extensions {
  83880. /**
  83881. * @hidden
  83882. */
  83883. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83884. /** Name of this extension */
  83885. readonly name: string;
  83886. /** Defines whether this extension is enabled */
  83887. enabled: boolean;
  83888. /** Defines whether this extension is required */
  83889. required: boolean;
  83890. private _wasUsed;
  83891. constructor(exporter: _Exporter);
  83892. /** @hidden */
  83893. get wasUsed(): boolean;
  83894. dispose(): void;
  83895. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83896. }
  83897. }
  83898. declare module BABYLON {
  83899. /**
  83900. * Class for generating STL data from a Babylon scene.
  83901. */
  83902. export class STLExport {
  83903. /**
  83904. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83905. * @param meshes list defines the mesh to serialize
  83906. * @param download triggers the automatic download of the file.
  83907. * @param fileName changes the downloads fileName.
  83908. * @param binary changes the STL to a binary type.
  83909. * @param isLittleEndian toggle for binary type exporter.
  83910. * @returns the STL as UTF8 string
  83911. */
  83912. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83913. }
  83914. }
  83915. declare module "babylonjs-gltf2interface" {
  83916. export = BABYLON.GLTF2;
  83917. }
  83918. /**
  83919. * Module for glTF 2.0 Interface
  83920. */
  83921. declare module BABYLON.GLTF2 {
  83922. /**
  83923. * The datatype of the components in the attribute
  83924. */
  83925. const enum AccessorComponentType {
  83926. /**
  83927. * Byte
  83928. */
  83929. BYTE = 5120,
  83930. /**
  83931. * Unsigned Byte
  83932. */
  83933. UNSIGNED_BYTE = 5121,
  83934. /**
  83935. * Short
  83936. */
  83937. SHORT = 5122,
  83938. /**
  83939. * Unsigned Short
  83940. */
  83941. UNSIGNED_SHORT = 5123,
  83942. /**
  83943. * Unsigned Int
  83944. */
  83945. UNSIGNED_INT = 5125,
  83946. /**
  83947. * Float
  83948. */
  83949. FLOAT = 5126,
  83950. }
  83951. /**
  83952. * Specifies if the attirbute is a scalar, vector, or matrix
  83953. */
  83954. const enum AccessorType {
  83955. /**
  83956. * Scalar
  83957. */
  83958. SCALAR = "SCALAR",
  83959. /**
  83960. * Vector2
  83961. */
  83962. VEC2 = "VEC2",
  83963. /**
  83964. * Vector3
  83965. */
  83966. VEC3 = "VEC3",
  83967. /**
  83968. * Vector4
  83969. */
  83970. VEC4 = "VEC4",
  83971. /**
  83972. * Matrix2x2
  83973. */
  83974. MAT2 = "MAT2",
  83975. /**
  83976. * Matrix3x3
  83977. */
  83978. MAT3 = "MAT3",
  83979. /**
  83980. * Matrix4x4
  83981. */
  83982. MAT4 = "MAT4",
  83983. }
  83984. /**
  83985. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83986. */
  83987. const enum AnimationChannelTargetPath {
  83988. /**
  83989. * Translation
  83990. */
  83991. TRANSLATION = "translation",
  83992. /**
  83993. * Rotation
  83994. */
  83995. ROTATION = "rotation",
  83996. /**
  83997. * Scale
  83998. */
  83999. SCALE = "scale",
  84000. /**
  84001. * Weights
  84002. */
  84003. WEIGHTS = "weights",
  84004. }
  84005. /**
  84006. * Interpolation algorithm
  84007. */
  84008. const enum AnimationSamplerInterpolation {
  84009. /**
  84010. * The animated values are linearly interpolated between keyframes
  84011. */
  84012. LINEAR = "LINEAR",
  84013. /**
  84014. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84015. */
  84016. STEP = "STEP",
  84017. /**
  84018. * The animation's interpolation is computed using a cubic spline with specified tangents
  84019. */
  84020. CUBICSPLINE = "CUBICSPLINE",
  84021. }
  84022. /**
  84023. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84024. */
  84025. const enum CameraType {
  84026. /**
  84027. * A perspective camera containing properties to create a perspective projection matrix
  84028. */
  84029. PERSPECTIVE = "perspective",
  84030. /**
  84031. * An orthographic camera containing properties to create an orthographic projection matrix
  84032. */
  84033. ORTHOGRAPHIC = "orthographic",
  84034. }
  84035. /**
  84036. * The mime-type of the image
  84037. */
  84038. const enum ImageMimeType {
  84039. /**
  84040. * JPEG Mime-type
  84041. */
  84042. JPEG = "image/jpeg",
  84043. /**
  84044. * PNG Mime-type
  84045. */
  84046. PNG = "image/png",
  84047. }
  84048. /**
  84049. * The alpha rendering mode of the material
  84050. */
  84051. const enum MaterialAlphaMode {
  84052. /**
  84053. * The alpha value is ignored and the rendered output is fully opaque
  84054. */
  84055. OPAQUE = "OPAQUE",
  84056. /**
  84057. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84058. */
  84059. MASK = "MASK",
  84060. /**
  84061. * 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)
  84062. */
  84063. BLEND = "BLEND",
  84064. }
  84065. /**
  84066. * The type of the primitives to render
  84067. */
  84068. const enum MeshPrimitiveMode {
  84069. /**
  84070. * Points
  84071. */
  84072. POINTS = 0,
  84073. /**
  84074. * Lines
  84075. */
  84076. LINES = 1,
  84077. /**
  84078. * Line Loop
  84079. */
  84080. LINE_LOOP = 2,
  84081. /**
  84082. * Line Strip
  84083. */
  84084. LINE_STRIP = 3,
  84085. /**
  84086. * Triangles
  84087. */
  84088. TRIANGLES = 4,
  84089. /**
  84090. * Triangle Strip
  84091. */
  84092. TRIANGLE_STRIP = 5,
  84093. /**
  84094. * Triangle Fan
  84095. */
  84096. TRIANGLE_FAN = 6,
  84097. }
  84098. /**
  84099. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84100. */
  84101. const enum TextureMagFilter {
  84102. /**
  84103. * Nearest
  84104. */
  84105. NEAREST = 9728,
  84106. /**
  84107. * Linear
  84108. */
  84109. LINEAR = 9729,
  84110. }
  84111. /**
  84112. * Minification filter. All valid values correspond to WebGL enums
  84113. */
  84114. const enum TextureMinFilter {
  84115. /**
  84116. * Nearest
  84117. */
  84118. NEAREST = 9728,
  84119. /**
  84120. * Linear
  84121. */
  84122. LINEAR = 9729,
  84123. /**
  84124. * Nearest Mip-Map Nearest
  84125. */
  84126. NEAREST_MIPMAP_NEAREST = 9984,
  84127. /**
  84128. * Linear Mipmap Nearest
  84129. */
  84130. LINEAR_MIPMAP_NEAREST = 9985,
  84131. /**
  84132. * Nearest Mipmap Linear
  84133. */
  84134. NEAREST_MIPMAP_LINEAR = 9986,
  84135. /**
  84136. * Linear Mipmap Linear
  84137. */
  84138. LINEAR_MIPMAP_LINEAR = 9987,
  84139. }
  84140. /**
  84141. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84142. */
  84143. const enum TextureWrapMode {
  84144. /**
  84145. * Clamp to Edge
  84146. */
  84147. CLAMP_TO_EDGE = 33071,
  84148. /**
  84149. * Mirrored Repeat
  84150. */
  84151. MIRRORED_REPEAT = 33648,
  84152. /**
  84153. * Repeat
  84154. */
  84155. REPEAT = 10497,
  84156. }
  84157. /**
  84158. * glTF Property
  84159. */
  84160. interface IProperty {
  84161. /**
  84162. * Dictionary object with extension-specific objects
  84163. */
  84164. extensions?: {
  84165. [key: string]: any;
  84166. };
  84167. /**
  84168. * Application-Specific data
  84169. */
  84170. extras?: any;
  84171. }
  84172. /**
  84173. * glTF Child of Root Property
  84174. */
  84175. interface IChildRootProperty extends IProperty {
  84176. /**
  84177. * The user-defined name of this object
  84178. */
  84179. name?: string;
  84180. }
  84181. /**
  84182. * Indices of those attributes that deviate from their initialization value
  84183. */
  84184. interface IAccessorSparseIndices extends IProperty {
  84185. /**
  84186. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84187. */
  84188. bufferView: number;
  84189. /**
  84190. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84191. */
  84192. byteOffset?: number;
  84193. /**
  84194. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84195. */
  84196. componentType: AccessorComponentType;
  84197. }
  84198. /**
  84199. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84200. */
  84201. interface IAccessorSparseValues extends IProperty {
  84202. /**
  84203. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84204. */
  84205. bufferView: number;
  84206. /**
  84207. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84208. */
  84209. byteOffset?: number;
  84210. }
  84211. /**
  84212. * Sparse storage of attributes that deviate from their initialization value
  84213. */
  84214. interface IAccessorSparse extends IProperty {
  84215. /**
  84216. * The number of attributes encoded in this sparse accessor
  84217. */
  84218. count: number;
  84219. /**
  84220. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84221. */
  84222. indices: IAccessorSparseIndices;
  84223. /**
  84224. * 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
  84225. */
  84226. values: IAccessorSparseValues;
  84227. }
  84228. /**
  84229. * 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
  84230. */
  84231. interface IAccessor extends IChildRootProperty {
  84232. /**
  84233. * The index of the bufferview
  84234. */
  84235. bufferView?: number;
  84236. /**
  84237. * The offset relative to the start of the bufferView in bytes
  84238. */
  84239. byteOffset?: number;
  84240. /**
  84241. * The datatype of components in the attribute
  84242. */
  84243. componentType: AccessorComponentType;
  84244. /**
  84245. * Specifies whether integer data values should be normalized
  84246. */
  84247. normalized?: boolean;
  84248. /**
  84249. * The number of attributes referenced by this accessor
  84250. */
  84251. count: number;
  84252. /**
  84253. * Specifies if the attribute is a scalar, vector, or matrix
  84254. */
  84255. type: AccessorType;
  84256. /**
  84257. * Maximum value of each component in this attribute
  84258. */
  84259. max?: number[];
  84260. /**
  84261. * Minimum value of each component in this attribute
  84262. */
  84263. min?: number[];
  84264. /**
  84265. * Sparse storage of attributes that deviate from their initialization value
  84266. */
  84267. sparse?: IAccessorSparse;
  84268. }
  84269. /**
  84270. * Targets an animation's sampler at a node's property
  84271. */
  84272. interface IAnimationChannel extends IProperty {
  84273. /**
  84274. * The index of a sampler in this animation used to compute the value for the target
  84275. */
  84276. sampler: number;
  84277. /**
  84278. * The index of the node and TRS property to target
  84279. */
  84280. target: IAnimationChannelTarget;
  84281. }
  84282. /**
  84283. * The index of the node and TRS property that an animation channel targets
  84284. */
  84285. interface IAnimationChannelTarget extends IProperty {
  84286. /**
  84287. * The index of the node to target
  84288. */
  84289. node: number;
  84290. /**
  84291. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84292. */
  84293. path: AnimationChannelTargetPath;
  84294. }
  84295. /**
  84296. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84297. */
  84298. interface IAnimationSampler extends IProperty {
  84299. /**
  84300. * The index of an accessor containing keyframe input values, e.g., time
  84301. */
  84302. input: number;
  84303. /**
  84304. * Interpolation algorithm
  84305. */
  84306. interpolation?: AnimationSamplerInterpolation;
  84307. /**
  84308. * The index of an accessor, containing keyframe output values
  84309. */
  84310. output: number;
  84311. }
  84312. /**
  84313. * A keyframe animation
  84314. */
  84315. interface IAnimation extends IChildRootProperty {
  84316. /**
  84317. * An array of channels, each of which targets an animation's sampler at a node's property
  84318. */
  84319. channels: IAnimationChannel[];
  84320. /**
  84321. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84322. */
  84323. samplers: IAnimationSampler[];
  84324. }
  84325. /**
  84326. * Metadata about the glTF asset
  84327. */
  84328. interface IAsset extends IChildRootProperty {
  84329. /**
  84330. * A copyright message suitable for display to credit the content creator
  84331. */
  84332. copyright?: string;
  84333. /**
  84334. * Tool that generated this glTF model. Useful for debugging
  84335. */
  84336. generator?: string;
  84337. /**
  84338. * The glTF version that this asset targets
  84339. */
  84340. version: string;
  84341. /**
  84342. * The minimum glTF version that this asset targets
  84343. */
  84344. minVersion?: string;
  84345. }
  84346. /**
  84347. * A buffer points to binary geometry, animation, or skins
  84348. */
  84349. interface IBuffer extends IChildRootProperty {
  84350. /**
  84351. * 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
  84352. */
  84353. uri?: string;
  84354. /**
  84355. * The length of the buffer in bytes
  84356. */
  84357. byteLength: number;
  84358. }
  84359. /**
  84360. * A view into a buffer generally representing a subset of the buffer
  84361. */
  84362. interface IBufferView extends IChildRootProperty {
  84363. /**
  84364. * The index of the buffer
  84365. */
  84366. buffer: number;
  84367. /**
  84368. * The offset into the buffer in bytes
  84369. */
  84370. byteOffset?: number;
  84371. /**
  84372. * The lenth of the bufferView in bytes
  84373. */
  84374. byteLength: number;
  84375. /**
  84376. * The stride, in bytes
  84377. */
  84378. byteStride?: number;
  84379. }
  84380. /**
  84381. * An orthographic camera containing properties to create an orthographic projection matrix
  84382. */
  84383. interface ICameraOrthographic extends IProperty {
  84384. /**
  84385. * The floating-point horizontal magnification of the view. Must not be zero
  84386. */
  84387. xmag: number;
  84388. /**
  84389. * The floating-point vertical magnification of the view. Must not be zero
  84390. */
  84391. ymag: number;
  84392. /**
  84393. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84394. */
  84395. zfar: number;
  84396. /**
  84397. * The floating-point distance to the near clipping plane
  84398. */
  84399. znear: number;
  84400. }
  84401. /**
  84402. * A perspective camera containing properties to create a perspective projection matrix
  84403. */
  84404. interface ICameraPerspective extends IProperty {
  84405. /**
  84406. * The floating-point aspect ratio of the field of view
  84407. */
  84408. aspectRatio?: number;
  84409. /**
  84410. * The floating-point vertical field of view in radians
  84411. */
  84412. yfov: number;
  84413. /**
  84414. * The floating-point distance to the far clipping plane
  84415. */
  84416. zfar?: number;
  84417. /**
  84418. * The floating-point distance to the near clipping plane
  84419. */
  84420. znear: number;
  84421. }
  84422. /**
  84423. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84424. */
  84425. interface ICamera extends IChildRootProperty {
  84426. /**
  84427. * An orthographic camera containing properties to create an orthographic projection matrix
  84428. */
  84429. orthographic?: ICameraOrthographic;
  84430. /**
  84431. * A perspective camera containing properties to create a perspective projection matrix
  84432. */
  84433. perspective?: ICameraPerspective;
  84434. /**
  84435. * Specifies if the camera uses a perspective or orthographic projection
  84436. */
  84437. type: CameraType;
  84438. }
  84439. /**
  84440. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84441. */
  84442. interface IImage extends IChildRootProperty {
  84443. /**
  84444. * 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
  84445. */
  84446. uri?: string;
  84447. /**
  84448. * The image's MIME type
  84449. */
  84450. mimeType?: ImageMimeType;
  84451. /**
  84452. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84453. */
  84454. bufferView?: number;
  84455. }
  84456. /**
  84457. * Material Normal Texture Info
  84458. */
  84459. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84460. /**
  84461. * The scalar multiplier applied to each normal vector of the normal texture
  84462. */
  84463. scale?: number;
  84464. }
  84465. /**
  84466. * Material Occlusion Texture Info
  84467. */
  84468. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84469. /**
  84470. * A scalar multiplier controlling the amount of occlusion applied
  84471. */
  84472. strength?: number;
  84473. }
  84474. /**
  84475. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84476. */
  84477. interface IMaterialPbrMetallicRoughness {
  84478. /**
  84479. * The material's base color factor
  84480. */
  84481. baseColorFactor?: number[];
  84482. /**
  84483. * The base color texture
  84484. */
  84485. baseColorTexture?: ITextureInfo;
  84486. /**
  84487. * The metalness of the material
  84488. */
  84489. metallicFactor?: number;
  84490. /**
  84491. * The roughness of the material
  84492. */
  84493. roughnessFactor?: number;
  84494. /**
  84495. * The metallic-roughness texture
  84496. */
  84497. metallicRoughnessTexture?: ITextureInfo;
  84498. }
  84499. /**
  84500. * The material appearance of a primitive
  84501. */
  84502. interface IMaterial extends IChildRootProperty {
  84503. /**
  84504. * 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
  84505. */
  84506. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84507. /**
  84508. * The normal map texture
  84509. */
  84510. normalTexture?: IMaterialNormalTextureInfo;
  84511. /**
  84512. * The occlusion map texture
  84513. */
  84514. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84515. /**
  84516. * The emissive map texture
  84517. */
  84518. emissiveTexture?: ITextureInfo;
  84519. /**
  84520. * 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
  84521. */
  84522. emissiveFactor?: number[];
  84523. /**
  84524. * The alpha rendering mode of the material
  84525. */
  84526. alphaMode?: MaterialAlphaMode;
  84527. /**
  84528. * The alpha cutoff value of the material
  84529. */
  84530. alphaCutoff?: number;
  84531. /**
  84532. * Specifies whether the material is double sided
  84533. */
  84534. doubleSided?: boolean;
  84535. }
  84536. /**
  84537. * Geometry to be rendered with the given material
  84538. */
  84539. interface IMeshPrimitive extends IProperty {
  84540. /**
  84541. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84542. */
  84543. attributes: {
  84544. [name: string]: number;
  84545. };
  84546. /**
  84547. * The index of the accessor that contains the indices
  84548. */
  84549. indices?: number;
  84550. /**
  84551. * The index of the material to apply to this primitive when rendering
  84552. */
  84553. material?: number;
  84554. /**
  84555. * The type of primitives to render. All valid values correspond to WebGL enums
  84556. */
  84557. mode?: MeshPrimitiveMode;
  84558. /**
  84559. * 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
  84560. */
  84561. targets?: {
  84562. [name: string]: number;
  84563. }[];
  84564. }
  84565. /**
  84566. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84567. */
  84568. interface IMesh extends IChildRootProperty {
  84569. /**
  84570. * An array of primitives, each defining geometry to be rendered with a material
  84571. */
  84572. primitives: IMeshPrimitive[];
  84573. /**
  84574. * Array of weights to be applied to the Morph Targets
  84575. */
  84576. weights?: number[];
  84577. }
  84578. /**
  84579. * A node in the node hierarchy
  84580. */
  84581. interface INode extends IChildRootProperty {
  84582. /**
  84583. * The index of the camera referenced by this node
  84584. */
  84585. camera?: number;
  84586. /**
  84587. * The indices of this node's children
  84588. */
  84589. children?: number[];
  84590. /**
  84591. * The index of the skin referenced by this node
  84592. */
  84593. skin?: number;
  84594. /**
  84595. * A floating-point 4x4 transformation matrix stored in column-major order
  84596. */
  84597. matrix?: number[];
  84598. /**
  84599. * The index of the mesh in this node
  84600. */
  84601. mesh?: number;
  84602. /**
  84603. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84604. */
  84605. rotation?: number[];
  84606. /**
  84607. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84608. */
  84609. scale?: number[];
  84610. /**
  84611. * The node's translation along the x, y, and z axes
  84612. */
  84613. translation?: number[];
  84614. /**
  84615. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84616. */
  84617. weights?: number[];
  84618. }
  84619. /**
  84620. * Texture sampler properties for filtering and wrapping modes
  84621. */
  84622. interface ISampler extends IChildRootProperty {
  84623. /**
  84624. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84625. */
  84626. magFilter?: TextureMagFilter;
  84627. /**
  84628. * Minification filter. All valid values correspond to WebGL enums
  84629. */
  84630. minFilter?: TextureMinFilter;
  84631. /**
  84632. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84633. */
  84634. wrapS?: TextureWrapMode;
  84635. /**
  84636. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84637. */
  84638. wrapT?: TextureWrapMode;
  84639. }
  84640. /**
  84641. * The root nodes of a scene
  84642. */
  84643. interface IScene extends IChildRootProperty {
  84644. /**
  84645. * The indices of each root node
  84646. */
  84647. nodes: number[];
  84648. }
  84649. /**
  84650. * Joints and matrices defining a skin
  84651. */
  84652. interface ISkin extends IChildRootProperty {
  84653. /**
  84654. * 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
  84655. */
  84656. inverseBindMatrices?: number;
  84657. /**
  84658. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84659. */
  84660. skeleton?: number;
  84661. /**
  84662. * 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)
  84663. */
  84664. joints: number[];
  84665. }
  84666. /**
  84667. * A texture and its sampler
  84668. */
  84669. interface ITexture extends IChildRootProperty {
  84670. /**
  84671. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84672. */
  84673. sampler?: number;
  84674. /**
  84675. * The index of the image used by this texture
  84676. */
  84677. source: number;
  84678. }
  84679. /**
  84680. * Reference to a texture
  84681. */
  84682. interface ITextureInfo extends IProperty {
  84683. /**
  84684. * The index of the texture
  84685. */
  84686. index: number;
  84687. /**
  84688. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84689. */
  84690. texCoord?: number;
  84691. }
  84692. /**
  84693. * The root object for a glTF asset
  84694. */
  84695. interface IGLTF extends IProperty {
  84696. /**
  84697. * An array of accessors. An accessor is a typed view into a bufferView
  84698. */
  84699. accessors?: IAccessor[];
  84700. /**
  84701. * An array of keyframe animations
  84702. */
  84703. animations?: IAnimation[];
  84704. /**
  84705. * Metadata about the glTF asset
  84706. */
  84707. asset: IAsset;
  84708. /**
  84709. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84710. */
  84711. buffers?: IBuffer[];
  84712. /**
  84713. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84714. */
  84715. bufferViews?: IBufferView[];
  84716. /**
  84717. * An array of cameras
  84718. */
  84719. cameras?: ICamera[];
  84720. /**
  84721. * Names of glTF extensions used somewhere in this asset
  84722. */
  84723. extensionsUsed?: string[];
  84724. /**
  84725. * Names of glTF extensions required to properly load this asset
  84726. */
  84727. extensionsRequired?: string[];
  84728. /**
  84729. * An array of images. An image defines data used to create a texture
  84730. */
  84731. images?: IImage[];
  84732. /**
  84733. * An array of materials. A material defines the appearance of a primitive
  84734. */
  84735. materials?: IMaterial[];
  84736. /**
  84737. * An array of meshes. A mesh is a set of primitives to be rendered
  84738. */
  84739. meshes?: IMesh[];
  84740. /**
  84741. * An array of nodes
  84742. */
  84743. nodes?: INode[];
  84744. /**
  84745. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84746. */
  84747. samplers?: ISampler[];
  84748. /**
  84749. * The index of the default scene
  84750. */
  84751. scene?: number;
  84752. /**
  84753. * An array of scenes
  84754. */
  84755. scenes?: IScene[];
  84756. /**
  84757. * An array of skins. A skin is defined by joints and matrices
  84758. */
  84759. skins?: ISkin[];
  84760. /**
  84761. * An array of textures
  84762. */
  84763. textures?: ITexture[];
  84764. }
  84765. /**
  84766. * The glTF validation results
  84767. * @ignore
  84768. */
  84769. interface IGLTFValidationResults {
  84770. info: {
  84771. generator: string;
  84772. hasAnimations: boolean;
  84773. hasDefaultScene: boolean;
  84774. hasMaterials: boolean;
  84775. hasMorphTargets: boolean;
  84776. hasSkins: boolean;
  84777. hasTextures: boolean;
  84778. maxAttributesUsed: number;
  84779. primitivesCount: number
  84780. };
  84781. issues: {
  84782. messages: Array<string>;
  84783. numErrors: number;
  84784. numHints: number;
  84785. numInfos: number;
  84786. numWarnings: number;
  84787. truncated: boolean
  84788. };
  84789. mimeType: string;
  84790. uri: string;
  84791. validatedAt: string;
  84792. validatorVersion: string;
  84793. }
  84794. /**
  84795. * The glTF validation options
  84796. */
  84797. interface IGLTFValidationOptions {
  84798. /** Uri to use */
  84799. uri?: string;
  84800. /** Function used to load external resources */
  84801. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84802. /** Boolean indicating that we need to validate accessor data */
  84803. validateAccessorData?: boolean;
  84804. /** max number of issues allowed */
  84805. maxIssues?: number;
  84806. /** Ignored issues */
  84807. ignoredIssues?: Array<string>;
  84808. /** Value to override severy settings */
  84809. severityOverrides?: Object;
  84810. }
  84811. /**
  84812. * The glTF validator object
  84813. * @ignore
  84814. */
  84815. interface IGLTFValidator {
  84816. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84817. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84818. }
  84819. /**
  84820. * Interfaces from the EXT_lights_image_based extension
  84821. */
  84822. /** @hidden */
  84823. interface IEXTLightsImageBased_LightReferenceImageBased {
  84824. light: number;
  84825. }
  84826. /** @hidden */
  84827. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84828. intensity: number;
  84829. rotation: number[];
  84830. specularImageSize: number;
  84831. specularImages: number[][];
  84832. irradianceCoefficients: number[][];
  84833. }
  84834. /** @hidden */
  84835. interface IEXTLightsImageBased {
  84836. lights: IEXTLightsImageBased_LightImageBased[];
  84837. }
  84838. /**
  84839. * Interfaces from the EXT_mesh_gpu_instancing extension
  84840. * !!! Experimental Extension Subject to Changes !!!
  84841. */
  84842. /** @hidden */
  84843. interface IEXTMeshGpuInstancing {
  84844. mesh?: number;
  84845. attributes: { [name: string]: number };
  84846. }
  84847. /**
  84848. * Interfaces from the KHR_draco_mesh_compression extension
  84849. */
  84850. /** @hidden */
  84851. interface IKHRDracoMeshCompression {
  84852. bufferView: number;
  84853. attributes: { [name: string]: number };
  84854. }
  84855. /**
  84856. * Interfaces from the KHR_lights_punctual extension
  84857. */
  84858. /** @hidden */
  84859. const enum IKHRLightsPunctual_LightType {
  84860. DIRECTIONAL = "directional",
  84861. POINT = "point",
  84862. SPOT = "spot"
  84863. }
  84864. /** @hidden */
  84865. interface IKHRLightsPunctual_LightReference {
  84866. light: number;
  84867. }
  84868. /** @hidden */
  84869. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84870. type: IKHRLightsPunctual_LightType;
  84871. color?: number[];
  84872. intensity?: number;
  84873. range?: number;
  84874. spot?: {
  84875. innerConeAngle?: number;
  84876. outerConeAngle?: number;
  84877. };
  84878. }
  84879. /** @hidden */
  84880. interface IKHRLightsPunctual {
  84881. lights: IKHRLightsPunctual_Light[];
  84882. }
  84883. /**
  84884. * Interfaces from the KHR_materials_clearcoat extension
  84885. * !!! Experimental Extension Subject to Changes !!!
  84886. */
  84887. /** @hidden */
  84888. interface IKHRMaterialsClearcoat {
  84889. clearcoatFactor: number;
  84890. clearcoatTexture: ITextureInfo;
  84891. clearcoatRoughnessFactor: number;
  84892. clearcoatRoughnessTexture: ITextureInfo;
  84893. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84894. }
  84895. /**
  84896. * Interfaces from the KHR_materials_ior extension
  84897. * !!! Experimental Extension Subject to Changes !!!
  84898. */
  84899. /** @hidden */
  84900. interface IKHRMaterialsIor {
  84901. ior: number;
  84902. }
  84903. /**
  84904. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84905. */
  84906. /** @hidden */
  84907. interface IKHRMaterialsPbrSpecularGlossiness {
  84908. diffuseFactor: number[];
  84909. diffuseTexture: ITextureInfo;
  84910. specularFactor: number[];
  84911. glossinessFactor: number;
  84912. specularGlossinessTexture: ITextureInfo;
  84913. }
  84914. /**
  84915. * Interfaces from the KHR_materials_sheen extension
  84916. * !!! Experimental Extension Subject to Changes !!!
  84917. */
  84918. /** @hidden */
  84919. interface IKHRMaterialsSheen {
  84920. sheenColorFactor?: number[];
  84921. sheenTexture?: ITextureInfo;
  84922. sheenRoughnessFactor?: number;
  84923. }
  84924. /**
  84925. * Interfaces from the KHR_materials_specular extension
  84926. * !!! Experimental Extension Subject to Changes !!!
  84927. */
  84928. /** @hidden */
  84929. interface IKHRMaterialsSpecular {
  84930. specularFactor: number;
  84931. specularColorFactor: number[];
  84932. specularTexture: ITextureInfo;
  84933. }
  84934. /**
  84935. * Interfaces from the KHR_materials_transmission extension
  84936. * !!! Experimental Extension Subject to Changes !!!
  84937. */
  84938. /** @hidden */
  84939. interface IKHRMaterialsTransmission {
  84940. transmissionFactor?: number;
  84941. transmissionTexture?: ITextureInfo;
  84942. }
  84943. /**
  84944. * Interfaces from the KHR_materials_variants extension
  84945. * !!! Experimental Extension Subject to Changes !!!
  84946. */
  84947. /** @hidden */
  84948. interface IKHRMaterialVariants_Mapping extends IProperty {
  84949. mappings: Array<{
  84950. variants: number[];
  84951. material: number;
  84952. }>;
  84953. }
  84954. /** @hidden */
  84955. interface IKHRMaterialVariants_Variant extends IProperty {
  84956. name: string;
  84957. }
  84958. /** @hidden */
  84959. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  84960. variants: Array<IKHRMaterialVariants_Variant>;
  84961. }
  84962. /**
  84963. * Interfaces from the KHR_texture_basisu extension
  84964. * !!! Experimental Extension Subject to Changes !!!
  84965. */
  84966. /** @hidden */
  84967. interface IKHRTextureBasisU {
  84968. source: number;
  84969. }
  84970. /**
  84971. * Interfaces from the EXT_texture_webp extension
  84972. */
  84973. /** @hidden */
  84974. interface IEXTTextureWebP {
  84975. source: number;
  84976. }
  84977. /**
  84978. * Interfaces from the KHR_texture_transform extension
  84979. */
  84980. /** @hidden */
  84981. interface IKHRTextureTransform {
  84982. offset?: number[];
  84983. rotation?: number;
  84984. scale?: number[];
  84985. texCoord?: number;
  84986. }
  84987. /**
  84988. * Interfaces from the KHR_xmp extension
  84989. * !!! Experimental Extension Subject to Changes !!!
  84990. */
  84991. /** @hidden */
  84992. interface IKHRXmp_Data {
  84993. [key: string]: unknown;
  84994. }
  84995. /** @hidden */
  84996. interface IKHRXmp_Gltf {
  84997. packets: IKHRXmp_Data[];
  84998. }
  84999. /** @hidden */
  85000. interface IKHRXmp_Node {
  85001. packet: number;
  85002. }
  85003. /**
  85004. * Interfaces from the MSFT_audio_emitter extension
  85005. */
  85006. /** @hidden */
  85007. interface IMSFTAudioEmitter_ClipReference {
  85008. clip: number;
  85009. weight?: number;
  85010. }
  85011. /** @hidden */
  85012. interface IMSFTAudioEmitter_EmittersReference {
  85013. emitters: number[];
  85014. }
  85015. /** @hidden */
  85016. const enum IMSFTAudioEmitter_DistanceModel {
  85017. linear = "linear",
  85018. inverse = "inverse",
  85019. exponential = "exponential",
  85020. }
  85021. /** @hidden */
  85022. interface IMSFTAudioEmitter_Emitter {
  85023. name?: string;
  85024. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85025. refDistance?: number;
  85026. maxDistance?: number;
  85027. rolloffFactor?: number;
  85028. innerAngle?: number;
  85029. outerAngle?: number;
  85030. loop?: boolean;
  85031. volume?: number;
  85032. clips: IMSFTAudioEmitter_ClipReference[];
  85033. }
  85034. /** @hidden */
  85035. const enum IMSFTAudioEmitter_AudioMimeType {
  85036. WAV = "audio/wav",
  85037. }
  85038. /** @hidden */
  85039. interface IMSFTAudioEmitter_Clip extends IProperty {
  85040. uri?: string;
  85041. bufferView?: number;
  85042. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85043. }
  85044. /** @hidden */
  85045. const enum IMSFTAudioEmitter_AnimationEventAction {
  85046. play = "play",
  85047. pause = "pause",
  85048. stop = "stop",
  85049. }
  85050. /** @hidden */
  85051. interface IMSFTAudioEmitter_AnimationEvent {
  85052. action: IMSFTAudioEmitter_AnimationEventAction;
  85053. emitter: number;
  85054. time: number;
  85055. startOffset?: number;
  85056. }
  85057. /**
  85058. * Interfaces from the MSFT_lod extension
  85059. */
  85060. /** @hidden */
  85061. interface IMSFTLOD {
  85062. ids: number[];
  85063. }
  85064. }
  85065. declare module BABYLON {
  85066. /** @hidden */
  85067. export var cellPixelShader: {
  85068. name: string;
  85069. shader: string;
  85070. };
  85071. }
  85072. declare module BABYLON {
  85073. /** @hidden */
  85074. export var cellVertexShader: {
  85075. name: string;
  85076. shader: string;
  85077. };
  85078. }
  85079. declare module BABYLON {
  85080. export class CellMaterial extends BABYLON.PushMaterial {
  85081. private _diffuseTexture;
  85082. diffuseTexture: BABYLON.BaseTexture;
  85083. diffuseColor: BABYLON.Color3;
  85084. _computeHighLevel: boolean;
  85085. computeHighLevel: boolean;
  85086. private _disableLighting;
  85087. disableLighting: boolean;
  85088. private _maxSimultaneousLights;
  85089. maxSimultaneousLights: number;
  85090. constructor(name: string, scene: BABYLON.Scene);
  85091. needAlphaBlending(): boolean;
  85092. needAlphaTesting(): boolean;
  85093. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85094. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85095. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85096. getAnimatables(): BABYLON.IAnimatable[];
  85097. getActiveTextures(): BABYLON.BaseTexture[];
  85098. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85099. dispose(forceDisposeEffect?: boolean): void;
  85100. getClassName(): string;
  85101. clone(name: string): CellMaterial;
  85102. serialize(): any;
  85103. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85104. }
  85105. }
  85106. declare module BABYLON {
  85107. export class CustomShaderStructure {
  85108. FragmentStore: string;
  85109. VertexStore: string;
  85110. constructor();
  85111. }
  85112. export class ShaderSpecialParts {
  85113. constructor();
  85114. Fragment_Begin: string;
  85115. Fragment_Definitions: string;
  85116. Fragment_MainBegin: string;
  85117. Fragment_Custom_Diffuse: string;
  85118. Fragment_Before_Lights: string;
  85119. Fragment_Before_Fog: string;
  85120. Fragment_Custom_Alpha: string;
  85121. Fragment_Before_FragColor: string;
  85122. Vertex_Begin: string;
  85123. Vertex_Definitions: string;
  85124. Vertex_MainBegin: string;
  85125. Vertex_Before_PositionUpdated: string;
  85126. Vertex_Before_NormalUpdated: string;
  85127. Vertex_After_WorldPosComputed: string;
  85128. Vertex_MainEnd: string;
  85129. }
  85130. export class CustomMaterial extends BABYLON.StandardMaterial {
  85131. static ShaderIndexer: number;
  85132. CustomParts: ShaderSpecialParts;
  85133. _isCreatedShader: boolean;
  85134. _createdShaderName: string;
  85135. _customUniform: string[];
  85136. _newUniforms: string[];
  85137. _newUniformInstances: {
  85138. [name: string]: any;
  85139. };
  85140. _newSamplerInstances: {
  85141. [name: string]: BABYLON.Texture;
  85142. };
  85143. _customAttributes: string[];
  85144. FragmentShader: string;
  85145. VertexShader: string;
  85146. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85147. ReviewUniform(name: string, arr: string[]): string[];
  85148. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85149. constructor(name: string, scene: BABYLON.Scene);
  85150. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85151. AddAttribute(name: string): CustomMaterial;
  85152. Fragment_Begin(shaderPart: string): CustomMaterial;
  85153. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85154. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85155. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85156. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85157. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85158. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85159. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85160. Vertex_Begin(shaderPart: string): CustomMaterial;
  85161. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85162. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85163. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85164. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85165. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85166. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85167. }
  85168. }
  85169. declare module BABYLON {
  85170. export class ShaderAlebdoParts {
  85171. constructor();
  85172. Fragment_Begin: string;
  85173. Fragment_Definitions: string;
  85174. Fragment_MainBegin: string;
  85175. Fragment_Custom_Albedo: string;
  85176. Fragment_Before_Lights: string;
  85177. Fragment_Custom_MetallicRoughness: string;
  85178. Fragment_Custom_MicroSurface: string;
  85179. Fragment_Before_Fog: string;
  85180. Fragment_Custom_Alpha: string;
  85181. Fragment_Before_FragColor: string;
  85182. Vertex_Begin: string;
  85183. Vertex_Definitions: string;
  85184. Vertex_MainBegin: string;
  85185. Vertex_Before_PositionUpdated: string;
  85186. Vertex_Before_NormalUpdated: string;
  85187. Vertex_After_WorldPosComputed: string;
  85188. Vertex_MainEnd: string;
  85189. }
  85190. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85191. static ShaderIndexer: number;
  85192. CustomParts: ShaderAlebdoParts;
  85193. _isCreatedShader: boolean;
  85194. _createdShaderName: string;
  85195. _customUniform: string[];
  85196. _newUniforms: string[];
  85197. _newUniformInstances: {
  85198. [name: string]: any;
  85199. };
  85200. _newSamplerInstances: {
  85201. [name: string]: BABYLON.Texture;
  85202. };
  85203. _customAttributes: string[];
  85204. FragmentShader: string;
  85205. VertexShader: string;
  85206. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85207. ReviewUniform(name: string, arr: string[]): string[];
  85208. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85209. constructor(name: string, scene: BABYLON.Scene);
  85210. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85211. AddAttribute(name: string): PBRCustomMaterial;
  85212. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85213. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85214. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85215. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85216. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85217. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85218. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85219. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85220. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85221. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85222. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85223. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85224. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85225. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85226. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85227. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85228. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85229. }
  85230. }
  85231. declare module BABYLON {
  85232. /** @hidden */
  85233. export var firePixelShader: {
  85234. name: string;
  85235. shader: string;
  85236. };
  85237. }
  85238. declare module BABYLON {
  85239. /** @hidden */
  85240. export var fireVertexShader: {
  85241. name: string;
  85242. shader: string;
  85243. };
  85244. }
  85245. declare module BABYLON {
  85246. export class FireMaterial extends BABYLON.PushMaterial {
  85247. private _diffuseTexture;
  85248. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85249. private _distortionTexture;
  85250. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85251. private _opacityTexture;
  85252. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85253. diffuseColor: BABYLON.Color3;
  85254. speed: number;
  85255. private _scaledDiffuse;
  85256. private _lastTime;
  85257. constructor(name: string, scene: BABYLON.Scene);
  85258. needAlphaBlending(): boolean;
  85259. needAlphaTesting(): boolean;
  85260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85262. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85263. getAnimatables(): BABYLON.IAnimatable[];
  85264. getActiveTextures(): BABYLON.BaseTexture[];
  85265. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85266. getClassName(): string;
  85267. dispose(forceDisposeEffect?: boolean): void;
  85268. clone(name: string): FireMaterial;
  85269. serialize(): any;
  85270. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85271. }
  85272. }
  85273. declare module BABYLON {
  85274. /** @hidden */
  85275. export var furPixelShader: {
  85276. name: string;
  85277. shader: string;
  85278. };
  85279. }
  85280. declare module BABYLON {
  85281. /** @hidden */
  85282. export var furVertexShader: {
  85283. name: string;
  85284. shader: string;
  85285. };
  85286. }
  85287. declare module BABYLON {
  85288. export class FurMaterial extends BABYLON.PushMaterial {
  85289. private _diffuseTexture;
  85290. diffuseTexture: BABYLON.BaseTexture;
  85291. private _heightTexture;
  85292. heightTexture: BABYLON.BaseTexture;
  85293. diffuseColor: BABYLON.Color3;
  85294. furLength: number;
  85295. furAngle: number;
  85296. furColor: BABYLON.Color3;
  85297. furOffset: number;
  85298. furSpacing: number;
  85299. furGravity: BABYLON.Vector3;
  85300. furSpeed: number;
  85301. furDensity: number;
  85302. furOcclusion: number;
  85303. furTexture: BABYLON.DynamicTexture;
  85304. private _disableLighting;
  85305. disableLighting: boolean;
  85306. private _maxSimultaneousLights;
  85307. maxSimultaneousLights: number;
  85308. highLevelFur: boolean;
  85309. _meshes: BABYLON.AbstractMesh[];
  85310. private _furTime;
  85311. constructor(name: string, scene: BABYLON.Scene);
  85312. get furTime(): number;
  85313. set furTime(furTime: number);
  85314. needAlphaBlending(): boolean;
  85315. needAlphaTesting(): boolean;
  85316. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85317. updateFur(): void;
  85318. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85319. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85320. getAnimatables(): BABYLON.IAnimatable[];
  85321. getActiveTextures(): BABYLON.BaseTexture[];
  85322. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85323. dispose(forceDisposeEffect?: boolean): void;
  85324. clone(name: string): FurMaterial;
  85325. serialize(): any;
  85326. getClassName(): string;
  85327. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85328. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85329. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85330. }
  85331. }
  85332. declare module BABYLON {
  85333. /** @hidden */
  85334. export var gradientPixelShader: {
  85335. name: string;
  85336. shader: string;
  85337. };
  85338. }
  85339. declare module BABYLON {
  85340. /** @hidden */
  85341. export var gradientVertexShader: {
  85342. name: string;
  85343. shader: string;
  85344. };
  85345. }
  85346. declare module BABYLON {
  85347. export class GradientMaterial extends BABYLON.PushMaterial {
  85348. private _maxSimultaneousLights;
  85349. maxSimultaneousLights: number;
  85350. topColor: BABYLON.Color3;
  85351. topColorAlpha: number;
  85352. bottomColor: BABYLON.Color3;
  85353. bottomColorAlpha: number;
  85354. offset: number;
  85355. scale: number;
  85356. smoothness: number;
  85357. private _disableLighting;
  85358. disableLighting: boolean;
  85359. constructor(name: string, scene: BABYLON.Scene);
  85360. needAlphaBlending(): boolean;
  85361. needAlphaTesting(): boolean;
  85362. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85363. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85364. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85365. getAnimatables(): BABYLON.IAnimatable[];
  85366. dispose(forceDisposeEffect?: boolean): void;
  85367. clone(name: string): GradientMaterial;
  85368. serialize(): any;
  85369. getClassName(): string;
  85370. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85371. }
  85372. }
  85373. declare module BABYLON {
  85374. /** @hidden */
  85375. export var gridPixelShader: {
  85376. name: string;
  85377. shader: string;
  85378. };
  85379. }
  85380. declare module BABYLON {
  85381. /** @hidden */
  85382. export var gridVertexShader: {
  85383. name: string;
  85384. shader: string;
  85385. };
  85386. }
  85387. declare module BABYLON {
  85388. /**
  85389. * The grid materials allows you to wrap any shape with a grid.
  85390. * Colors are customizable.
  85391. */
  85392. export class GridMaterial extends BABYLON.PushMaterial {
  85393. /**
  85394. * Main color of the grid (e.g. between lines)
  85395. */
  85396. mainColor: BABYLON.Color3;
  85397. /**
  85398. * Color of the grid lines.
  85399. */
  85400. lineColor: BABYLON.Color3;
  85401. /**
  85402. * The scale of the grid compared to unit.
  85403. */
  85404. gridRatio: number;
  85405. /**
  85406. * Allows setting an offset for the grid lines.
  85407. */
  85408. gridOffset: BABYLON.Vector3;
  85409. /**
  85410. * The frequency of thicker lines.
  85411. */
  85412. majorUnitFrequency: number;
  85413. /**
  85414. * The visibility of minor units in the grid.
  85415. */
  85416. minorUnitVisibility: number;
  85417. /**
  85418. * The grid opacity outside of the lines.
  85419. */
  85420. opacity: number;
  85421. /**
  85422. * Determine RBG output is premultiplied by alpha value.
  85423. */
  85424. preMultiplyAlpha: boolean;
  85425. private _opacityTexture;
  85426. opacityTexture: BABYLON.BaseTexture;
  85427. private _gridControl;
  85428. /**
  85429. * constructor
  85430. * @param name The name given to the material in order to identify it afterwards.
  85431. * @param scene The scene the material is used in.
  85432. */
  85433. constructor(name: string, scene: BABYLON.Scene);
  85434. /**
  85435. * Returns wehter or not the grid requires alpha blending.
  85436. */
  85437. needAlphaBlending(): boolean;
  85438. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85439. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85440. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85441. /**
  85442. * Dispose the material and its associated resources.
  85443. * @param forceDisposeEffect will also dispose the used effect when true
  85444. */
  85445. dispose(forceDisposeEffect?: boolean): void;
  85446. clone(name: string): GridMaterial;
  85447. serialize(): any;
  85448. getClassName(): string;
  85449. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85450. }
  85451. }
  85452. declare module BABYLON {
  85453. /** @hidden */
  85454. export var lavaPixelShader: {
  85455. name: string;
  85456. shader: string;
  85457. };
  85458. }
  85459. declare module BABYLON {
  85460. /** @hidden */
  85461. export var lavaVertexShader: {
  85462. name: string;
  85463. shader: string;
  85464. };
  85465. }
  85466. declare module BABYLON {
  85467. export class LavaMaterial extends BABYLON.PushMaterial {
  85468. private _diffuseTexture;
  85469. diffuseTexture: BABYLON.BaseTexture;
  85470. noiseTexture: BABYLON.BaseTexture;
  85471. fogColor: BABYLON.Color3;
  85472. speed: number;
  85473. movingSpeed: number;
  85474. lowFrequencySpeed: number;
  85475. fogDensity: number;
  85476. private _lastTime;
  85477. diffuseColor: BABYLON.Color3;
  85478. private _disableLighting;
  85479. disableLighting: boolean;
  85480. private _unlit;
  85481. unlit: boolean;
  85482. private _maxSimultaneousLights;
  85483. maxSimultaneousLights: number;
  85484. private _scaledDiffuse;
  85485. constructor(name: string, scene: BABYLON.Scene);
  85486. needAlphaBlending(): boolean;
  85487. needAlphaTesting(): boolean;
  85488. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85489. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85490. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85491. getAnimatables(): BABYLON.IAnimatable[];
  85492. getActiveTextures(): BABYLON.BaseTexture[];
  85493. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85494. dispose(forceDisposeEffect?: boolean): void;
  85495. clone(name: string): LavaMaterial;
  85496. serialize(): any;
  85497. getClassName(): string;
  85498. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85499. }
  85500. }
  85501. declare module BABYLON {
  85502. /** @hidden */
  85503. export var mixPixelShader: {
  85504. name: string;
  85505. shader: string;
  85506. };
  85507. }
  85508. declare module BABYLON {
  85509. /** @hidden */
  85510. export var mixVertexShader: {
  85511. name: string;
  85512. shader: string;
  85513. };
  85514. }
  85515. declare module BABYLON {
  85516. export class MixMaterial extends BABYLON.PushMaterial {
  85517. /**
  85518. * Mix textures
  85519. */
  85520. private _mixTexture1;
  85521. mixTexture1: BABYLON.BaseTexture;
  85522. private _mixTexture2;
  85523. mixTexture2: BABYLON.BaseTexture;
  85524. /**
  85525. * Diffuse textures
  85526. */
  85527. private _diffuseTexture1;
  85528. diffuseTexture1: BABYLON.Texture;
  85529. private _diffuseTexture2;
  85530. diffuseTexture2: BABYLON.Texture;
  85531. private _diffuseTexture3;
  85532. diffuseTexture3: BABYLON.Texture;
  85533. private _diffuseTexture4;
  85534. diffuseTexture4: BABYLON.Texture;
  85535. private _diffuseTexture5;
  85536. diffuseTexture5: BABYLON.Texture;
  85537. private _diffuseTexture6;
  85538. diffuseTexture6: BABYLON.Texture;
  85539. private _diffuseTexture7;
  85540. diffuseTexture7: BABYLON.Texture;
  85541. private _diffuseTexture8;
  85542. diffuseTexture8: BABYLON.Texture;
  85543. /**
  85544. * Uniforms
  85545. */
  85546. diffuseColor: BABYLON.Color3;
  85547. specularColor: BABYLON.Color3;
  85548. specularPower: number;
  85549. private _disableLighting;
  85550. disableLighting: boolean;
  85551. private _maxSimultaneousLights;
  85552. maxSimultaneousLights: number;
  85553. constructor(name: string, scene: BABYLON.Scene);
  85554. needAlphaBlending(): boolean;
  85555. needAlphaTesting(): boolean;
  85556. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85557. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85558. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85559. getAnimatables(): BABYLON.IAnimatable[];
  85560. getActiveTextures(): BABYLON.BaseTexture[];
  85561. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85562. dispose(forceDisposeEffect?: boolean): void;
  85563. clone(name: string): MixMaterial;
  85564. serialize(): any;
  85565. getClassName(): string;
  85566. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85567. }
  85568. }
  85569. declare module BABYLON {
  85570. /** @hidden */
  85571. export var normalPixelShader: {
  85572. name: string;
  85573. shader: string;
  85574. };
  85575. }
  85576. declare module BABYLON {
  85577. /** @hidden */
  85578. export var normalVertexShader: {
  85579. name: string;
  85580. shader: string;
  85581. };
  85582. }
  85583. declare module BABYLON {
  85584. export class NormalMaterial extends BABYLON.PushMaterial {
  85585. private _diffuseTexture;
  85586. diffuseTexture: BABYLON.BaseTexture;
  85587. diffuseColor: BABYLON.Color3;
  85588. private _disableLighting;
  85589. disableLighting: boolean;
  85590. private _maxSimultaneousLights;
  85591. maxSimultaneousLights: number;
  85592. constructor(name: string, scene: BABYLON.Scene);
  85593. needAlphaBlending(): boolean;
  85594. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85595. needAlphaTesting(): boolean;
  85596. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85597. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85598. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85599. getAnimatables(): BABYLON.IAnimatable[];
  85600. getActiveTextures(): BABYLON.BaseTexture[];
  85601. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85602. dispose(forceDisposeEffect?: boolean): void;
  85603. clone(name: string): NormalMaterial;
  85604. serialize(): any;
  85605. getClassName(): string;
  85606. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85607. }
  85608. }
  85609. declare module BABYLON {
  85610. /** @hidden */
  85611. export var shadowOnlyPixelShader: {
  85612. name: string;
  85613. shader: string;
  85614. };
  85615. }
  85616. declare module BABYLON {
  85617. /** @hidden */
  85618. export var shadowOnlyVertexShader: {
  85619. name: string;
  85620. shader: string;
  85621. };
  85622. }
  85623. declare module BABYLON {
  85624. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85625. private _activeLight;
  85626. private _needAlphaBlending;
  85627. constructor(name: string, scene: BABYLON.Scene);
  85628. shadowColor: BABYLON.Color3;
  85629. needAlphaBlending(): boolean;
  85630. needAlphaTesting(): boolean;
  85631. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85632. get activeLight(): BABYLON.IShadowLight;
  85633. set activeLight(light: BABYLON.IShadowLight);
  85634. private _getFirstShadowLightForMesh;
  85635. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85636. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85637. clone(name: string): ShadowOnlyMaterial;
  85638. serialize(): any;
  85639. getClassName(): string;
  85640. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85641. }
  85642. }
  85643. declare module BABYLON {
  85644. /** @hidden */
  85645. export var simplePixelShader: {
  85646. name: string;
  85647. shader: string;
  85648. };
  85649. }
  85650. declare module BABYLON {
  85651. /** @hidden */
  85652. export var simpleVertexShader: {
  85653. name: string;
  85654. shader: string;
  85655. };
  85656. }
  85657. declare module BABYLON {
  85658. export class SimpleMaterial extends BABYLON.PushMaterial {
  85659. private _diffuseTexture;
  85660. diffuseTexture: BABYLON.BaseTexture;
  85661. diffuseColor: BABYLON.Color3;
  85662. private _disableLighting;
  85663. disableLighting: boolean;
  85664. private _maxSimultaneousLights;
  85665. maxSimultaneousLights: number;
  85666. constructor(name: string, scene: BABYLON.Scene);
  85667. needAlphaBlending(): boolean;
  85668. needAlphaTesting(): boolean;
  85669. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85670. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85671. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85672. getAnimatables(): BABYLON.IAnimatable[];
  85673. getActiveTextures(): BABYLON.BaseTexture[];
  85674. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85675. dispose(forceDisposeEffect?: boolean): void;
  85676. clone(name: string): SimpleMaterial;
  85677. serialize(): any;
  85678. getClassName(): string;
  85679. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85680. }
  85681. }
  85682. declare module BABYLON {
  85683. /** @hidden */
  85684. export var skyPixelShader: {
  85685. name: string;
  85686. shader: string;
  85687. };
  85688. }
  85689. declare module BABYLON {
  85690. /** @hidden */
  85691. export var skyVertexShader: {
  85692. name: string;
  85693. shader: string;
  85694. };
  85695. }
  85696. declare module BABYLON {
  85697. /**
  85698. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85699. * @see https://doc.babylonjs.com/extensions/sky
  85700. */
  85701. export class SkyMaterial extends BABYLON.PushMaterial {
  85702. /**
  85703. * Defines the overall luminance of sky in interval ]0, 1[.
  85704. */
  85705. luminance: number;
  85706. /**
  85707. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85708. */
  85709. turbidity: number;
  85710. /**
  85711. * Defines the sky appearance (light intensity).
  85712. */
  85713. rayleigh: number;
  85714. /**
  85715. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85716. */
  85717. mieCoefficient: number;
  85718. /**
  85719. * Defines the amount of haze particles following the Mie scattering theory.
  85720. */
  85721. mieDirectionalG: number;
  85722. /**
  85723. * Defines the distance of the sun according to the active scene camera.
  85724. */
  85725. distance: number;
  85726. /**
  85727. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85728. * "inclined".
  85729. */
  85730. inclination: number;
  85731. /**
  85732. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85733. * an object direction and a reference direction.
  85734. */
  85735. azimuth: number;
  85736. /**
  85737. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85738. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85739. */
  85740. sunPosition: BABYLON.Vector3;
  85741. /**
  85742. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85743. * .sunPosition property.
  85744. */
  85745. useSunPosition: boolean;
  85746. /**
  85747. * Defines an offset vector used to get a horizon offset.
  85748. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85749. */
  85750. cameraOffset: BABYLON.Vector3;
  85751. private _cameraPosition;
  85752. /**
  85753. * Instantiates a new sky material.
  85754. * This material allows to create dynamic and texture free
  85755. * effects for skyboxes by taking care of the atmosphere state.
  85756. * @see https://doc.babylonjs.com/extensions/sky
  85757. * @param name Define the name of the material in the scene
  85758. * @param scene Define the scene the material belong to
  85759. */
  85760. constructor(name: string, scene: BABYLON.Scene);
  85761. /**
  85762. * Specifies if the material will require alpha blending
  85763. * @returns a boolean specifying if alpha blending is needed
  85764. */
  85765. needAlphaBlending(): boolean;
  85766. /**
  85767. * Specifies if this material should be rendered in alpha test mode
  85768. * @returns false as the sky material doesn't need alpha testing.
  85769. */
  85770. needAlphaTesting(): boolean;
  85771. /**
  85772. * Get the texture used for alpha test purpose.
  85773. * @returns null as the sky material has no texture.
  85774. */
  85775. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85776. /**
  85777. * Get if the submesh is ready to be used and all its information available.
  85778. * Child classes can use it to update shaders
  85779. * @param mesh defines the mesh to check
  85780. * @param subMesh defines which submesh to check
  85781. * @param useInstances specifies that instances should be used
  85782. * @returns a boolean indicating that the submesh is ready or not
  85783. */
  85784. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85785. /**
  85786. * Binds the submesh to this material by preparing the effect and shader to draw
  85787. * @param world defines the world transformation matrix
  85788. * @param mesh defines the mesh containing the submesh
  85789. * @param subMesh defines the submesh to bind the material to
  85790. */
  85791. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85792. /**
  85793. * Get the list of animatables in the material.
  85794. * @returns the list of animatables object used in the material
  85795. */
  85796. getAnimatables(): BABYLON.IAnimatable[];
  85797. /**
  85798. * Disposes the material
  85799. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85800. */
  85801. dispose(forceDisposeEffect?: boolean): void;
  85802. /**
  85803. * Makes a duplicate of the material, and gives it a new name
  85804. * @param name defines the new name for the duplicated material
  85805. * @returns the cloned material
  85806. */
  85807. clone(name: string): SkyMaterial;
  85808. /**
  85809. * Serializes this material in a JSON representation
  85810. * @returns the serialized material object
  85811. */
  85812. serialize(): any;
  85813. /**
  85814. * Gets the current class name of the material e.g. "SkyMaterial"
  85815. * Mainly use in serialization.
  85816. * @returns the class name
  85817. */
  85818. getClassName(): string;
  85819. /**
  85820. * Creates a sky material from parsed material data
  85821. * @param source defines the JSON representation of the material
  85822. * @param scene defines the hosting scene
  85823. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85824. * @returns a new sky material
  85825. */
  85826. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85827. }
  85828. }
  85829. declare module BABYLON {
  85830. /** @hidden */
  85831. export var terrainPixelShader: {
  85832. name: string;
  85833. shader: string;
  85834. };
  85835. }
  85836. declare module BABYLON {
  85837. /** @hidden */
  85838. export var terrainVertexShader: {
  85839. name: string;
  85840. shader: string;
  85841. };
  85842. }
  85843. declare module BABYLON {
  85844. export class TerrainMaterial extends BABYLON.PushMaterial {
  85845. private _mixTexture;
  85846. mixTexture: BABYLON.BaseTexture;
  85847. private _diffuseTexture1;
  85848. diffuseTexture1: BABYLON.Texture;
  85849. private _diffuseTexture2;
  85850. diffuseTexture2: BABYLON.Texture;
  85851. private _diffuseTexture3;
  85852. diffuseTexture3: BABYLON.Texture;
  85853. private _bumpTexture1;
  85854. bumpTexture1: BABYLON.Texture;
  85855. private _bumpTexture2;
  85856. bumpTexture2: BABYLON.Texture;
  85857. private _bumpTexture3;
  85858. bumpTexture3: BABYLON.Texture;
  85859. diffuseColor: BABYLON.Color3;
  85860. specularColor: BABYLON.Color3;
  85861. specularPower: number;
  85862. private _disableLighting;
  85863. disableLighting: boolean;
  85864. private _maxSimultaneousLights;
  85865. maxSimultaneousLights: number;
  85866. constructor(name: string, scene: BABYLON.Scene);
  85867. needAlphaBlending(): boolean;
  85868. needAlphaTesting(): boolean;
  85869. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85870. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85871. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85872. getAnimatables(): BABYLON.IAnimatable[];
  85873. getActiveTextures(): BABYLON.BaseTexture[];
  85874. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85875. dispose(forceDisposeEffect?: boolean): void;
  85876. clone(name: string): TerrainMaterial;
  85877. serialize(): any;
  85878. getClassName(): string;
  85879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85880. }
  85881. }
  85882. declare module BABYLON {
  85883. /** @hidden */
  85884. export var triplanarPixelShader: {
  85885. name: string;
  85886. shader: string;
  85887. };
  85888. }
  85889. declare module BABYLON {
  85890. /** @hidden */
  85891. export var triplanarVertexShader: {
  85892. name: string;
  85893. shader: string;
  85894. };
  85895. }
  85896. declare module BABYLON {
  85897. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85898. mixTexture: BABYLON.BaseTexture;
  85899. private _diffuseTextureX;
  85900. diffuseTextureX: BABYLON.BaseTexture;
  85901. private _diffuseTextureY;
  85902. diffuseTextureY: BABYLON.BaseTexture;
  85903. private _diffuseTextureZ;
  85904. diffuseTextureZ: BABYLON.BaseTexture;
  85905. private _normalTextureX;
  85906. normalTextureX: BABYLON.BaseTexture;
  85907. private _normalTextureY;
  85908. normalTextureY: BABYLON.BaseTexture;
  85909. private _normalTextureZ;
  85910. normalTextureZ: BABYLON.BaseTexture;
  85911. tileSize: number;
  85912. diffuseColor: BABYLON.Color3;
  85913. specularColor: BABYLON.Color3;
  85914. specularPower: number;
  85915. private _disableLighting;
  85916. disableLighting: boolean;
  85917. private _maxSimultaneousLights;
  85918. maxSimultaneousLights: number;
  85919. constructor(name: string, scene: BABYLON.Scene);
  85920. needAlphaBlending(): boolean;
  85921. needAlphaTesting(): boolean;
  85922. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85923. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85924. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85925. getAnimatables(): BABYLON.IAnimatable[];
  85926. getActiveTextures(): BABYLON.BaseTexture[];
  85927. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85928. dispose(forceDisposeEffect?: boolean): void;
  85929. clone(name: string): TriPlanarMaterial;
  85930. serialize(): any;
  85931. getClassName(): string;
  85932. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85933. }
  85934. }
  85935. declare module BABYLON {
  85936. /** @hidden */
  85937. export var waterPixelShader: {
  85938. name: string;
  85939. shader: string;
  85940. };
  85941. }
  85942. declare module BABYLON {
  85943. /** @hidden */
  85944. export var waterVertexShader: {
  85945. name: string;
  85946. shader: string;
  85947. };
  85948. }
  85949. declare module BABYLON {
  85950. export class WaterMaterial extends BABYLON.PushMaterial {
  85951. renderTargetSize: BABYLON.Vector2;
  85952. private _bumpTexture;
  85953. bumpTexture: BABYLON.BaseTexture;
  85954. diffuseColor: BABYLON.Color3;
  85955. specularColor: BABYLON.Color3;
  85956. specularPower: number;
  85957. private _disableLighting;
  85958. disableLighting: boolean;
  85959. private _maxSimultaneousLights;
  85960. maxSimultaneousLights: number;
  85961. /**
  85962. * @param {number}: Represents the wind force
  85963. */
  85964. windForce: number;
  85965. /**
  85966. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85967. */
  85968. windDirection: BABYLON.Vector2;
  85969. /**
  85970. * @param {number}: Wave height, represents the height of the waves
  85971. */
  85972. waveHeight: number;
  85973. /**
  85974. * @param {number}: Bump height, represents the bump height related to the bump map
  85975. */
  85976. bumpHeight: number;
  85977. /**
  85978. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85979. */
  85980. private _bumpSuperimpose;
  85981. bumpSuperimpose: boolean;
  85982. /**
  85983. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85984. */
  85985. private _fresnelSeparate;
  85986. fresnelSeparate: boolean;
  85987. /**
  85988. * @param {boolean}: bump Waves modify the reflection.
  85989. */
  85990. private _bumpAffectsReflection;
  85991. bumpAffectsReflection: boolean;
  85992. /**
  85993. * @param {number}: The water color blended with the refraction (near)
  85994. */
  85995. waterColor: BABYLON.Color3;
  85996. /**
  85997. * @param {number}: The blend factor related to the water color
  85998. */
  85999. colorBlendFactor: number;
  86000. /**
  86001. * @param {number}: The water color blended with the reflection (far)
  86002. */
  86003. waterColor2: BABYLON.Color3;
  86004. /**
  86005. * @param {number}: The blend factor related to the water color (reflection, far)
  86006. */
  86007. colorBlendFactor2: number;
  86008. /**
  86009. * @param {number}: Represents the maximum length of a wave
  86010. */
  86011. waveLength: number;
  86012. /**
  86013. * @param {number}: Defines the waves speed
  86014. */
  86015. waveSpeed: number;
  86016. /**
  86017. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86018. * will avoid calculating useless pixels in the pixel shader of the water material.
  86019. */
  86020. disableClipPlane: boolean;
  86021. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86022. private _mesh;
  86023. private _refractionRTT;
  86024. private _reflectionRTT;
  86025. private _reflectionTransform;
  86026. private _lastTime;
  86027. private _lastDeltaTime;
  86028. private _useLogarithmicDepth;
  86029. private _waitingRenderList;
  86030. private _imageProcessingConfiguration;
  86031. private _imageProcessingObserver;
  86032. /**
  86033. * Gets a boolean indicating that current material needs to register RTT
  86034. */
  86035. get hasRenderTargetTextures(): boolean;
  86036. /**
  86037. * Constructor
  86038. */
  86039. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86040. get useLogarithmicDepth(): boolean;
  86041. set useLogarithmicDepth(value: boolean);
  86042. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86043. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86044. addToRenderList(node: any): void;
  86045. enableRenderTargets(enable: boolean): void;
  86046. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86047. get renderTargetsEnabled(): boolean;
  86048. needAlphaBlending(): boolean;
  86049. needAlphaTesting(): boolean;
  86050. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86051. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86052. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86053. private _createRenderTargets;
  86054. getAnimatables(): BABYLON.IAnimatable[];
  86055. getActiveTextures(): BABYLON.BaseTexture[];
  86056. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86057. dispose(forceDisposeEffect?: boolean): void;
  86058. clone(name: string): WaterMaterial;
  86059. serialize(): any;
  86060. getClassName(): string;
  86061. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86062. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86063. }
  86064. }
  86065. declare module BABYLON {
  86066. /** @hidden */
  86067. export var asciiartPixelShader: {
  86068. name: string;
  86069. shader: string;
  86070. };
  86071. }
  86072. declare module BABYLON {
  86073. /**
  86074. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86075. *
  86076. * It basically takes care rendering the font front the given font size to a texture.
  86077. * This is used later on in the postprocess.
  86078. */
  86079. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86080. private _font;
  86081. private _text;
  86082. private _charSize;
  86083. /**
  86084. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86085. */
  86086. get charSize(): number;
  86087. /**
  86088. * Create a new instance of the Ascii Art FontTexture class
  86089. * @param name the name of the texture
  86090. * @param font the font to use, use the W3C CSS notation
  86091. * @param text the caracter set to use in the rendering.
  86092. * @param scene the scene that owns the texture
  86093. */
  86094. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86095. /**
  86096. * Gets the max char width of a font.
  86097. * @param font the font to use, use the W3C CSS notation
  86098. * @return the max char width
  86099. */
  86100. private getFontWidth;
  86101. /**
  86102. * Gets the max char height of a font.
  86103. * @param font the font to use, use the W3C CSS notation
  86104. * @return the max char height
  86105. */
  86106. private getFontHeight;
  86107. /**
  86108. * Clones the current AsciiArtTexture.
  86109. * @return the clone of the texture.
  86110. */
  86111. clone(): AsciiArtFontTexture;
  86112. /**
  86113. * Parses a json object representing the texture and returns an instance of it.
  86114. * @param source the source JSON representation
  86115. * @param scene the scene to create the texture for
  86116. * @return the parsed texture
  86117. */
  86118. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86119. }
  86120. /**
  86121. * Option available in the Ascii Art Post Process.
  86122. */
  86123. export interface IAsciiArtPostProcessOptions {
  86124. /**
  86125. * The font to use following the w3c font definition.
  86126. */
  86127. font?: string;
  86128. /**
  86129. * The character set to use in the postprocess.
  86130. */
  86131. characterSet?: string;
  86132. /**
  86133. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86134. * This number is defined between 0 and 1;
  86135. */
  86136. mixToTile?: number;
  86137. /**
  86138. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86139. * This number is defined between 0 and 1;
  86140. */
  86141. mixToNormal?: number;
  86142. }
  86143. /**
  86144. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86145. *
  86146. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86147. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86148. */
  86149. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86150. /**
  86151. * The font texture used to render the char in the post process.
  86152. */
  86153. private _asciiArtFontTexture;
  86154. /**
  86155. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86156. * This number is defined between 0 and 1;
  86157. */
  86158. mixToTile: number;
  86159. /**
  86160. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86161. * This number is defined between 0 and 1;
  86162. */
  86163. mixToNormal: number;
  86164. /**
  86165. * Instantiates a new Ascii Art Post Process.
  86166. * @param name the name to give to the postprocess
  86167. * @camera the camera to apply the post process to.
  86168. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86169. */
  86170. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86171. }
  86172. }
  86173. declare module BABYLON {
  86174. /** @hidden */
  86175. export var digitalrainPixelShader: {
  86176. name: string;
  86177. shader: string;
  86178. };
  86179. }
  86180. declare module BABYLON {
  86181. /**
  86182. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86183. *
  86184. * It basically takes care rendering the font front the given font size to a texture.
  86185. * This is used later on in the postprocess.
  86186. */
  86187. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86188. private _font;
  86189. private _text;
  86190. private _charSize;
  86191. /**
  86192. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86193. */
  86194. get charSize(): number;
  86195. /**
  86196. * Create a new instance of the Digital Rain FontTexture class
  86197. * @param name the name of the texture
  86198. * @param font the font to use, use the W3C CSS notation
  86199. * @param text the caracter set to use in the rendering.
  86200. * @param scene the scene that owns the texture
  86201. */
  86202. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86203. /**
  86204. * Gets the max char width of a font.
  86205. * @param font the font to use, use the W3C CSS notation
  86206. * @return the max char width
  86207. */
  86208. private getFontWidth;
  86209. /**
  86210. * Gets the max char height of a font.
  86211. * @param font the font to use, use the W3C CSS notation
  86212. * @return the max char height
  86213. */
  86214. private getFontHeight;
  86215. /**
  86216. * Clones the current DigitalRainFontTexture.
  86217. * @return the clone of the texture.
  86218. */
  86219. clone(): DigitalRainFontTexture;
  86220. /**
  86221. * Parses a json object representing the texture and returns an instance of it.
  86222. * @param source the source JSON representation
  86223. * @param scene the scene to create the texture for
  86224. * @return the parsed texture
  86225. */
  86226. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86227. }
  86228. /**
  86229. * Option available in the Digital Rain Post Process.
  86230. */
  86231. export interface IDigitalRainPostProcessOptions {
  86232. /**
  86233. * The font to use following the w3c font definition.
  86234. */
  86235. font?: string;
  86236. /**
  86237. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86238. * This number is defined between 0 and 1;
  86239. */
  86240. mixToTile?: number;
  86241. /**
  86242. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86243. * This number is defined between 0 and 1;
  86244. */
  86245. mixToNormal?: number;
  86246. }
  86247. /**
  86248. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86249. *
  86250. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86251. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86252. */
  86253. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86254. /**
  86255. * The font texture used to render the char in the post process.
  86256. */
  86257. private _digitalRainFontTexture;
  86258. /**
  86259. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86260. * This number is defined between 0 and 1;
  86261. */
  86262. mixToTile: number;
  86263. /**
  86264. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86265. * This number is defined between 0 and 1;
  86266. */
  86267. mixToNormal: number;
  86268. /**
  86269. * Instantiates a new Digital Rain Post Process.
  86270. * @param name the name to give to the postprocess
  86271. * @camera the camera to apply the post process to.
  86272. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86273. */
  86274. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86275. }
  86276. }
  86277. declare module BABYLON {
  86278. /** @hidden */
  86279. export var brickProceduralTexturePixelShader: {
  86280. name: string;
  86281. shader: string;
  86282. };
  86283. }
  86284. declare module BABYLON {
  86285. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86286. private _numberOfBricksHeight;
  86287. private _numberOfBricksWidth;
  86288. private _jointColor;
  86289. private _brickColor;
  86290. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86291. updateShaderUniforms(): void;
  86292. get numberOfBricksHeight(): number;
  86293. set numberOfBricksHeight(value: number);
  86294. get numberOfBricksWidth(): number;
  86295. set numberOfBricksWidth(value: number);
  86296. get jointColor(): BABYLON.Color3;
  86297. set jointColor(value: BABYLON.Color3);
  86298. get brickColor(): BABYLON.Color3;
  86299. set brickColor(value: BABYLON.Color3);
  86300. /**
  86301. * Serializes this brick procedural texture
  86302. * @returns a serialized brick procedural texture object
  86303. */
  86304. serialize(): any;
  86305. /**
  86306. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86307. * @param parsedTexture defines parsed texture data
  86308. * @param scene defines the current scene
  86309. * @param rootUrl defines the root URL containing brick procedural texture information
  86310. * @returns a parsed Brick Procedural BABYLON.Texture
  86311. */
  86312. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86313. }
  86314. }
  86315. declare module BABYLON {
  86316. /** @hidden */
  86317. export var cloudProceduralTexturePixelShader: {
  86318. name: string;
  86319. shader: string;
  86320. };
  86321. }
  86322. declare module BABYLON {
  86323. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86324. private _skyColor;
  86325. private _cloudColor;
  86326. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86327. updateShaderUniforms(): void;
  86328. get skyColor(): BABYLON.Color4;
  86329. set skyColor(value: BABYLON.Color4);
  86330. get cloudColor(): BABYLON.Color4;
  86331. set cloudColor(value: BABYLON.Color4);
  86332. /**
  86333. * Serializes this cloud procedural texture
  86334. * @returns a serialized cloud procedural texture object
  86335. */
  86336. serialize(): any;
  86337. /**
  86338. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86339. * @param parsedTexture defines parsed texture data
  86340. * @param scene defines the current scene
  86341. * @param rootUrl defines the root URL containing cloud procedural texture information
  86342. * @returns a parsed Cloud Procedural BABYLON.Texture
  86343. */
  86344. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86345. }
  86346. }
  86347. declare module BABYLON {
  86348. /** @hidden */
  86349. export var fireProceduralTexturePixelShader: {
  86350. name: string;
  86351. shader: string;
  86352. };
  86353. }
  86354. declare module BABYLON {
  86355. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86356. private _time;
  86357. private _speed;
  86358. private _autoGenerateTime;
  86359. private _fireColors;
  86360. private _alphaThreshold;
  86361. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86362. updateShaderUniforms(): void;
  86363. render(useCameraPostProcess?: boolean): void;
  86364. static get PurpleFireColors(): BABYLON.Color3[];
  86365. static get GreenFireColors(): BABYLON.Color3[];
  86366. static get RedFireColors(): BABYLON.Color3[];
  86367. static get BlueFireColors(): BABYLON.Color3[];
  86368. get autoGenerateTime(): boolean;
  86369. set autoGenerateTime(value: boolean);
  86370. get fireColors(): BABYLON.Color3[];
  86371. set fireColors(value: BABYLON.Color3[]);
  86372. get time(): number;
  86373. set time(value: number);
  86374. get speed(): BABYLON.Vector2;
  86375. set speed(value: BABYLON.Vector2);
  86376. get alphaThreshold(): number;
  86377. set alphaThreshold(value: number);
  86378. /**
  86379. * Serializes this fire procedural texture
  86380. * @returns a serialized fire procedural texture object
  86381. */
  86382. serialize(): any;
  86383. /**
  86384. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86385. * @param parsedTexture defines parsed texture data
  86386. * @param scene defines the current scene
  86387. * @param rootUrl defines the root URL containing fire procedural texture information
  86388. * @returns a parsed Fire Procedural BABYLON.Texture
  86389. */
  86390. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86391. }
  86392. }
  86393. declare module BABYLON {
  86394. /** @hidden */
  86395. export var grassProceduralTexturePixelShader: {
  86396. name: string;
  86397. shader: string;
  86398. };
  86399. }
  86400. declare module BABYLON {
  86401. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86402. private _grassColors;
  86403. private _groundColor;
  86404. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86405. updateShaderUniforms(): void;
  86406. get grassColors(): BABYLON.Color3[];
  86407. set grassColors(value: BABYLON.Color3[]);
  86408. get groundColor(): BABYLON.Color3;
  86409. set groundColor(value: BABYLON.Color3);
  86410. /**
  86411. * Serializes this grass procedural texture
  86412. * @returns a serialized grass procedural texture object
  86413. */
  86414. serialize(): any;
  86415. /**
  86416. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86417. * @param parsedTexture defines parsed texture data
  86418. * @param scene defines the current scene
  86419. * @param rootUrl defines the root URL containing grass procedural texture information
  86420. * @returns a parsed Grass Procedural BABYLON.Texture
  86421. */
  86422. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86423. }
  86424. }
  86425. declare module BABYLON {
  86426. /** @hidden */
  86427. export var marbleProceduralTexturePixelShader: {
  86428. name: string;
  86429. shader: string;
  86430. };
  86431. }
  86432. declare module BABYLON {
  86433. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86434. private _numberOfTilesHeight;
  86435. private _numberOfTilesWidth;
  86436. private _amplitude;
  86437. private _jointColor;
  86438. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86439. updateShaderUniforms(): void;
  86440. get numberOfTilesHeight(): number;
  86441. set numberOfTilesHeight(value: number);
  86442. get amplitude(): number;
  86443. set amplitude(value: number);
  86444. get numberOfTilesWidth(): number;
  86445. set numberOfTilesWidth(value: number);
  86446. get jointColor(): BABYLON.Color3;
  86447. set jointColor(value: BABYLON.Color3);
  86448. /**
  86449. * Serializes this marble procedural texture
  86450. * @returns a serialized marble procedural texture object
  86451. */
  86452. serialize(): any;
  86453. /**
  86454. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86455. * @param parsedTexture defines parsed texture data
  86456. * @param scene defines the current scene
  86457. * @param rootUrl defines the root URL containing marble procedural texture information
  86458. * @returns a parsed Marble Procedural BABYLON.Texture
  86459. */
  86460. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86461. }
  86462. }
  86463. declare module BABYLON {
  86464. /** @hidden */
  86465. export var normalMapProceduralTexturePixelShader: {
  86466. name: string;
  86467. shader: string;
  86468. };
  86469. }
  86470. declare module BABYLON {
  86471. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86472. private _baseTexture;
  86473. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86474. updateShaderUniforms(): void;
  86475. render(useCameraPostProcess?: boolean): void;
  86476. resize(size: any, generateMipMaps: any): void;
  86477. get baseTexture(): BABYLON.Texture;
  86478. set baseTexture(texture: BABYLON.Texture);
  86479. /**
  86480. * Serializes this normal map procedural texture
  86481. * @returns a serialized normal map procedural texture object
  86482. */
  86483. serialize(): any;
  86484. /**
  86485. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86486. * @param parsedTexture defines parsed texture data
  86487. * @param scene defines the current scene
  86488. * @param rootUrl defines the root URL containing normal map procedural texture information
  86489. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86490. */
  86491. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86492. }
  86493. }
  86494. declare module BABYLON {
  86495. /** @hidden */
  86496. export var perlinNoiseProceduralTexturePixelShader: {
  86497. name: string;
  86498. shader: string;
  86499. };
  86500. }
  86501. declare module BABYLON {
  86502. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86503. time: number;
  86504. timeScale: number;
  86505. translationSpeed: number;
  86506. private _currentTranslation;
  86507. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86508. updateShaderUniforms(): void;
  86509. render(useCameraPostProcess?: boolean): void;
  86510. resize(size: any, generateMipMaps: any): void;
  86511. /**
  86512. * Serializes this perlin noise procedural texture
  86513. * @returns a serialized perlin noise procedural texture object
  86514. */
  86515. serialize(): any;
  86516. /**
  86517. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86518. * @param parsedTexture defines parsed texture data
  86519. * @param scene defines the current scene
  86520. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86521. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86522. */
  86523. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86524. }
  86525. }
  86526. declare module BABYLON {
  86527. /** @hidden */
  86528. export var roadProceduralTexturePixelShader: {
  86529. name: string;
  86530. shader: string;
  86531. };
  86532. }
  86533. declare module BABYLON {
  86534. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86535. private _roadColor;
  86536. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86537. updateShaderUniforms(): void;
  86538. get roadColor(): BABYLON.Color3;
  86539. set roadColor(value: BABYLON.Color3);
  86540. /**
  86541. * Serializes this road procedural texture
  86542. * @returns a serialized road procedural texture object
  86543. */
  86544. serialize(): any;
  86545. /**
  86546. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86547. * @param parsedTexture defines parsed texture data
  86548. * @param scene defines the current scene
  86549. * @param rootUrl defines the root URL containing road procedural texture information
  86550. * @returns a parsed Road Procedural BABYLON.Texture
  86551. */
  86552. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86553. }
  86554. }
  86555. declare module BABYLON {
  86556. /** @hidden */
  86557. export var starfieldProceduralTexturePixelShader: {
  86558. name: string;
  86559. shader: string;
  86560. };
  86561. }
  86562. declare module BABYLON {
  86563. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86564. private _time;
  86565. private _alpha;
  86566. private _beta;
  86567. private _zoom;
  86568. private _formuparam;
  86569. private _stepsize;
  86570. private _tile;
  86571. private _brightness;
  86572. private _darkmatter;
  86573. private _distfading;
  86574. private _saturation;
  86575. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86576. updateShaderUniforms(): void;
  86577. get time(): number;
  86578. set time(value: number);
  86579. get alpha(): number;
  86580. set alpha(value: number);
  86581. get beta(): number;
  86582. set beta(value: number);
  86583. get formuparam(): number;
  86584. set formuparam(value: number);
  86585. get stepsize(): number;
  86586. set stepsize(value: number);
  86587. get zoom(): number;
  86588. set zoom(value: number);
  86589. get tile(): number;
  86590. set tile(value: number);
  86591. get brightness(): number;
  86592. set brightness(value: number);
  86593. get darkmatter(): number;
  86594. set darkmatter(value: number);
  86595. get distfading(): number;
  86596. set distfading(value: number);
  86597. get saturation(): number;
  86598. set saturation(value: number);
  86599. /**
  86600. * Serializes this starfield procedural texture
  86601. * @returns a serialized starfield procedural texture object
  86602. */
  86603. serialize(): any;
  86604. /**
  86605. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86606. * @param parsedTexture defines parsed texture data
  86607. * @param scene defines the current scene
  86608. * @param rootUrl defines the root URL containing startfield procedural texture information
  86609. * @returns a parsed Starfield Procedural BABYLON.Texture
  86610. */
  86611. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86612. }
  86613. }
  86614. declare module BABYLON {
  86615. /** @hidden */
  86616. export var woodProceduralTexturePixelShader: {
  86617. name: string;
  86618. shader: string;
  86619. };
  86620. }
  86621. declare module BABYLON {
  86622. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86623. private _ampScale;
  86624. private _woodColor;
  86625. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86626. updateShaderUniforms(): void;
  86627. get ampScale(): number;
  86628. set ampScale(value: number);
  86629. get woodColor(): BABYLON.Color3;
  86630. set woodColor(value: BABYLON.Color3);
  86631. /**
  86632. * Serializes this wood procedural texture
  86633. * @returns a serialized wood procedural texture object
  86634. */
  86635. serialize(): any;
  86636. /**
  86637. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86638. * @param parsedTexture defines parsed texture data
  86639. * @param scene defines the current scene
  86640. * @param rootUrl defines the root URL containing wood procedural texture information
  86641. * @returns a parsed Wood Procedural BABYLON.Texture
  86642. */
  86643. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86644. }
  86645. }